#! /usr/bin/perl -- -*-perl-*-> # A perl cgi program to display an HTML table index of photos in a directory. # Copy this perl script to your public_html/cgi-bin directory. $RelativeDir refers to directories under public_html/. # Note: When this script executes, the home directory ~ is cgi-bin/. # Note: If you're having trouble, change "cgiwrap" to "cgiwrapd" to show debug info. # # SSI usage example: (Copy and remove '#' at the beginning of the line. Subsitute your username for USERNAME below. # Be sure to name your file with the .shtml extension for server side parsing.) # # # # Family Photos # # # # # # # # # # # # # use CGI qw(param); $RelativeDir= param("reldir"); $Xtable= (param("xtable")==undef) ? 4 : param("xtable"); $Xwidth= (param("xwidth")==undef) ? 600 : param("xwidth"); $Xcell= (param("xcell")== undef) ? 150 : param("xcell"); $PhotoDir="../$RelativeDir"; print "Content-type: text/html\n\n"; opendir(PHOTODIR, "$PhotoDir") || die "Error: no directory $PhotoDir $!"; while ($FileName= readdir(PHOTODIR)) { if ($FileName=~ /.*\.(jpg|JPG|gif|GIF)/) { $i++; if ($i==1) {print "\n \n";} print " \n"; if ($i % $Xtable == 0) {print " \n \n";} } } print " \n
$FileName
\n"; closedir (PHOTODIR); exit 0; # End Program.