View Full Version : PHP Photo Album script v2.11

05-02-2010, 06:15 PM
1) Script Title: PHP Photo Album script v2.11

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

3) Describe problem:
Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this (eregi) function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.

link: http://us.php.net/manual/en/function.eregi.php

Since preg_match is supported from PHP 4 on, the getalbumpics.php should be updated to, or at least be offered as an alternative - I suppose some folks are still stuck with PHP 3, but I wonder how well PHP 3 would do with the rest of the original code:

Header("content-type: application/x-javascript");
if (phpversion() >= 5.1){

function returnimages($dirname=".") {
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(preg_match($pattern, $file)){
$filedate=date ("M d, Y H:i:s", filemtime($file));
echo " [$curimage, \"$file\", \"$filedate\"],\n";
echo ' ["placeholder"]' . "\n";

if (!preg_match('/^[a-z_][a-z0-9_]+$/i', $photovar)){
echo 'alert("Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number")';
echo "var $photovar={\n";
echo " baseurl: \"http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER['PHP_SELF']) . "/\",\n";
echo " images: [\n";
echo " ],\n";
echo " desc: []\n";
echo "}\n";

Folks with PHP 5.3+ must use the above or else the script this supports will fail. And, as I say it's good for PHP 4+.

I also have now added another die(); at the end. This will prevent those servers which automatically add tracking code and/or ads to the end of all served PHP pages from breaking the generated javascript code.

Still later, added:

if (phpversion() >= 5.1){

to deal with PHP 5.1+ systems with no date.time set.