#!/usr/bin/perl ############################################################# # Ikonboard v2.1 # Copyright 2001 Ikonboard.com - All Rights Reserved # Ikonboard is a trademark of Ikonboard.com # # Software Distributed by: Ikonboard.com # Visit us online at http://www.ikonboard.com # Email us on boards@ikonboard.com # # All files written by Matthew Mecham ############################################################# use CGI::Carp "fatalsToBrowser"; # Output errors to browser use CGI qw(:standard); # Saves loads of work $CGI::POST_MAX=1024 * 150; # limit post data $CGI::DISABLE_UPLOADS = 1; # Disable uploads eval { ($0 =~ m,(.*)/[^/]+,) and unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1"); require "ikon.lib"; # Require ikonboard () require "data/progs.cgi"; # Require prog names require "data/boardinfo.cgi";# Require board info require "data/styles.cgi"; # Require styles info }; if ($@) { print header(); print start_html(-title=>"Ikonboard Error!"); print "Could not find these files: $@\nIf you are running NT you may need to enter the full path in each require statement in each script"; print end_html; exit; } $|++; # Unbuffer the output #################--- Begin the program ---################### $thisprog = "forums.cgi"; $query = new CGI; $cookiepath = $query->url(-absolute=>1); $cookiepath =~ s/$thisprog//sg; $bypass = $query -> param('bypass'); $inforum = $query -> param('forum'); $intopic = $query -> param('topic'); $action = $query -> param('action'); $inshow = $query -> param('show'); $jumpto = $query -> param('jumpto'); die "Hack attempt!" unless $inforum =~ m!\A\d{1,3}\Z!; die "Hack attempt!" if $intopic && $intopic !~ m!\A\d{1,7}\Z!; $inmembername = cookie("amembernamecookie"); $inpassword = cookie("apasswordcookie"); $bypass = &stripMETA("$bypass"); $inforum = &stripMETA("$inforum"); $intopic = &stripMETA("$intopic"); $action = &stripMETA("$action"); $inshow = &stripMETA("$inshow"); $jumpto = &stripMETA("$jumpto"); if ((!$inmembername) or ($inmembername eq "Guest")) { $inmembername = "Guest"; } else { &getmemberstime("$inmembername"); &getlastvisit; $forumlastvisit = $lastvisitinfo{$inforum}; $currenttime = time; &setlastvisit("$inforum,$currenttime"); } if ($action eq "accessrequired") { $inmembername = $query -> param('membername'); $inpassword = $query -> param('password'); &getmember("$inmembername"); if ($userregistered ne "no" && $allowedentry{$inforum} eq "yes" && $inpassword eq $password) { $allowcookiename = "forumsallowed" . "$inforum"; print "Set-Cookie: $allowcookiename=yes\;"; print "\n"; $allowed = "yes"; } else { $allowed = "no"; } } else { $tempaccess = "forumsallowed". "$inforum"; $testentry = cookie("$tempaccess"); if ($testentry eq "yes") { $allowed = "yes"; } else { $allowed = "no"; } } if ($action eq "resetposts") { $currenttime = time; $currenttime = ($currenttime+10); $mv=1; &setlastvisit("$inforum,$currenttime"); print redirect(-location=>"$boardurl/$thisprog?forum=$inforum", -cookie=>[$tempvisitcookie, $permvisitcookie]); exit; } print header(-cookie=>[$tempvisitcookie, $permvisitcookie]); &forumjump; if ($jumpto) { print redirect(-location=>"$jumpto"); exit; } &getforum("$inforum"); # define the thread button/forumgraphic, forum moderator and thread age menu $newthreadbutton = qq~~; if ($forumgraphic) { $forumgraphic = qq~~; } else { $forumgraphic = qq~~; } &moderator; &title; # Print the header $output .= qq~ $uservisitdata
$forumgraphic     $boardname
    $forumname

~; # Check if it's a private forum, and is the member cleared? if (("$privateforum" eq "yes") && ("$allowed" ne "yes")) { &accessneeded; } if (($inmembername) && ($privateforum ne "yes")) { &whosonline("$inmembername|Viewing forum $forumname|none"); } # Open up the forum threads list $filetoopen = "$ikondir" . "forum$inforum/list.cgi"; $filetoopen = &stripMETA($filetoopen); if (-e $filetoopen) { open(FILE, "$filetoopen") or &error("Opening the forum&Sorry, that forum doesn't exist"); flock (FILE, 2); @topics = ; close(FILE); } # Limit the total topics to a span $numberofitems = @topics; $maxtopics = 15; $numberofpages = $numberofitems / $maxtopics; if ($numberofitems > $maxtopics) { #if $showmore = "yes"; if ($inshow eq "" || $inshow < 0) { $inshow = 0; } if ($inshow > 0) { $startarray = $inshow; } else { $startarray = 0; } $endarray = $inshow + $maxtopics - 1; if ($endarray < ($numberofitems - 1)) { $more = "yes"; } elsif (($endarray > ($maxtopics - 1)) && ($more ne "yes")) { $endarray = $numberofitems - 1; } } # else { $showmore = "no"; $startarray = 0; $topicpages = qq~Single Page for this forum~; $toptopicpages = $topicpages; $endarray = @topics - 1; } # if we have multiple pages, print them if ($showmore eq "yes") { #1 if ($maxtopics < $numberofitems) { #2 ($integer,$decimal) = split(/\./,$numberofpages); if ($decimal > 0) { $numberofpages = $integer + 1; } $pagestart = 0; $counter = 0; while ($numberofpages > $counter) { #3 $counter++; if ($inshow ne $pagestart) { $pages .= qq~$counter ~; } else { $pages .= qq~$counter ~; } $pagestart = $pagestart + $maxtopics; } #e3 } #e2 $topicpages = qq~Multiple pages for this forum [ $pages ]~; } #1 # Limit the pages output at the top, so we don't distort the tables if ($numberofpages > 10) { $toptopicpages = qq~Multiple pages for this forum [ see below ]~; } else { $toptopicpages = $topicpages; } # Print the forum top bar $output .= qq~
$toptopicpages Forum moderated by: $modoutput

~; # Start printing the threads $output .= qq~
~; # Grab the threads to show foreach $topic (@topics[$startarray ... $endarray]) { # start topic foreach chomp $topic; ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts, $threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$topic); # Span time, yet again. Who needs sub-routes? $numberofitems = $threadposts + 1; $numberofpages = $numberofitems / $maxthreads; if ($numberofitems > $maxthreads) { #if if ($maxthreads < $numberofitems) { #2 ($integer,$decimal) = split(/\./,$numberofpages); if ($decimal > 0) { $numberofpages = $integer + 1; } $pagestart = 0; $counter = 0; while ($numberofpages > $counter) { #3 $counter++; $threadpages .= qq~ $counter ~; $pagestart = $pagestart + $maxthreads; } #e3 } #e2 $pagestoshow = qq~  [ Pages $threadpages ]~; } #1 # Forum Post markers if (!$forumlastvisit) { $forumlastvisit = "0"; } $topicicon = ""; if (($threadposts => $hottopicmark) && ($forumlastvisit < $lastpostdate) && ($inmembername ne "Guest")) { $topicicon = ""; } if (($threadposts => $hottopicmark) && ($forumlastvisit > $lastpostdate) && ($inmembername ne "Guest")) { $topicicon = ""; } if (($threadposts < $hottopicmark) && ($forumlastvisit < $lastpostdate) && ($inmembername ne "Guest")) { $topicicon = ""; } if (($threadposts < $hottopicmark) && ($forumlastvisit > $lastpostdate) && ($inmembername ne "Guest")) { $topicicon = ""; } if ($threadstate =~ /\bclosed\b/) { $topicicon = ""; } if ($lastpostdate ne "") { $lastpostdate = $lastpostdate + ($timedifferencevalue*3600) + ($timezone*3600); $longdate = &longdate("$lastpostdate"); $shorttime = &shorttime("$lastpostdate"); $lastpostdate = qq~$longdate - $shorttime~; } else { $lastpostdate = qq~N/A~; $lastpoststamp = ""; } $startedpostdate = $startedpostdate + ($timedifferencevalue*3600) + ($timezone*3600); $startedlongdate = &shortdate("$startedpostdate"); $startedshorttime = &shorttime("$startedpostdate"); $startedpostdate = qq~$startedlongdate~; $topictitle = qq~$topictitle~; $topicsticky = ($threadstate =~ /\bsticky\b/ ? '[ Sticky ]  ' : ''); $startedbyfilename = $startedby; $startedbyfilename =~ s/ /\_/isg; $lastposterfilename = $lastposter; $lastposterfilename =~ s/ /\_/isg; $lastposter = qq~$lastposter~; if ($topicdescription) { $topicdescription = qq~  »$topicdescription~; } $output .=qq~ ~; $pagestoshow = undef; $threadpages = undef; } # end topic foreach $output .= qq~
$newthreadbutton Topic Info Last Post
$topicicon $topicsticky$topictitle $pagestoshow
$topicdescription
$threadposts replies, viewed $threadviews times
Started by: $startedby
$lastpostdate
by: $lastposter
$newthreadbutton
$topicpages$jumphtml
~; &getmember("$inmembername"); if ($membercode eq "ad" || $membercode eq "mo") { $output .= qq~
Forum Options: Prune Forum
~; } $output .= qq~ ~; if ($inmembername ne "Guest") { $output .= qq~ ~; } $output .= qq~
Locked topic, no new replies accepted
Open topic
Open topic, new replies since your last visit
  Topic with more than $hottopicmark replies

~; $output =~ s/value=\"$inthreadages\"/value=\"$inthreadages\" selected/; &output( -Title => "$boardname > $category > $forumname", -ToPrint => $output, -Version => $versionnumber ); #### Access needed form sub accessneeded { $output .= qq~

Please enter your details to log in to the private forum

You are required to log in once per browser session. Please make sure that you have cookies enabled in your web browser.
Only those that are granted permission to view this forum by the board Administrator are granted access

Please enter your username   Are you registered?
Please enter your password   Forgotten your password?
~; &output( -Title => "$boardname", -ToPrint => $output, -Version => $versionnumber ); }