include("functions.php");
include("forum_template.php");
mysql_connect($db_Hostname, $db_UserName, $db_Password) || die("Can't Connect to Database: ".mysql_error());
mysql_select_db($db_Database);
$fSettings = GetSettings();
if (empty($BoardID) || ($BoardID == 0))
{fHeader();UhOh($txt['errNoBoardID']);}
$LastVisit = fHeader();
//New Post Icon Grabber --Derrick Hopkins 5-10
$d_Icons = d_GetPostIcons();
if (!CheckViewAccess($BoardID))
UhOh($txt['CantRead']);
$topicsperpage = $fSettings['topicsperpage'];
$query = "SELECT count(*) from t_messages where BoardID = $BoardID AND FirstMessage = 'yes'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$totaltopic = $row[0];
$pages = DoPageSpan($topicsperpage,$totaltopic,"viewboard.php?BoardID=$BoardID");
$Board = GrabBoardInfo($BoardID);
$BoardName = $Board["bName"];
$ent["fTitleBGColor"] = $fSettings["title_backcolor"];
$ent["fTitleTColor"] = $fSettings["title_textcolor"];
$ent["fCatBGColor"] = $fSettings["cat_backcolor"];
$ent["fCatTColor"] = $fSettings["cat_textcolor"];
$ent["fMsgBGColor1"] = $fSettings["msg_backcolor"];
$ent["fMsgBGColor2"] = $fSettings["msg_backcolor2"];
$ent["fBorderColor"] = $fSettings["bordercolor"];
$ent["AnnouncementMSG"] = GrabAnnouncement($BoardID);
$ent["NavPath"] = "$fSettings[ForumName] : $BoardName";
$ent["PageSpan"] = $pages;
$ent["LoginBox"] = GrabLoginBox("$fSettings[ScriptURL]/viewboard.php?BoardID=$BoardID");
$ent["Moderator"] = GrabModerators($BoardID);
$ent["NewandReply"] = ""."";
$CurrentUserPass = GrabUserPass();
if (is_mod($CurrentUserPass[UserName],$CurrentUserPass[Password],$BoardID))
$ent["ModFunctions"] = "Moderator Functions: $txt[LockTopic] | $txt[MoveTopic]";
$template = ReadTemplate("viewboard");
$pos_start = strpos($template,"")+strlen("");
$pos_end = strpos($template,"",$pos_start);
$first_part = substr($template,0,$pos_start-strlen(""));
$last_part = substr($template,$pos_end,strlen($template)-$pos_end);
print ParseTemp($first_part,$ent);
$first_loop = substr($template,$pos_start,$pos_end-$pos_start);
$table = "";
$limit = $page*$topicsperpage;
$query = "SELECT ID,Subject,BoardID,TopicID,Poster,Locked,DatePosted,ReplyNotice,Emoticon,FirstMessage,PosterIP,PostIcon,numReplies,numViews from t_messages where BoardID = $BoardID AND FirstMessage = 'yes' Order By DateEdited DESC LIMIT $limit,$topicsperpage";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result))
{
do
{
$tInfo = $row;
$totalmessage = $tInfo["numReplies"]+1;
$messagesperpage = $fSettings["messagesperpage"];
$div = ceil($totalmessage/$messagesperpage);
$pages2 = "";
$temp = 0;
$temp2 = 0;
$div2 = $div-1;
$div = $div-1;
if ($totalmessage > $messagesperpage)
{
$temp = 0;
$pages2 = "( ";
while ($temp < $div)
{
$temp2 = $temp+1;
if ($temp2 > 3)
{
$pages2 .= " .. Last page";
$temp = $div;
}
else
$pages2 .= " $temp2";
$temp++;
}
$pages2 .= " )";
}
$query = "SELECT DatePosted,Poster from t_messages where TopicID =".$tInfo["TopicID"]." Order By DatePosted DESC LIMIT 1";
$result2 = mysql_query($query);
$row2 = mysql_fetch_row($result2);
$tIcon = GrabPostIcon($row["ID"]);
$row2[1] = trim($row2[1]);
$ent["LatestMSGPoster"] = "$row2[1]";
$ent["LatestMSGDate"] = FormatDate($row2[0]);
$ent["LatestMSGTime"] = FormatTime($row2[0]);
$ent["TopicIcon"] = "";
$ent["tSubject"] = "".SensorWord(stripslashes($tInfo['Subject']))." ";
$ent["tSubject"] .= " $pages2";
if (!is_read_topic($tInfo["TopicID"],$LastVisit))
{
$ent['FolderIcon'] = "";
if ($totalmessage > 25)
$ent['FolderIcon'] = "";
}
else
{
$ent['FolderIcon'] = "";
if ($totalmessage > 25)
$ent['FolderIcon'] = "";
}
//if ($tInfo["Locked"] == 1) {$ent['tSubject'] .= "";}
if ($tInfo["Locked"] == 1) {$ent['FolderIcon'] = "";}
$tInfo["Poster"] = trim($tInfo["Poster"]);
$ent["tTopicStarter"] = "$tInfo[Poster]";
$ent["tReplies"] = $tInfo["numReplies"];
$ent["tViews"] = $tInfo["numViews"];
print ParseTemp($first_loop,$ent);
} while ($row = mysql_fetch_array($result));
}
print ParseTemp($last_part,$ent);
fFooter();
?>