[Fixed]: Batch upload dupes? [Fixed]: Batch upload dupes?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Fixed]: Batch upload dupes?

Started by SamBuca, January 25, 2009, 10:02:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SamBuca

Didn't see this bug anywhere and the bug forum appears to be locked....so here it is....

First, all the occurrences of readdir() may cause a problem because they don't do the boolean check.

Second, I had a problem when I upgraded to 1.4.19 where the batch upload function would put 2 of every picture on the page where you select the album, select the pictures, and press "insert selected files" (last step of the batch upload)....but ONLY if it was automatically renaming the files.  It seems that by using readdir(), the actively open file handle is returning the "new" files, and since you put the new file name into $pic_array already, it's putting everything on twice.  Using scandir() would solve that by taking a snapshot of the directory and then processing it, but a huge directory would create a huge array and eat up memory.  Therefore, keeping things the way they are and adding a simple in_array() check is a quick fix.  Here are the fixes I did:

searchnew.php line 225:

while ($file = readdir($dir)) {

BECOMES

while (false !== ($file = readdir($dir))) {


searchnew.php line 231:

if (is_file($CONFIG['fullpath'] . $folder . $file)) {

BECOMES

if (is_file($CONFIG['fullpath'] . $folder . $file) && !in_array($file, $pic_array)) {


To reproduce it:

1) Upload a directory of files which will be renamed (a space in the file name).
2) chmod -R 777
3) Batch add files
4) Browseable is ON but it doesn't make a difference.
5) Click on the directory and hit OK.
6) The list will double up on all the files that were renamed.

I'm not sure if this is because I'm still running PHP4....they may have changed under-the-hood of readdir() in PHP5.

Debugging output from the program:
==========================
VERSION INFO :
------------------
PHP version: 4.3.10 - OK
------------------
mySQL version: 4.0.24-log
------------------
Coppermine version: 1.4.19(stable)
==========================
Module: GD
------------------
GD Version: bundled (2.0.28 compatible)
FreeType Support:
T1Lib Support:
GIF Read Support: 1
GIF Create Support: 1
JPG Support: 1
PNG Support: 1
WBMP Support: 1
XBM Support: 1
JIS-mapped Japanese Font Support:

==========================
Module: mysql
------------------
MySQL Supportenabled
Active Persistent Links 0
Active Links 1
Client API version 3.23.49
MYSQL_MODULE_TYPE builtin
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE no value
MYSQL_LIBS no value
==========================
Module: zlib
------------------
ZLib Support enabled
Compiled Version 1.1.4
Linked Version 1.2.3
==========================
Server restrictions (safe mode)?
------------------
Directive | Local Value | Master Value
safe_mode | Off | Off
safe_mode_exec_dir | no value | no value
safe_mode_gid | Off | Off
safe_mode_include_dir | no value | no value
safe_mode_exec_dir | no value | no value
sql.safe_mode | Off | Off
disable_functions | no value | no value
file_uploads | On | On
include_path | .:/usr/local/lib/php | .:/usr/local/lib/php
open_basedir | no value | no value
==========================
email
------------------
Directive | Local Value | Master Value
sendmail_from | no value | no value
sendmail_path | /usr/sbin/sendmail -t -i  | /usr/sbin/sendmail -t -i
SMTP | localhost | localhost
smtp_port | 25 | 25
==========================
Size and Time
------------------
Directive | Local Value | Master Value
max_execution_time | 30 | 30
max_input_time | 60 | 60
upload_max_filesize | 2M | 2M
post_max_size | 2M | 2M
==========================

Since I've been using coppermine for years now....I should say thanks for a great piece of software :)

chelnov

Hi,
I have the same problem with PHP5.
Coppermine UI says that there is 111 pictures in the gallery but when I do like:
ls | grep ^G | nl
index of last image is 101..

Joachim Müller

There's no support on the bugs board. Post relevant information or don't post at all.

Joachim Müller

@SamBuca: thanks for your suggestions - applied them to the SVN both for cpg1.4.x as well as cpg1.5.x. The changes will go into cpg1.4.24

derangedtaco

This problem does not appear to be fixed in cpg1.4.24 :-\

Joachim Müller

But the code changes you suggested are in the SVN and the package as far as I can see.