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 "
$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." ".
"
",
MSGBODY => "$msgBody
";
/*$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
$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;$i
";
mysql_free_result($result);
}
else
myDie("No messages found.");
?>