define( array('main' => "main.tpl", 'table' => $style."listForumTable.tpl")); $tpl->define_dynamic( "row" , "table" ); $tpl->define_dynamic( "jumprow" , "table" ); $start = utime(); if(isset($forumid)) { if(ereg('4.0.3|4.0.4', phpversion())) session_cache_limiter(""); //act normally - cached. session_start(); //-- since we want DOT hack, we must start it anyhow. db_connect($dbname); $footNote =" New Topics: All registered users may post new topics in this forum."; $footNote .= "
Replies: All registered users may post replies in this forum.
"; //check to see if can post poll if(getNumFromRow("select canpoll from board where forum_id='$forumid'")==1) $tpl->assign(POLLICON,""); else $tpl->assign('POLLICON', ""); //check if it is closed? if (!isForumOpen($forumid)) myDie ("This forum is closed, you have no way to access it!","board.php"); //check if he can see this private forum $p = $forumid.'password'; if(isForumPrivate($forumid) ) { //session_start(); $footNote =" New Topics: Only administrators, moderators, and authorized registered users."; $footNote .= "
Replies: Only authorized users may post replies to topics in this forum.
"; if ($SESSION[$p] !="canView" ) { gotoURL("privateForumLogin.php?forumid=$forumid", 0); die(""); } } if (allowAnonPost($forumid)) { $footNote =" New Topics: Any visitors (including unregistered) may post new topics in this forum."; $footNote .= "
Replies: Any visitors (including unregistered) may post replies in this forum.
"; } //--ANNOUNCEMENT HACK! $tpl->assign(ROWSTYLE, "row3"); //special color row for announcement $query = "select ann_id, userid, subject, unix_timestamp(set_date) as s_date ,location from announce where expire_date >= now() order by set_date desc"; $result = mysql_query($query); if (!mysql_error() && mysql_num_rows($result) > 0){ for ($i = 0; $i < mysql_num_rows($result); $i++ ){ if ($row = mysql_fetch_array($result)){ $forumArr = explode(";", $row['location']); $show_announcement = false; for($j=0; $jassign(array( COL1=>"Announcement: $row[subject]", BULB => "boardicons/on02.gif", THREADICON => "icon71.gif", //icon for announcement COL2 => "$ann_poster[username]", COL3 => "-", COL4 => date("D d M Y", $row['s_date'] + ($timeoffset * 3600)) )); $tpl->parse(ROW, ".row"); } } } } //-END OF ANNOUNCEMENT HACK! //##########proceed to list the threads! ####// (!isset($pruneDaysCookie)|| $pruneDaysCookie < 1 )?$pruneDays = $defaultPruneDay:$pruneDays = $pruneDaysCookie; $prunesArr = array("1"=>"1 day ago","2"=>"2 days ago","5"=>"5 days ago","10"=>"10 days ago","20"=>"20 days ago", "30"=>"1 month ago","45"=>"45 days ago","60"=>"2 months ago","75"=>"75 days ago", "100"=>"100 days ago","365"=>"one year ago","9999"=>"all the days"); while (list($key, $val)= each($prunesArr)) { if($pruneDays==$key) { $tpl->assign(PRUNEDAYSTR, $val); $pruneOptStr .=""; } else $pruneOptStr .=""; } $tpl->assign(PRUNEOPT, $pruneOptStr); //SQL str ($pruneDays=="9999")? $where_prune = "": $where_prune ="where TO_DAYS(NOW()) - TO_DAYS(last_date) <= $pruneDays"; //- paginate $numThreads = getNumFromRow("select count(*) from ".$forumid."_t $where_prune"); $numPages = intval($numThreads / $threadsLimit); if($numThreads % $threadsLimit) $numPages++; //- $page = 0; //init if(!isset($offset) || empty($offset)) $pageOffset =0; else $pageOffset = (int)$offset; //-------DOT hack! show a special icon if I've taken part in the topic //session_start(); if($SESSION['username'] !="") //if there is a session name, check if he takes part in any of the listed threads { //echo "hey there $SESSION[username]
"; $query =" select thread_id from ".$forumid."_t $where_prune order by last_date desc limit $pageOffset, $threadsLimit"; $r = mysql_query($query); $tAr = array(); while($row = mysql_fetch_array($r)) $in_str .=" $row[thread_id],"; $in_str = substr($in_str, 0,-1); if($in_str !="") { $r = mysql_query("select distinct thread_id from $forumid"."_m where user_id=".getUserid($SESSION['username'])." AND thread_id in($in_str) "); while($row = mysql_fetch_array($r)){ $tAr[]=$row['thread_id']; //echo $row[thread_id].","; } } //echo count($tAr); //echo "

"; } //----cut here --- //show thread list $query =" select thread_id,subject, start_poster, thread_icon, closed, unix_timestamp(last_date) as last_date, last_poster, num_replies from ".$forumid."_t $where_prune order by last_date desc limit $pageOffset, $threadsLimit"; $result = mysql_query($query); if(!$result) myDie("$query
Error in selecting from ".$forumid."_t table
Please report this error message to the admin."); if (!mysql_error() && mysql_num_rows($result) > 0) { for ($i = 0; $i < mysql_num_rows($result); $i++ ) { if ($row = mysql_fetch_array($result)) { $lastReplyURL = "read_msg.php?tid=$row[thread_id]&forumid=$forumid#last"; //the EXACT url to the last reply MSG //paginate $threadNumPages = intval( ($row['num_replies']+1) / $msgsLimit); if(($row['num_replies']+1) % $msgsLimit) $threadNumPages++; $threadPaginateStr = "

"; if($threadNumPages>5) { $threadPaginateStr .= "".$row['subject']."". "
"; $threadPaginateStr .="Pages: ". " of $threadNumPages
"; } elseif ($threadNumPages>1) { $threadPaginateStr = "".$row['subject'].""; $threadPaginateStr .= "
Pages: "; for($j=1;$j<=$threadNumPages;$j++) { $offset = ($j - 1) * $msgsLimit; $threadPaginateStr .= "$j "; if($j == $threadNumPages) $lastReplyURL = "read_msg.php?tid=$row[thread_id]&forumid=$forumid&offset=$offset#last"; //set the last reply MSG url to that of the last page } $threadPaginateStr .=""; } else $threadPaginateStr = "".$row['subject'].""; //$threadPaginateStr .=""; //- //color rotator if ($i % 2 ==0) $tpl->assign(ROWSTYLE, "row1"); else $tpl->assign(ROWSTYLE, "row2"); // //$bulb = ($SESSION['lastlogin'] < $row['last_date'] ) ? $newPostIcon:$noNewPostIcon; //the bulb to show if there is newpost //$bulb = ($lastloginCookie < $row['last_date'] ) ? $newPostIcon:$noNewPostIcon; //the bulb to show if there is newpost if ($lastloginCookie < $row['last_date'] ) { //add the triangle to jump to new post! $threadPaginateStr = str_replace('
', '', $threadPaginateStr); $threadPaginateStr = "\"Go $threadPaginateStr"; $bulb = $newPostIcon; } else $bulb = $noNewPostIcon; $bulb = ($row['closed']==1) ? $closedThreadIcon:$bulb; //check if this thread is closed $threadicon = "icon".$row['thread_icon'].".gif" ; //-DOT hack if($SESSION['username'] !="" && in_array($row['thread_id'],$tAr)){ if($boldMyTopicCookie=="true") //check if boldMyTopic cookie is set? $threadPaginateStr = "$threadPaginateStr"; ($bulb == $newPostIcon)?$bulb = $myNewPostIcon:$bulb = $myNoNewPostIcon; } //-- $tpl->assign(array( COL1=>$threadPaginateStr, //$tpl->assign(array( COL1=>"".$row['subject']."".$threadPaginateStr, //$tpl->assign(array( COL1=>"".$row['subject']."$threadPaginateStr", BULB => $bulb, THREADICON => $threadicon, COL2 => ($row['start_poster']=="")?" ":htmlspecialchars($row['start_poster']), //Sep 24 Quick hack to remove pesky < > in nicks COL3 => $row['num_replies'], COL4 => $row['last_poster']." at
".(date("d M Y h:i A",$row['last_date'] + ($timeoffset * 3600) ))."" )); $tpl->parse(ROW, ".row"); } } } else if(!$got_announcement) myDie("There are no new topics in this forum. Please come back again later, or post a new message here!
"); //echo "done table - ".(($tpl->utime() - $start) * 1000 )." ms
" ; $forumName = getForumName($forumid); $tpl->assign(FORUMID, $forumid); $tpl->assign(FORUMNAME, $forumName); $tpl->assign(BOARDNAME,$boardname ); $tpl->assign(TITLE,$forumName ); $tpl->assign(FORUMDESC, getStrFromRow("select description from board where forum_id = '$forumid'")); $paginateStr="Page: "; if($numPages < 20) { if($numPages > 0) { for($i=1;$i<=$numPages;$i++) { $offset = ($i - 1) * $threadsLimit; if($pageOffset==$offset) $paginateStr .= "$i "; else $paginateStr .= "$i "; /*if($i % 20 ==0) //prevent long line of page numbers $paginateStr .="
";*/ } ($pageOffset == 0)?$paginateStr = $paginateStr: $paginateStr ="< Previous | $paginateStr"; ($pageOffset == ($numPages -1)*$threadsLimit)?$paginateStr = $paginateStr: $paginateStr ="$paginateStr | Next >"; } } else//28DEC2000 hack { $paginateStr ='Page:  of $numPages "; ($pageOffset == 0)?$paginateStr = $paginateStr: $paginateStr ="< Previous | $paginateStr"; ($pageOffset == ($numPages -1)*$threadsLimit)?$paginateStr = $paginateStr: $paginateStr ="$paginateStr | Next >"; $paginateStr = "$paginateStr
"; } //$start = utime(); $tpl->assign(PAGENUMS, $paginateStr); $tpl->assign(FORUMSKIN, "template/$forumSkin"); $tpl->assign(FOOTER, $footNote); //-- list moderators $mods = getModerators($forumid); for($i=0;$i$mods[$i] "; $tpl->assign(MODERATORS, $modStr); //-- //######FORUM JUMPER######### $query = "select forum_name, forum_id from board where status = 1 order by category, cat_order"; $result = mysql_query($query); if(!$result) myDie("ERROR: search.php - getting forum list"); if(!mysql_error() && mysql_num_rows($result) > 0) { for($i = 0; $i < mysql_num_rows($result); $i++) if($row= mysql_fetch_array($result) ) { $tpl->assign(array( JUMPFORUMNAME => $row['forum_name'], JID => $i, JUMPFORUMID => $row['forum_id'] )); $tpl->parse(JUMPROW, ".jumprow"); } } //-- $tpl->assign(BANNERCODE,$bannercode); $tpl->assign(FOOTERCODE, $footercode); $tpl->assign(TIMEZONE, $timezone); $tpl->parse(MAIN, array("table","main")); $tpl->FastPrint(); //echo session_cache_limiter()."-"; //echo " - ".(($tpl->utime() - $start) * 1000 )." ms" ; mysql_free_result($result); //free result since this is a potentially large list } else myDie("There is no such forum.
"); ?>