Altered view next and previous topic code and minor updates or fixes

git-svn-id: file:///svn/phpbb/trunk@566 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-07-05 17:39:38 +00:00
parent a73375e5b0
commit 48c93d1568
2 changed files with 137 additions and 191 deletions

View file

@ -158,7 +158,12 @@ $lang['Sticky'] = "<b>Sticky:</b>";
// Viewtopic // Viewtopic
// //
$lang['Guest'] = 'Guest'; $lang['Guest'] = 'Guest';
$lang['Post_subject'] = "Post subject";
$lang['View_next_topic'] = "View next topic";
$lang['View_previous_topic'] = "View previous topic";
$lang['No_newer_topics'] = "There are no newer topics in this forum";
$lang['No_older_topics'] = "There are no older topics in this forum";
$lang['Topic_post_not_exist'] = "The topic or post you requested does not exist"; $lang['Topic_post_not_exist'] = "The topic or post you requested does not exist";
// //

View file

@ -30,128 +30,89 @@ $pagetype = "viewtopic";
// //
// Start initial var setup // Start initial var setup
// //
if(isset($HTTP_GET_VARS[POST_TOPIC_URL]))
if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility
{ {
$topic_id = $HTTP_GET_VARS[POST_TOPIC_URL]; $topic_id = $HTTP_GET_VARS[POST_TOPIC_URL];
} }
else
{
$topic_id = $HTTP_GET_VARS['topic'];
}
if(isset($HTTP_GET_VARS[POST_POST_URL])) if(isset($HTTP_GET_VARS[POST_POST_URL]))
{ {
$post_id = $HTTP_GET_VARS[POST_POST_URL]; $post_id = $HTTP_GET_VARS[POST_POST_URL];
} }
$start = (isset($HTTP_GET_VARS['start'])) ? $HTTP_GET_VARS['start'] : 0;
$is_moderator = 0;
if(!isset($topic_id) && !isset($post_id)) if(!isset($topic_id) && !isset($post_id))
{ {
message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist']); message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist']);
} }
$start = (isset($HTTP_GET_VARS['start'])) ? $HTTP_GET_VARS['start'] : 0;
// //
// End initial var setup // End initial var setup
// //
// This is the single/double 'integrated'
// query to obtain the next/previous
// topic from just the current topic_id
// //
// We will make this word, if it's the last thing I // Find topic id if user requested a newer
// do ... and it quite possibly will be! // or older topic
/* //
if(isset($HTTP_GET_VARS['view'])) if( isset($HTTP_GET_VARS["view"]) )
{ {
if($HTTP_GET_VARS['view'] == 'newer') if($HTTP_GET_VARS["view"] == "next")
{ {
$operator = ">"; $sql_condition = ">";
$sql_ordering = "ASC";
} }
else if($HTTP_GET_VARS['view'] == 'older') else if($HTTP_GET_VARS["view"] == "previous")
{ {
$operator = "<"; $sql_condition = "<";
$sql_ordering = "DESC";
} }
switch($dbms) $sql = "SELECT t.topic_id
FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
WHERE t2.topic_id = $topic_id
AND t.forum_id = t2.forum_id
AND t.topic_time $sql_condition t2.topic_time
ORDER BY t.topic_time $sql_ordering
LIMIT 1";
if(!$result = $db->sql_query($sql))
{ {
case 'mysql': message_die(GENERAL_ERROR, "Couldn't obtain newer/older topic information", "", __LINE__, __FILE__, $sql);
// And now the stupid MySQL case...I wish they would get around to implementing subselectes... }
$sub_query = "SELECT topic_time
FROM ".TOPICS_TABLE." list($topic_id) = $db->sql_fetchrow($result);
WHERE topic_id = $topic_id"; if(empty($topic_id))
if($sub_result = $db->sql_query($sub_query)) {
{ if($HTTP_GET_VARS["view"] == "next")
$resultset = $db->sql_fetchrowset($sub_result); {
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, message_die(GENERAL_MESSAGE, $lang['No_newer_topics']);
f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id }
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u else
WHERE t.topic_time ".$operator." ".$resultset[0]['topic_time']." {
AND f.forum_id = ".$HTTP_GET_VARS[POST_FORUM_URL]." message_die(GENERAL_MESSAGE, $lang['No_older_topics']);
AND f.forum_id = t.forum_id }
AND fm.forum_id = t.forum_id
AND u.user_id = fm.user_id";
$db->sql_freeresult($sub_result);
}
else
{
if(DEBUG)
{
$dberror = $db->sql_error();
error_die(SQL_QUERY, "Couldn't obtain topic information.<br>Reason: ".$dberror['message']."<br>Query: $sql", __LINE__, __FILE__);
}
else
{
error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
}
}
break;
default:
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE t.topic_id in
(select max(topic_id) from ".TOPICS_TABLE." WHERE topic_time ".$operator." (select topic_time as t_time from ".TOPICS_TABLE." where topic_id = $topic_id))
AND f.forum_id = ".$HTTP_GET_VARS[POST_FORUM_URL]."
AND f.forum_id = t.forum_id
AND fm.forum_id = t.forum_id
AND u.user_id = fm.user_id";
break;
} }
} }
// //
// End. // This rather complex gaggle of code handles querying for topics but
// also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic)
// //
else $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, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
// This is perhaps a bodged(?) way of allowing a direct link to a post
// it also allows calculation of which page the post should be on. This
// query no longer grabs moderator info for this forum ... right now
// that's fine, but if needed it can be easily replaced/added
//
$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, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, 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, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments" . $count_sql . "
FROM $join_sql_table " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments" . $count_sql . " WHERE $join_sql
FROM $join_sql_table " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f AND f.forum_id = t.forum_id
WHERE $join_sql $order_sql";
AND f.forum_id = t.forum_id
$order_sql";
// This closes out the opening braces above
// Needed for the view/next query
//}
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist'], "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
} }
if(!$total_rows = $db->sql_numrows($result)) if(!$total_rows = $db->sql_numrows($result))
@ -159,6 +120,7 @@ if(!$total_rows = $db->sql_numrows($result))
message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist'], "", __LINE__, __FILE__, $sql); message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist'], "", __LINE__, __FILE__, $sql);
} }
$forum_row = $db->sql_fetchrowset($result); $forum_row = $db->sql_fetchrowset($result);
$forum_name = stripslashes($forum_row[0]['forum_name']); $forum_name = stripslashes($forum_row[0]['forum_name']);
$forum_id = $forum_row[0]['forum_id']; $forum_id = $forum_row[0]['forum_id'];
$topic_id = $forum_row[0]['topic_id']; $topic_id = $forum_row[0]['topic_id'];
@ -188,12 +150,9 @@ $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row[0]);
if(!$is_auth['auth_view'] || !$is_auth['auth_view']) if(!$is_auth['auth_view'] || !$is_auth['auth_view'])
{ {
// //
// Ooopss, user is not authed // The user is not authed to read this forum ...
// to read this forum ...
// //
include('includes/page_header.'.$phpEx); $msg = $lang['Sorry_auth'] . $is_auth['auth_read_type'] . $lang['can_read'] . $lang['this_forum'];
$msg = "I am sorry but only " . $is_auth['auth_read_type'] . " can read this topic.";
message_die(GENERAL_MESSAGE, $msg); message_die(GENERAL_MESSAGE, $msg);
} }
@ -203,13 +162,10 @@ if(!$is_auth['auth_view'] || !$is_auth['auth_view'])
/* /*
// //
// This code allows for individual topic // This code allows for individual topic read tracking, on small, low volume sites
// read tracking, on small, low volume sites // it'll probably work very well. However, for busy sites the use of a text field
// it'll probably work very well. However, for // in the DB combined with the additional UPDATE's required in viewtopic may be
// busy sites the use of a text field in the DB // unacceptable. So, by default this code is off, however you may want to play
// combined with the additional UPDATE's required
// in viewtopic may be unacceptable. So, by default
// this code is off, however you may want to play
// ... // ...
// //
// psoTFX // psoTFX
@ -233,45 +189,11 @@ if($userdata['user_id'] != ANONYMOUS)
} }
*/ */
for($x = 0; $x < $total_rows; $x++)
{
$moderators[] = array(
"user_id" => $forum_row[$x]['user_id'],
"username" => $forum_row[$x]['username']);
if($userdata['user_id'] == $forum_row[$x]['user_id'])
{
$is_moderator = 1;
}
}
//
// Get next and previous topic_id's
//
$sql_next_id = "SELECT topic_id
FROM ".TOPICS_TABLE."
WHERE topic_time > $topic_time
AND forum_id = $forum_id
ORDER BY topic_time ASC
LIMIT 1";
$sql_prev_id = "SELECT topic_id
FROM ".TOPICS_TABLE."
WHERE topic_time < $topic_time
AND forum_id = $forum_id
ORDER BY topic_time DESC
LIMIT 1";
$result_next = $db->sql_query($sql_next_id);
$result_prev = $db->sql_query($sql_prev_id);
$topic_next_row = $db->sql_fetchrow($result_next);
$topic_prev_row = $db->sql_fetchrow($result_prev);
// //
// Go ahead and pull all data for this topic // Go ahead and pull all data for this topic
// //
$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, u.user_rank, u.user_sig, u.user_avatar, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject, p.post_username $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, u.user_rank, u.user_sig, u.user_avatar, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject, p.post_username
FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id AND p.poster_id = u.user_id
AND p.post_id = pt.post_id AND p.post_id = pt.post_id
@ -281,18 +203,15 @@ if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Couldn't obtain post/user information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain post/user information.", "", __LINE__, __FILE__, $sql);
} }
if(!$total_posts = $db->sql_numrows($result)) if(!$total_posts = $db->sql_numrows($result))
{ {
//
// Again this should be considered temporary and
// will appear in the templates file at some
// point
//
message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql);
} }
$sql = "SELECT * $sql = "SELECT *
FROM ".RANKS_TABLE." FROM " . RANKS_TABLE . "
ORDER BY rank_min"; ORDER BY rank_special, rank_min";
if(!$ranks_result = $db->sql_query($sql)) if(!$ranks_result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Couldn't obtain ranks information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain ranks information.", "", __LINE__, __FILE__, $sql);
@ -301,8 +220,7 @@ $postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult); $ranksrow = $db->sql_fetchrowset($ranksresult);
// //
// Dump out the page header and // Dump out the page header and oad viewtopic body template
// load viewtopic body template
// //
include('includes/page_header.'.$phpEx); include('includes/page_header.'.$phpEx);
@ -310,12 +228,14 @@ $template->set_filenames(array(
"body" => "viewtopic_body.tpl", "body" => "viewtopic_body.tpl",
"jumpbox" => "jumpbox.tpl") "jumpbox" => "jumpbox.tpl")
); );
$jumpbox = make_jumpbox(); $jumpbox = make_jumpbox();
$template->assign_vars(array( $template->assign_vars(array(
"JUMPBOX_LIST" => $jumpbox, "JUMPBOX_LIST" => $jumpbox,
"SELECT_NAME" => POST_FORUM_URL) "SELECT_NAME" => POST_FORUM_URL)
); );
$template->assign_var_from_handle("JUMPBOX", "jumpbox"); $template->assign_var_from_handle("JUMPBOX", "jumpbox");
$template->assign_vars(array( $template->assign_vars(array(
"FORUM_ID" => $forum_id, "FORUM_ID" => $forum_id,
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
@ -334,25 +254,31 @@ $template->assign_vars(array(
// //
$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"); $new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id");
$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id&" . POST_FORUM_URL . "=$forum_id"); $reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id&" . POST_FORUM_URL . "=$forum_id");
$view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"); $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
$view_prev_topic_url = (!empty($topic_prev_row['topic_id'])) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_prev_row['topic_id']) : "";
$view_next_topic_url = (!empty($topic_next_row['topic_id'])) ? append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_next_row['topic_id']) : ""; $view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous");
$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next");
$template->assign_vars(array( $template->assign_vars(array(
"L_POSTED" => $l_posted,
"U_POST_NEW_TOPIC" => $new_topic_url,
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
"TOPIC_TITLE" => $topic_title, "TOPIC_TITLE" => $topic_title,
"L_POSTED" => $lang['Posted'],
"L_POST_SUBJECT" => $lang['Post_subject'],
"L_VIEW_NEXT_TOPIC" => $lang['View_next_topic'],
"L_VIEW_PREVIOUS_TOPIC" => $lang['View_previous_topic'],
"U_VIEW_FORUM" => $view_forum_url, "U_VIEW_FORUM" => $view_forum_url,
"U_VIEW_OLDER_TOPIC" => $view_prev_topic_url, "U_VIEW_OLDER_TOPIC" => $view_prev_topic_url,
"U_VIEW_NEWER_TOPIC" => $view_next_topic_url, "U_VIEW_NEWER_TOPIC" => $view_next_topic_url,
"U_POST_NEW_TOPIC" => $new_topic_url,
"U_POST_REPLY_TOPIC" => $reply_topic_url)); "U_POST_REPLY_TOPIC" => $reply_topic_url));
// //
// Update the topic view counter // Update the topic view counter
// //
$sql = "UPDATE ".TOPICS_TABLE." $sql = "UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1 SET topic_views = topic_views + 1
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
if(!$update_result = $db->sql_query($sql)) if(!$update_result = $db->sql_query($sql))
@ -364,92 +290,104 @@ if(!$update_result = $db->sql_query($sql))
// Okay, let's do the loop, yeah come on baby let's do the loop // Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ... // and it goes like this ...
// //
for($x = 0; $x < $total_posts; $x++) for($i = 0; $i < $total_posts; $i++)
{ {
$poster = stripslashes($postrow[$x]['username']);
$poster_id = $postrow[$x]['user_id'];
$post_date = create_date($board_config['default_dateformat'], $postrow[$x]['post_time'], $board_config['default_timezone']); $poster_id = $postrow[$i]['user_id'];
$poster = stripslashes($postrow[$i]['username']);
$poster_posts = ($postrow[$x]['user_id'] != ANONYMOUS) ? $lang['Posts'] . ": " . $postrow[$x]['user_posts'] : ""; $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['default_timezone']);
$poster_from = ($postrow[$x]['user_from'] && $postrow[$x]['user_id'] != ANONYMOUS) ? $lang['From'] . ": " .$postrow[$x]['user_from'] : ""; $poster_posts = ($postrow[$i]['user_id'] != ANONYMOUS) ? $lang['Posts'] . ": " . $postrow[$i]['user_posts'] : "";
$poster_joined = ($postrow[$x]['user_id'] != ANONYMOUS) ? $lang['Joined'] . ": " . create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']) : ""; $poster_from = ($postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS) ? $lang['From'] . ": " .$postrow[$i]['user_from'] : "";
$poster_avatar = ($postrow[$x]['user_avatar'] != "" && $userdata['user_id'] != ANONYMOUS) ? "<img src=\"".$board_config['avatar_path']."/".$postrow[$x]['user_avatar']."\">" : ""; $poster_joined = ($postrow[$i]['user_id'] != ANONYMOUS) ? $lang['Joined'] . ": " . create_date($board_config['default_dateformat'], $postrow[$i]['user_regdate'], $board_config['default_timezone']) : "";
if(empty($postrow[$x]['user_rank']) && $postrow[$x]['user_id'] != ANONYMOUS) if($postrow[$i]['user_avatar'] != "" && $userdata['user_id'] != ANONYMOUS)
{ {
for($i = 0; $i < count($ranksrow); $i++) $poster_avatar = (strstr("http", $postrow[$i]['user_avatar']) && $board_config['allow_avatar_remote']) ? "<img src=\"" . $postrow[$i]['user_avatar'] . "\">" : "<img src=\"" . $board_config['avatar_path'] . "/" . $postrow[$i]['user_avatar'] . "\">";
}
//
// Generate ranks
//
if( $postrow[$i]['user_id'] == ANONYMOUS )
{
$poster_rank = "";
$rank_image = "";
}
else if( $postrow[$i]['user_rank'] )
{
for($j = 0; $j < count($ranksrow); $j++)
{ {
if($poster_posts > $ranksrow[$i]['rank_min'] && $poster_posts < $ranksrow[$i]['rank_max']) if($postrow[$i]['user_rank'] == $ranksrow[$j]['rank_special'])
{ {
$poster_rank = $ranksrow[$i]['rank_title']; $poster_rank = $ranksrow[$j]['rank_title'];
$rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : ""; $rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\">" : "";
} }
} }
} }
else else
{ {
if(!empty($postrow[$x]['user_rank'])) for($j = 0; $j < count($ranksrow); $j++)
{ {
for($i = 0; $i < count($ranksrow); $i++) if($postrow[$i]['user_posts'] > $ranksrow[$j]['rank_min'] && $postrow[$i]['user_posts'] < $ranksrow[$j]['rank_max'])
{ {
if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special']) $poster_rank = $ranksrow[$j]['rank_title'];
{ $rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\">" : "";
$poster_rank = $ranksrow[$i]['rank_title'];
$rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : "";
}
} }
} }
} }
//
// Handle anon users posting with usernames // Handle anon users posting with usernames
if($poster_id == ANONYMOUS && $postrow[$x]['post_username'] != '') //
if($poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '')
{ {
$poster = stripslashes($postrow[$x]['post_username']); $poster = stripslashes($postrow[$i]['post_username']);
$poster_rank = $lang['Guest']; $poster_rank = $lang['Guest'];
} }
$profile_img = "<a href=\"".append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id")."\"><img src=\"".$images['profile']."\" alt=\"$l_profileof $poster\" border=\"0\"></a>"; $profile_img = "<a href=\"".append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id")."\"><img src=\"".$images['profile']."\" alt=\"$l_profileof $poster\" border=\"0\"></a>";
$search_img = "<a href=\"" . append_sid("search.$phpEx?a=" . urlencode($poster) . "&f=all&b=0&d=DESC&c=100&dosearch=1") . "\"><img src=\"" . $images['search_icon'] . "\" border=\"0\"></a>";
$pm_img = "<a href=\"" . append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL. "=$poster_id") . "\"><img src=\"". $images['privmsg'] . "\" alt=\"" . $lang['Private_messaging'] . "\" border=\"0\"></a>"; $pm_img = "<a href=\"" . append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL. "=$poster_id") . "\"><img src=\"". $images['privmsg'] . "\" alt=\"" . $lang['Private_messaging'] . "\" border=\"0\"></a>";
$email_img = ($postrow[$x]['user_viewemail'] == 1) ? "<a href=\"mailto:".$postrow[$x]['user_email']."\"><img src=\"".$images['email']."\" alt=\"$l_email $poster\" border=\"0\"></a>" : ""; $email_img = ($postrow[$i]['user_viewemail'] == 1) ? "<a href=\"mailto:".$postrow[$i]['user_email']."\"><img src=\"".$images['email']."\" alt=\"$l_email $poster\" border=\"0\"></a>" : "";
$www_img = ($postrow[$x]['user_website']) ? "<a href=\"".$postrow[$x]['user_website']."\"><img src=\"".$images['www']."\" alt=\"$l_viewsite\" border=\"0\"></a>" : ""; $www_img = ($postrow[$i]['user_website']) ? "<a href=\"".$postrow[$i]['user_website']."\"><img src=\"".$images['www']."\" alt=\"$l_viewsite\" border=\"0\"></a>" : "";
if($postrow[$x]['user_icq']) if($postrow[$i]['user_icq'])
{ {
$icq_status_img = "<a href=\"http://wwp.icq.com/".$postrow[$x]['user_icq']."#pager\"><img src=\"http://online.mirabilis.com/scripts/online.dll?icq=".$postrow[$x]['user_icq']."&img=5\" alt=\"$l_icqstatus\" border=\"0\"></a>"; $icq_status_img = "<a href=\"http://wwp.icq.com/".$postrow[$i]['user_icq']."#pager\"><img src=\"http://online.mirabilis.com/scripts/online.dll?icq=".$postrow[$i]['user_icq']."&img=5\" alt=\"$l_icqstatus\" border=\"0\"></a>";
$icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$postrow[$x]['user_icq']."\"><img src=\"".$images['icq']."\" alt=\"$l_icq\" border=\"0\"></a>"; $icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$postrow[$i]['user_icq']."\"><img src=\"".$images['icq']."\" alt=\"$l_icq\" border=\"0\"></a>";
} }
else else
{ {
$icq_status_img = ""; $icq_status_img = "";
$icq_add_img = ""; $icq_add_img = "";
} }
$aim_img = ($postrow[$x]['user_aim']) ? "<a href=\"aim:goim?screenname=".$postrow[$x]['user_aim']."&message=Hello+Are+you+there?\"><img src=\"".$images['aim']."\" border=\"0\"></a>" : ""; $aim_img = ($postrow[$i]['user_aim']) ? "<a href=\"aim:goim?screenname=".$postrow[$i]['user_aim']."&message=Hello+Are+you+there?\"><img src=\"".$images['aim']."\" border=\"0\"></a>" : "";
$msn_img = ($postrow[$x]['user_msnm']) ? "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id\"><img src=\"".$images['msn']."\" border=\"0\"></a>" : ""; $msn_img = ($postrow[$i]['user_msnm']) ? "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id\"><img src=\"".$images['msn']."\" border=\"0\"></a>" : "";
$yim_img = ($postrow[$x]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$x]['user_yim']."&.src=pg\"><img src=\"".$images['yim']."\" border=\"0\"></a>" : ""; $yim_img = ($postrow[$i]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$i]['user_yim']."&.src=pg\"><img src=\"".$images['yim']."\" border=\"0\"></a>" : "";
if($x == 0) if($i == 0)
{ {
$edit_post_url = append_sid("posting.$phpEx?mode=editpost&".POST_POST_URL."=".$postrow[$x]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id&is_first_post=1"); $edit_post_url = append_sid("posting.$phpEx?mode=editpost&".POST_POST_URL."=".$postrow[$i]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id&is_first_post=1");
} }
else else
{ {
$edit_post_url = append_sid("posting.$phpEx?mode=editpost&".POST_POST_URL."=".$postrow[$x]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id"); $edit_post_url = append_sid("posting.$phpEx?mode=editpost&".POST_POST_URL."=".$postrow[$i]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id");
} }
$edit_img = "<a href=\"".$edit_post_url."\"><img src=\"".$images['edit']."\" alt=\"$l_editdelete\" border=\"0\"></a>"; $edit_img = "<a href=\"".$edit_post_url."\"><img src=\"".$images['edit']."\" alt=\"$l_editdelete\" border=\"0\"></a>";
$quote_img = "<a href=\"".append_sid("posting.$phpEx?mode=reply&quote=true&".POST_POST_URL."=".$postrow[$x]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id")."\"><img src=\"".$images['quote']."\" alt=\"$l_replyquote\" border=\"0\"></a>"; $quote_img = "<a href=\"".append_sid("posting.$phpEx?mode=reply&quote=true&".POST_POST_URL."=".$postrow[$i]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id")."\"><img src=\"".$images['quote']."\" alt=\"$l_replyquote\" border=\"0\"></a>";
$pmsg_img = "<a href=\"".append_sid("privmsg.$phpEx?mode=send&" . POST_USERS_URL . "=" .$poster_id) . "\"><img src=\"".$images['pmsg']."\" alt=\"$l_sendpmsg\" border=\"0\"></a>"; $pmsg_img = "<a href=\"".append_sid("privmsg.$phpEx?mode=send&" . POST_USERS_URL . "=" .$poster_id) . "\"><img src=\"".$images['pmsg']."\" alt=\"$l_sendpmsg\" border=\"0\"></a>";
@ -457,22 +395,23 @@ for($x = 0; $x < $total_posts; $x++)
{ {
$ip_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=viewip&".POST_USERS_URL."=".$poster_id)."\"><img src=\"".$images['ip']."\" alt=\"$l_viewip\" border=\"0\"></a>"; $ip_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=viewip&".POST_USERS_URL."=".$poster_id)."\"><img src=\"".$images['ip']."\" alt=\"$l_viewip\" border=\"0\"></a>";
$delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost&".POST_POST_URL."=".$postrow[$x]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>"; $delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost&".POST_POST_URL."=".$postrow[$i]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>";
} }
$post_subject = ($postrow[$x]['post_subject'] != "") ? stripslashes($postrow[$x]['post_subject']) : "Re: ".$topic_title; $post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : $topic_title;
$bbcode_uid = $postrow[$x]['bbcode_uid']; $bbcode_uid = $postrow[$i]['bbcode_uid'];
$user_sig = stripslashes($postrow[$x]['user_sig']); $user_sig = stripslashes($postrow[$i]['user_sig']);
$message = stripslashes($postrow[$x]['post_text']); $message = stripslashes($postrow[$i]['post_text']);
if(!$board_config['allow_html']) if(!$board_config['allow_html'])
{ {
$user_sig = strip_tags($user_sig); $user_sig = strip_tags($user_sig);
$message = strip_tags($message); $message = strip_tags($message);
} }
if($board_config['allow_bbcode']) if($board_config['allow_bbcode'])
{ {
// do bbcode stuff here // do bbcode stuff here
@ -490,7 +429,7 @@ for($x = 0; $x < $total_posts; $x++)
// Again this will be handled by the templating // Again this will be handled by the templating
// code at some point // code at some point
// //
if(!($x % 2)) if(!($i % 2))
{ {
$color = "#".$theme['td_color1']; $color = "#".$theme['td_color1'];
} }
@ -514,6 +453,7 @@ for($x = 0; $x < $total_posts; $x++)
"POST_SUBJECT" => $post_subject, "POST_SUBJECT" => $post_subject,
"MESSAGE" => $message, "MESSAGE" => $message,
"PROFILE_IMG" => $profile_img, "PROFILE_IMG" => $profile_img,
"SEARCH_IMG" => $search_img,
"PM_IMG" => $pm_img, "PM_IMG" => $pm_img,
"EMAIL_IMG" => $email_img, "EMAIL_IMG" => $email_img,
"WWW_IMG" => $www_img, "WWW_IMG" => $www_img,
@ -528,7 +468,8 @@ for($x = 0; $x < $total_posts; $x++)
"IP_IMG" => $ip_img, "IP_IMG" => $ip_img,
"DELPOST_IMG" => $delpost_img, "DELPOST_IMG" => $delpost_img,
"U_POST_ID" => $postrow[$x]['post_id'])); "U_POST_ID" => $postrow[$i]['post_id'])
);
} }
$s_auth_can = "You " . (($is_auth['auth_read']) ? "<b>can</b>" : "<b>cannot</b>" ) . " read posts in this forum<br>"; $s_auth_can = "You " . (($is_auth['auth_read']) ? "<b>can</b>" : "<b>cannot</b>" ) . " read posts in this forum<br>";