#!/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"; use CGI qw(:standard); $CGI::POST_MAX=1024 * 150; $CGI::DISABLE_UPLOADS = 1; eval { ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); require "ikon.lib"; require "data/progs.cgi"; require "data/boardinfo.cgi"; require "data/styles.cgi"; require "data/membertitles.cgi"; }; 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; } $|++; #################--- Begin the program ---################### $thisprog = "topic.cgi"; $query = new CGI; $cookiepath = $query->url(-absolute=>1); $cookiepath =~ s/$thisprog//sg; $inforum = $query -> param('forum'); $inforum = &stripMETA("$inforum"); $intopic = $query -> param('topic'); $intopic = &stripMETA("$intopic"); $instart = $query -> param('start'); $instart = &stripMETA("$instart"); $jumpto = $query -> param('jumpto'); $jumpto = &stripMETA("$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"); &forumjump; if ($jumpto) { print redirect(-location=>"$jumpto"); exit; } if (!$inmembername) { $inmembername = "Guest"; } else { &getmember("$inmembername"); if ($allowedentry{$inforum} eq "yes") { $allowed = "yes"; } else { $allowed = "no"; } &getmemberstime("$inmembername"); &getlastvisit; $forumlastvisit = $lastvisitinfo{$inforum}; $currenttime = time; &setlastvisit("$inforum,$currenttime"); } print header(-cookie=>[$tempvisitcookie, $permvisitcookie]); &getforum($inforum); if ($forumgraphic) { $forumgraphic = qq~~; } else { $forumgraphic = qq~~; } $filetoopen = "$ikondir" . "forum$inforum/list.cgi"; $filetoopen = &stripMETA($filetoopen); if (-e $filetoopen) { open(FILE, $filetoopen) or &error("Opening File&Cannot locate forum$inforum/list.cgi"); flock (FILE, 1); @allthreads = ; close(FILE); $totalthreadcount = @allthreads; $count = 0; foreach $line (@allthreads) { #start foreach @threads ($tempno, $trash) = split(/\|/, $line); chomp $line; push (@numbercounter, $tempno); if ($intopic eq $tempno) { ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$line); $threadviews++; $keepcounter = $count; $linetokeep = "$topicid|$topictitle|$topicdescription|$threadstate|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate"; chomp $linetokeep; $processed_data .= "$linetokeep\n"; } else { $processed_data .= "$line\n"; } $count++; } if (($processed_data eq "") || ($processed_data !~ m!\|!)) { &error("Missing Data&Data as corrupted on the server. Please go back and try again"); } open(FILE, ">$filetoopen"); flock(FILE, 2); print FILE $processed_data; close(FILE); undef $processed_data; my $file = "$ikondir" . "forum$inforum/$intopic.pl"; open(MSG, ">$file"); flock(MSG, 2); print MSG $linetokeep; close(MSG); } $totalthreadcount = @numbercounter; $totalthreadcount--; if ($intopic eq $numbercounter[0]) { undef $nextlink; } else { $nexttopic = $keepcounter - 1; $threadnext = $numbercounter[$nexttopic]; $nextlink = qq~ Next >>~; } if ($intopic eq $numbercounter[$totalthreadcount]) { undef $backlink; } else { $backtopic = $keepcounter + 1; $threadback = $numbercounter[$backtopic]; $backlink = qq~<< Back ~; } $nexttopiclinks = "Topic Jump
"; $nexttopiclinks .= "$backlink" if $backlink; $nexttopiclinks .= "$nextlink" if $nextlink; &postings; &whosonline("$inmembername|Viewing topic $topictitle in $forumname|none") if ($privateforum ne "yes"); &moderator; &title; $filetoopen = "$ikondir" . "forum$inforum/$intopic.thd"; $filetoopen = &stripMETA($filetoopen); if (-e $filetoopen) { open(FILE, $filetoopen) or &error("Opening a topic&This topic does not exist"); @threads = ; close(FILE); } ($trash, $topictitle) = split(/\|/,$threads[0]); $numberofitems = @threads; $numberofpages = $numberofitems / $maxthreads; if ($numberofitems > $maxthreads) { $showmore = "yes"; if ((!$instart) or ($instart < 0)) { $instart = 0; } if ($instart > 0) { $startarray = $instart; } else { $startarray = 0; } $endarray = $instart + $maxthreads - 1; if ($endarray < ($numberofitems - 1)) { $more = "yes"; } if (($endarray > ($maxthreads - 1)) and ($more ne "yes")) { $endarray = $numberofitems - 1; } } else { $showmore = "no"; $startarray = 0; $pages = qq~Single Page for this topic~; $endarray = $numberofitems - 1; } if ($showmore eq "yes") { if ($maxthreads < $numberofitems) { ($integer,$decimal) = split(/\./,$numberofpages); if ($decimal > 0) { $numberofpages = $integer + 1; } $pagestart = 0; $counter = 0; while ($numberofpages > $counter) { $counter++; if ($instart ne $pagestart) { $pages .= qq~$counter ~; } else { $pages .= qq~$counter ~; } $pagestart = $pagestart + $maxthreads; } } $pages = qq~Multiple pages for this topic [ $pages ]~; } if (("$privateforum" eq "yes" && "$allowed" ne "yes")) { &error("Entering Private Topic&Sorry, you do not have access in this forum"); } $printpageicon = qq~~; if ($privateforum ne "yes") { $sendtofriendicon = qq~~; } #------- HTML $output .= qq~ $uservisitdata
$forumgraphic     $boardname
    $forumname
        $topictitle

$nexttopiclinks$pages
Forum moderated by: $modoutput
$sendtofriendicon $printpageicon

~; #------- END HTML $editpostnumber = $startarray; $editpostnumber++; $postcountnumber = 0; foreach (@threads[$startarray .. $endarray]) { ($membername, $topictitle, $postipaddress, $showemoticons, $showsignature, $postdate, $post) = split(/\|/,$_); $postdate = $postdate + ($timedifferencevalue*3600) + ($timezone*3600); $postdate = &dateformat("$postdate"); &getmember("$membername"); $m_membername = &stripMETA($membername); $m_membername =~ y! !_!; &set_up_guest() unless (-e $ikondir . 'members/'.$m_membername.'.cgi'); if ($joineddate) { $joineddate = $joineddate + ($timedifferencevalue*3600) + ($timezone*3600); $joineddate = &joineddate("$joineddate"); } else { $joineddate = "N/A"; } if (!$numberofposts) { $numberofposts = "N/A"; } if (($post =~ /#Moderation Mode/i) and ($membercode eq 'mo' || $membercode eq 'ad')) { $post =~ s/<//g; $post =~ s/"/\"/g; } if ($htmlstate eq 'on') { $post =~ s/<//g; $post =~ s/"/\"/g; } if ($idmbcodestate eq 'on') { $post = &ikoncode("$post"); } if ($count eq 1) { $postbackcolor = "$postcolorone"; $postfontcolor = "$postfontcolorone"; $count++; } else { $postbackcolor = "$postcolortwo"; $postfontcolor = "$postfontcolortwo"; $count = 1; } if (($emoticons eq 'on') and ($showemoticons eq 'yes') and ($post =~ /:(.+?):/)) { $post = &doemoticons("$post"); } if (($emoticons eq 'on') && ($showemoticons eq 'yes')) { $post =~ s/\:\)//g; $post =~ s/\;\)//g; $post =~ s/\:\(//g; $post =~ s/\:o//g; } if (($signature) and ($showsignature eq 'yes')) { $signature =~ s//>/g; $signature =~ s/\&/\&/isg; $signature =~ s/\[b\]//isg; $signature =~ s/\[\/b\]/<\/b>/isg; $signature =~ s/\[i\]//isg; $signature =~ s/\[\/i\]/<\/i>/isg; $signature =~ s/\[url=\s*(.*?)\s*\]\s*(.*?)\s*\[\/url\]/$2<\/a>/isg; $signature =~ s/\[url\]\s*http:\/\/(.*?)\s*\[\/url\]/http:\/\/$1<\/a>/isg; $signature =~ s/\[url\]\s*(.*?)\s*\[\/url\]/$1<\/a>/isg; $signature =~ s/\[br\]/\/isg; $signature =~ s/\\(\S+?)\@(\S+)/$1\@$2<\/a>/ig; $signature =~ s/\[email=(\S+?)\]//isg; $signature =~ s/\[\/email\]/<\/a>/isg; $signature =~ s/\[img\](.+?)\[\/img\]//isg; $signature =~ s/\[color=(\S+?)\]//isg; $signature =~ s/\[\/color\]/<\/font>/isg; $post = qq($post

——
$signature); } if ($numberofposts > $mpostmark5) { $mtitle = "$mtitle5"; $membergraphic = "$mgraphic5"; } elsif ($numberofposts > $mpostmark4) { $mtitle = "$mtitle4"; $membergraphic = "$mgraphic4"; } elsif ($numberofposts > $mpostmark3) { $mtitle = "$mtitle3"; $membergraphic = "$mgraphic3"; } elsif ($numberofposts > $mpostmark2) { $mtitle = "$mtitle2"; $membergraphic = "$mgraphic2"; } else { $mtitle = "$mtitle1"; $membergraphic = "$mgraphic1"; } if ($membergraphic) { $membergraphic = ""; } if (($avatars eq "on") && ($useravatar) && ($useravatar ne "noavatar")) { ($avatarwidth, $avatarheight) = (32, 32); ($avatarwidth, $avatarheight) = ($1, $2) if $useravatar =~ /\((\d+)x(\d+)\)$/; $useravatar = qq(
); } else { undef $useravatar; } $memberfilename = $membername; $memberfilename =~ y/ /_/; if ($threadstate !~ /\bclosed\b/) { $replygraphic = qq~
~; } else { undef $replygraphic; } $privatemessagegraphic = qq~~; $profilegraphic = qq~~; $editgraphic = qq~~; $partition = qq~~; if($showemail eq "yes") { $emailgraphic = qq~~; } else { undef $emailgraphic; } $homepage =~ s/http\:\/\///sg; if($homepage) { $homepagegraphic = qq~~; } else { undef $homepagegraphic; } if ($aolname) { $aolgraphic = qq~~; } else { undef $aolgraphic; } #if (($icqnumber) && ($icqnumber =~ /[0-9]/)) { $icqgraphic = qq~~; } # else { undef $icqgraphic; } undef $icqgraphic; if ($membercode eq "ad") { $posterfontcolor = "$adminnamecolor"; $membername = "$membername "; $membergraphic = ""; if ($membertitle eq "") { $membertitle = "Administrator"; } } elsif ($membercode eq "mo") { $posterfontcolor = "$teamnamecolor"; $membername = "$membername "; if ($membertitle eq "") { $membertitle = "Moderator"; } } elsif ($membercode eq "banned") { $posterfontcolor = "$posternamecolor"; $membergraphic = ""; $membertitle = "BANNED"; } else { $posterfontcolor = "$posternamecolor"; } if ($membertitle eq "member" || $membertitle eq "Member") { $membertitle = $mtitle; } $membertitle =~ s/<//g; $membertitle =~ s/"/"/g; $post =~ s/\(Edited by(.+?)\)/\\(Edited by$1\)\<\/font\>/isg; #------- HTML $output .= qq~
~; #------- END HTML $editpostnumber++; $postcountnumber++; undef $membercode; } #------- HTML $output .= qq~
$newthreadbutton   $replybutton
$membername
$useravatar
$membergraphic
$membertitle
$editgraphic   $partition $profilegraphic $homepagegraphic $emailgraphic $privatemessagegraphic $aolgraphic $icqgraphic $partition   $replygraphic
$post

Total Posts: $numberofposts | Joined $joineddate | Posted on: $postdate | IP
$newthreadbutton   $replybutton

$nexttopiclinks $pages $jumphtml

~; &getmember($inmembername); if ($membercode eq "ad" || $membercode eq "mo") { $output .= qq~
Topic Options: Lock topic | Edit topic | Unlock topic | Delete topic | Move topic

~; } #------- END HTML &output( -Title => "$boardname - $topictitle", -ToPrint => $output, -Version => $versionnumber ); sub postings { $newthreadbutton = qq~~; if ($threadstate !~ /\bclosed\b/) { $replybutton = qq~~; } else { $replybutton = qq~~; } } #------- END OF SCRIPT