#!/usr/local/bin/perl
#
### PRIMARY UBB SCRIPT ##
#
# Ultimate Bulletin Board is copyright Infopop Corporation (formerly Madrona Park, Inc.), 1998.
#
# ------------ forumdisplay.cgi -------------
#
# This file contains the functionality for the UBB
# individual forum page display.
#
# Infopop Corporation (formerly Madrona Park, Inc.) offers no
# warranties on this script. The owner/licensee of the script is
# solely responsible for any problems caused by installation of
# the script or use of the script, including messages that may be
# posted on the BB.
#
# All copyright notices regarding the Ultimate Bulletin Board
# must remain intact on the scripts and in the HTML
# for the scripts.
#
# For more info on the Ultimate BB,
# see http://www.UltimateBB.com
#
###############################################################
#
#If you are running UBB on IIS,
#you may need to add the following line
#if so, just remove the "#" sign before the print line below
#print "HTTP/1.0 200 OK\n";
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX / or Windows /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
#substitute all require files here for the file
require "UltBB.setup";
require "Date.pl";
require "mods.file";
require "cookie-lib.pl";
require "ubb_library.pl";
};
print ("Content-type: text/html\n\n");
&ReadParse;
foreach $row(@in) {
($Name, $Value) = split ("=", $row);
$Name = &decodeURL($Name);
$Value = &decodeURL($Value);
if ($Name eq "forum") {
$Forum = $Value;
$Forum =~ s/\/\\//g;
$ForumCoded = &HTMLIFY($Forum);
$ForumCoded =~ tr/ /+/;
$Forum = &UNHTMLIFY($Forum);
}
if ($Name eq "TopicSubject") {
$TopicSubject = $Value;
$TopicSubject =~ s/<.+?>//g;
$TopicSubject = &UNHTMLIFY($TopicSubject);
}
if ($Name eq "UserName") {
$UserName = $Value;
$UserNameFile = $UserName;
$UserNameFile =~ s/ /_/g; #remove spaces
}
if ($Name eq "BypassCookie") {
$BypassCookie = $Value;
}
if ($Name eq "category") {
$category = $Value;
$CategoryName = &GetCatName($category);
}
if ($Name eq "PasswordConfirm") {
$PasswordConfirm = $Value;
}
if ($Name eq "number") {
$number = $Value;
}
if ($Name eq "DaysPrune") {
$DaysPrune = $Value;
}
if ($Name eq "topic") {
$topic = $Value;
}
if ($Name eq "Email") {
$Email = $Value;
$Email =~tr/A-Z/a-z/;
}
if ($Name eq "URL") {
$URL = &CleanThis($Value);
$URL = &PipeCleaner($URL);
}
if ($Name eq "Permissions") {
$Permissions = $Value;
}
if ($Name eq "Occupation") {
$Occupation = &CleanThis($Value);
$Occupation = &PipeCleaner($Occupation);
}
if ($Name eq "Location") {
$Location = &CleanThis($Value);
$Location = &PipeCleaner($Location);
}
if ($Name eq "TotalPosts") {
$TotalPosts = $Value;
}
if ($Name eq "Status") {
$Status = $Value;
}
if ($Name eq "Interests") {
$Interests = &CleanThis($Value);
$Interests = &PipeCleaner($Value);
}
if ($Name eq "sendto") {
$sendto = $Value;
}
} # end FOREACH $row
if ($VariablesPath eq "") {
$VariablesPath = $CGIPath;
}
if (-e "$ForumsPath/Forum$number/forumstyles.file") {
require "$ForumsPath/Forum$number/forumstyles.file";
} else {
require "$VariablesPath/Styles.file";
}
my $RegLinkHere = "";
unless ($DisplayRegistration eq "NO") {
$RegLinkHere = qq(profile | register |);
}
if ($AllowSearch eq "FALSE") {
$SearchOption = "";
} else {
$SearchOption = qq(| search);
}
#create random numbers for headers/footers
$RandomNumber = &MakeRandomNumber;
$RandomNumber2 = $RandomNumber + 100074;
if (-e "$ForumsPath/Forum$number/forumstyles.file") {
if ($ForumHeader ne "") {
$Header = $ForumHeader;
$Header =~ s/UBBrandomX/$RandomNumber/isg;
$Header =~ s/UBBrandomY/$RandomNumber2/isg;
} else {
if ($Header ne "") {
$Header =~ s/UBBrandomX/$RandomNumber/isg;
$Header =~ s/UBBrandomY/$RandomNumber2/isg;
}
}
if ($ForumFooter ne "") {
$Footer = $ForumFooter;
$Footer =~ s/UBBrandomX/$RandomNumber/isg;
$Footer =~ s/UBBrandomY/$RandomNumber2/isg;
} else {
if ($Footer ne "") {
$Footer =~ s/UBBrandomX/$RandomNumber/isg;
$Footer =~ s/UBBrandomY/$RandomNumber2/isg;
}
}
} else {
if ($Header ne "") {
$Header =~ s/UBBrandomX/$RandomNumber/isg;
$Header =~ s/UBBrandomY/$RandomNumber2/isg;
}
if ($Footer ne "") {
$Footer =~ s/UBBrandomX/$RandomNumber/isg;
$Footer =~ s/UBBrandomY/$RandomNumber2/isg;
}
}
#adjust bgcolor variables
if ($BGColor ne ""){
$BGColor = qq(bgcolor="$BGColor");
}
if ($AltColumnColor1 ne ""){
$AltColumnColor1 = qq(bgcolor="$AltColumnColor1");
}
if ($AltColumnColor2 ne ""){
$AltColumnColor2 = qq(bgcolor="$AltColumnColor2");
}
if ($CategoryStripColor ne ""){
$CategoryStripColor = qq(bgcolor="$CategoryStripColor");
}
if ($TableColorStrip ne ""){
$TableColorStrip = qq(bgcolor="$TableColorStrip");
}
if ($PageBackground ne ""){
$PageBackground = qq(background="$NonCGIURL/$PageBackground");
}
if ($TableBorderColor ne ""){
$TableWidth2 = "100%";
$BorderTop = qq(
);
$BorderBottom = qq(
);
} else {
$TableWidth2 = $TableWidth;
$BorderTop = "";
$BorderBottom = "";
}
if ($BBStatus eq "OFF") {
&StandardHTML("Sorry, this bulletin board is temporarily unavailable, while we perform some routine maintenance. Please try back again later. Feel free to email us at $BBEmail.");
exit;
}
$ReplyMessage = $in{'ReplyMessage'};
$Message = $in{'Message'};
$SubjectCoded = &HTMLIFY($TopicSubject);
$SubjectCoded =~ tr/ /+/;
if (@in == 0) {
&Topics;
exit;
}
if ($in{'action'} eq "topics") {
&Topics;
exit;
}
if ($in{'action'} eq "idcheck") {
&idcheck;
}
if ($in{'action'} eq "displayprivate") {
&DisplayPrivate;
}
sub Topics {
if ($number eq "") {
&StandardHTML("You did not select a specific forum or archive. Please go back and try again.");
exit;
}
&get_cookie; #retrieves all current cookies
$SessionLogin = "$cookie{sessionLogin}";
$SessionLoginDT = "$cookie{sessionLoginDT}";
#check to see if forum is private!
if ($number =~ /A/) {
($junk, $ArchiveNumber) = split(/\:/, $number);
&DisplayArchive($ArchiveNumber);
exit;
}
@thisforum = &GetForumRecord($number);
if ($thisforum[8] eq "") {
&StandardHTML("We could not find that forum or archive. Please go back and try again.");
exit;
}
$category = $thisforum[0];
$CategoryName = &GetCatName($category);
$ForumPW = $thisforum[12];
$LWA = $thisforum[6];
if ($LWA eq "private") {
$ReplyRestrict = "restrict";
$TopicRestrict = "restrict";
} else {
($TopicRestrict, $ReplyRestrict) = split("&", $LWA);
}
$Moderator = ("Forum" . "$number" . "Moderator");
$Moderator = $$Moderator;
#split up Mod var
@mods = split(/\|\|\^\|\|/, $Moderator);
if ($LWA eq "private") {
$PrivateMax = $thisforum[13];
chomp($PrivateMax);
#check for private cookies to see if we can proceed immediately
$PasswordPrivate = "$cookie{PasswordPrivate}";
$UserNamePrivate = "$cookie{UserNamePrivate}";
$NumbersPrivate = "$cookie{ForumNumberPrivate}";
$DIRPW = "$thisforum[7]";
$ExactPath = "Forum$number/private-$DIRPW";
if ($PasswordPrivate ne "") {
&VerifyID;
if (($ForumPW ne "") && ($ProceedNow ne "true")) {
&ConfirmIdentity;
exit;
}
} else {
&ConfirmIdentity;
exit;
}
} else {
$DIRPW = "";
$ExactPath = "Forum$number";
$ProceedNow = "true";
}
if ($ProceedNow eq "true") {
if ($DaysPrune eq "") {
$DaysPrune = "$cookie{DaysPrune}";
}
if ($DaysPrune eq "") {
$DaysPrune = $DaysPruneDefault;
}
if ($in{'start'} eq "here") {
$AddNewSessionLogin = "true";
}
$Forum = $thisforum[1];
$CustomTitle = $thisforum[9];
chomp($CustomTitle);
if ($CustomTitle eq "") {
$CustomTitle = "$BBTitle";
}
if ($TopicRestrict eq "restrict") {
$TopicLegend = "New Topics: Only authorized users may post new topics in this forum.";
}
elsif ($TopicRestrict eq "allreg") {
$TopicLegend = "New Topics: All registered users may post new topics in this forum.";
} else {
$TopicLegend = "New Topics: Any visitors (including unregistered) may post new topics in this forum.";
}
if ($ReplyRestrict eq "restrict") {
$ReplyLegend = "Replies: Only authorized users may post replies to topics in this forum.";
}
elsif ($ReplyRestrict eq "allreg") {
$ReplyLegend = "Replies: All registered users may post replies in this forum.";
}
elsif ($ReplyRestrict eq "all") {
$ReplyLegend = "Replies: Any visitors (including unregistered) may post replies in this forum.";
} else {
$ReplyLegend = "Replies: No replies are permitted in this forum.";
}
$ForumCoded = &HTMLIFY($Forum);
$ForumCoded =~ tr/ /+/;
foreach $unomod(@mods) {
chomp($unomod);
$ModNumber = &GetUserNumber($unomod);
if ($ModNumber ne "") {
@theprofile = &OpenProfile("$ModNumber.cgi");
$ModeratorEmail = "$theprofile[2]";
if ($ModeratorLine ne "") {
$ModeratorLine .= qq(, $unomod);
} else {
$ModeratorLine = qq($unomod);
}
}
}
#are icons allowed? - ICON CONCEPT BY KOMBAT03!
if ($AllowIcons eq "TRUE") {
$IconFieldHeader = qq(
GUTS
} ## END Guts HTML for Topic Page
sub TopicBottomHTML {
print<
$BorderBottom
$MoreTopicsW
All times are $TimeZone. $DateWording
Contains new posts since the last time you logged on $RedHot. No new posts since the last time you logged on $YellowHot. A Closed thread - no new replies accepted.
TrueTopicBottom
&PageBottomHTML;
}
sub idcheck {
#open member file to see if user can access private forum
if (($in{'UserName'} eq "") || ($in{'Password'} eq "")) {
&StandardHTML("You did not complete all required form fields! Please go back and re-enter.");
} else {
#open registration file, if possible
$NameFound = "no";
$ProfileNumber = &GetUserNumber($in{'UserName'});
if ($ProfileNumber ne "") {
$NameFound = "yes";
} else {
$NameFound = "no";
}
$AllowedToEnter = "";
if ($NameFound eq "yes") {
@theprofile = &OpenProfile("$ProfileNumber.cgi");
if ($in{'Password'} eq "$theprofile[1]") {
$Permission = $theprofile[4];
$Status = $theprofile[8];
if ($Permission =~ /\&/) {
($junk, $forumnumbers) = split(/\&/, $Permission);
chomp($forumnumbers);
if ($forumnumbers =~ /,/) {
@forumnums = split(",", $forumnumbers);
} else {
@forumnums = "$forumnumbers";
}
}
#check against forum password, if necessary
@thisforum = &GetForumRecord($in{'forumnumber'});
if ($thisforum[12] ne "") {
if ($in{'ForumPassword'} eq "$thisforum[12]") {
$PasswordCheck = "true";
}
}
my $PermissionCheck = "false";
CHECKPERM: foreach $theesone(@forumnums) {
if ($theesone eq "$in{'forumnumber'}") {
$PermissionCheck = "true";
last CHECKPERM;
}
}
$ThisNumber = $in{'forumnumber'};
$UserName = &decodeURL("$in{'UserName'}");
&CheckModStatus("Forum$in{'forumnumber'}", "$UserName");
if (($Status eq "Administrator") || ($PermissionCheck eq "true") || ($ModMatch eq "yes") || ($PasswordCheck eq "true")) {
&GrantAccess;
} else {
&StandardHTML("Sorry, but you are not permitted to access this forum.");
}
} else {
&StandardHTML("The password you entered was not correct. Please use your back button to try again.");
}
} else {
&StandardHTML("We have no record of anyone registered with the name you entered. Please use your back button to try again.");
}
}
} # end id check
sub ConfirmIdentity {
if ($ForumPW ne "") {
$FPWWording = qq(
If you are not an administrator or moderator and have not been given specific permission to access this forum but know the forum password, you must enter the password below in order to gain access.