#!/usr/ucb/perl ########################################################################### # cgi-lib.sol # # # # This script was written by Selena Sol (selena@eff.org # # http://www.eff.org/~erict) having been inspired by countless other # # perl authors. Feel free to copy, cite, reference, sample, borrow or # # plagiarize the contents. However, please let me know where it goes so # # that I can at least watch and take part in the development of the # # memes. Information wants to be free, support public domain freeware. # # # ########################################################################### ########################################################################### # counter # ########################################################################### sub counter { # Assign to the local variable $counter_file, the filename that we passed # to this subroutine from the main script. local($counter_file) = @_; # Open up the counter file. If the counter file cannot be opened, # however, access the &open_error routine passing it the filename open (COUNTER_FILE, "$counter_file") || &open_error($counter_file); # Check to see what number the counter is currently on and assign that # value to $_ while () { $item_number = "$_"; } close (COUNTER_FILE); # Add one to that number, change the counter file to the new number, # return the number to the mian script, and close the counterfile. $item_number += 1; open (NOTE, ">$counter_file") || &open_error($counter_file); print NOTE "$item_number\n"; close (NOTE); return $item_number; } ########################################################################### # open_error # ########################################################################### sub open_error { # Assign to the local variable $file_name, the filename that we passed # to this subroutine from the referenceing routine. local ($filename) = @_; # Let the client know that the script was unable to open the requested file # and then die so that the routine does not continue print "I am really sorry, but for some reason I was unable to open

$filename

Would you please make sure that the filename is correctly defined in define_variables.pl, actually exists, and has the right permissions relative to the web browser. Thanks!"; die; } ########################################################################### # header_tags # ########################################################################### sub header_tags { local ($title) = @_; $header_tags = "\n\n$title\n\n"; return $header_tags; } ########################################################################### # table_header # ########################################################################### sub table_header { # Assign to the local variable $file_name, the filename that we passed # to this subroutine from the referenceing routine. local (@headings) = @_; local ($table_header); # Now dump the HTML arguments into the $table_tag variable. foreach $table_field (@headings) { $table_header .= "$table_field\n"; } $table_header .= "\n"; return $table_header; } ########################################################################### # select_tag # ########################################################################### sub select_tag { # Assign to the local variable $file_name, the filename that we passed # to this subroutine from the referenceing routine. local ($name, $size, $multiple) = @_; local ($select_tag, $select_argument); local (@select_arguments, @select_values, %SELECT_ARGUMENTS); %SELECT_ARGUMENTS = ("NAME", "$name", "SIZE", "$size", "MULTIPLE", "$multiple"); @select_arguments = keys %SELECT_ARGUMENTS; @select_values = values %SELECT_ARGUMENTS; $select_tag = ""; $select_argument = ""; # Now dump the HTML arguments into the $table_tag variable. $select_tag .= "