#!@PERL@ # # # Auto-Image Lister V1.4 # Streamlined and improved. ######################### # AUTHOR: David Powell # http://www.matrixvault.com/cgi/ # Copyright 1999,2000 David Powell and "The Matrix Vault" # A Matrix Vault Production. # Tested and run on a UNIX system with PERL 5 # This script is an original script by David Powell. You may use it free of charge, if you keep this header intact, # along with any other copyright notices found in the resulting HTML output or text files generated by this script. # ######################### # This program will assemble 'on the fly' a web page full of images # from a directory in your archive on your server. It is customizeable in that you # use a pre-made HTML template for the output screen. You can make the template #using all the colors and design of the rest of your site, making it fit right in. # # To install: # 1. Edit the variables below. # 2. Make a template web page. Use <--TITLE--> and <--IMAGES--> where you want # the title and image to be inserted. It's OK to use a WYSIWYG editor. This script will # weed out the < code. # 3. Upload everything to it's place: # The script: To your CGI BIN. Chmod 755 # The Template: To $TEMPLATE's path # 4. Call the script with your browser: http://www.yoursite.com/cgi-bin/AI.cgi # 5. Note: if you do not have a template file, you will get an error. ######################################################## # # NEW FEATURE: # You can run this program stand alone, which will read the designated directory, # Or you can run it to read different directories of images with a command line. # http://www.yourdomain.com/cgi-bin/AI.cgi?/image_dir/ # Where /image_dir/ is the dir you wish to display in relation to your public_html root. # You must use the forward slashes around your image dir, or it will not work. # ######################################################### # E D I T V A R I A B L E S ######################################################### $URL_ROOT = ""; # The HTTP root of your site. $PAGE_TITLE = "iptotal image archive"; # The title of the results page. Set to "" for none. $TEMPLATE= "@datadir@/template.html"; # the complete UNIX path and filename of your template # Thumbnail size $width ="150"; $height = "70"; # number of thumbnails per line $num_per_line="5"; ######################################################### # # Edit These two if you wish to process one and only one dir. # $UNIX_PATH = "@datadir@/archive"; # The unix path to the dir you wish to process. $URL_PATH = "/iptotal/archive"; # The HTTP equivelent of $UNIX_PATH- but with no trailing slash. # E N D E D I T V A R I A B L E S ######################################################### print "Content-type: text/html\n\n"; ######################################### # Read and store the images in the dir ######################################### $HTML_ROOT = "$ENV{'DOCUMENT_ROOT'}"; $remote_path= "$ENV{'QUERY_STRING'}"; if ($remote_path ne "") {$UNIX_PATH = "$HTML_ROOT"."$remote_path";} opendir(DIR,"$UNIX_PATH") || &error ("Cannot open $UNIX_PATH"); foreach (sort readdir(DIR)) { $file = $_; $lcfile = lc($file); if ($lcfile =~ /.png/) { push (@dir_list, "$file"); } } $count=@dir_list; closedir(DIR); ############################## # Read and store the template: ############################## open(TEMPLATE_file,"$TEMPLATE") || &error ("Can't open $TEMPLATE\n"); @html=; close(TEMPLATE_file); ############################# # Start html insert routine ############################# if ($remote_path ne "") {$URL_PATH = "$URL_ROOT"."$remote_path";} $output = "\n
"; $piccount=0; foreach $file(@dir_list) { $piccount++; $output .= "\n"; push(@linelist,"$file"); if ($piccount eq $num_per_line) { $output .= ""; foreach $label(@linelist) { $output .= ""; } $output .= ""; $piccount=0; undef @linelist; } } if (defined @linelist) { $output .= ""; foreach $label(@linelist) { $output .= ""; } $output .= ""; $piccount=0; undef @linelist; } $output .= "
\n\"Filename:
$label
$label
"; ######################### # Now search and replace ######################### foreach $line(@html) { $REP_TEXT=""; $REP_TEXT = "<--TITLE-->"; $line =~ s/$REP_TEXT/$PAGE_TITLE/gi; $REP_TEXT="<--TITLE-->"; $line =~ s/$REP_TEXT/$PAGE_TITLE/gi; $REP_TEXT = "<--IMAGES-->"; $line=~ s/$REP_TEXT/$output/gi; $REP_TEXT="<--IMAGES-->"; $line =~ s/$REP_TEXT/$output/gi; if (($line =~/<\/body>/) || ($line =~/<\/html>/)) {$line="";} print "$line"; } print <<__HTML;
This Page powered by:
"Auto Image Lister"
A Matrix Vault Production
Modified for iptotal by dingetje
__HTML exit; ###################### # ERROR HANDLING ###################### sub error { print ""; print "

Auto Image Error: $_[0]
"; exit; }