#!/usr/bin/perl ############################################################ # Symposium.cgi # # This script was written by Gunther Birznieks # Date Created: 4-18-96 # Extensively revised by Curtis C.Hovey # # You may copy this under the terms of the GNU General Public # License or the Artistic License which is distributed with # copies of Perl v5.x for UNIX # # Purpose: To provide routines for all BBS Forum activities including # Posting, Replying, Reading Messages, Deleting old messages, Filtering # Messages, and Filtering HTML based on Authentication Scripts. # # Main Procedures: # &PrintPostOrReplyPage = Prints Post/Reply Data EntryScreen # &EditPage = edit a message # &CreatePosting = Posts a Message # &ReadMessage = Reads a message # &PrintForumPage = Lists all the posts in a forum # # Inputs: # Form Variables: # forum = Forum name # ini = ini file identifier. Default is "symposium". # session = Session code for authentication # postOp = is this a post # replyOp = is this a reply # editOp = is this an edit # createMessageOp = is this a create message # read = message to read # # Form Variables for pruning List of Messages displayed: # beginDate = First date in range to view messages # endDate = Last date in range to view messages # youngestAge = earliest number of days old to view msgs # oldestAge = latest number of days old to view msgs # keywords = keywords to search for # exactMatch = "on" if the search is exact rather than pattern match based # # useLastRead = "on" if $displayNewMessages is on, # and we want to only see new messages since # our last read. This only works with # authentication activated. # # lastRead = Last message read in the forum. # # diget = display the forum as a digest of messages. # # Outputs: # Depending on the previous form variables, the output # will be a list of forum messages, posting screen, or # reading messages screen. # # SPECIAL NOTE: # # If you are interested in file attachments, you must # set that information in the following variables: # $allowUserAttachments, $maximumAttachmentSize, # $attachDir, $attachUrl. These variables are set below. # ############################################################ if ($ENV{"SERVER_SOFTWARE"} =~ /IIS/) { $realPath = substr($ENV{"PATH_TRANSLATED"}, 2, (rindex($ENV{"PATH_TRANSLATED"}, "\\") - 2)); $realPath =~ s%\\%/%g; chdir("$realPath"); } require "symposium.ini"; #require "cgi-lib.pl"; use CGI qw(:cgi-lib); use CGI::Carp qw(fatalsToBrowser); if ($allowUserAttachments eq "on") { $cgi_lib'maxdata = $maximumAttachmentSize; $cgi_lib'writefiles = "tmp"; } print "Content-type: text/html\n\n"; $createMsgError = ""; &ReadParse; $iniFile = $in{"ini"}; if ($iniFile ne "") {require "$iniFile" . ".ini";} if ($mainScript eq "") {$mainScript = $ENV{"SCRIPT_NAME"};} $board = $iniFile; $board =~ s/(.*)-.*/\1/g; $forum = $in{"forum"}; if ($forum eq "") {$forum = "forums";} ($forumName, $forumDir, $forumUniqueHTML, $forumModerate) = &GetForumInfo($forum); $session = $in{"session"}; ($session, $username, $group, $name, $email) = &GetSessionInfo($session, "$mainScript", *in); $replyOp = ($in{"replyOp"} ne "" || $in{"replyOp.x"} ne "") ? "on" : ""; $editOp = ($in{"editOp"} ne "" || $in{"editOp.x"} ne "") ? "on" : ""; $postOp = ($in{"postOp"} ne "" || $in{"postOp.x"} ne "") ? "on" : ""; $createMessageOp = ($in{"createMessageOp"} ne "" || $in{"createMessageOp.x"} ne "") ? "on" : ""; $deleteMessageOp = ($in{"deleteMessageOp"} ne "" || $in{"deleteMessageOp.x"} ne "") ? "on" : ""; $searchOp = ($in{"searchOp"} ne "" || $in{"searchOp.x"} ne "") ? "on" : ""; $messageName = $in{"messageName"}; $read = $in{"read"}; $digest = $in{"digest"}; $thread = $in{"thread"}; $beginDate = $in{"begindate"}; $endDate = $in{"enddate"}; $keywords = $in{"keywords"}; $exactMatch = $in{"exactmatch"}; $youngestAge = $in{"youngestage"}; $oldestAge = $in{"oldestage"}; $useLastRead = $in{"uselastread"}; $lastRead = $in{"lastread"}; $rangefrom = $in{"rangefrom"}; $rangeby = $in{"rangeby"}; if (($replyOp eq "on") || ($postOp eq "on")) {&PrintPostOrReplyPage;} elsif ($editOp eq "on") {&PrintEditPage;} elsif ($createMessageOp ne "") {&CreatePosting;} elsif ($deleteMessageOp ne "") {&DeleteMessage($messageName);} elsif ($searchOp ne "") {&PrintSearchPage;} elsif ($read ne "") { if ($read eq "new") { opendir(FORUMDIR, "$forumDir") || &CgiDie("Could not open forum directory $forumDir\n"); @files = sort(grep(/.*msg$/,readdir(FORUMDIR))); closedir(FORUMDIR); $read = pop(@files); } &ReadMessage($read); } elsif ($forum ne "forums") {&PrintForumPage;} else {&PrintForumsPage;} ############################################################ # # subroutine: PrintBoardsPage # Usage: # &ReadMessage; # # Parameters: # none # # Output: # Prints a display of the boards available to symposium # Dependant on symposium.html ############################################################ sub PrintBoardsPage{ $boards = ""; opendir(FORUMDIR, "./") || &CgiDie("Could not open this directory\n"); @files = sort(grep(/.*ini$/,readdir(FORUMDIR))); closedir(FORUMDIR); foreach $directory (@files) { $directory =~ s/(.*)\.ini/\1/g; if (-e $directory) {$boards .= qq^
$directory\n^,} } require "symposium.html"; } ############################################################ # # subroutine: PrintForumsPage # Usage: # &ReadMessage; # # Parameters: # none # # Output: # Prints a display of the forums in this board # Dependant on forums.html ############################################################ sub PrintForumsPage { $forumList = ""; $formNameField = "$name"; $formPasswordField = ""; $formLogonButton = ""; $formRegisterButton = ""; $formSearchButton = ""; if ($session eq "") { for ($x = 1; $x < @forums; $x++) {$forumList .= qq^