#!/usr/bin/perl -- print "Content-type:text/HTML\n\n"; #Parameters separate with && # Required: # directory==Sports/TestTournament/Division1/Team_vs_Team001/Pictures # # Optional: # size==Thumbnails # cols==3 defaults to 5 if not included # table==600 sets the table width # border==1 turns on the table border # cellpadding==1 sets the amount of padding inside each table cell # imagenames==on turn the image names on for viewing at the Thumbnail level # heading_text==Alaska vs Illinois Text to appear at the top of the page # title==www.CarmoPhotography.com # bgcolor==FFFFFF rgb value of color -- do not include the # # background==/Background/0003.jpg path to background image # text_color==000000 rgb value of color -- do not include the # # full_size_style==popup OR page # image_viewer.cgi $script_name = "image_viewer.cgi"; $header = "image_header.jpg"; # Set default values $PARAM{'cols'}="2"; $PARAM{'size'}="Thumbnails"; $PARAM{'table'}="600"; $PARAM{'border'}="0"; $PARAM{'cellpadding'}="10"; $PARAM{'imagenames'}="on"; $PARAM{'heading_text'}="Buy Your Team Photo Now"; $PARAM{'title'}="PA-Softball.com"; $PARAM{'bgcolor'}="FFFFFF"; $PARAM{'background'}=""; $PARAM{'text_color'}="000000"; $PARAM{'full_size_style'}="page"; $PARAM{'link_color'}="0000FF"; $PARAM{'visited_link_color'}="FF0000"; $PARAM{'hover_link_color'}="FF0000"; $PARAM{'paypal_checkout'}="on"; $PARAM{'paypal_userid'}="greg.barrick\@pa-softball.com"; $PARAM{'image_price'}="10.00"; if($ENV{'QUERY_STRING'} ne "") { $query_string = $ENV{'QUERY_STRING'}; # the file to display $query_string =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; @qs = split(/&&/,$query_string); foreach (@qs) { ($name, $value)=split(/==/,$_); $PARAM{$name} = $value; # print "$name = \"$value\"
"; } } #default number of columns if not set in query string $number_of_columns=$PARAM{'cols'}; #$directory = $PARAM{'directory'} . "/" . $PARAM{'size'}; $output = "$PARAM{'title'} \n\n
"; # if specific file not given, dispaly all images if ( $PARAM{'file'} eq "" ) { $directory = $PARAM{'directory'} . "/" . $PARAM{'size'}; if (-d $directory) { opendir(DIR, "$directory"); @files = readdir(DIR); closedir(DIR); } else { print "Directory [ $directory ] does not exist."; exit; } #Take files out of array that are not images .gif of .jpg foreach $file (@files) { ($filename, $extension) = split(/\./,$file); if (($extension eq "gif") || ($extension eq "jpg")) { @image_file[$number_images] = $file; $number_images++; } } # See if image header file exists, if not use text if(-e $header) { $output .= "\"Image"; } else { $output .= "

$PARAM{'heading_text'}

"; } $output .= "Click on image to view at full size.

"; $current_image="1"; $array_image_number="0"; foreach $file (@image_file) { $cur_column = ( $current_image % $number_of_columns ); if ( $cur_column eq "1" ) { $output .= ""; if ( $cur_column eq "0" ) { $output .= "\n"; } $current_image++; $array_image_number++; } # end foreach if ( $cur_column ne "0" ) { $output .= "\n"; } $output .= "
"; } else { $output .= "
"; } $url_string="image_viewer.cgi?directory==$PARAM{'directory'}/FullSize_Reduced&&file==$file&&file_number==$array_image_number&&bgcolor==$PARAM{'bgcolor'}&&background==$PARAM{'background'}&&text_color==$PARAM{'text_color'}&&title==$PARAM{'title'}&&full_size_style==$PARAM{'full_size_style'}"; if ( $PARAM{'full_size_style'} eq "popup") { $output_type = "\n"; $output .= "$output_type"; } else { $output_type = "\n"; $output .= "$output_type"; } $output .= "\n "; if ( $PARAM{'imagenames'} ne "off" ) { $output .= "\n\t\t\t
$output_type $file"; } $output .= "\n\t\t\t
"; } #end if else { # a file or file_number supplied in URL string.... show selected image if (-d $PARAM{'directory'}) { opendir(DIR, "$PARAM{'directory'}"); @files = readdir(DIR); closedir(DIR); } else { print "Directory [ $PARAM{'directory'} ] does not exist."; exit; } #Take files out of array that are not images .gif of .jpg $number_images = "0"; foreach $file (@files) { ($filename, $extension) = split(/\./,$file); if (($extension eq "gif") || ($extension eq "jpg")) { @image_file[$number_images] = $file; $number_images++; } } $previous = $PARAM{'file_number'} - 1; $next = $PARAM{'file_number'} + 1; if ( $previous >= "0" ){ $previous_url_string=" << "; } else { $previous_url_string=""; } if ( $next < $number_images ) { $next_url_string=" >> "; } else { $next_url_string=""; } $output .= "
"; $output .= "$previous_url_string   $PARAM{'file'}   $next_url_string"; # add text "Back" on bottom of image if run in "page" mode if ( $PARAM{'full_size_style'} eq "page" ){ $output .= "

Back"; } # add paypal stuff if paypal is turned "on" if ( $PARAM{'paypal_checkout'} eq "on" ){ $output .= "
Buy Now using
Item: $PARAM{'file'}
Price: \$$PARAM{'image_price'}
Shipping/Handling: FREE
Photo Size: 8\" x 10\"
** PA Softball Special -- Order 4 or more of the same picture and get 1 free **
"; } } $output .= "

\n"; print "$output";