Index of /images/photos

Up to parent folder | Jump to files | hide source code

Thumb File (small) (LARGE) Size Timestamp
folder 01 At Home Sacramento/ - - Thu, 11 Nov 2010 03:48:23 +0000
folder 02 At Home Illinois/ - - Mon, 08 Jul 2013 17:26:44 +0000
folder 03 At Work Sacramento/ - - Thu, 11 Nov 2010 03:48:18 +0000
folder 04 Travel/ - - Thu, 11 Nov 2010 03:48:13 +0000
folder 05 Events/ - - Mon, 14 Feb 2011 06:03:10 +0000
folder 50 Mom and Dads Rome Trip/ - - Thu, 11 Nov 2010 03:47:02 +0000
folder 53 Mom 55th, Mikeys Bday/ - - Thu, 08 Mar 2012 11:28:15 +0000
folder 54 Carolyn Erwin Wedding/ - - Fri, 07 Aug 2015 14:24:32 +0000
folder 55 Scott Brunch 2013-11-10/ - - Fri, 07 Aug 2015 14:25:41 +0000
folder 56 Nut Harvesting (Herb Yolitz) 2013-11-12/ - - Sun, 09 Aug 2015 10:45:02 +0000
Thumb File (small) (LARGE) Size Timestamp

Up to parent folder


PHP Source:

<?php
// 2002-06-25 17:44 by Chris Snyder  (csnyder@chxo.com)
// 2002-07-28 16:44 added paging ($skip and $perpage)
// 2002-08-16 11:50 updated for REGISTER_GLOBALS turned off
// 2002-08-25 20:11 listing directories first
// 2003-01-06 12:56 alphabetize folders and files, use apache icons, and don't show thumbs over 500k
// 2003-01-09 18:08 skip-to-files link
// 2003-01-22 18:20 fix alt/title tags for filetype icons, add .zip
// 2003-02-14 10:50 add $filepath suggestion on line 78
// 2003-03-15 19:49 urlencode foldernames
// 2004-01-30 Dave Thornton changes:
//            removed image height/width scaling (and downloading - very slow)
//            added support for pre-created thumbnails and smaller-size images
//            changed urlencode to rawurlencode
//            show thumbs for video (if present)
//            removed display of real directory, and added hide source option
// 2007-10-25 DJT - suppress links
// 2008-07-14 DJT - suppress error_log files
//
// find and list images in path (a folder) as thumbnails
// drop in replacement for fancyindexing -> either drop into an image directory as index.php
//              -OR-  point to script in Apache DirectoryIndex directive:
//                    DirectoryIndex index.html index.htm /cgi-bin/image-list.php

/*
image-list.php -- fancy image indexing using PHP
Copyright (C) 2003 by Chris Snyder (csnyder@chxo.com)
    
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

$thumbwidth=80;
$thumbheight=60;
$skip$_REQUEST["skip"];
$perpage$_REQUEST["perpage"];
$showsource$_REQUEST["showsource"];
$REQUEST_URIgetenv("REQUEST_URI");
$DOCUMENT_ROOTgetenv("DOCUMENT_ROOT");
$SCRIPT_NAMEgetenv("SCRIPT_NAME");
$SCRIPT_FILENAMEgetenv("SCRIPT_FILENAME");
$SERVER_SIGNATUREgetenv("SERVER_SIGNATURE");
$my_top_index="/images/photos";

if (
$skip==""$skip0;
if (
$perpage==""$perpage48;

function 
myfilesize($file) {
    
// First check if the file exists.
    
if(!is_file($file)) exit("File does not exist!");
    
    
// Setup some common file size measurements.
    
$kb 1024;         // Kilobyte
    
$mb 1024 $kb;   // Megabyte
    
$gb 1024 $mb;   // Gigabyte
    
$tb 1024 $gb;   // Terabyte
    
    // Get the file size in bytes.
    
$size filesize($file);
    
    if(
$size $kb) return $size." B";
    else if(
$size $mb) return round($size/$kb,2)." KB";
    else if(
$size $gb) return round($size/$mb,2)." MB";
    else if(
$size $tb) return round($size/$gb,2)." GB";
    else return 
round($size/$tb,2)." TB";
    }

if (
substr($REQUEST_URI,-1)=="/") {
    
$lengthstrlen($REQUEST_URI)-1;
    
$uripathsubstr($REQUEST_URI,0,$length);
    }
else {
    
$uripathdirname($REQUEST_URI);
    }
$filepath$DOCUMENT_ROOT.urldecode($uripath);
// Some users have suggested: 
// $filepath= realpath("."); 
// instead of using $DOCUMENT_ROOT.
// print "filepath= $filepath and realpath=".realpath(".")." and uripath= $uripath ";

$lastslashstrrpos($uripath,"/");
if (
$uripath==$my_top_index) {
    
$parenturi="";
    }
else {
    
$parenturisubstr($uripath,0,$lastslash+1);
    
$parenturi.="image-list.php";
    }
if (
$parenturi==""$parenturi"/";
$displayuripathurldecode($uripath);

// show source code?
if ($showsource$sourceinfo"| <a href='$SCRIPT_NAME'>hide source code</a>";
else 
$sourceinfo"| <a href='$SCRIPT_NAME?showsource=1#source'>show source code</a>";

print 
"<html>
<head>
<title>
$displayuripath</title>
<style type='text/css'>
    body { font-family: Verdana, Geneva, sans-serif; font-size: 12px; background-color: #ffffee;}
    table { font-family: Verdana, Geneva, sans-serif; font-size: 12px; }
    .heading { font-size: 12px; font-weight: bold; background-color: #666677; color: #dddddd; border: 1px; border-style: solid; }
    .oddrow { background-color: #ffffff; }
    .evenrow { background-color: #ddffdd; }
</style>
</head>
<body>
<h1>Index of 
$displayuripath</h1>
<p><a href='
$parenturi'><img src='/icons/back.gif' border=0 hspace=5 align=absmiddle>Up to parent folder</a> | <a href='#files'>Jump to files</a> $sourceinfo</p>";

if (
$skip) {
    
$prevskip$skip $perpage;
    if (
$prevskip<0$prevskip0;
    
$prevtag"<a href='?skip=$prevskip'>Previous Page</a>";
    print 
"<p>$prevtag</p>";
    }

if (
$handle opendir($filepath)) {
    print 
"
<table cellpadding=5>
    <tr class=heading>
        <td align=center>Thumb</td>
        <td>File (small)</td>
        <td>(LARGE)</td>
        <td align=center>Size</td>
        <td>Timestamp</td>
    </tr>"
;
        
    
// FIRST PASS for subdirectories only -- makes $mydirarray, which can be sorted alphabetically
    
$count0;
    while (
$file readdir($handle)) {
        if (
substr($file,0,1)==".") continue;
        if (@
is_dir("$filepath/$file")) {
                        
$mydirarray[$count]="$file";
                        
$count$count+1;
        }
    }
    
closedir($handle);
        
    
// now sort and print subfolders...
    
if (is_array($mydirarray)) {
        
sort($mydirarray);
        
reset($mydirarray);
        foreach (
$mydirarray AS $key=>$file) {
            
$timestampfilemtime("$filepath/$file");
            
$modifieddate("r"$timestamp);
            if (
$evenrow) {
                
$evenrow=0;
                
$rowclass"evenrow";
            }
            else {
                
$evenrow=1;
                
$rowclass"oddrow";
            }
            if (
$key==($count-1)) $separator"<a name='files'> </a>";
            
$safefilerawurlencode($file);
            print 
"
            <tr class='
$rowclass'>
                <td align=right><img src='/icons/folder.gif' alt=folder title=folder></td>
                <td><a href='
$uripath/$safefile/image-list.php'>$file/</a>$separator</td>
                <td align=center>-</td>
                <td align=center>-</td>
                <td>
$modified</td>
            </tr>"
;
        } 
/* foreach */
    
/* if */


    // SECOND PASS for files only
    
$handle opendir($filepath);
    
$skipped0;
    
$index0;
    
$count0;
    while (
$file readdir($handle)) {
        
// don't show .dotfiles, self, directories, or links (links are bad??? hmm)
        
if (substr($file,0,1)==".") continue;
        if (
substr($file,strlen($file)-10,10)=="_thumb.jpg") continue;
        if (
substr($file,strlen($file)-12,12)=="_640x480.jpg") continue;
        if (
$file=="error_log") continue;
        if (
$file=="index.php") continue;
        if (
$file=="image-list.php") continue;
        if (@
is_dir("$filepath/$file")) continue;
        if (@
is_link("$filepath/$file")) continue;
        
$myfilearray[$count]= $file;
        
$count$count+1;
    }
    
closedir($handle);

    
// now sort on filename
    
if (is_array($myfilearray)) {
        
sort($myfilearray);
        
reset($myfilearray);
        foreach (
$myfilearray AS $key=>$file) {
            if (
$index >= $perpage) {
                
$shownext1;
                break;
            }
            if (
$skipped<$skip && $skip!= 0) {
                
$skipped$skipped 1;
                continue;
            }
            
$index$index 1;
            
$timestampfilemtime("$filepath/$file");
            
$modifieddate("r"$timestamp);
            if (
$evenrow) {
                
$evenrow=0;
                
$rowclass"evenrow";
            }
            else {
                
$evenrow=1;
                
$rowclass"oddrow";
            }
            unset(
$info);
            unset(
$extrainfo);
            unset(
$sizetag);
            
$thumbfile=$file;
            
$smallfile=$file;
            
$lastdotstrrpos($file".");
            
$extensionstrtolower(substr($file,$lastdot+1));
            switch (
$extension) {
                case 
"pdf"$extensiontype"pdf"; break;
                case 
"txt"$extensiontype"text"; break;
                case 
"htm"$extensiontype"html"; break;
                case 
"html"$extensiontype"html"; break;
                case 
"wav"$extensiontype"sound"; break;
                case 
"au"$extensiontype"sound"; break;
                case 
"aiff"$extensiontype"sound"; break;
                case 
"mp3"$extensiontype"sound"; break;
                case 
"ogg"$extensiontype"sound"; break;
                case 
"mov"$extensiontype"video"; break;
                case 
"avi"$extensiontype"video"; break;
                case 
"mpg"$extensiontype"video"; break;
                case 
"mpeg"$extensiontype"video"; break;
                case 
"mp4"$extensiontype"video"; break;
                case 
"divx"$extensiontype"video"; break;
                case 
"zip"$extensiontype"zip"; break;
                default: 
$extensiontype"file"; break;
                }
            if (
$extension=="jpg"||$extensiontype="video") {
                
$thumbfile=substr($file,0,$lastdot);
                
// print "thumbfile=$thumbfile,";
                
$thumbfile .= "_thumb.jpg";
                
$smallfile=substr($file,0,$lastdot);
                
$smallfile .= "_640x480.jpg";
            }
            
$filesizemyfilesize("$filepath/$file");
            if ((
$imagesize=@getimagesize("$filepath/$file",$info))&&($extensiontype!="video")) {
                
$width$imagesize[0];
                
$height$imagesize[1];
                if (
$width>$thumbwidth) {
                    
$ratio$thumbwidth $width;
                    
$width=$thumbwidth;
                    
$height$height*$ratio;
                    }
                if (
$height>$thumbheight) {
                    
$ratio$thumbheight $height;
                    
$height=$thumbheight;
                    
$width$width*$ratio;
                    }
                
//print"imagesize[2]=$imagesize[2],";
                
switch ($imagesize[2]) {
                    case 
5$icontag"<img src='/icons/image3.gif' alt=file title='photoshop image'>"; break;
                    case 
7$icontag"<img src='/icons/image2.gif' alt=file title='tiff image'>";  break;
                    case 
8$icontag"<img src='/icons/image2.gif' alt=file title='tiff image'>";  break;
                    
// default: $icontag= "<img src='$uripath/$file' width=$width height=$height alt=image title=image>"; break;
                    
default: $safethumbfilerawurlencode($thumbfile);
                             
$icontag"<img src='$uripath/$safethumbfile' alt=image title=image>";
                             break;
                    }
                
$sizetag"($imagesize[0]x$imagesize[1])";

                if (isset (
$info['APP13'])) {
                    
$iptc iptcparse ($info['APP13']);
                    if (
is_array($iptc)) {
                        foreach (
$iptc AS $key=>$val) {
                            if (
$key=="2#000") continue;
                            
$extrainfo.="$val[0]<br>";
                            }
                        }
                    }
                
// don't show thumbnails bigger than 500K!
                
$safesmallfilerawurlencode($smallfile);
                
$smalltag="<a href='$uripath/$safesmallfile'>$smallfile</a> (640x480)";
                }
            else {
                
// try to determine from extension...
                //flerror("File extension is $extension.");
                
switch ($extensiontype) {
                    case 
"pdf"$icontag"<img src='/icons/layout.gif' alt=pdf title=pdf>"; break;
                    case 
"text"$icontag"<img src='/icons/text.gif' alt=text title=text>"; break;
                    case 
"html"$icontag"<img src='/icons/text.gif' alt=html title=html>"; break;
                    case 
"sound"$icontag"<img src='/icons/sound1.gif' alt=sound title=sound>"; break;
                    case 
"video": if (file_exists("$filepath/$thumbfile")) {
                                      
$safethumbfilerawurlencode($thumbfile);
                                      
$icontag"<img src='$uripath/$safethumbfile' alt=image title=image>";
                                      }
                                  else {
                                      
$icontag"<img src='/icons/movie.gif' alt=video title=video>";
                                      };
                                  break;
                    case 
"zip"$icontag"<img src='/icons/compressed.gif' alt='archive' title='zip archive'>"; break;
                    default: 
$icontag"<img src='/icons/generic.gif' alt=file title=file>"; break;
                    }
                
$smalltag="-";
                }
            
// file row
            
$safefilerawurlencode($file);
            print 
"
        <tr class='
$rowclass'>
            <td valign=top align=right>
$icontag</td>
            <td valign=top>
$smalltag</td>
            <td valign=top><a href='
$uripath/$safefile'>$file</a> $sizetag</td>
            <td valign=top align=center>
$filesize</td>
            <td valign=top>
$modified</td>
            </tr>"
;
            }
        };
//  else print "
//      <tr>
//          <td valign=middle colspan='4'>&nbsp; No files here.</td>
//          </tr>";

    
print "
    <tr class=heading>
        <td align=center>Thumb</td>
        <td>File (small)</td>
        <td>(LARGE)</td>
        <td align=center>Size</td>
        <td>Timestamp</td>
    </tr>
</table>"
;

    if (
$shownext) {
        
$nextskip$skip $index;
        if (
$prevtag$prevtag .= " | ";
        print 
"<p>$prevtag <a href='?skip=$nextskip'>Next Page</a></p>";
        }
    elseif (
$skip) {
        print 
"<p>$prevtag</p>";
        }

    print 
"
<p><a href='
$parenturi'><img src='/icons/back.gif' border=0 hspace=5 align=absmiddle>Up to parent folder</a></p>";
    }

if (
$showsource) {
    print 
"<hr><a name='source'> </a><h1>PHP Source:</h1>";
    
$voidshow_source($SCRIPT_FILENAME);
    }
print 
"
<hr>
image-list.php Copyright (C) 2003 by Chris Snyder<br>
Modified 1/30/2004 by Dave Thornton<br>
This program comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are welcome
to redistribute it under certain conditions; please refer to the 
<a href='http://www.gnu.org/licenses/gpl.html'>GNU General Public License</a> for details.

</body>
</html>"
;
?>

image-list.php Copyright (C) 2003 by Chris Snyder
Modified 1/30/2004 by Dave Thornton
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; please refer to the GNU General Public License for details.