| 1 |
#!@PERL@ |
| 2 |
# |
| 3 |
# |
| 4 |
# Auto-Image Lister V1.4 |
| 5 |
# Streamlined and improved. |
| 6 |
######################### |
| 7 |
# AUTHOR: David Powell |
| 8 |
# http://www.matrixvault.com/cgi/ |
| 9 |
# Copyright 1999,2000 David Powell and "The Matrix Vault" |
| 10 |
# A Matrix Vault Production. |
| 11 |
# Tested and run on a UNIX system with PERL 5 |
| 12 |
# This script is an original script by David Powell. You may use it free of charge, if you keep this header intact, |
| 13 |
# along with any other copyright notices found in the resulting HTML output or text files generated by this script. |
| 14 |
# |
| 15 |
######################### |
| 16 |
# This program will assemble 'on the fly' a web page full of images |
| 17 |
# from a directory in your archive on your server. It is customizeable in that you |
| 18 |
# use a pre-made HTML template for the output screen. You can make the template |
| 19 |
#using all the colors and design of the rest of your site, making it fit right in. |
| 20 |
# |
| 21 |
# To install: |
| 22 |
# 1. Edit the variables below. |
| 23 |
# 2. Make a template web page. Use <--TITLE--> and <--IMAGES--> where you want |
| 24 |
# the title and image to be inserted. It's OK to use a WYSIWYG editor. This script will |
| 25 |
# weed out the < code. |
| 26 |
# 3. Upload everything to it's place: |
| 27 |
# The script: To your CGI BIN. Chmod 755 |
| 28 |
# The Template: To $TEMPLATE's path |
| 29 |
# 4. Call the script with your browser: http://www.yoursite.com/cgi-bin/AI.cgi |
| 30 |
# 5. Note: if you do not have a template file, you will get an error. |
| 31 |
######################################################## |
| 32 |
# |
| 33 |
# NEW FEATURE: |
| 34 |
# You can run this program stand alone, which will read the designated directory, |
| 35 |
# Or you can run it to read different directories of images with a command line. |
| 36 |
# http://www.yourdomain.com/cgi-bin/AI.cgi?/image_dir/ |
| 37 |
# Where /image_dir/ is the dir you wish to display in relation to your public_html root. |
| 38 |
# You must use the forward slashes around your image dir, or it will not work. |
| 39 |
# |
| 40 |
######################################################### |
| 41 |
# E D I T V A R I A B L E S |
| 42 |
######################################################### |
| 43 |
|
| 44 |
$URL_ROOT = ""; |
| 45 |
# The HTTP root of your site. |
| 46 |
|
| 47 |
$PAGE_TITLE = "iptotal image archive"; |
| 48 |
# The title of the results page. Set to "" for none. |
| 49 |
|
| 50 |
$TEMPLATE= "@datadir@/template.html"; |
| 51 |
# the complete UNIX path and filename of your template |
| 52 |
|
| 53 |
# Thumbnail size |
| 54 |
$width ="150"; |
| 55 |
$height = "70"; |
| 56 |
|
| 57 |
# number of thumbnails per line |
| 58 |
$num_per_line="5"; |
| 59 |
|
| 60 |
######################################################### |
| 61 |
# |
| 62 |
# Edit These two if you wish to process one and only one dir. |
| 63 |
# |
| 64 |
|
| 65 |
$UNIX_PATH = "@datadir@/archive"; |
| 66 |
# The unix path to the dir you wish to process. |
| 67 |
|
| 68 |
$URL_PATH = "/iptotal/archive"; |
| 69 |
# The HTTP equivelent of $UNIX_PATH- but with no trailing slash. |
| 70 |
|
| 71 |
# E N D E D I T V A R I A B L E S |
| 72 |
######################################################### |
| 73 |
|
| 74 |
print "Content-type: text/html\n\n"; |
| 75 |
|
| 76 |
######################################### |
| 77 |
# Read and store the images in the dir |
| 78 |
######################################### |
| 79 |
|
| 80 |
$HTML_ROOT = "$ENV{'DOCUMENT_ROOT'}"; |
| 81 |
$remote_path= "$ENV{'QUERY_STRING'}"; |
| 82 |
|
| 83 |
if ($remote_path ne "") {$UNIX_PATH = "$HTML_ROOT"."$remote_path";} |
| 84 |
|
| 85 |
opendir(DIR,"$UNIX_PATH") || &error ("Cannot open $UNIX_PATH"); |
| 86 |
|
| 87 |
|
| 88 |
foreach (sort readdir(DIR)) |
| 89 |
{ |
| 90 |
$file = $_; |
| 91 |
$lcfile = lc($file); |
| 92 |
if ($lcfile =~ /.png/) |
| 93 |
{ |
| 94 |
push (@dir_list, "$file"); |
| 95 |
} |
| 96 |
} |
| 97 |
$count=@dir_list; |
| 98 |
closedir(DIR); |
| 99 |
|
| 100 |
############################## |
| 101 |
# Read and store the template: |
| 102 |
############################## |
| 103 |
|
| 104 |
open(TEMPLATE_file,"$TEMPLATE") || &error ("Can't open $TEMPLATE\n"); |
| 105 |
@html=<TEMPLATE_file>; |
| 106 |
close(TEMPLATE_file); |
| 107 |
|
| 108 |
############################# |
| 109 |
# Start html insert routine |
| 110 |
############################# |
| 111 |
|
| 112 |
if ($remote_path ne "") {$URL_PATH = "$URL_ROOT"."$remote_path";} |
| 113 |
$output = "\n<center><table border=0><tr>"; |
| 114 |
$piccount=0; |
| 115 |
foreach $file(@dir_list) |
| 116 |
{ |
| 117 |
$piccount++; |
| 118 |
$output .= "<td><a href=\"$URL_PATH/$file\">\n<img src=\"$URL_PATH/$file\" ALT=\"Filename: $file\" border=0 width=$width height=$height></a></td>\n"; |
| 119 |
push(@linelist,"$file"); |
| 120 |
if ($piccount eq $num_per_line) |
| 121 |
{ |
| 122 |
$output .= "</tr><tr>"; |
| 123 |
foreach $label(@linelist) |
| 124 |
{ |
| 125 |
$output .= "<td align=center>$label</td>"; |
| 126 |
} |
| 127 |
$output .= "</tr><tr>"; |
| 128 |
$piccount=0; |
| 129 |
undef @linelist; |
| 130 |
} |
| 131 |
} |
| 132 |
if (defined @linelist) |
| 133 |
{ |
| 134 |
$output .= "</tr><tr>"; |
| 135 |
foreach $label(@linelist) |
| 136 |
{ |
| 137 |
$output .= "<td align=center>$label</td>"; |
| 138 |
} |
| 139 |
$output .= "</tr><tr>"; |
| 140 |
$piccount=0; |
| 141 |
undef @linelist; |
| 142 |
} |
| 143 |
$output .= "</tr></table></center>"; |
| 144 |
######################### |
| 145 |
# Now search and replace |
| 146 |
######################### |
| 147 |
foreach $line(@html) |
| 148 |
{ |
| 149 |
$REP_TEXT=""; |
| 150 |
$REP_TEXT = "<--TITLE-->"; |
| 151 |
$line =~ s/$REP_TEXT/$PAGE_TITLE/gi; |
| 152 |
|
| 153 |
$REP_TEXT="<--TITLE-->"; |
| 154 |
$line =~ s/$REP_TEXT/$PAGE_TITLE/gi; |
| 155 |
|
| 156 |
$REP_TEXT = "<--IMAGES-->"; |
| 157 |
$line=~ s/$REP_TEXT/$output/gi; |
| 158 |
|
| 159 |
$REP_TEXT="<--IMAGES-->"; |
| 160 |
$line =~ s/$REP_TEXT/$output/gi; |
| 161 |
|
| 162 |
if (($line =~/<\/body>/) || ($line =~/<\/html>/)) {$line="";} |
| 163 |
|
| 164 |
print "$line"; |
| 165 |
} |
| 166 |
|
| 167 |
print <<__HTML; |
| 168 |
|
| 169 |
<BR><center><b><font face="Verdana"><font size=-2>This Page powered by:</b> |
| 170 |
<br><font face="Verdana"><font size=-2>"Auto Image Lister" |
| 171 |
<br><font face="Verdana"><font size=-2> |
| 172 |
A <b><a href="http://www.matrixvault.com/">Matrix Vault</a></b> Production |
| 173 |
</font></font><br> |
| 174 |
<font face="Verdana"><font size=-2>Modified for <font color="#ff0000">iptotal</font> by |
| 175 |
<a href="mailto:webmaster\@dingetje.homeip.net">dingetje</a></font></font> |
| 176 |
</center> |
| 177 |
|
| 178 |
</body> |
| 179 |
</html> |
| 180 |
__HTML |
| 181 |
exit; |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
###################### |
| 186 |
# ERROR HANDLING |
| 187 |
###################### |
| 188 |
sub error |
| 189 |
{ |
| 190 |
print "<HTML><BODY>"; |
| 191 |
print "<BOLD><p><FONT size=+1>Auto Image Error:<FONT COLOR=\"#FF0000\"> <B>$_[0]</B></FONT></FONT><BR>"; |
| 192 |
exit; |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|