#!/usr/bin/perl # # Ultimate Bulletin Board is copyright Infopop Corporation, 1998-2000. # # ------------ announce.cgi ------------- # print ("Content-type: text/html\n\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 "ubb_library.pl"; require "ubb_library2.pl"; require "mods.file"; require "Date.pl"; }; if ($@) { print "Error including required files: $@\n"; print "Make sure these files exist, permissions are set properly, and paths are set correctly."; exit; } &ReadParse; if ($in{'action'} eq "center") { &Center; } if ($in{'action'} eq "enter") { &Enter; } if ($in{'action'} eq "submitanncedit") { &SubmitEdit; } if ($in{'action'} eq "reviewannounce") { &RetrieveAnnounce; } if ($in{'action'} eq "submitannounce") { &SubmitNew; } sub SubmitEdit { $GetAll = ""; $UserName = $in{'UserName'}; #re-confirm user $ProfileNumber = &GetUserNumber($UserName); @theprofile = &OpenProfile("$ProfileNumber.cgi"); if ($in{'Password'} eq "$theprofile[1]") { $Status = $theprofile[8]; &CheckStatus; if (($AdminStatus eq "true") || ($ModStatus eq "true")) { &ProceedWithEditWrite; } else { &StandardHTML("Sorry, but you are not authorized to perform this function. Use your Back button."); } } else { &StandardHTML("Sorry, but the password you entered was not correct. Please try again. Use your Back button."); } } #end Submit Edit sr sub RetrieveAnnounce { ## Get current announcement info from file @thisannc = &OpenFile("$in{'EditAnnounce'}"); $message = $thisannc[4]; chomp($message); $author = $thisannc[0]; chomp($author); $subject = $thisannc[1]; chomp($subject); $forumslist = $thisannc[3]; chomp($forumslist); $status = $thisannc[2]; chomp($status); $message =~ s/

/\n\r\n/ig; $message =~ s/
/\n/ig; $message =~ s//:\)/isg; $message =~ s//:\(/isg; $message =~ s//\:D/isg; $message =~ s//\;\)/isg; $message =~ s//\:o/isg; #convert UBB Code $UBBImages = "ON"; $OverrideImages = "no"; $message = &EditUBBConvert("$message"); #Retrieve names of each forum where displayed if ($forumslist eq "ALL") { $forumnames = "All"; } else { @forumnames = split(/\|/, $forumslist); foreach $forumname(@forumnames) { @theforum = &GetForumRecord($forumname); if ($forumnames ne "") { $forumnames .= ", $theforum[1]"; } else { $forumnames = "$theforum[1]"; } } } #get start, end dates (@splitit) = split("/", $in{'EditAnnounce'}); @sortedfiles = grep(/.annc/, @splitit); $announcefile = $sortedfiles[0]; $EndMonth = substr($announcefile, 9, 2); $EndDay = substr($announcefile, 11, 2); $EditEndYear = substr($announcefile, 13, 4); $StartMonth = substr($announcefile, 0, 2); $StartDay = substr($announcefile, 2, 2); $EditStartYear = substr($announcefile, 4, 4); print < $BBName - Edit this announcement

Review/Edit Announcement

Note: Only administrators or moderators may edit this announcement.

Contact Us | $MyHomePage $PrivacyStatement

$infopopcopy
Ultimate Bulletin Board $Version

EditFORM3 } sub SubmitNew { $GetAll = ""; $UserName = $in{'UserName'}; #re-confirm user $ProfileNumber = &GetUserNumber($UserName); @theprofile = &OpenProfile("$ProfileNumber.cgi"); if ($in{'Password'} eq "$theprofile[1]") { $Status = $theprofile[8]; &CheckStatus; if (($AdminStatus eq "true") || ($ModStatus eq "true")) { &ProceedWithNew; } else { &StandardHTML("Sorry, but you are not authorized to perform this function. Use your Back button."); } } else { &StandardHTML("Sorry, but the password you entered was not correct. Please try again. Use your Back button."); } } # End SubmitNew sr sub ProceedWithNew { for $getnumbers(@in) { ($Name, $Value) = split ("=", $getnumbers); $Name = &decodeURL($Name); $Value = &decodeURL($Value); if ($Name eq "ForumNumber") { if ($Value ne "ALL") { ($trash, $thenumber) = split(/orum/, $Value); push(@anncforums, $thenumber); } else { $GetAll = "true"; } } } #format dates $StartDate = ("$in{'StartMonth'}" . "$in{'StartDay'}" . "$in{'StartYear'}"); $EndDate = ("$in{'EndMonth'}" . "$in{'EndDay'}" . "$in{'EndYear'}"); &GetTime; #retrieve time for use in filename --> $timestamp $FileName = ("$StartDate-$EndDate-$timestamp.annc"); $Message = "$in{'EditedMessage'}"; $UBBImages = "ON"; $OverrideImages = "no"; #convert carriage returns, UBB Code, and smilies $Message = &ConvertReturns("$Message"); $Message = &UBBCode("$Message"); $Message = &Smilies("$Message"); #print announcement to applicable forum(s) $addtoit = ""; for $that(@anncforums) { chomp($that); if ($addtoit eq "") { $addtoit = "$that"; } else { $addtoit .= "|$that"; } } if ($GetAll ne "true") { foreach $thisuno(@anncforums) { chomp($thisuno); @thisforum = &GetForumRecord($thisuno); if ($thisforum[6] eq "private") { $ExactPath = "Forum$thisuno/private-$thisforum[7]"; } else { $ExactPath = "Forum$thisuno"; } unless (-d "$ForumsPath/$ExactPath/ANNC") { mkdir("$ForumsPath/$ExactPath/ANNC", 0777); chmod (0777, "$ForumsPath/$ExactPath/ANNC"); } open (THISFORUM, ">$ForumsPath/$ExactPath/ANNC/$FileName"); print THISFORUM ("$UserName\n"); print THISFORUM ("$in{'Subject'}\n"); print THISFORUM ("$Status\n"); print THISFORUM ("$addtoit\n"); print THISFORUM ("$Message\n"); close(THISFORUM); chmod(0777, "$ForumsPath/$ExactPath/ANNC/$FileName"); } } else { #add announcement to all forums! @allforums = &OpenForumsFile; for $eachforum(@allforums) { @foruminfo = split(/\|/, $eachforum); $ForumNumber = "$foruminfo[8]"; if ($foruminfo[6] eq "private") { $ExactPath = "Forum$ForumNumber/private-$foruminfo[7]"; } else { $ExactPath = "Forum$ForumNumber"; } open (THISFORUM, ">$ForumsPath/$ExactPath/ANNC/$FileName"); print THISFORUM ("$UserName\n"); print THISFORUM ("$in{'Subject'}\n"); print THISFORUM ("$Status\n"); print THISFORUM ("ALL\n"); print THISFORUM ("$Message\n"); close(THISFORUM); chmod(0777, "$ForumsPath/$ExactPath/ANNC/$FileName"); } } #print confirmation on screen print <

Announcement Added!

Confirm } #end ProceedWithNew sr sub ProceedWithEditWrite { if ($AdminStatus eq "true") { $Status = "Administrator"; } else { $Status = "Moderator"; } ### Determine Edited File Name ############## $StartDate = ("$in{'StartMonth'}" . "$in{'StartDay'}" . "$in{'StartYear'}"); $EndDate = ("$in{'EndMonth'}" . "$in{'EndDay'}" . "$in{'EndYear'}"); &GetTime; #retrieve time for use in filename -- > $timestamp $NewFileName = ("$StartDate-$EndDate-$timestamp.annc"); ################################################ ## Format the message text $Message = "$in{'EditedMessage'}"; $UBBImages = "ON"; $OverrideImages = "no"; #convert carriage returns, UBB Code, and smilies $Message = &ConvertReturns("$Message"); $Message = &UBBCode("$Message"); $Message = &Smilies("$Message"); #### process the edit! if ($in{'forumslist'} eq "ALL") { $ForumTotal = &GetTotalForums; for ($x = 1; $x <= $ForumTotal; $x++) { &GetExactPath($x); #delete previous announcement in all applicable forums #must delete, because date changes require new file name unlink ("$ForumsPath/$ExactPath/ANNC/$in{'anncfile'}"); unless ($in{'Delete'} eq "yes") { #write edited announcement open (THISFORUM, ">$ForumsPath/$ExactPath/ANNC/$NewFileName"); print THISFORUM ("$UserName\n"); print THISFORUM ("$in{'Subject'}\n"); print THISFORUM ("$Status\n"); print THISFORUM ("ALL\n"); print THISFORUM ("$Message\n"); close(THISFORUM); } } #end for $x } else { #update announcement in applicable forums if ($in{'forumslist'} =~ /\|/) { @forumnums = split(/\|/, $in{'forumslist'}); } else { @forumnums = $in{'forumslist'}; } foreach $oneforum(@forumnums) { chomp($oneforum); &GetExactPath("$oneforum"); unlink ("$ForumsPath/$ExactPath/ANNC/$in{'anncfile'}"); #write edited announcement unless ($in{'Delete'} eq "yes") { open (THISFORUM, ">$ForumsPath/$ExactPath/ANNC/$NewFileName"); print THISFORUM ("$UserName\n"); print THISFORUM ("$in{'Subject'}\n"); print THISFORUM ("$Status\n"); print THISFORUM ("$in{'forumslist'}\n"); print THISFORUM ("$Message\n"); close(THISFORUM); } #end delete check } #end foreach $oneforum } # end if/else ALL/selected forums #print confirmation on screen print <

Announcement Updated!

Confirm } #end ProceedWithEditWrite sr sub Enter { ## identify user-- moderator/administrator/neither $NameFound = "no"; $UserName = "$in{'UserName'}"; $UserNameFile = $UserName; $UserNameFile =~ s/ /_/g; #remove spaces $ProfileNumber = &GetUserNumber($UserName); if ($ProfileNumber ne "") { $NameFound = "yes"; } else { $NameFound = "no"; } &decodeURL("$in{'Password'}"); if ($NameFound eq "yes") { @profilestats = &OpenProfile("$ProfileNumber.cgi"); if ($in{'Password'} eq "$profilestats[1]") { $Status = "$profilestats[8]"; &CheckStatus; if ($AdminStatus eq "true") { if ($in{'AnnounceFunction'} eq "CreateAnnouncement") { &Announce("Admin"); } else { &Edit("Admin"); } } elsif ($ModStatus eq "true") { if ($in{'AnnounceFunction'} eq "CreateAnnouncement") { &Announce("Mod"); } else { &Edit("Mod"); } } else { &StandardHTML("Sorry, but you are not authorized to perform this function. Use your Back button."); } } else { &StandardHTML("Sorry, but the password you entered was not correct. Please try again. Use your Back button."); } } else { &StandardHTML("Sorry, but no one is registered with the User Name you listed. Please try again. Use your Back button."); } ##END IF/ELSE NAME CHECK BLOCK } # end Enter sr sub GetTime { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time); $hour = sprintf ("%2d", $hour); $hour =~tr/ /0/; $min = sprintf ("%2d", $min); $min =~tr/ /0/; $sec = sprintf ("%2d", $sec); $sec =~tr/ /0/; $Year = (1900 + $year); $timestamp = ("$hour" . "$min" . "$sec"); } sub Center { print< $BBTitle- Anouncement Center (Control Panel)

Announcement Center
Identify Yourself: Select One:
Your User Name

Your Password

   Create New Announcement
   Review/Edit Announcements

Note: only moderators and administrators may create, review, or edit announcements.

CenterHTML } sub Announce { $Type = shift; $UserName = "$in{'UserName'}"; $Password = "$in{'Password'}"; ## grab current year to fill into form fields &GetTime; #retrieving $Year (4-digit) print < $BBName - Write Announcement
Create New Announcement

Note: Only administrators and moderators may post announcements.

HTMLalice } #end Announce sr sub Edit { $Type = shift; $UserName = "$in{'UserName'}"; $Password = "$in{'Password'}"; print < $BBName - Review/Edit Announcement

Review/Edit Announcements

Note: Only administrators and moderators may review or edit announcements.