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);
$CurrentUserInfo = GrabUserTZone();
$fSettings = GetSettings();
$gStats = GlobalStats();
$template = ReadTemplate("index");
$pos_start = strpos($template,"")+strlen("");
$pos_end = strpos($template,"",strpos($template,"")+strlen(""));
$pos_end_cat = strpos($template,"",$pos_start);
$cat_loop = substr($template,$pos_start,$pos_end_cat-$pos_start);
$first_loop = substr($template,$pos_start,$pos_end-$pos_start);
$first_part = substr($template,0,$pos_start-strlen(""));
$last_part = substr($template,$pos_end,strlen($template)-$pos_end);
$LastVisit = fHeader();
if (!CheckViewAccess(9999))
UhOh($txt['errBanned']);
$ActiveUsers = GrabActiveList();
$ent["gtTopics"] = $gStats["TotalTopics"];
$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["CurrentTime"] = FormatDate(time(),$CurrentUserInfo[timezone])." at ".FormatTime(time(),$CurrentUserInfo[timezone]);
$ent["gtPosts"] = $gStats["TotalPosts"];
$ent["gtMembers"] = $gStats["TotalUsers"];
$gStats[NewestMem2] = rawurlencode($gStats[NewestMem]);
$ent["NewestMember"] = "$gStats[NewestMem]";
$ent["TodayPost"] = $fSettings["ScriptURL"]."/search.php?action=viewtoday";
$ent["LastVisit"] = FormatTime($LastVisit,$CurrentUserInfo[timezone]);
$ent["AnnouncementMSG"] = GrabAnnouncement($BoardID);
$ent["NavPath"] = $fSettings["ForumName"];
$ent["UsersActive"] = $ActiveUsers['Users'];
$ent["GuestsActive"] = $ActiveUsers['Guests'];
$ent["LoginBox"] = GrabLoginBox("$fSettings[ScriptURL]/index.php");
$ent["PM"] = GrabPM("$fSettings[ScriptURL]/index.php");
print ParseTemp($first_part,$ent);
$query = "SELECT * FROM t_categories Order By cOrder ASC";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result))
{
do
{
$ent["CatName"] = $row["CatName"];
print ParseTemp($cat_loop,$ent);
$query = "select * from t_boards where CatID = ".$row["ID"]." Order By bOrder ASC";
$result2 = mysql_query($query);
if ($row2 = mysql_fetch_array($result2))
{
$pos_start2 = strpos($first_loop,"")+strlen("");
$pos_end2 = strpos($first_loop,"",$pos_start2);
$second_loop = substr($first_loop,$pos_start2,$pos_end2-$pos_start2);
do
{
$bInfo = $row2;
$query = "select count(*) from t_messages where BoardID = ". $bInfo["ID"] ." AND FirstMessage='yes'";
$result3 = mysql_query($query);
$row3 = mysql_fetch_row($result3);
$row3 ? $bInfo["NumTopics"] = $row3[0] : $bInfo["NumTopics"] = 0;
$query = "select count(*) from t_messages where BoardID = ". $bInfo["ID"];
$result3 = mysql_query($query);
$row3 = mysql_fetch_row($result3);
$row3 ? $bInfo["NumPosts"] = $row3[0] : $bInfo["NumPosts"] = 0;
$query = "select DatePosted,Poster from t_messages where BoardID = ". $bInfo["ID"] ." Order By DatePosted DESC LIMIT 1";
$result3 = mysql_query($query);
$row3 = mysql_fetch_row($result3);
if ($row3)
{
$bInfo["LatestPost"] = FormatDate($row3[0],$CurrentUserInfo[timezone]);
$bInfo["LatestPostTime"] = FormatTime($row3[0],$CurrentUserInfo[timezone]);
$bInfo["LatestPoster"] = $row3[1];
}
else
{
$bInfo["LatestPost"] = "n/a";
$bInfo["LatestPostTime"] = "n/a";
$bInfo["LatestPoster"] = "n/a";
}
$ent["BoardName"] = "$bInfo[bName]";
//if (!is_read_board($bInfo["ID"],$LastVisit)) {$ent["BoardName"] .= "";}
$ent["BoardDesc"] = $bInfo["bDesc"];
$ent["bNumTopics"] = $bInfo["NumTopics"];
$ent["bNumPosts"] = $bInfo["NumPosts"];
$ent["Moderator"] = GrabModerators($bInfo["ID"]);
$ent["LatestMSGDate"] = $bInfo["LatestPost"];
$ent["LatestMSGTime"] = $bInfo["LatestPostTime"];
$ent["LatestMSGPoster"] = "$bInfo[LatestPoster]";
if (!is_read_board($bInfo["ID"],$LastVisit))
$ent['FolderIcon'] = "";
else
$ent['FolderIcon'] = "";
print ParseTemp($second_loop,$ent);
} while ($row2 = mysql_fetch_array($result2));
}
} while ($row = mysql_fetch_array($result));
}
print ParseTemp($last_part,$ent);
fFooter();
?>