#!/usr/bin/perl
#############################################################
#update!!! this version now includes better error messages, with an option to have either technical error messages
#or nice ones for non-sysadmins. With the non-technical error message is a mailto link so the viewer can email you the #problem info--already filled out in the email for them
# --I am considering writing to a log file instead, but that could needlessly complicate matters--once the program is up
#and running and debugged, it really should not generate any more errors
#
# #
# photoview Version 1.55b#
#automatic thumbnail photo gallery creation and viewing of images at different resolutions
#works with any image format
#Version Date: 12 December 2000
#works with picsize_finder version 1.31 or higher
#Copyright 2000 by Michael K. Goode#
#This script is free for use, distribution, and modification#
#The only right I reserve is this header must remain intact, as long as the program#
#is used for its original purpose (displaying a thumbnail gallery and pictures at different resolutions).#
#This header may be removed, if, and only if, a portion of the code is used in a program that does not#
#fulfill either of the two functions of this program#
#The home of this script: http://www.mikegoode.com/web/scripts/#
#please check there for any updates or upgrades or bug fixes and for help files#
#my email address: mike@mikegoode.com#
#if you have any good changes or additions, please email them to me,#
#and I will add them to the picvu program or add new versions of the program#
#to my website and credit you.#
##
#I am not responsible for any damage resulting from the use of this program#
#and I make no guarentees about its performance, specific or implied#
#I am also not able to help anyone with support, other than #
#by providing some basic help info on my website.#
#############################################################
# YOU CAN CHANGE ANYTHING BELOW THIS POINT TO YOUR HEART'S CONTENT#
#############################################################
#all the images in a certain gallery must be in the same directory
#This program requires a text file
#be present in the same directory as the full-size photos and the
#thumbnails. The gallery.txt file should be in this format:
# thumbnail(tab)width of thumb(tab)height of thumb(tab)
# full-size(tab)width (pixels) of full size(tab)height (pixels) of full size(tab)title [new line]
# thumbnail2(tab)width of thumb(tab)height of thumb(tab)full-size2(tab)
# width (pixels) of full size(tab)height (pixels) of full size(tab)title [new line] . . . etc.
#include the three letter filename ending (.jpg) of the file!!!
#Each entry should be separated by one tab, and there
#should be a new line for each different picture.
#the thumbnails do not need to have the same name as the big image files
#to have this gallery.txt file automatically created, go to my script archive and download picsize_finder.pl
#
#When linking to a particular gallery, make the hyperlink like this:
#"http://www.mikegoode.com/cgi-#bin/photoview.pl?http://www.mikegoode.com/photo/gallery/mike3&Photo=Gallery=3&gallery"
#where you link to the program's absolute url, and after the question mark have the absolute url of the directory
#of the thumbnail gallery. Make sure to NOT include the trailing slash after the directory title.
#And then have an '&' and the title of the gallery.
#also, make sure to have an equals sign [=] in place of any spaces in the title section of the hyperlink to this program
#the spaces will be put back later. Without changing the code of this program, the title
#can be up to four words long
#also, the links to the thumbnail page must end in '&gallery' --that is how the program decides whether to run
#the thumbnail or pictureview subroutine.
###########
#version info: this upgrade from v1.51 allows infinitely long gallery titles
################################################################
#General and gallery configuration section
###################################
use strict;
my($text_file) = 'cheese.txt';
#this is the file name of the text file that has all the information in it
my($absolut_directory) = '/data/domains/mikegoode.com/public_html/photo/gallery';
#this is the absolute path to your base photo gallery directory - leave the trailing slash off
my($program) = 'http://www.mikegoode.com/cgi-bin/photoview151b.pl';
#this is the URL of this program
my($gallery_bgcolor) = "ECECEC";
#the background color of the gallery in hexadecimal notation (put "FFFFFF" for white)
my($thumb_border) = "0";
#the size of border you want on the thumbnails, in pixels. "0" for no border
my($table_border) = "0";
#the width in pixels of the table borders; '0' for invisible borders
my($table_align) = "left";
#alignment of pictures in table--either left, center, or right
#############################################
#Configuration section for Image Viewer section (not thumbnails)
#############################################
my($title) = "GodotWEB Photo Gallery";
# This is the title of your page
my($bgcolor) = "ececec";
# This is the background color for the pages this script creates
#in hexadecimal. put "FFFFFF" for white
my($border) = "0";
# This is the size of the border you want around the large images. "0" for no border
my($small_multiplier) = .25;
my($medium_multiplier) = .50;
my($large_multiplier) = .75;
#these are the proportions of the full size image
#that you will multiply the dimensions by to get
#the different size images
#use decimals, and not fractions
my($default_picture_size) = 'medium';
#set the default picture size to 'small' , 'medium' , 'large' , or 'full'
######################################
###Configuration section for &error subroutine
######################################
my($email) = 'mike@mikegoode.com';
#the sysadmin's email (yours, I assume)
my($debuggy) = '0';
#1 if you are debugging the program, otherwise 0
##############################################
##Below here all you need to edit is the html in the header and footer for
##both the thumbnail gallery and image viewer subroutines
########################################
#print "Content-type: text/html\n\n";
#this prints out the html header before anything else, so
#any errors will be displayed properly
if ($ENV{'QUERY_STRING'} eq ""){
error("no info in query string!!!");
}
my($directory_and_title) = "$ENV{'QUERY_STRING'}";
my(@test2) = split(/&/, $directory_and_title);
my($test3) = pop(@test2);
unless ($test3 eq 'gallery'){&pictureview}
########################################
#predeclare thumbnail gallery variables
my($row, $count, @directory_plus_title, $directory, $gallery_title, $return, @directory, $gallery_directory, @ga_title, $gal_footer, $gal_header, $this_line, @pic_info, $thumbnail, $x, $y, $big_pic, $width, $height, $pic_title);
#################################################
##this may seem confusing, but it is basically checking to see if the program was called
##to display a thumbnail gallery or one picture. If the latter, it goes to the pictureview subroutine.
#it gets the info from the query string, and if it finds 'gallery' on the end, it runs the thumbnail routine
#it then stores the query string as a scalar
#this next section gets the gallery directory and title from the query string
#and puts together $return
#it will be used to form the $return_string for future versions
@directory_plus_title = split(/&/, $directory_and_title);
$directory = shift(@directory_plus_title);
$gallery_title = shift(@directory_plus_title);
$return = "$program" . '?' . "$directory" . '&' . "$gallery_title";
#this takes the query string info, and parses the directory and
#gallery title info into two different variables,
@directory = split(/\//, $directory);
$gallery_directory = pop(@directory);
@ga_title = split(/=/, $gallery_title);
$gallery_title = join(" ", @ga_title);
#this puts the gallery title in a nice-looking string, eliminating the equals signs
#########################################
#thumbnail gallery header and footer html
########################################
#just change the html to edit the parts of the thumbnail gallery above (header) and
#below (footer) the photos
##no backslash is needed before quotes --just enter normal html between the
##and comments, and the same with the header.
$gal_footer = <<"BOB";
Navigate GodotWeb
Home > Photo > Photo Galleries > $gallery_title
(All photos © 1999 by Michael Goode. Note: You may copy the
eletronic versions of these photos for your own personal use.
they may be displayed on any not for profit website, as long
as you credit me and link to this site, and do not use them
in any way that implies that I have any connection at all to
you or your website or that I endorse any goals, aims, ideas,
or beliefs of you or your organization. You may not display
them on any website that includes pornographic or violent
content. You may not charge for them, alter them or
disseminate them by any non-electronic method, such as
printing. I reserve all rights not explicitly given up by
this disclaimer. If you want to include these photos on
your website, I would ask you to please ask me, just as a matter of courtesy.)