coppermine-gallery.com/forum

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: Oz on November 25, 2003, 11:14:07 PM

Title: CPG 1.2.0-final and PHP5 ?
Post by: Oz on November 25, 2003, 11:14:07 PM
Hi,
I've just tried installing CPG120final on a freebsd box running PHP 5.0.0a3-alexdupre. It seems to work, except when trying to batch add pictures I get the following error:

Fatal error: Cannot redeclare scandir() in /path/to/gallery/searchnew.php on line 309

Has anybody seen this (and fixed it ;-) )then please let me know.

Rgds
Oz
Title: CPG 1.2.0-final and PHP5 ?
Post by: viguera on November 25, 2003, 11:47:09 PM
Weird... I'm no PHP genius but it sounds like there's another "scandir" function somewhere else -- a quick search of the CPG stuff shows that there's only one, however.

I'd venture a guess and say that if you hack the searchnew.php and change the function name and calls, it will probably go away.  Of course, that's just a temporary fix until somebody figures out what the deal is...

Under the impression that you already know the standard disclaimer that if you break your box it's on you, I'd say that you can do this:

Change line 282 in searchnew.php from:

function scandir($dir, &$expic_array)

to

function cpgscandir($dir, &$expic_array)

then the calls on 305 from

scandir($dir . $directory . '/', $expic_array);

to cpgscandir($dir . $directory . '/', $expic_array);

and line 393 from

   if (scandir($HTTP_GET_VARS['startdir'] . '/', $expic_array)) {


to    if (cpgscandir($HTTP_GET_VARS['startdir'] . '/', $expic_array)) {

You might wanna make a backup first, in case I'm wrong -- which I could be... :)
Title: CPG 1.2.0-final and PHP5 ?
Post by: Oz on November 26, 2003, 08:34:33 AM
Thanks - you're obviously right. I guess I was too tired to read by myself  :oops:  .
The function "scandir" clashes with a new function in PHP5 of the same name (http://www.php.net/manual/en/function.scandir.php ). In case anybody else is/wants to be playing around with PHP5, I just did a

mv searchnew.php searchnew.php.ORIG
sed 's/scandir/cpg_scandir/g' searchnew.php.ORIG > searchnew.php

And now it seems to work!

Thanks again,
Oz
Title: Thx , I have fixed this error
Post by: knives on March 14, 2004, 05:33:13 PM
As title , i haved fixed the same error
Title: CPG 1.2.0-final and PHP5 ?
Post by: Joachim Müller on March 14, 2004, 11:09:27 PM
Thanks for pointing this out - it's a known issue and has been solved in the next version of coppermine which will (hopefully) be released soon, where we renamed the function in searchnew.php (it only is in that particular file - you can simply replace "scandir" with "CPGscandir").
Afaik PHP5 is still experimental - such clashes may happen with other apps as well when using PHP5...

GauGau
Title: Re: CPG 1.2.0-final and PHP5 ?
Post by: exir on October 03, 2004, 07:21:46 PM
At the server where my site is being hosted is running php5.0.2
i have applied the hack but i still dont see any images.
what already worked is that i can add pictures with the batch add picture function, before the hack i did get the same error as above

does anyone know a solution to this?

hope so
Title: Re: CPG 1.2.0-final and PHP5 ?
Post by: Casper on October 03, 2004, 10:19:20 PM
What version are you using.

Try these threads, and the ones they link to;

http://forum.coppermine-gallery.net/index.php?topic=10066.0
http://forum.coppermine-gallery.net/index.php?topic=10482.0