|
From: Paul S. O. <ps...@us...> - 2002-03-20 15:04:27
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv7313
Modified Files:
viewtopic.php
Log Message:
Fix error when view is set to somethng unexpected
Index: viewtopic.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/viewtopic.php,v
retrieving revision 1.181
retrieving revision 1.182
diff -C2 -r1.181 -r1.182
*** viewtopic.php 19 Mar 2002 00:43:19 -0000 1.181
--- viewtopic.php 20 Mar 2002 15:04:21 -0000 1.182
***************
*** 59,71 ****
// or older topic
//
! if( isset($HTTP_GET_VARS["view"]) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{
! if( $HTTP_GET_VARS["view"] == "newest" )
{
! if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"]) )
{
! $session_id = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"];
! if( $session_id )
{
$sql = "SELECT p.post_id
--- 59,71 ----
// or older topic
//
! if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{
! if ( $HTTP_GET_VARS['view'] == 'newest' )
{
! if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) )
{
! $session_id = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'];
! if ( $session_id )
{
$sql = "SELECT p.post_id
***************
*** 77,86 ****
ORDER BY p.post_time ASC
LIMIT 1";
! if( !$result = $db->sql_query($sql) )
{
! message_die(GENERAL_ERROR, "Couldn't obtain newer/older topic information", "", __LINE__, __FILE__, $sql);
}
! if( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
--- 77,86 ----
ORDER BY p.post_time ASC
LIMIT 1";
! if ( !($result = $db->sql_query($sql)) )
{
! message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
}
! if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
***************
*** 90,93 ****
--- 90,94 ----
$post_id = $row['post_id'];
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id", true));
+ exit;
}
}
***************
*** 95,98 ****
--- 96,100 ----
{
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
+ exit;
}
}
***************
*** 100,149 ****
{
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
}
}
! else if( $HTTP_GET_VARS["view"] == "next" )
{
! $sql_condition = ">";
! $sql_ordering = "ASC";
! }
! else if( $HTTP_GET_VARS["view"] == "previous" )
! {
! $sql_condition = "<";
! $sql_ordering = "DESC";
! }
! $sql = "SELECT t.topic_id
! FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2
! WHERE t2.topic_id = $topic_id
! AND p2.post_id = t2.topic_last_post_id
! AND t.forum_id = t2.forum_id
! AND p.post_id = t.topic_last_post_id
! AND p.post_time $sql_condition p2.post_time
! AND p.topic_id = t.topic_id
! ORDER BY p.post_time $sql_ordering
! LIMIT 1";
! if(!$result = $db->sql_query($sql))
! {
! message_die(GENERAL_ERROR, "Couldn't obtain newer/older topic information", "", __LINE__, __FILE__, $sql);
! }
! if( !$row = $db->sql_fetchrow($result) )
! {
! if( $HTTP_GET_VARS["view"] == "next" )
{
! message_die(GENERAL_MESSAGE, 'No_newer_topics');
}
else
{
! message_die(GENERAL_MESSAGE, 'No_older_topics');
}
}
- else
- {
- $topic_id = $row['topic_id'];
- }
}
-
//
// This rather complex gaggle of code handles querying for topics but
--- 102,146 ----
{
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
+ exit;
}
}
! else if( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
{
! $sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<';
! $sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';
! $sql = "SELECT t.topic_id
! FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2
! WHERE t2.topic_id = $topic_id
! AND p2.post_id = t2.topic_last_post_id
! AND t.forum_id = t2.forum_id
! AND p.post_id = t.topic_last_post_id
! AND p.post_time $sql_condition p2.post_time
! AND p.topic_id = t.topic_id
! ORDER BY p.post_time $sql_ordering
! LIMIT 1";
! if ( !($result = $db->sql_query($sql)) )
! {
! message_die(GENERAL_ERROR, "Couldn't obtain newer/older topic information", "", __LINE__, __FILE__, $sql);
! }
! if ( !($row = $db->sql_fetchrow($result)) )
{
! if( $HTTP_GET_VARS['view'] == 'next' )
! {
! message_die(GENERAL_MESSAGE, 'No_newer_topics');
! }
! else
! {
! message_die(GENERAL_MESSAGE, 'No_older_topics');
! }
}
else
{
! $topic_id = $row['topic_id'];
}
}
}
//
// This rather complex gaggle of code handles querying for topics but
***************
*** 151,159 ****
// page the post is on and the correct display of viewtopic)
//
! $join_sql_table = ( !isset($post_id) ) ? "" : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( !isset($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
! $count_sql = ( !isset($post_id) ) ? "" : ", COUNT(p2.post_id) AS prev_posts";
! $order_sql = ( !isset($post_id) ) ? "" : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
--- 148,156 ----
// page the post is on and the correct display of viewtopic)
//
! $join_sql_table = ( !isset($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( !isset($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
! $count_sql = ( !isset($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
! $order_sql = ( !isset($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
|