diff --git a/phpBB/functions/error.php b/phpBB/functions/error.php index e4277883a2..6b53da1838 100644 --- a/phpBB/functions/error.php +++ b/phpBB/functions/error.php @@ -24,6 +24,7 @@ function error_die($db, $error_code = "", $error_msg = "") { + global $template, $phpEx; if(!$error_msg) { switch($error_code) @@ -42,10 +43,15 @@ function error_die($db, $error_code = "", $error_msg = "") case SESSION_CREATE: $error_msg = "Error creating session. Could not log you in. Please go back and try again."; break; + case NO_POSTS: + $error_msg = "There are no posts in this forum. Click on the 'Post New Topic' link on this page to post one."; } } - - die($error_msg); + $template->set_file(array("error_body" => "error_body.tpl")); + $template->set_var(array("ERROR_MESSAGE" => $error_msg)); + $template->pparse("output", "error_body"); + include('page_tail.'.$phpEx); + exit(); } diff --git a/phpBB/index.php b/phpBB/index.php index b97060bf7d..0ac1a4847a 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -38,6 +38,7 @@ $newest_uid = $newest_userdata["user_id"]; $users_browsing = "4 Users"; $pagetype = "index"; +$page_title = "Forum Index"; include('page_header.'.$phpEx); $template->set_block("body", "catrow", "cats"); @@ -84,7 +85,7 @@ if($total_categories) } else { - $last_post = ""; + $last_post = "No Posts"; } $moderators = "theFinn"; diff --git a/phpBB/page_header.php b/phpBB/page_header.php index 1f4bf2d4d6..b259220977 100644 --- a/phpBB/page_header.php +++ b/phpBB/page_header.php @@ -35,7 +35,6 @@ $template->pparse("output", "overall_header"); switch($pagetype) { case 'index': - $page_title = "Forum Index"; $template->set_file(array("header" => "index_header.tpl", "body" => "index_body.tpl", "footer" => "index_footer.tpl")); @@ -50,7 +49,6 @@ switch($pagetype) break; case 'viewforum': - $page_title = "View Forum"; $template->set_file(array("header" => "viewforum_header.tpl", "body" => "viewforum_body.tpl", "footer" => "viewforum_footer.tpl")); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index b4278d1182..d1a69cf156 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -21,7 +21,92 @@ * * ***************************************************************************/ +include('extension.inc'); +include('config.'.$phpEx); +include('template.inc'); +include('functions/sessions.'.$phpEx); +include('functions/auth.'.$phpEx); +include('functions/functions.'.$phpEx); +include('db.'.$phpEx); +include('functions/error.'.$phpEx); +if(isset($forum_id)) +{ + $sql = "SELECT f.forum_type, f.forum_name + FROM ".FORUMS_TABLE." f + WHERE forum_id = '$forum_id'"; +} +else +{ + error_die($db, "You have reached this page in error, please go back and try again"); +} + +if(!$result = $db->sql_query($sql)) +{ + error_die($db, QUERY_ERROR); +} +$total_rows = $db->sql_numrows($result); +$forum_row = $db->sql_fetchrowset($result); +if(!$forum_row) +{ + error_die($db, QUERY_ERROR); +} +$forum_name = stripslashes($forum_row[0]["forum_name"]); +$forum_moderators = "james"; +$pagetype = "viewforum"; +$page_title = "View Forum - $forum_name"; +include('page_header.'.$phpEx); + + +// Add checking for private forums here!! + +$template->set_block("body", "topicrow", "topics"); + +if(!isset($start)) +{ + $start = 0; +} + +$sql = "SELECT t.*, u.username, p.post_time FROM " . TOPICS_TABLE ." t, ". USERS_TABLE. " u + LEFT JOIN ".POSTS_TABLE." p ON p.post_id = t.topic_last_post_id + WHERE t.forum_id = '$forum_id' AND t.topic_poster = u.user_id + ORDER BY topic_time DESC LIMIT $start, $topics_per_page"; +if(!$t_result = $db->sql_query($sql)) +{ + error_die($db, QUERY_ERROR); +} +$total_topics = $db->sql_numrows(); + +if($total_topics) +{ + $topic_rowset = $db->sql_fetchrowset($t_result); + for($x = 0; $x < $total_topics; $x++) + { + $topic_title = stripslashes($topic_rowset[$x]["topic_title"]); + $topic_id = $topic_rowset[$x]["topic_id"]; + $replies = $topic_rowset[$x]["topic_replies"]; + $views = $topic_rowset[$x]["topic_views"]; + $last_post_time = date($date_format, $topic_rowset[$x]["post_time"]); + $last_post_user = $topic_rowset[$x]["username"]; + $folder_img = ""; + $template->set_var(array("FORUM_ID" => $forum_id, + "TOPIC_ID" => $topic_id, + "FOLDER" => $folder_img, + "REPLIES" => $replies, + "TOPIC_TITLE" => $topic_title, + "VIEWS" => $views, + "LAST_POST" => $last_post_time . "
" . $last_post_user)); + $template->parse("topics", "topicrow", true); + } + $template->pparse("output", array("topics", "body")); +} +else +{ + error_die($db, NO_POSTS); +} + + +include('page_tail.'.$phpEx); ?>