News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

serch for a "userpics to subdir" plugin

Started by Chris99, Yesterday at 08:02:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris99

Hi,
 I searching for a plugin "userpics to subdir" which creates a subdir in Userpics Folder and move the files in the subdir. 

I have that same problem like in 2015. too much files in Userpics Directory:
André creates a script:
https://coppermine-gallery.com/forum/index.php/topic,78004.0.html

Will this work with the 1.6 Coppermine?

Thank you.

ron4mac


Chris99

Hi, thank you. Ive tried this tool, but it seems there are too many files (500.000) in userpics folder. I get a white page and nothing happens.... neither after 30 min...


Andre wrote this tool, it works perfect in those days with 1.5, does it work also with 1.6?

Thank you.
 
<?php
define
('IN_COPPERMINE'true);
define('DB_INPUT_PHP'true);
require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODE) {
    
cpg_die(ERROR$lang_errors['access_denied']);
}

$limit 50;
$result cpg_db_query("SELECT pid, aid, filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE filepath LIKE '{$CONFIG['userpics']}%' AND filepath NOT LIKE CONCAT('%/', aid, '/') LIMIT $limit");

if (
mysql_num_rows($result)) {
    
pageheader('Moving''<meta http-equiv="refresh" content="1; URL='.$CPG_PHP_SELF.'">');
    echo 
'<table width="100%"><tr><td class="tableh1" width="50%">File</td><td class="tableh1" width="50%">Moved to</td></tr>';
} else {
    
pageheader('Done');
    echo 
'<table width="100%"><tr><td>Done.</td></tr>';
}

while (
$row mysql_fetch_assoc($result)) {
    
$dest_dir_sql $row['filepath'].$row['aid'].'/';
    
$dest_dir $CONFIG['fullpath'].$dest_dir_sql;
    
$src_dir $CONFIG['fullpath'].$row['filepath'];
    
$images = array($row['filename'], $CONFIG['normal_pfx'].$row['filename'], $CONFIG['thumb_pfx'].$row['filename'], $CONFIG['orig_pfx'].$row['filename']);

    if (!
is_dir($dest_dir)) {
        
mkdir($dest_diroctdec($CONFIG['default_dir_mode']));
        if (!
is_dir($dest_dir)) {
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_mkdir'], $dest_dir), __FILE____LINE__);
        }
        @
chmod($dest_diroctdec($CONFIG['default_dir_mode'])); //silence the output in case chmod is disabled
        
$fp fopen($dest_dir '/index.php''w');
        
fwrite($fp' ');
        
fclose($fp);
    }

    foreach (
$images as $image) {
        if (!
file_exists($src_dir.$image)) {
            continue;
        }
        if (!
rename($src_dir.$image$dest_dir.$image)) {
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_move'], $src_dir.$image$dest_dir), __FILE____LINE__);
        } else {
            echo 
'<tr><td>'.$src_dir.$image.'</td><td>'.$dest_dir.'</td></tr>';
        }
    }

    
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filepath = '$dest_dir_sql' WHERE pid = {$row['pid']}");
}

echo 
'</table>';
pagefooter();