0) { for($i =0; $i< mysql_num_rows($result); $i++) { if($row = mysql_fetch_array($result)) { $where .= ($i>0)? " or":""; $where .= " user_id=".$row['user_id']; //($where == "")? $where = " $row[user_id] ": $where .= ", $row[user_id] "; } } } mysql_free_result($result); $query2 = "select user_id,username, user_icon, icq, totalpost,useremail, rank_id, rank_name,signature from users where $where"; $result2=mysql_query($query2); if(!$result2) myDie ("getUserInfo: Error in Query2!"); $users =array(); if (!mysql_error() && mysql_num_rows($result2) > 0) { for ($i = 0; $i < mysql_num_rows($result2); $i++ ) { if ($row2 = mysql_fetch_array($result2)) { $users[$row2['user_id']] = $row2['username'].";".$row2['user_icon'].";".$row2['icq'].";".$row2['totalpost'].";".$row2['useremail'].";".$row2['rank_name'].";".$row2['rank_id'].";".$row2['signature']; } } } mysql_free_result($result2); return $users; } //====================================================================================================== //Query to get the subject of the thread function printTopicSubject($tid, $forumid) { $query2 = "select subject from ".$forumid."_t where thread_id=".$tid; $result2 = mysql_query($query2); if(!$result2 ) myDie ("$query2 printTopicSubject: error in Query2","board.php"); $row2 = mysql_fetch_array($result2); return $row2['subject']; } //====================================================================================================== //Query to get the message from a thread with a given msg_id function getMsg($msgid, $forumid) { $query2 = "select msg_body from ".$forumid."_m where msg_id=".$msgid; $result2 = mysql_query($query2); if(!$result2 ) myDie("$query2
getMsg: error in Query2
","board.php"); $row2 = mysql_fetch_array($result2); return $row2['msg_body']; } ///====================================================================================================== //main include("forumlib.inc"); include("class.template.inc"); global $dbname, $usericonDir, $msgiconDir, $forumSkin, $msgsLimit, $anon_username, $boardname; //cookie for unregistered user global $allowSignature, $bannercode, $footercode, $timezone, $timeoffset; db_connect($dbname); //session_start(); //call this to use sesssion management if(ereg('4.0.3|4.0.4', phpversion())) session_cache_limiter(""); //act normally - cached. $tpl = new FastTemplate("./template/default"); $loginBox = ""; //depend we need to login this user, will contain null str or a loginbox html //check to see if $replyto or //$editto isset and get the respective msgid if(isset($replyto) ) { $editto = eregi_replace("[#-+()_%$@;*^]","",$editto); $action="reply"; $msgid = $replyto; } elseif(isset($editto) ) { $replyto = eregi_replace("[#-+()_%$@;*^]","",$replyto); $action="edit"; $msgid = $editto; } //--------- Proceed to list msgs --------------------// if(isset($tid) && isset($forumid) ) { //check if it is closed? if (!isForumOpen($forumid)) myDie ("Forum Closed. You have no way to access this forum!","board.php"); //check if this thread is Closed? $threadClosed = isThreadClosed($forumid, $tid); if($threadClosed && ($action == "edit" || $action == "reply") ) myDie("This thread is closed, no more replies/edits are allowed", "read_msg.php?forumid=$forumid&tid=$tid"); //cheesy checking to see if this guy can view a private forum $p = $forumid.'password'; if(isForumPrivate($forumid)) { session_start(); if ($SESSION[$p] !="canView") { gotoURL("privateForumLogin.php?forumid=$forumid", 0); die(""); } } //remove special chars from HTTP Variables $tid = eregi_replace("[#-+()_%$@;*^]","",$tid); $forumid = eregi_replace("[#-+()_%$@;*^]","",$forumid); //assign the correct template if(ereg("-IE", $forumSkin)) $style ="../default-IE/"; else $style =""; //Check to see if this is a reply/edit if($action=="reply" || $action=="edit") { //only login used can edit or reply session_start(); //wah u dun call session start here it will re-login that guy=> mess up lastlogin! if(! isLogin()) { //quick hack 21 June //shld incorprate into the template with fake/real comments code echo ""; $loginBox = "Name\t     :\t "; $loginBox .= "
Password\t: "; $loginBox .="
   Remember my Login
"; echo "
"; } //add in the reply row in the table $tpl->define( array( main => "main.tpl", msg => "msg.tpl", replycol=>"replyBox.tpl", table => $style."msgTable.tpl")); } else $tpl->define( array( main => "main.tpl", msg => "msg.tpl", table => $style."msgTable.tpl")); $tpl->define_dynamic( "2c_row" , "table" ); //2 column rows for the messages $tpl->define_dynamic( "jumprow" , "table" ); //2 column rows for the messages //--- /* $start = $tpl->utime(); $message = "Database Query starts:
"; */ //paginate $numMsgs = getNumFromRow("select count(*) from ".$forumid."_m where thread_id=$tid" ); $numPages = intval($numMsgs / $msgsLimit); if($numMsgs % $msgsLimit) $numPages++; //-- newpost hack 13-DEC-2000 if($goto =="newpost") { $hasread = getNumFromRow("select count(*) from ".$forumid."_m where unix_timestamp(msg_date) < $lastloginCookie AND thread_id=$tid" ); $targetpage = intval($hasread / $msgsLimit) +1; $offset = ($msgsLimit * $targetpage) - $msgsLimit; //get the correct offset $hasnewposted = false; //myDie("$hasread / $numMsgs = Your target page is $targetpage and corr offset is $npOffset"); } // $page = 0; //init redundant? if(!isset($offset) || empty($offset)) $pageOffset =0; else $pageOffset = (int)$offset; //-- //get the last post date of this thread $lastpostDate = getStrFromRow("select unix_timestamp(last_date) as date from ".$forumid."_t where thread_id=$tid"); //######### GET POLL ############ $pollBody = ""; $result = mysql_query("select question, options, pollid from polls where forumid = '$forumid' && threadid = $tid"); if(!$result) myDie("error in poll retrievial query
$query"); //yup there is a poll in this thread if(mysql_num_rows($result)== 1) { $row = mysql_fetch_array($result); //check if he has voted session_start(); $votedUserid = getUserid($SESSION['username']); $hasVoted = getNumFromRow("select userid from pollvotes where pollid=$row[pollid] and userid=$votedUserid"); if($hasVoted>0 && $hasVoted == $votedUserid) { $pollBody .= getPollResult($forumid, $tid, $row[pollid]) ."

You have already voted on this poll.
"; } else //no, he has not voted -> show form { $pollOptions = stripslashes($row['options']); $pollQn = stripslashes($row['question']); $pollBody = "
". "$pollQn
"; $pollOptionArr = explode(";",$pollOptions); for($i=0;$i'' ) $pollBody .= "$pollOptionArr[$i]
"; $pollBody .="
". " ". "\"View". "". "". "". ""; } $pollbody .= "
"; } //---end of get poll //get all messages //if(isset($goto)&& $goto="newpost" ) //{ // $query = "select user_id, unix_timestamp(msg_date) as date,msg_icon,msg_id,msg_body,ip_log from ".$forumid."_m where unix_timestamp(msg_date) >= $lastloginCookie AND thread_id =".$tid." limit $msgsLimit" ; //} //else $query = "select user_id, unix_timestamp(msg_date) as date,msg_icon,msg_id,msg_body,ip_log from ".$forumid."_m where thread_id =".$tid." limit $pageOffset, $msgsLimit" ; $result = mysql_query($query); //$message .= "done - ".(($tpl->utime() - $start) * 1000 )." ms
" ; if(!$result) myDie ("Error in reading ".$forumid."_m","board.php"); //==== start to generate the messages and print them === // //print the TITLE ROW of the table $topicSubject = printTopicSubject($tid, $forumid); $tpl->assign(TOPIC, $topicSubject); if (!mysql_error() && mysql_num_rows($result) > 0) { //$start = $tpl->utime(); //$message .= "generate all darn icons
"; //gather ALL users info into array $userInfo //Change this if userbase gets big?? (by using min & max userid of this thread $usersInfo = getUsersInfo($forumid, $tid); for ($i = 0; $i < mysql_num_rows($result); $i++ ) { if ($row = mysql_fetch_array($result)) { $rankid =100; //init to anon level in case we cant find this userid / or it is an anon poster $thisUser = $usersInfo[$row['user_id']]; //try to retrieve this userid from the users array //check for anon poster list($username, $usericon, $icq, $totalpost, $useremail, $rankname, $rankid, $signature) = split(";", $thisUser); //non register user if($rankid <=100) { $rankname = "Unregistered User"; $totalpost = ""; $usericon = "anon"; //give this anon user a cow icon! $listAuthorPost = ""; } else { $totalpost = "Total Posts: ".$totalpost; $listAuthorPost = "\"Click"; } //color rotator if ($i % 2 ==0) $tpl->assign(ROWSTYLE, "row1"); else $tpl->assign(ROWSTYLE, "row2"); // if($icq!="") $tpl->assign(ICQADD,"\"Click   "); else $tpl->assign(ICQADD,""); if($i == (mysql_num_rows($result) -1 )) $anchorStr = ""; elseif($goto=="newpost" && !$hasnewposted && $lastloginCookie <= $row['date'])//newpost hack { $hasnewposted = true; $anchorStr = ""; }else $anchorStr = ""; //$anchorStr = ""; if($i==0)//show poll only in msg 1 //$msgBody = "$row[msg_body]

$pollBody"; $msgBody = $pollBody."

$row[msg_body]"; else $msgBody = "$row[msg_body]"; //allow signature? if($allowSignature && $signature !="") $msgBody .="

------------------
$signature"; //Sep 24 Quick hack to remove pesky < > in nicks $username = htmlspecialchars($username); //chitika ads for older than 2 yr post if (date('U') - $row['date'] > 63072000 && $i== 0){ $chitika="". " "; }elseif (date('U') - $row['date'] < 63072000 && $i== 0) { $chitika_cat =array('1722','1724','96259','96297','9','7185','93767','89','95'); $chitika=' '; }else { $chitika ='';} $tpl->assign( array ( USERNAME => $username, ANCHOR => $anchorStr, PROFILE => urlencode($username), //not needed rite? USERICON => $usericonDir."/".$usericon.".gif", TOTALPOST => $totalpost, RANKNAME => $rankname, //."
$row[user_id]", USEREMAIL => $useremail, MSGICON => $msgiconDir."/icon".$row['msg_icon'].".gif", POSTDATE => date("D d M Y h:i A",$row['date'] + ($timeoffset * 3600) ), EDITURL => "read_msg.php?forumid=".$forumid."&tid=".$tid."&editto=".$row['msg_id'], REPLYURL => "read_msg.php?offset=$offset&forumid=".$forumid."&tid=".$tid."&replyto=".$row['msg_id']."&author=".$username, DELETEURL => "adminfun.php?forumid=".$forumid."&tid=".$tid."&msg_id=".$row['msg_id']."&function=delete", LISTAUTHOR => $listAuthorPost."  \"Send". " \"Add", MSGBODY => "$msgBody

\"IP
$chitika")) ; $tpl->parse(ROW,".2c_row"); } } //$message .= "done - ".( ($tpl->utime() - $start ) *1000 )." ms
".(date("d M Y h:i A",$lastpostDate))."
"; //$tpl->assign(MSG , $message ); //$tpl->parse(MAIN, ".msg"); //######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"); } } //-- //GENERATE THE PRE / NEXT THREAD_ID $prevTid = getNumFromRow("select thread_id from ".$forumid."_t where unix_timestamp(last_date) < $lastpostDate order by last_date desc limit 1"); $nextTid = getNumFromRow("select thread_id from ".$forumid."_t where unix_timestamp(last_date) > $lastpostDate order by last_date limit 1"); // $tpl->assign(PREVURL , $prevTid>0?" << Next older topic ":""); // $tpl->assign(NEXTURL , $nextTid>0?" Next newer topic >>":""); //-------- //if this is a reply or Edit //render the reply/edit form if($action=="reply" || $action=="edit") { $tpl->assign(OFFSET,(($numPages -1) * $msgsLimit)); //sent to posting.php so that after replying can go straight to lst page $tpl->assign(MSGID, $msgid); //for the edit/reply form $tpl->assign(ACTION, $action);// " " if($msgid==0) //reply w/o quote $tpl->assign(REPLYMSG, ""); else { $quotedMsg = getMsg($msgid, $forumid); //get msg to quote-reply or edit if($action=="edit") $tpl->assign(REPLYMSG, html2ubb($quotedMsg)); //edit this msg else //quote-reply { $msgAuthor = (isset($author))? $author:""; //check who is the author with this msg, passed via url $quotedMsg = eregi_replace("

This message was edited(.*)(<\/i>)","", $quotedMsg);//remove this msg was edited by $quotedMsg = html2ubb($quotedMsg); //convert to ubb format //if($forumid!="testing") {$patterns = array("/\[QUOTE\](.*)(\[\/QUOTE\])/is"); $replace = array(""); $quotedMsg = preg_replace($patterns, $replace, $quotedMsg); //take away others pple quotation and leaves only author replies $quotedMsg = eregi_replace("\r\n\r\n", "\r",$quotedMsg); //2 nl - > 1 nl } /*else { $qMsgArr = split ("\[QUOTE\]|\[\/QUOTE\]", $quotedMsg); $quotedMsg = ""; for ($i=0;$iassign(REPLYMSG, "[QUOTE]Originally posted by $msgAuthor:\r[B]".$quotedMsg."[/B][/QUOTE]\r" ); } } $tpl->parse(REPLYROW, "replycol"); } else //parse null string to REPLYROW if this is not a reply/edit, assuming STRICT parsing, UNSTRICT parsing will have errors !!! $tpl->assign(REPLYROW,""); } else myDie("Error reading messages from database.","board.php"); $tpl->assign(TITLE, $topicSubject); $tpl->assign(LOGINBOX,$loginBox); $tpl->assign(FORUMNAME,getForumName($forumid)); $tpl->assign(FORUMURL, "list_forum.php?forumid=".$forumid); $tpl->assign(FORUMID, $forumid); //hack to make reply show the right page if (isset($offset)) $tpl->assign(OFFSET, $offset); else $tpl->assign(OFFSET, "0"); $tpl->assign(BOARDNAME,$boardname ); $tpl->assign(TID,$tid); //use the correct url for closing or opening this thread $threadClosed? $tpl->assign(CLOSE_OPEN, "Open"): $tpl->assign(CLOSE_OPEN, "Close"); $paginateStr=""; if($numPages < 10) { for($i=1;$i<=$numPages;$i++) { $offset = ($i - 1) * $msgsLimit; if($pageOffset==$offset) $paginateStr .= "$i "; else $paginateStr .= "$i "; } $tpl->assign(PREVURL , $prevTid>0?" << Next older topic ":""); $tpl->assign(NEXTURL , $nextTid>0?" Next newer topic >>":""); } //28DEC2000 hack for super long thread. else { $paginateStr .='Page:  "; ($pageOffset == 0)?$paginateStr = $paginateStr: $paginateStr ="< Previous | $paginateStr"; ($pageOffset == ($numPages -1)*$msgsLimit)?$paginateStr = $paginateStr: $paginateStr ="$paginateStr | Next > "; $tpl->assign(PREVURL , $prevTid>0?"

 << Next older topic ":""); $tpl->assign(NEXTURL , $nextTid>0?" Next newer topic >>":""); } $tpl->assign(BANNERCODE,$bannercode); $tpl->assign(FOOTERCODE, $footercode); $tpl->assign(TIMEZONE, $timezone); $tpl->assign(EMAILFRIENDURL, "mailthread.php?subject=".urlencode($topicSubject)."&forumid=$forumid&tid=$tid"); $tpl->assign(PAGENUMS, $paginateStr); $tpl->assign(FORUMSKIN, "template/$forumSkin"); $start = utime(); $tpl->parse(MAIN, ".table"); //apend parse result of "table" to MAIN $tpl->parse(MAIN, "main"); //now, MAIN is msg+table(with rows), use MAIN to parse "main" $tpl->FastPrint(); //echo session_cache_limiter()."--

"; /*$raw = $tpl->fetch(); echo $raw; $fp = fopen("static/".$forumid."/".$tid.".html", "w"); fwrite($fp, $raw); fclose($fp);*/ //echo "

/$forumid/$tid/ done printing all html - ".( (utime() - $start ) *1000 )." ms
"; mysql_free_result($result); } else myDie("No messages found."); ?>