#!/usr/bin/perl ########################################################################## # # DForum 1.01 (11/02/1999) # http://www.dansteinman.com/dforum # # Copyright (C) 1998 Dan Steinman # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License (license.txt) for more details. # ########################################################################## # # Forum Administration Script # filename: forum-admin.pl # description: Deletes or edits the messages in the forum # ########################################################################## # Set-Up Variables $root = "$ENV{'DOCUMENT_ROOT'}"; $forumdir = "$root/cgi-bin/dforum/forumdata"; # username and password are needed to enter the admin area, they're just hard-coded. $username = "username"; # change this to something else $password = "password"; # change this to something else ########################################################################## # parse form values read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $in{$name} = $value; } ########################################################################## # miscellaneous values $command = $in{'command'}; @months = ("January","February","March","April","May","June","July","August","September","October","November","December"); ########################################################################## # determine what sub-routine to run based on the $command form value if ($command eq '') {&login;} elsif ($command eq 'displayList') {&displayList;} elsif ($command eq 'displayThreads') {&displayThreads;} elsif ($command eq 'deleteThreads') {&deleteThreads;} elsif ($command eq 'displayEditThread') {&displayEditThread;} elsif ($command eq 'editThread') {&editThread;} ########################################################################## # prints the login page sub login { &printHeader("Forum - [Admin Login]"); print <<"EOF";
EOF &printFooter; } ########################################################################## # checks username and password, called from every sub-routine sub checkAccess { if ($in{'username'} ne $username || $in{'password'} ne $password) { print "Content-type: text/html\n\n"; print "Access Denied"; exit(0); } } ########################################################################## # prints a list of months that have been archived sub displayList { &checkAccess; &printHeader("Forum - [Choose Month To Edit]"); print " EOF &printFooter; } ########################################################################## # print the headers for a particular month sub displayThreads { &checkAccess; $headerfile = $in{'headerfile'}; $year = substr ($headerfile,0,4); $month = substr ($headerfile,4,5); $month = sprintf("%5.0f", $month); $monthname = $months[$month-1]; open(DATA,"$forumdir/$headerfile.txt"); @headerlines = ; close(DATA); $length = @headerlines; &printHeader("Forum - Edit/Delete Threads"); print <<"EOF"; $monthname $yearDelete | Edit | Num | Subject | Author | Responses | Date |
Message number $toedit has been saved
EOF } ########################################################################## # common HTML footer for all pages sub printFooter { print <<"EOF";
DForum 1.0
EOF
}