From 9ef35696d2d221a1ab58886f5db94e4988833b0b Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Wed, 7 Mar 2001 06:53:39 +0000 Subject: Started on posting.php, got the logic done for displaying the new topic form git-svn-id: file:///svn/phpbb/trunk@83 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 136 ++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 69 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index ebedb1b5c3..e93da664f5 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1,48 +1,48 @@ sql_query($sql)) -{ +{ error_die($db, QUERY_ERROR); } // // Add checking for private forums here -// +// if(!$total_rows = $db->sql_numrows($result)) { @@ -50,6 +50,7 @@ if(!$total_rows = $db->sql_numrows($result)) } $forum_row = $db->sql_fetchrowset($result); +$forum_name = stripslashes($forum_row[0]["forum_name"]); for($x = 0; $x < $total_rows; $x++) { $moderators[] = array("user_id" => $forum_row[$x]["user_id"], @@ -64,19 +65,18 @@ if(!isset($start)) { $start = 0; } -$sql = "SELECT t.topic_title, t.topic_status, t.topic_replies, f.forum_name - FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f - WHERE t.topic_id = '$topic_id' AND f.forum_id = t.forum_id"; +$sql = "SELECT topic_title, topic_status, topic_replies + FROM ".TOPICS_TABLE." + WHERE topic_id = '$topic_id'"; if(!$result = $db->sql_query($sql)) { - error_die($db, QUERY_ERROR); + error_die($db, QUERY_ERROR); } if(!$topic_info = $db->sql_fetchrowset($result)) { - error_die($db, GENERAL_ERROR, "Could not get topic data
$sql"); + error_die($db, GENERAL_ERROR, "Could not get topic data
$sql"); } -$forum_name = stripslashes($topic_info[0]["forum_name"]); $topic_title = stripslashes($topic_info[0]["topic_title"]); $total_replies = $topic_info[0]["topic_replies"] + 1; @@ -84,14 +84,15 @@ $pagetype = "viewtopic"; $page_title = "View Topic - $topic_title"; include('page_header.'.$phpEx); -$sql = "SELECT u.*, r.rank_title, r.rank_image, - p.post_time, p.post_id, pt.post_text - FROM ".POSTS_TABLE." p - LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id - LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id) AND NOT (u.user_posts > r.rank_min AND u.user_posts < r.rank_max) - LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id - WHERE p.topic_id = '$topic_id' - ORDER BY p.post_time ASC LIMIT $start, $posts_per_page"; +$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, + u.user_regdate, u.user_msnm, u.user_viewemail, r.rank_title, r.rank_image, + p.post_time, p.post_id, pt.post_text + FROM ".POSTS_TABLE." p + LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id + LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id) AND NOT (u.user_posts > r.rank_min AND u.user_posts < r.rank_max) + LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id + WHERE p.topic_id = '$topic_id' + ORDER BY p.post_time ASC LIMIT $start, $posts_per_page"; if(!$result = $db->sql_query($sql)) { @@ -99,20 +100,20 @@ if(!$result = $db->sql_query($sql)) } if(!$total_posts = $db->sql_numrows($result)) { - error_die($db, GENERAL_ERROR, "Error getting post data."); + error_die($db, GENERAL_ERROR, "Error getting post data."); } $postrow = $db->sql_fetchrowset($result); $template->set_block("body", "postrow", "posts"); -for($x = 0; $x < $total_posts; $x++) +for($x = 0; $x < $total_posts; $x++) { $poster = stripslashes($postrow[$x]["username"]); $poster_id = $postrow[$x]["user_id"]; $poster_rank = stripslashes($postrow[$x]["rank_title"]); $rank_image = ($postrow[$x]["rank_image"]) ? "" : ""; $post_date = date($date_format, $postrow[$x]["post_time"]); - + $poster_posts = $postrow[$x]["user_posts"]; $poster_from = ($postrow[$x]["user_from"]) ? "$l_from: ".$postrow[$x]["user_from"] : ""; $poster_joined = $postrow[$x]["user_regdate"]; @@ -132,18 +133,18 @@ for($x = 0; $x < $total_posts; $x++) $icq_add_img = ""; } $aim_img = ($postrow[$x]["user_aim"]) ? "" : ""; - $msn_img = ($postrow[$x]["user_msn"]) ? "" : ""; + $msn_img = ($postrow[$x]["user_msnm"]) ? "" : ""; $yim_img = ($postrow[$x]["user_yim"]) ? "" : ""; - + $edit_img = "\"$l_editdelete\""; $quote_img = "\"$l_replyquote\""; $pmsg_img = "\"$l_sendpmsg\""; - if($is_moderator) + if($is_moderator) { $ip_img = "\"$l_viewip\""; $delpost_img = "\"$l_delete\""; } - + $message = stripslashes($postrow[$x]["post_text"]); if(!$allow_html) { @@ -153,7 +154,7 @@ for($x = 0; $x < $total_posts; $x++) { // do bbcode stuff here } - + if(!($x % 2)) { $color = "#DDDDDD"; @@ -162,7 +163,7 @@ for($x = 0; $x < $total_posts; $x++) { $color = "#CCCCCC"; } - + $message = eregi_replace("\[addsig]$", "
_________________
" . stripslashes($postrow[$x]["user_sig"]), $message); $template->set_var(array("TOPIC_TITLE" => $topic_title, @@ -193,44 +194,44 @@ for($x = 0; $x < $total_posts; $x++) $template->parse("posts", "postrow", true); } -if($total_replies > $posts_per_page) +if($total_replies > $posts_per_page) { $times = 0; for($x = 0; $x < $total_replies; $x += $posts_per_page) - { + { $times++; } $pages = $times . " pages"; - + $times = 1; $pagination = "$l_gotopage ("; - + $last_page = $start - $posts_per_page; - if($start > 0) + if($start > 0) { $pagination .= "$l_prevpage "; } - for($x = 0; $x < $total_replies; $x += $posts_per_page) + for($x = 0; $x < $total_replies; $x += $posts_per_page) { - if($times != 1) + if($times != 1) { $pagination .= " | "; } - if($start && ($start == $x)) + if($start && ($start == $x)) { $pagination .= $times; } - else if($start == 0 && $x == 0) + else if($start == 0 && $x == 0) { $pagination .= "1"; } - else + else { $pagination .= "$times"; } - $times++; - } - if(($start + $posts_per_page) < $total_replies) + $times++; + } + if(($start + $posts_per_page) < $total_replies) { $next_page = $start + $posts_per_page; $pagination .= " $l_nextpage"; @@ -245,9 +246,6 @@ $template->set_var(array("PAGES" => $pages, "PAGINATION" => $pagination)); $template->pparse("output", array("posts", "body")); -include('page_tail.'.$phpEx); - - - +include('page_tail.'.$phpEx); ?> -- cgit v1.2.1