Results 1 to 3 of 3

Thread: PHP Photo Album script v2.11 not displaying most recent image

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default PHP Photo Album script v2.11 not displaying most recent image

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

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

    3) Describe problem: I notice that the most recent image file is not being displayed. In this case the image that is not being displayed in the gallery is http://www.animeviews.com/images/x23_26.jpg

    The gallery is located at http://www.animeviews.com/images/gallery2.php

    here are the other files involved:

    http://www.animeviews.com/images/ddphpalbum.js
    http://www.animeviews.com/images/ddphpalbum.css
    http://www.animeviews.com/images/gallery2.phps
    http://www.animeviews.com/images/getalbumpics.phps
    Last edited by james438; 01-20-2011 at 07:54 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Works in IE actually. But that's because two quirky but technically accurate things cancel each other out. Other browsers get it wrong though and the last image is skipped and would be regardless of which it is.

    Use the current getalbumpics.php (available on the demo page):

    PHP Code:
    <?
    Header
    ("content-type: application/x-javascript");

    function 
    returnimages($dirname=".") {
       
    $pattern="\.(jpg|jpeg|png|gif|bmp)$";
       
    $files = array();
       
    $curimage=0;
       if(
    $handle opendir($dirname)) {
           while(
    false !== ($file readdir($handle))){
                   if(
    eregi($pattern$file)){
             
    $filedate=date ("M d, Y H:i:s"filemtime($file));
                     echo 
    "        [$curimage, \"$file\", \"$filedate\"],\n";
                     
    $curimage++;
                   }
           }
           echo 
    "        [\"placeholder\"]\n";
           
    closedir($handle);
       }
       return(
    $files);
    }

    $photovar=$_GET['id'];
    if (!
    eregi("^[a-zA-Z0-9_]+$"$photovar)){
        echo 
    "alert(\"Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number\")";
        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";
    ?>
    Or, for the purist (see http://www.dynamicdrive.com/forums/s...674#post225674 for explanation):

    PHP Code:
    <?php
    Header
    ("content-type: application/x-javascript");
    if (
    phpversion() >= 5.1){
       @
    date_default_timezone_set(date_default_timezone_get());
    }

    function 
    returnimages($dirname=".") {
       
    $pattern='/\.(jpg|jpeg|png|gif|bmp)$/i';
       
    $curimage=0;
       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";
                     
    $curimage++;
                   }
           }
           echo 
    '        ["placeholder"]' "\n";
           
    closedir($handle);
       }
    }

    $photovar=$_GET['id'];
    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")';
        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";
    die();
    ?>
    Last edited by jscheuer1; 01-21-2011 at 03:32 AM. Reason: fix broken link
    - John
    ________________________

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

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    james438 (01-20-2011)

  4. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Yuck, I didn't realize that eregi was being used. If not wanting to use deprecated functions makes me a purist then I am definitely a purist.

    Thanks for your help
    To choose the lesser of two evils is still to choose evil. My personal site

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
  •