#!/usr/local/bin/perl ############################################################################## # Single Admin Script for WWWboard2 Multi-Page # # Author Steven C Miller Jr # # Date Created: 2/24/1999 # # Description: This allow a user to delete one message without # having to pull up the whole admin page # ########################################################################### use CGI::Carp "fatalsToBrowser"; ################################################### ### Update Multi-Page Bulletin Boards Also When Done $basedir = "//wwwboard"; $baseurl = "http:///wwwboard"; $cgi_url_admin = "http:///cgi-bin/multipageboardadmin.pl"; $cgi_board_name = "multipageboard.pl"; # the name of the main perl script $password = 'admin'; $mesgdir = "messages"; $datafile = "data.txt"; $mesgfile = "baseboard.html"; $ext = '.html'; $title = "The Test Admin GUI"; $use_time = 1; # 1 = YES; 0 = NO ########################################## &parse_form; if($FORM{'password'} eq '') { &opening_page; } elsif($FORM{'password'} eq $password) { &remove_item; } else { &opening_page; } ####################### # Parse Form Subroutine sub parse_form { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } ########################################################################### # Remove Action # # This portion is used by the options remove and remove_by_num. # ########################################################################### sub remove_item{ if ($FORM{'Delete_Type'} eq 'all') { push(@ALL,$FORM{'Delete_Entry'}); } elsif ($FORM{'Delete_Type'} eq 'single') { push(@SINGLE,$FORM{'Delete_Entry'}); } open(MSGS,"$basedir/$mesgfile"); @lines = ; close(MSGS); foreach $single (@SINGLE) { foreach ($j = 0;$j <= @lines;$j++) { if ($lines[$j] =~ //) { splice(@lines, $j, 3); $j -= 3; } elsif ($lines[$j] =~ //) { splice(@lines, $j, 1); $j--; } } $filename = "$basedir/$mesgdir/$single$ext"; if (-e $filename) { unlink("$filename") || push(@NOT_REMOVED,$single); } else { push(@NO_FILE,$single); } push(@ATTEMPTED,$filename); } foreach $all (@ALL) { undef($top); undef($bottom); foreach ($j = 0;$j <= @lines;$j++) { if ($lines[$j] =~ //) { $top = $j; } elsif ($lines[$j] =~ //) { $bottom = $j; } } if ($top && $bottom) { $diff = ($bottom - $top); $diff++; for ($k = $top;$k <= $bottom;$k++) { if ($lines[$k] =~ //) { push(@DELETE,$1); } } splice(@lines, $top, $diff); foreach $delete (@DELETE) { $filename = qq{$basedir/$mesgdir/$delete$ext}; if (-e $filename) { unlink($filename) || push(@NOT_REMOVED,$filename); } else { push(@NO_FILE,$delete); } push(@ATTEMPTED,$filename); } } else { push(@TOP_BOT,$all); } } open(WWWBOARD,">$basedir/$mesgfile"); print WWWBOARD @lines; close(WWWBOARD); &return_html($FORM{'type'}); } ########################################################## ## Print Opening Page ######################################################### sub opening_page{ print "Content-type: text/html\n\n"; print "Remove a Message From Tinnitus Message Board\n"; print "

Remove a Message From WWWBoard

\n"; print "Checking the Input Box on the left will remove the whole thread\n"; print "while checking the Input Box on the right to remove just that posting.

\n"; print "Than Simply Enter the Message Number in the Message Number Field\n"; print "If the message to be deleted is name 12345.html the message number\n"; print "is simple 12345\n"; print "

\n"; print "


\n"; print "
\n"; print "\n"; print qq~ \n ~; print "
Message Number Thread Single
Password:

\n"; print " \n"; print "

\n"; print "\n"; } ########################################################### ## Return HTML ########################################################## sub return_html { $type = $_[0]; ## Updates Multi Page Bulletin Boards $admin = 1; eval { require "$cgi_board_name"; # Multipage Update }; print "Content-type: text/html\n\n"; print "Results of Message Board Removal\n"; print "

Results of Message Board Removal

\n"; print "Below is a short summary of what messages were removed from $mesgpage and the\n"; print "$mesgdir directory. All files that the script attempted to remove, were removed,\n"; print "unless there is an error message stating otherwise.


\n"; print "The following messages have been removed unless and error is shown below : @ATTEMPTED

\n"; if (@NOT_REMOVED) { print "Files That Could Not Be Deleted: @NOT_REMOVED

\n"; } if (@NO_FILE) { print "Files Not Found: @NO_FILE

\n"; } print "


\n"; print qq{Return to Main Page}; print "
\n"; print "\n"; } sub error { $error = $_[0]; if ($error eq 'bad_combo') { print "Bad Username - Password Combination\n"; print "

Bad Username - Password Combination

\n"; print "You entered and invalid username password pair. Please try again.

\n"; &passwd_trailer } elsif ($error eq 'passwd_file') { print "Could Not Open Password File For Reading\n"; print "

Could Not Open Password File For Reading

\n"; print "Could not open the password file for reading! Check permissions and try again.

\n"; &passwd_trailer } elsif ($error eq 'not_same') { print "Incorrect Password Type-In\n"; print "

Incorrect Password Type-In

\n"; print "The passwords you typed in for your new password were not the same.\n"; print "You may have mistyped, please try again.

\n"; &passwd_trailer } elsif ($error eq 'no_change') { print "Could Not Open Password File For Writing\n"; print "

Could Not Open Password File For Writing

\n"; print "Could not open the password file for writing! Password not changed!

\n"; &passwd_trailer } exit; }