#!/usr/local/bin/perl ############################################################################## # WWWBoard Version 2.0 ALPHA 2 # # Copyright 1996 Matt Wright mattw@worldwidemart.com # # Created 10/21/95 Last Modified 11/25/95 # # Scripts Archive at: http://www.worldwidemart.com/scripts/ # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1996 Matthew M. Wright All Rights Reserved. # # # # WWWBoard may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Matthew M. Wright from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# ############################################################################## # Define Variables # DBasics mod to set background and a logo. # Add this in the "Define Variables" section near the top of the wwwboard.cgi script. $background = '
home questions looks like is like not like modelling
'; #$basedir = "/path/to/wwwboard"; #$baseurl = "http://your.host.xxx/wwwboard"; #$cgi_url = "http://your.host.xx/cgi-bin/wwwboard.pl"; $basedir='/user/fa/fatemaps/public_html/breath/forum/'.$ENV{'QUERY_STRING'}; $baseurl='http://www.interlog.com/~fatemaps/breath/forum/'.$ENV{'QUERY_STRING'}; $cgi_url='http://www.interlog.com/~fatemaps/breath/forum/wwwboard.cgi?'.$ENV{'QUERY_STRING'}; #DBasics mod to support multiple boards with one script #$basedir='/cgi-bin/'.$ENV{'QUERY_STRING'}; #$baseurl='http://home.netinc.ca/cgi-bin/'.$ENV{'QUERY_STRING'}; #$http://home.netinc.ca/cgi-bin/wwwboard.cgi?'.$ENV{'QUERY_STRING'}; # DBasics mod to allow e-mail subscriptions # Add this to the WWWBoard Script at the top with the other variables defined. # This should match the mail program on your system. $mailprog = '/usr/sbin/sendmail'; $host = 'mail.interlog.com'; $subscribe = "email.txt"; $mesgdir = "messages"; $datafile = "data.txt"; $mesgfile = "index.html"; $faqfile = "../faq.html"; $ext = "html"; # Jeff Mann mod - get name of forum from a text file #$title = "List Messages"; open (FILE,"$basedir/forumname.txt"); $title = ; close(FILE); # Done ########################################################################### ########################################################################### # Configure Options $show_faq = 0; # 1 - YES; 0 = NO $allow_html = 1; # 1 = YES; 0 = NO $quote_text = 0; # 1 = YES; 0 = NO $subject_line = 2; # 0 = Quote Subject Editable; 1 = Quote Subject # UnEditable; 2 = Don't Quote Subject, Editable. $use_time = 0; # 1 = YES; 0 = NO # Done ########################################################################### # Get the Data Number &get_number; # Get Form Information &parse_form; # Put items into nice variables &get_variables; # View Before Posting Modification #if ($FORM{'action'} ne "post") { # &view_post #} # Open the new file and write information to it. &new_file; # Open the Main WWWBoard File to add link &main_page; # Now Add Thread to Individual Pages if ($num_followups >= 1) { &thread_pages; } # Return the user HTML &return_html; # Increment Number &increment_num; ############################ # Get Data Number Subroutine sub get_number { open(NUMBER,"$basedir/$datafile"); $num = ; close(NUMBER); if ($num == 99999) { $num = "1"; } else { $num++; } } ####################### # 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; $value =~ s///g; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } else { unless ($name eq 'body') { $value =~ s/<([^>]|\n)*>//g; } } $FORM{$name} = $value; } } ############### # Get Variables sub get_variables { if ($FORM{'followup'}) { $followup = "1"; @followup_num = split(/,/,$FORM{'followup'}); $num_followups = @followups = @followup_num; $last_message = pop(@followups); $origdate = "$FORM{'origdate'}"; $origname = "$FORM{'origname'}"; $origsubject = "$FORM{'origsubject'}"; } else { $followup = "0"; } if ($FORM{'name'}) { $name = "$FORM{'name'}"; $name =~ s/"//g; $name =~ s///g; $name =~ s/\&//g; } else { &error(no_name); } if ($FORM{'email'} =~ /.*\@.*\..*/) { $email = "$FORM{'email'}"; } if ($FORM{'subject'}) { $subject = "$FORM{'subject'}"; $subject =~ s/\&/\&\;/g; $subject =~ s/"/\"\;/g; } else { &error(no_subject); } if ($FORM{'url'} =~ /.*\:.*\..*/ && $FORM{'url_title'}) { $message_url = "$FORM{'url'}"; $message_url_title = "$FORM{'url_title'}"; } if ($FORM{'img'} =~ /.*tp:\/\/.*\..*/) { $message_img = "$FORM{'img'}"; } if ($FORM{'body'}) { $body = "$FORM{'body'}"; $body =~ s/\cM//g; $body =~ s/\n\n/

/g; $body =~ s/\n/
/g; $body =~ s/<//g; $body =~ s/"/"/g; } else { &error(no_body); } if ($quote_text == 1) { $hidden_body = "$body"; $hidden_body =~ s//>/g; $hidden_body =~ s/"/"/g; } ($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"; } $month = ($mon + 1); @months = ("January","February","March","April","May","June","July","August","September","October","November","December"); if ($use_time == 1) { $date = "$hour\:$min\:$sec $month/$mday/$year"; } else { $date = "$month/$mday/$year"; } chop($date) if ($date =~ /\n$/); $long_date = "$months[$mon] $mday, 19$year at $hour\:$min\:$sec"; } #################################################################### # viewpost View WWWBOARD Article Before Posting Add-On # Created by Craig Horton (chorton@dbasic.com) # Contributions by Matt Wright (mattw@misha.net) # Created on: 5/4/96 # I can be reached at: chorton@dbasic.com # Script Found at: http://www.dbasic.com/scripts/ # This script may be redistributed for non-commericial reasons # as long as this header remains intact. All copyrights reserved. #################################################################### ############################### # View Post Subroutine Add-On # ############################### sub view_post { print "Content-type: text/html\n\n"; print "$subject\n"; print "$background

$subject

\n"; print "


\n"; print "Name: $name
\n"; print "E-Mail: $email
\n"; print "Subject: $subject
\n"; if ($followup == 1) { print "In Reply to: $origsubject posted by "; if ($origemail) { print "$origname on $origdate:

\n"; } else { print "$origname on $origdate:

\n"; } } print "Body of Message:

\n"; if ($message_img) { print "

\n"; } print "$body

\n"; if ($message_url) { print "Link: $message_url_title\n"; } print "

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

Use Your Browser's [Back] Button To Make Changes\n"; print "

\n"; print "


\n"; exit; } # END OF SCRIPT ADD-ON ##################### # New File Subroutine sub new_file { open(NEWFILE,">$basedir/$mesgdir/$num\.$ext") || die $!; print NEWFILE "\n"; print NEWFILE " \n"; print NEWFILE " Embryogenesis response: $subject\n"; print NEWFILE " \n"; print NEWFILE " $background\n"; print NEWFILE "
\n"; # if ($show_faq == 1) { # print NEWFILE "[ Follow Ups ] [ Post Followup ] [ $title ] [ FAQ ]\n"; # } # else { # print NEWFILE "[ Follow Ups ] [ Post Followup ] [ $title ]\n"; # } # print NEWFILE "

\n"; print NEWFILE "posted by "; if ($email) { print NEWFILE "$name on $long_date:\n"; } else { print NEWFILE "$name on $long_date:\n"; } if ($followup == 1) { print NEWFILE "
in reply to: $origsubject posted by "; if ($origemail) { print NEWFILE "$origname on $origdate:

\n"; } else { print NEWFILE "$origname on $origdate:

\n"; } } print NEWFILE "


\n"; print NEWFILE " $subject

\n"; if ($message_img) { print NEWFILE "

\n"; } print NEWFILE "$body\n"; # print NEWFILE "
\n"; if ($message_url) { print NEWFILE "

\n"; } print NEWFILE "
\n"; # print NEWFILE "

\n"; print NEWFILE "Follow Ups:\n"; # print NEWFILE "
\n"; print NEWFILE "
    \n"; print NEWFILE "
\n"; print NEWFILE "
\n"; print NEWFILE "post a Follow Up:\n"; print NEWFILE "\n"; print NEWFILE "\n"; print NEWFILE "\n"; if ($email) { print NEWFILE "\n"; } print NEWFILE "\n"; print NEWFILE "\n"; print NEWFILE "name:

\n"; print NEWFILE "email:

\n"; if ($subject_line == 1) { if ($subject_line =~ /^Re:/) { print NEWFILE "\n"; print NEWFILE "comments: $subject
\n"; } else { print NEWFILE "\n"; print NEWFILE "title: Re: $subject
\n"; } } elsif ($subject_line == 2) { print NEWFILE "title:

\n"; } else { if ($subject =~ /^Re:/) { print NEWFILE "title:

\n"; } else { print NEWFILE "title:

\n"; } } print NEWFILE "comments:
\n"; print NEWFILE "\n"; print NEWFILE "
optional link URL (please include http://):\n"; print NEWFILE "

\n"; print NEWFILE "link title:

\n"; # print NEWFILE "optional image URL:
\n"; print NEWFILE "
\n"; print NEWFILE " or \n"; print NEWFILE "
\n"; # if ($show_faq == 1) { # print NEWFILE "[ Follow Ups ] [ Post Followup ] [ $title ] [ FAQ ]\n"; # } # else { # print NEWFILE "
[ Follow Ups ] [ Post Followup ] [ $title ]
\n"; # } print NEWFILE "[ return to responses ]\n"; print NEWFILE "
\n"; close(NEWFILE); #DBasics mod for e-mail subscriptions, with Jeff Mann mod for multiple boards open(EMAIL,"$basedir/$subscribe") || die $!; @recipient = ; close(EMAIL); # Now send mail to $recipient foreach $recipient (@recipient) { open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n"; print MAIL "From: $host\n"; print MAIL "Subject: $subject\n"; if ($email) { print MAIL "Reply-To: $email\n\n"; } else { print MAIL "Reply-To: NO_ADDRESS_GIVEN\n\n"; } # print MAIL "#\n"; # print MAIL "# Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'}) with $ENV{'SERVER_PROTOCOL'}.\n"; # print MAIL "#\n"; print MAIL "$name posted the following article on the \n"; print MAIL "Embryogenesis web site \n"; # print MAIL "Forum: $title"; # print MAIL "From: $name <$email>\n"; print MAIL "Subject: $subject\n"; print MAIL "Date: $long_date\n"; print MAIL "Post a follow-up at: $baseurl\n"; # print MAIL "E-mail $name at: mailto:$email \n"; print MAIL " \n"; print MAIL "$FORM{'body'}\n"; close (MAIL); } } ############################### # Main WWWBoard Page Subroutine sub main_page { open(MAIN,"$basedir/$mesgfile") || die $!; @main =
; close(MAIN); open(MAIN,">$basedir/$mesgfile") || die $!; if ($followup == 0) { foreach $main_line (@main) { if ($main_line =~ //) { print MAIN "\n"; print MAIN "
  • $subject - $name $date\n"; print MAIN "(0)\n"; print MAIN "
      \n"; print MAIN "
    \n"; } else { print MAIN "$main_line"; } } } else { foreach $main_line (@main) { $work = 0; if ($main_line =~ /
      /) { print MAIN "
        \n"; print MAIN "
      • $subject - $name $date\n"; print MAIN "(0)\n"; print MAIN "
          \n"; print MAIN "
        \n"; } elsif ($main_line =~ /\((.*)\)/) { $response_num = $1; $num_responses = $2; $num_responses++; foreach $followup_num (@followup_num) { if ($followup_num == $response_num) { print MAIN "($num_responses)\n"; $work = 1; } } if ($work != 1) { print MAIN "$main_line"; } } else { print MAIN "$main_line"; } } } close(MAIN); } ############################################ # Add Followup Threading to Individual Pages sub thread_pages { foreach $followup_num (@followup_num) { open(FOLLOWUP,"$basedir/$mesgdir/$followup_num\.$ext"); @followup_lines = ; close(FOLLOWUP); open(FOLLOWUP,">$basedir/$mesgdir/$followup_num\.$ext"); foreach $followup_line (@followup_lines) { $work = 0; if ($followup_line =~ /
          /) { print FOLLOWUP "
            \n"; print FOLLOWUP "
          • $subject $name $date\n"; print FOLLOWUP "(0)\n"; print FOLLOWUP "
              \n"; print FOLLOWUP "
            \n"; } elsif ($followup_line =~ /\((.*)\)/) { $response_num = $1; $num_responses = $2; $num_responses++; foreach $followup_num (@followup_num) { if ($followup_num == $response_num) { print FOLLOWUP "($num_responses)\n"; $work = 1; } } if ($work != 1) { print FOLLOWUP "$followup_line"; } } else { print FOLLOWUP "$followup_line"; } } close(FOLLOWUP); } } sub return_html { print "Content-type: text/html\n\n"; print "Message Added: $subject\n"; print "$background
            \n"; print "
            \n"; print "\n"; print "

            The following comments have been added:\n"; print "


            \n"; print "date added: $date
            \n"; print "name: $name
            \n"; print "email: $email
            \n"; print "topic: $subject
            \n"; print "comments:
            \n"; print "$body\n"; if ($message_url) { print "Link: $message_url_title
            \n"; } if ($message_img) { print "Image:
            \n"; } print "
            \n"; print "[ go back to responses ]\n"; print "
            \n"; print "
            \n"; } sub increment_num { open(NUM,">$basedir/$datafile") || die $!; print NUM "$num"; close(NUM); } sub error { $error = $_[0]; print "Content-type: text/html\n\n"; if ($error eq 'no_name') { print "$title ERROR: No Name\n"; print "$background

            ERROR: No Name

            \n"; print "You forgot to fill in the 'Name' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.

            \n"; &rest_of_form; } elsif ($error eq 'no_subject') { print "$title ERROR: No Subject\n"; print "$background

            ERROR: No Subject

            \n"; print "You forgot to fill in the 'Subject' field in your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.

            \n"; &rest_of_form; } elsif ($error eq 'no_body') { print "$title ERROR: No Message\n"; print "$background

            ERROR: No Message

            \n"; print "You forgot to fill in the 'Message' fieldin your posting. Correct it below and re-submit. The necessary fields are: Name, Subject and Message.

            \n"; &rest_of_form; } else { print "ERROR! Undefined.\n"; } exit; } sub rest_of_form { print "


            \n"; print "\n"; if ($followup == 1) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } print "Name:
            \n"; print "E-Mail:

            \n"; if ($subject_line == 1) { print "\n"; print "Subject: $FORM{'subject'}

            \n"; } else { print "Subject:

            \n"; } print "Message:
            \n"; print "\n"; print "
            Optional Link URL: (please include http://)

            \n"; print "Link Title:
            \n"; print "Optional Image URL:

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


            \n"; if ($show_faq == 1) { print "[ Follow Ups ] [ Post Followup ] [ $title ] [ FAQ ]\n"; } else { print "[ Follow Ups ] [ Post Followup ] [ $title ]\n"; } print "
            \n"; }