Results 1 to 3 of 3

Thread: "eregi" function in PHP Photo Album script v2.11 deprecated

  1. #1
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question "eregi" function in PHP Photo Album script v2.11 deprecated

    1) Script Title:
    PHP Photo Album script v2.11

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

    3) Describe problem:
    eregi($pattern, $file) function is deprecated and as such this script runs no more, at least it wont on my wamp server with php 5.3.8

    ive been thinkering with this one and changed the script to :

    Code:
    <?php
    
    Header("content-type: application/x-javascript");
    
    function returnimages($dirname="./") {
    	$pattern="{".$dirname."*.jpg,".$dirname."*.jpeg,".$dirname."*.png,".$dirname."*.gif,".$dirname."*.bmp}";
    	$files = array();
    	$curimage=0;
    	foreach (glob($pattern,GLOB_BRACE) as $file) {
    		$filedate=date ("M d, Y H:i:s", filemtime($file));
    		echo "		[$curimage, \"$file\", \"$filedate\"],\n";
    		$curimage++;
    	}
        echo "		[\"placeholder\"]\n";
       
        return($files);
    }
    
    $photovar=$_GET['id'];
    
    if (!preg_match("/^([a-zA-Z])([a-zA-Z0-9])+$/", $photovar)){
    	echo "alert(\"Photo Album ID must contain only letters\")";
    	die();
    }
    echo "var " . $photovar . "={\n";
    echo "	baseurl: \"http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER['PHP_SELF']) . "/\",\n";
    echo "	images: [\n";
    returnimages();
    echo "	],\n";
    echo "	desc: []\n";
    echo "}\n";
    ?>
    and it works or at least seems like it, but i want to know if theres another way around it, a better one perhaps

    btw: i may be mistaken but i downloaded the whole script page and the album in the example doesn't seem to be using the script it has a hardcoded object, at least the one i downloaded do.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The preg functions replace the ereg functions. I think what you've done will work (although I haven't tested it).

    As for downloading the script, please be more specific. Note that PHP only is visible in the original file (on the server), not if viewed as HTML-- then it is converted to text (without any PHP code) by the server-- that's how PHP works. So if you're using "view source" or "save page as" then you won't see any PHP code. This is one case where you can't build your page based on the source code of the demo page-- you'll need to save the .php page as a file.
    (Note: this is why it's in .txt format to download, not .php-- if it was PHP, it would be parsed as PHP, become HTML and lose the PHP code.)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,126
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •