#!"C:\xampp\perl\bin\perl.exe" ##! /usr/local/bin/perl ##! perl ###################################################################### # Name: ptcal.cgi # Contact: walt@cassbeth.com # Created: 01/08/97 # Archive: http://www.cassbeth.com/scripts/ ###################################################################### # COPYRIGHT NOTICE: Copyright 2010 CassBeth # # This program is being distributed as shareware. It may be used and # modified by anyone, so long as this copyright notice and the header # above remain intact, but any usage should be registered within 10 days. # By using this program you agree to indemnify everyone from any liability. # # Selling the code for this program without prior written consent is # expressly forbidden. Obtain permission before redistributing this # program over the Internet or in any other medium. # # In all commercial cases copyright and header must remain intact. # Professors and students are free to modify this header as needed. # # VERSION HISTORY: # # 1.0 02/18/2010 First Release $version = "021810"; ###################################################################### # Define Variables $url = "http://localhost:4444/html/web/cses"; $script = $ENV{'SCRIPT_NAME'}; $script =~ s/.*\/(.*)$/$1/; @months = ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"); %months = (Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec,12); #################### BEGIN { use CGI::Carp qw(carpout); open(LOG, ">>error-cgi.log") or die("Unable to open file: $!\n"); carpout(LOG); } use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; &get_date; &parse_form; if (!%FORM) {&control_menu;} if (%FORM) {&results}; &save_record; #print "\n"; #################### sub get_date { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($sec < 10) {$sec = "0$sec";} if ($min < 10) {$min = "0$min";} if ($hour < 10) {$hour = "0$hour";} if ($mon < 10) {$mon = "0$mon";} if ($mday < 10) {$mday = "0$mday";} $year = 2000 + $year - 100; $month = ($mon + 1); $date = "$month/$mday/$year, $hour\:$min\:$sec"; } #################### sub parse_form { if ($ENV{'REQUEST_METHOD'} eq 'GET') { # Split the name-value pairs @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); } foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # If they try to include server side includes, erase them, so they # arent a security risk if the html gets returned. Another # security hole plugged up. $value =~ s///g; $FORM{$name} = $value; } # debug to show all form entries and values #foreach $setting (keys %FORM) {print "$FORM{$setting} $setting
";} $accttype = $FORM{'accttype'}; if (!$accttype) {$show = $d_accttype;} $name = $FORM{'name'}; if (!$name) {$show = $d_name;} } #################### sub get_data { $file = "data.txt"; open(PRODUCTS,"$file") || print "Error $! - $file "; @PRODUCTS = ; close(PRODUCTS); $aip = $#PRODUCTS; } #################### sub get_template { $file = "template.html"; open(TEMPLATE,"$file") || print "Error $! - $file "; @TEMPLATE =