#!/usr/bin/perl # # Master Board V2 # Version 2.12-s # # Master Board version 1.0 completed January 2001 # Master Board V2 version 2.12 completed June 22, 2003 # # MasterBoard.cgi # (Master Board V2 Posts and Replies Handling) # # Author: William Bontrager # Email: william@willmaster.com # Site: http://www.willmaster.com/ # # Copyright 2001 William and Mari Bontrager. # Copyright 2002,2003 Bontrager Connection, LLC # # Before installing and/or using Master Board V2, # you must agree to the complete license agreement, # linked from http://willmaster.com/master # # Tech support: http://willmaster.com/support/cgi-bin/forum/MasterBoard.cgi # # MasterBoardManual.html has installation instructions. # #################################################### use LWP::Simple; $DataDirectory = 'MBdata'; $MBdatafile = 'MBposts'; $ArchiveDirectory = 'Archive'; $GlobalData = $DataDirectory . '/GlobalData.txt'; $EmailTemplate = $DataDirectory . '/emailtemplate.txt'; $ME = $0; $ME =~ s!.*[\\/]!!; unless(&GetGlobals) { ErrorHTML('Sorry, I can\'t find the global data file.'); } #if ($G{archive_it} eq $G{delete_it} ){&ErrorHTML ('Please choose EITHER "archive" or "delete" old files before you install this program')} &ArchiveOldThreads; &Parse; &HelpFile if $In{H}; &PostOpEntry if $In{opost}; &ReplyDisplay if $In{postlink}; &PostReEntry if $In{rpost}; &GetFirstPage; ########## ## Here are the subroutines ## #Read in the initial html page sub GetFirstPage { my $page = get $G{TemplatePosts} or &ErrorHTML("To retrieve the template for the first page ",$!,$G{TemplatePosts}); #do the search and replace stuff my $insert1= &InitialInsertOne; my $insert2= &InitialInsertTwo; my $insert3= &InitialInsertThree; my $biginsert = "$insert1 $insert2 $insert3"; $page =~ s/\[MasterBoard Here\]/$biginsert/sig; print "Content-Type: text/html\n\n"; print $page; goto BOTTOM; } #end sub GetFirstPage #looks up and displays initial (current) page insert part one sub InitialInsertOne { $insert1=<
|
Help Post a new message: |
HTML goto BOTTOM; } # end sub ErrorHTML # Parses input sub RB { my $s = shift; $s =~ /\&\#(\d{1,3})\;/; return $s unless chr($1) =~ /[et]/i; return '&' . substr($s,1); } # sub RB sub Parse { my $buffer; if ($ENV{REQUEST_METHOD} eq 'GET') { $buffer = $ENV{QUERY_STRING}; } else { read(STDIN,$buffer,$ENV{CONTENT_LENGTH}); } my @p = split(/&/,$buffer); foreach(@p) { $_ =~ tr/+/ /; my ($n,$v) = split(/=/,$_,2); $n =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge; $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ges; $v =~ s/(\&\#\d{1,3}\;)/RB($1)/ges; $v =~ s/(\<.*?)(embed|object|script|applet)(.*?\>)/$1$3/gis; if($In{$n}) { $In{$n} .= "\t$v"; } else { $In{$n} = $v; } } $In{postlink} =~ s/[^\w\.]//gs; $In{linkclicked} =~ s/[^\w\.]//gs; } # end sub Parse #Add an original post. sub PostOpEntry { unless ($In{name} =~ /\w/) { &ErrorHTML('Please enter your screen name.') } if ($In{email}) { &ValidEmail($In{email}) or &ErrorHTML('Your email address is invalid. Please click the back button and correct it.') } unless ($In{subject} =~ /\w/) { &ErrorHTML('Please provide a subject line.') } unless ($In{opentry} =~ /\w/) { &ErrorHTML('Please enter your question or comment.') } if ($In{NotifyMe} eq 'yes') {unless ($In{email}) {&ErrorHTML('We need your email address in order to notify you of new posts to this thread.') } } $In{name} = &AdjustForHTMLdisplay($In{name}); $In{email} = &AdjustForHTMLdisplay($In{email}); $In{email} =~s/\@/\*/; $In{subject} = &AdjustForHTMLdisplay($In{subject}); $In{opentry} = &AdjustForHTMLdisplay($In{opentry}); my $t=time; my $file = "$DataDirectory\/$t"; &LockFile($file); open W,">$file" or &ErrorHTML("The file could not be opened.\n"); print W "$In{name}\n"; print W "$In{email}\n"; print W " Notify Me - $In{NotifyMe}\n"; print W "$In{subject}\n"; print W "$In{opentry}\n"; close W; &UnLockFile($file); my $datafile = "$DataDirectory\/$MBdatafile"; &LockFile($datafile); open W,">>$datafile"; print W join("\t",$t,$In{name},$In{subject},'0'); print W "\n"; close W; &UnLockFile($datafile); &MaintainerMailOPost($In{name},$In{email},$In{subject},$In{opentry}); &GetFirstPage; } # end sub PostOpEntry ######################## #Display posts and any replies sub ReplyDisplay { my $newpage = get $G{TemplateReplies} or &ErrorHTML("To display a reply ",$!,$G{TemplateReplies}); #do the search and replace stuff $reinsert1= &ReplyInsertOne; $reinsert2= &ReplyInsertTwo; $reinsert3= &ReplyInsertThree; $reinsert4= &ReplyInsertFour; my $biginsert = "$reinsert1 $reinsert2 $reinsert3 $reinsert4"; $newpage =~ s/\[MasterBoard Here\]/$biginsert/sig; print "Content-Type: text/html\n\n"; print $newpage; goto BOTTOM; }#end sub ReplyDisplay #prints the top of the table sub ReplyInsertOne { $reinsert1 = <Notice:
- $s
|
-Back to forum- Help Reply to this thread: |
/g;
$s =~ s/\n/ The opening page of the bulletin board lists the subject of each post, who it is from and the number of responses the post has received. To see the complete message and/or any responses, click on the subject line.
To post a new question or observation on the Board, fill out the form titled "Post a new message"- (below the board on the initial page).
To contribute a response to any post, click on the subject line, if you haven't done so already, and you will be taken to a page containing the complete original post plus any responses already posted. Fill out the form below the board titled "Reply to this thread".
/g;
return $s;
} # end sub AdjustForHTMLdisplay
#Add REPLY to an original post.
sub PostReEntry
{
unless ($In{rname} =~ /\w/)
{
&ErrorHTML('Please enter your screen name.')
}
if ($In{remail})
{
&ValidEmail($In{remail}) or &ErrorHTML('Your email address is invalid. Please click the back button and correct it.')
}
unless ($In{rentry} =~ /\w/)
{
&ErrorHTML('Please enter your reply to the original post.')
}
if ($In{NotifyMe} eq 'yes')
{unless ($In{remail})
{&ErrorHTML('We need your email address in order to notify you of new posts to this thread.')
}
}
$In{rname} = &AdjustForHTMLdisplay($In{rname});
$In{remail} = &AdjustForHTMLdisplay($In{remail});
$In{email} =~s/\@/\*/;
$In{rentry} = &AdjustForHTMLdisplay($In{rentry});
&NotifyMe;
my $t= time;
my $file = "$DataDirectory\/$In{linkclicked}";
&LockFile($file);
open A,">>$file" or &ErrorHTML("The file $In{linkclicked}could not be opened to append at $t.\n");
print A "\t$t\n";
print A "$In{rname}\n";
print A "$In{remail}\n";
print A " Notify Me - $In{NotifyMe}\n";
print A "\n";
print A "$In{rentry}\n";
close A;
&UnLockFile($file);
open R,"$DataDirectory\/$MBdatafile" or &ErrorHTML("The file $MBdatafile could not be opened to read.\n");
my @F = Hints for using Master Board V2