Ticket #231 (reopened defect)

Opened 12 years ago

Last modified 12 years ago

Corecting the compatibility (PHP 4 / PHP 5) of the "linuxpici.class.php" file + some BUG fixes

Reported by: Jérémie78 <jiem78hotmail.com> Assigned to: somebody
Priority: minor Milestone:
Component: pici-server Version: 1.0
Keywords: linux pici class php Cc: jiem78@hotmail.com


[[ Correcting the compatibility or "ADMIN/linuxpici.class.php" with PHP 4/PHP 5 ]]

As PHP 4 doesn't to care about a PHP 5 class, as long as we create another constructor using the class-name, we copy our orignal file (linuxpici.class.php) to "linuxpici.class.php4.php". The PHP 4 class is done.

Then we copy the orignal file (linuxpici.class.php) to "linuxpici.class.php5.php" and we remove the PHP 4 contructor from line 38 to 41 (include). The PHP 5 class is done.

Now we need to load the PHP 4 or the PHP 5 version of this class, considering each server. The only file including this class is "ADMIN/get_picture.php at line 193. Remove the line 193 : <<

require_once ("linuxpici.class.php");

And replace her by : <<

if(phpversion() >= 5)

require_once ("linuxpici.class.php5.php");


require_once ("linuxpici.class.php4.php");

That's it ! Picidae will load the correct version of the class for each server. Furthermore, if you need to modify the linuxpici.class.php file, you modify the PHP 4 version, and you copy its content to the PHP 5 version, then you remove the PHP 4 contrsuctor for the PHP 5 version, and it's done !

[[ BUG fixes ]]

I found to bug (I mean, PHP warned me about 2 problems) :

Search for (line 140) : <<

if ($ps_array[1]) return true;

Replace it by : <<

if (isset($ps_array[1]) AND $ps_array[1]) return true;

Search for (line 183) : <<

$addStmt = "UPDATE $this->DB_table set loading = '2' where pic = '$idx';";

Replace by : <<

$addStmt = "UPDATE $this->DB_table set loading = '2' where pic = '" .$this->idx. "';";


Change History

07/11/08 13:29:35 changed by mj

  • status changed from new to closed.
  • resolution set to fixed.

Thank you very much jiem! I added to the repository.

07/11/08 14:22:15 changed by mj

  • status changed from closed to reopened.
  • resolution deleted.

Didn't add the php4 class compatibility yet, just added the bugfixes. php4 class compatibility still to come...

07/15/08 23:30:11 changed by Jérémie78 <jiem78hotmail.com>

The other possibility is to create two classes, each one written either for PHP 4 or for PHP 5. But having 2 versions means that each new feature is implemented twice.

Furthermore, PHP 4 will soon be without support from the PHP team ... so people are going to update massively to PHP 5 in a short time (due to security lack and bugs not fixed).

Add/Change #231 (Corecting the compatibility (PHP 4 / PHP 5) of the "linuxpici.class.php" file + some BUG fixes)

Change Properties