#!/usr/bin/perl require 'load.cgi'; &parse_query; if($QUERY{'action'} eq "") { print "Content-Type: text/html\n\n"; print "\n"; print "
\n";
print "Current Topics\n";
print "
| Key: | Question: | Expires: | Actions: |
| $topic | $question | $exp | \n"; print "Delete\n"; print " |
\n";
print "
| \n";
print "Add Topic Form \n"; print "\n"; print " |
"); } elsif($QUERY{'action'} eq "unlink") { &parse_form; if(!($FORM{'password'} eq "$password")) { &error("You entered an incorrect password. Please check your password and try again!"); } $dat_file = "$base_dir/$QUERY{'topic'}\.$file_ext"; if(! -e $dat_file) { $dat_file = "$dat_file\.old"; if(! -e $dat_file) { &error("Data file for the topic, $QUERY{'topic'}, was not found."); } } $ip = "$base_dir/$QUERY{'topic'}\.ip"; unlink("$dat_file"); unlink("$ip"); &error("The topic, $QUERY{'topic'}, has been successfully removed."); } elsif($QUERY{'action'} eq "add") { &parse_form; &error("Form Incomplete") unless $FORM{'password'}; &error("Form Incomplete") unless $FORM{'question'}; &error("Form Incomplete") unless $FORM{'key'}; &error("Form Incomplete") unless $FORM{'exp'}; if($FORM{'exp'} !~ /([0-9])*/ && $FORM{'exp'} !~ /never/i) { &error("Please enter the amount of days until the topic expires. If you do not want it to expire enter \"never\" as the expiration date.\n"); } if($FORM{'key'} =~ /\W/) { &error("You may only enter normal characters \(a-zA-z0-9\) in the reference key field"); } if(!($password eq "$FORM{'password'}")) { &error("You have entered an incorrect password. Please check your password and try again."); } $flag = 0; for($i=1;$i<=8;$i++) { $key = "a$i"; if($FORM{$key}) { if(! $flag) { $string = "$FORM{$key}=0"; $flag = 1; } else { $string = "$string&$FORM{$key}=0"; } $incomplete = 0; } } if($incomplete) { &error("Form Incomplete!"); } if($FORM{'exp'} !~ /never/i) { $FORM{'exp'} += &get_days; } $string = "$string&question=$FORM{'question'}&exp=$FORM{'exp'}"; open(FILE, ">$base_dir/$FORM{'key'}\.$file_ext") || die "Can't open $base_dir/$FORM{'key'}\.$file_ext\n"; print FILE "$string\n"; close(FILE); open(FILE, ">$base_dir/$FORM{'key'}\.ip") || die "Can't open $base_dir/$FORM{'key'}\.ip\n"; print FILE "[IP TRACKING FILE]\n"; close(FILE); &error("The new topic has been added!"); } else { &error("The function you entered in the query string was not found!"); }