New session code, probably still dodgy, fix for login failed message, search updates, highlighting URI messup fixes, max limit for ranks

git-svn-id: file:///svn/phpbb/trunk@1511 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-12-05 00:20:56 +00:00
parent 4d495f9a59
commit 2ace10e4c2
10 changed files with 841 additions and 578 deletions

View file

@ -179,7 +179,7 @@ else
} }
} }
if( $board_config['board_disable'] && !defined("IN_ADMIN") ) if( $board_config['board_disable'] && !defined("IN_ADMIN") && !defined("IN_LOGIN") )
{ {
message_die(GENERAL_MESSAGE, 'Board_disable', 'Information'); message_die(GENERAL_MESSAGE, 'Board_disable', 'Information');
} }

View file

@ -242,6 +242,7 @@ $template->assign_vars(array(
"PRIVATE_MESSAGE_INFO_UNREAD" => $l_privmsgs_text_unread, "PRIVATE_MESSAGE_INFO_UNREAD" => $l_privmsgs_text_unread,
"PRIVATE_MESSAGE_NEW_FLAG" => $s_privmsg_new, "PRIVATE_MESSAGE_NEW_FLAG" => $s_privmsg_new,
"LAST_VISIT_DATE" => sprintf($lang['You_last_visit'], $s_last_visit), "LAST_VISIT_DATE" => sprintf($lang['You_last_visit'], $s_last_visit),
"CURRENT_TIME" => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
"PRIVMSG_IMG" => $icon_pm, "PRIVMSG_IMG" => $icon_pm,
"FORUM_IMG" => $images['forum'], "FORUM_IMG" => $images['forum'],
@ -293,8 +294,6 @@ $template->assign_vars(array(
"L_MESSAGE" => $lang['Message'], "L_MESSAGE" => $lang['Message'],
"L_BY" => $lang['by'], "L_BY" => $lang['by'],
"L_LOGIN_LOGOUT" => $l_login_logout, "L_LOGIN_LOGOUT" => $l_login_logout,
"L_SEARCH_UNANSWERED" => $lang['Search_unanswered'],
"L_SEARCH_SELF" => $lang['Search_your_posts'],
"U_INDEX" => append_sid("index.".$phpEx), "U_INDEX" => append_sid("index.".$phpEx),
"U_REGISTER" => append_sid("profile.".$phpEx."?mode=register"), "U_REGISTER" => append_sid("profile.".$phpEx."?mode=register"),
@ -309,8 +308,6 @@ $template->assign_vars(array(
"U_LOGIN_LOGOUT" => append_sid($u_login_logout), "U_LOGIN_LOGOUT" => append_sid($u_login_logout),
"U_MEMBERSLIST" => append_sid("memberlist.".$phpEx), "U_MEMBERSLIST" => append_sid("memberlist.".$phpEx),
"U_GROUP_CP" => append_sid("groupcp.".$phpEx), "U_GROUP_CP" => append_sid("groupcp.".$phpEx),
"U_SEARCH_UNANSWERED" => append_sid("search.".$phpEx."?search_id=unanswered"),
"U_SEARCH_SELF" => append_sid("search.".$phpEx."?search_id=egosearch"),
"S_CONTENT_DIRECTION" => $lang['DIRECTION'], "S_CONTENT_DIRECTION" => $lang['DIRECTION'],
"S_CONTENT_ENCODING" => $lang['ENCODING'], "S_CONTENT_ENCODING" => $lang['ENCODING'],
@ -318,7 +315,6 @@ $template->assign_vars(array(
"S_CONTENT_DIR_RIGHT" => $lang['RIGHT'], "S_CONTENT_DIR_RIGHT" => $lang['RIGHT'],
"S_TIMEZONE" => sprintf($lang['All_times'], $lang[$board_config['board_timezone']]), "S_TIMEZONE" => sprintf($lang['All_times'], $lang[$board_config['board_timezone']]),
"S_LOGIN_ACTION" => append_sid("login.$phpEx"), "S_LOGIN_ACTION" => append_sid("login.$phpEx"),
"S_CURRENT_TIME" => create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']),
"T_HEAD_STYLESHEET" => $theme['head_stylesheet'], "T_HEAD_STYLESHEET" => $theme['head_stylesheet'],
"T_BODY_BACKGROUND" => $theme['body_background'], "T_BODY_BACKGROUND" => $theme['body_background'],

View file

@ -26,10 +26,10 @@
// Adds/updates a new session to the database for the given userid. // Adds/updates a new session to the database for the given userid.
// Returns the new session ID on success. // Returns the new session ID on success.
// //
function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0, $autologin = 0) function session_begin($user_id, $user_ip, $page_id, $session_length, $auto_create = 0, $enable_autologin = 0)
{ {
global $db, $lang, $board_config, $phpEx; global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID; global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
$cookiename = $board_config['cookie_name']; $cookiename = $board_config['cookie_name'];
@ -37,9 +37,9 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0
$cookiedomain = $board_config['cookie_domain']; $cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure']; $cookiesecure = $board_config['cookie_secure'];
if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename]) ) if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{ {
$sessiondata = isset($HTTP_COOKIE_VARS[$cookiename]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename])) : ""; $sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : "";
$session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? stripslashes($HTTP_COOKIE_VARS[$cookiename . '_sid']) : ""; $session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? stripslashes($HTTP_COOKIE_VARS[$cookiename . '_sid']) : "";
$sessionmethod = SESSION_METHOD_COOKIE; $sessionmethod = SESSION_METHOD_COOKIE;
@ -68,7 +68,7 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if (!$result) if (!$result)
{ {
message_die(CRITICAL_ERROR, "Couldn't obtain ban information.", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Couldn't obtain ban information.", "", __LINE__, __FILE__, $sql);
} }
$ban_info = $db->sql_fetchrow($result); $ban_info = $db->sql_fetchrow($result);
@ -82,19 +82,19 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0
} }
else else
{ {
if( $user_id == ANONYMOUS )
{
$login = 0;
$autologin = 0;
}
// //
// Try and pull the last time stored // Try and pull the last time stored
// in a cookie, if it exists // in a cookie, if it exists
// //
if( $sessionmethod == SESSION_METHOD_GET && $user_id != ANONYMOUS ) if( $user_id != ANONYMOUS )
{ {
$sql = "SELECT user_lastvisit //
// This is a 'work-around' since I managed to
// freeze the schema without re-visiting sessions,
// what's needed is a session timer in the user table
// + the user_lastvisit ... damn damn damn damn and blast
//
$sql = "SELECT user_autologin_key, user_lastvisit
FROM " . USERS_TABLE . " FROM " . USERS_TABLE . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -107,16 +107,50 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0
$sessiondata['lastvisit'] = $row['user_lastvisit']; $sessiondata['lastvisit'] = $row['user_lastvisit'];
if( $auto_create )
{
if( isset($sessiondata['autologinid']) )
{
if( $sessiondata['autologinid'] == $row['user_autologin_key'] )
{
$login = 1;
$enable_autologin = 1;
}
else
{
$login = 0;
$enable_autologin = 0;
$user_id = ANONYMOUS;
$sessiondata['lastvisit'] = ( !empty($sessiondata['lastvisit']) ) ? $sessiondata['lastvisit'] : $current_time;
}
}
else
{
$login = 0;
$enable_autologin = 0;
$user_id = ANONYMOUS;
$sessiondata['lastvisit'] = ( !empty($sessiondata['lastvisit']) ) ? $sessiondata['lastvisit'] : $current_time;
}
}
else
{
$login = 1;
}
} }
else else
{ {
$sessiondata['lastvisit'] = (!empty($sessiondata['sessiontime'])) ? $sessiondata['sessiontime'] : $current_time; $login = 0;
$enable_autologin = 0;
$sessiondata['lastvisit'] = ( !empty($sessiondata['lastvisit']) ) ? $sessiondata['lastvisit'] : $current_time;
} }
$sql = "UPDATE " . SESSIONS_TABLE . " $sql = "UPDATE " . SESSIONS_TABLE . "
SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login SET session_user_id = $user_id, session_start = $current_time, session_last_visit = " . $sessiondata['lastvisit'] . ", session_time = $current_time, session_page = $page_id, session_logged_in = $login
WHERE (session_id = '" . $session_id . "') WHERE session_id = '" . $session_id . "'
AND (session_ip = '$user_ip')"; AND session_ip = '$user_ip'";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if( !$result || !$db->sql_affectedrows() ) if( !$result || !$db->sql_affectedrows() )
@ -129,33 +163,36 @@ function session_begin($user_id, $user_ip, $page_id, $session_length, $login = 0
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if(!$result) if(!$result)
{ {
message_die(CRITICAL_ERROR, "Error creating new session : session_begin", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error creating new session : session_begin", "", __LINE__, __FILE__, $sql);
} }
} }
if( $autologin && $sessionmethod = SESSION_METHOD_COOKIE ) if( $user_id != ANONYMOUS )
{ {
mt_srand( (double) microtime() * 1000000); $autologin_sql = "";
$autologin_key = md5(uniqid(mt_rand())); if( $enable_autologin && $sessionmethod = SESSION_METHOD_COOKIE )
{
mt_srand( (double) microtime() * 1000000);
$autologin_key = md5(uniqid(mt_rand()));
$sessiondata['autologinid'] = $autologin_key;
$autologin_sql = ", user_autologin_key = '$autologin_key'";
}
$sql_auto = "UPDATE " . USERS_TABLE . " $sql_auto = "UPDATE " . USERS_TABLE . "
SET user_autologin_key = '$autologin_key' SET user_lastvisit = " . time() . $autologin_sql . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql_auto); $result = $db->sql_query($sql_auto);
if(!$result) if(!$result)
{ {
message_die(CRITICAL_ERROR, "Couldn't update users autologin key : session_begin", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Couldn't update users autologin key : session_begin", "", __LINE__, __FILE__, $sql);
} }
$sessiondata['autologinid'] = $autologin_key;
} }
$sessiondata['userid'] = $user_id; $sessiondata['userid'] = $user_id;
$sessiondata['sessionstart'] = $current_time;
$sessiondata['sessiontime'] = $current_time;
$serialised_cookiedata = serialize($sessiondata); $serialised_cookiedata = serialize($sessiondata);
setcookie($cookiename, $serialised_cookiedata, ($current_time + 31536000), $cookiepath, $cookiedomain, $cookiesecure); setcookie($cookiename . '_data', $serialised_cookiedata, ($current_time + 31536000), $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure); setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
$SID = ($sessionmethod == SESSION_METHOD_GET) ? "sid=" . $session_id : ""; $SID = ($sessionmethod == SESSION_METHOD_GET) ? "sid=" . $session_id : "";
@ -180,21 +217,22 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
$cookiedomain = $board_config['cookie_domain']; $cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure']; $cookiesecure = $board_config['cookie_secure'];
if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename]) ) $current_time = time();
unset($userdata);
if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{ {
$sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename])) : ""; $sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : "";
$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? stripslashes($HTTP_COOKIE_VARS[$cookiename . '_sid']) : ""; $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? stripslashes($HTTP_COOKIE_VARS[$cookiename . '_sid']) : "";
$sessionmethod = SESSION_METHOD_COOKIE; $sessionmethod = SESSION_METHOD_COOKIE;
} }
else else
{ {
$session_id = (isset($HTTP_GET_VARS['sid'])) ? $HTTP_GET_VARS['sid'] : ""; $session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : "";
$sessionmethod = SESSION_METHOD_GET; $sessionmethod = SESSION_METHOD_GET;
} }
$current_time = time();
unset($userdata);
// //
// Does a session exist? // Does a session exist?
@ -211,9 +249,9 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
AND s.session_ip = '$user_ip' AND s.session_ip = '$user_ip'
AND u.user_id = s.session_user_id"; AND u.user_id = s.session_user_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if (!$result) if( !$result )
{ {
message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart", "", __LINE__, __FILE__, $sql);
} }
$userdata = $db->sql_fetchrow($result); $userdata = $db->sql_fetchrow($result);
@ -223,11 +261,22 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
// //
if( isset($userdata['user_id']) ) if( isset($userdata['user_id']) )
{ {
$SID = ($sessionmethod == SESSION_METHOD_GET) ? "sid=" . $session_id : ""; $SID = ( $sessionmethod == SESSION_METHOD_GET ) ? "sid=" . $session_id : "";
$sessiondata['sessiontime'] = $current_time; if( empty($HTTP_COOKIE_VARS[$cookiename . '_data']) )
$serialised_cookiedata = serialize($sessiondata); {
setcookie($cookiename, $serialised_cookiedata, ($current_time + 31536000), $cookiepath, $cookiedomain, $cookiesecure); if( !empty($userdata['user_autologin']) && $sessionmethod = SESSION_METHOD_COOKIE )
{
$sessiondata['autologinid'] = $autologin_key;
}
$sessiondata['userid'] = $user_id;
$sessiondata['lastvisit'] = $userdata['session_last_visit'];
$serialised_cookiedata = serialize($sessiondata);
// session_send_cookie("_data", $serialised_cookiedata, ($current_time + 31536000));
setcookie($board_config['cookie_name'] . "_data", $serialised_cookiedata, ($current_time + 31536000), $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
setcookie($board_config['cookie_name'] . "_sid", $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"], 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
// //
// Only update session DB a minute or so after last update // Only update session DB a minute or so after last update
@ -240,25 +289,23 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
AND session_ip = '$user_ip' AND session_ip = '$user_ip'
AND session_user_id = " . $userdata['user_id']; AND session_user_id = " . $userdata['user_id'];
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if(!$result) if( !$result )
{ {
message_die(CRITICAL_ERROR, "Error updating sessions table : session_pagestart", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error updating sessions table : session_pagestart", "", __LINE__, __FILE__, $sql);
} }
if( $sessionmethod == SESSION_METHOD_GET ) if( $user_id != ANONYMOUS )
{ {
$sql = "UPDATE " . USERS_TABLE . " $sql = "UPDATE " . USERS_TABLE . "
SET user_lastvisit = $current_time SET user_lastvisit = $current_time
WHERE user_id = " . $userdata['user_id']; WHERE user_id = " . $userdata['user_id'];
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if(!$result) if( !$result )
{ {
message_die(CRITICAL_ERROR, "Error updating users table : session_pagestart (GET)", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error updating users table : session_pagestart (GET)", "", __LINE__, __FILE__, $sql);
} }
} }
$userdata['session_time'] = $current_time;
// //
// Delete expired sessions // Delete expired sessions
// //
@ -266,9 +313,9 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
$sql = "DELETE FROM " . SESSIONS_TABLE . " $sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_time < $expiry_time"; WHERE session_time < $expiry_time";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if(!$result) if( !$result )
{ {
message_die(CRITICAL_ERROR, "Error clearing sessions table : session_pagestart", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error clearing sessions table : session_pagestart", "", __LINE__, __FILE__, $sql);
} }
return $userdata; return $userdata;
@ -281,60 +328,20 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
return $userdata; return $userdata;
} }
} }
else
{
}
// //
// If we reach here then no (valid) session exists. So we'll create a new one, // If we reach here then no (valid) session exists. So we'll create a new one,
// using the cookie user_id if available to pull basic user prefs. // using the cookie user_id if available to pull basic user prefs.
// //
$login = 0; $user_id = ( isset($sessiondata['userid']) ) ? $sessiondata['userid'] : ANONYMOUS;
$autologin = 0;
if( isset($sessiondata['userid']) && isset($sessiondata['autologinid']) ) $result_id = session_begin($user_id, $user_ip, $thispage_id, $board_config['session_length'], TRUE);
if( !$result_id )
{ {
$sql = "SELECT user_id, user_autologin_key message_die(CRITICAL_ERROR, "Error creating user session : session_pagestart", "", __LINE__, __FILE__, $sql);
FROM " . USERS_TABLE . "
WHERE user_id = " . $sessiondata['userid'];
$result = $db->sql_query($sql);
if (!$result)
{
message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch (non-session) : session_pagestart", __LINE__, __FILE__, $sql);
}
$userdata = $db->sql_fetchrow($result);
if($userdata['user_autologin_key'])
{
if($userdata['user_autologin_key'] == $sessiondata['autologinid'])
{
//
// We have a match, and not the kind you light ...
//
$login = 1;
$autologin = 1;
$user_id = $sessiondata['userid'];
}
else
{
unset($userdata);
$user_id = ANONYMOUS;
}
}
else
{
unset($userdata);
$user_id = ANONYMOUS;
}
}
else
{
unset($userdata);
$user_id = ANONYMOUS;
}
$result_id = session_begin($user_id, $user_ip, $thispage_id, $session_length, $login, $autologin);
if(!$result_id)
{
message_die(CRITICAL_ERROR, "Error creating user session : session_pagestart", __LINE__, __FILE__, $sql);
} }
else else
{ {
@ -344,9 +351,9 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
AND s.session_ip = '$user_ip' AND s.session_ip = '$user_ip'
AND u.user_id = s.session_user_id"; AND u.user_id = s.session_user_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if (!$result) if ( !$result )
{ {
message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart new user", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error doing DB query userdata row fetch : session_pagestart new user", "", __LINE__, __FILE__, $sql);
} }
$userdata = $db->sql_fetchrow($result); $userdata = $db->sql_fetchrow($result);
@ -354,7 +361,7 @@ function session_pagestart($user_ip, $thispage_id, $session_length)
return $userdata; return $userdata;
} // session_check() } // session_pagestart()
// //
// session_end closes out a session // session_end closes out a session
@ -371,10 +378,15 @@ function session_end($session_id, $user_id)
$cookiedomain = $board_config['cookie_domain']; $cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure']; $cookiesecure = $board_config['cookie_secure'];
if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename]) ) $current_time = time();
//
// Pull cookiedata or grab the URI propagated sid
//
if( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{ {
$sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename])) : ""; $sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : "";
$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? stripslashes($HTTP_COOKIE_VARS[$cookiename . '_sid']) : ""; $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : "";
$sessionmethod = SESSION_METHOD_COOKIE; $sessionmethod = SESSION_METHOD_COOKIE;
} }
@ -384,36 +396,49 @@ function session_end($session_id, $user_id)
$sessionmethod = SESSION_METHOD_GET; $sessionmethod = SESSION_METHOD_GET;
} }
$current_time = time();
$sql = "UPDATE " . SESSIONS_TABLE . " //
SET session_logged_in = 0, session_user_id = -1, session_time = $current_time // Delete existing session
WHERE (session_id = '" . $session_id . "') //
AND (session_user_id = $user_id)"; $sql = "DELETE FROM " . SESSIONS_TABLE . "
$result = $db->sql_query($sql, BEGIN_TRANSACTION); WHERE session_id = '$session_id'
if (!$result) AND session_user_id = $user_id";
$result = $db->sql_query($sql);
if(!$result)
{ {
message_die(CRITICAL_ERROR, "Couldn't delete user session : session_end", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Error removing user session : session_end", "", __LINE__, __FILE__, $sql);
} }
if( isset($sessiondata['autologinid']) ) //
// If a registered user then update their last visit
// and autologin (if necessary) details
//
if( $user_id != ANONYMOUS )
{ {
$autologin_sql = "";
if( isset($sessiondata['autologinid']) && $sessionmethod = SESSION_METHOD_COOKIE )
{
unset($sessiondata['autologinid']);
$autologin_sql = ", user_autologin_key = ''";
}
$sql = "UPDATE " . USERS_TABLE . " $sql = "UPDATE " . USERS_TABLE . "
SET user_autologin_key = '' SET user_lastvisit = " . time() . $autologin_sql . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$result = $db->sql_query($sql, END_TRANSACTION); $result = $db->sql_query($sql, END_TRANSACTION);
if (!$result) if (!$result)
{ {
message_die(CRITICAL_ERROR, "Couldn't reset user autologin key : session_end", __LINE__, __FILE__, $sql); message_die(CRITICAL_ERROR, "Couldn't reset user autologin key : session_end", "", __LINE__, __FILE__, $sql);
} }
$sessiondata['autologinid'] = "";
} }
$sessiondata['sessionend'] = $current_time; $sessiondata['userid'] = ANONYMOUS;
$sessiondata['lastvisit'] = $current_time;
$serialised_cookiedata = serialize($sessiondata); $serialised_cookiedata = serialize($sessiondata);
setcookie($cookiename, $serialised_cookiedata, ($current_time + 31536000), $cookiepath, $cookiedomain, $cookiesecure); setcookie($cookiename . '_data', $serialised_cookiedata, ($current_time + 31536000), $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure); setcookie($cookiename . '_sid', '', 0, $cookiepath, $cookiedomain, $cookiesecure);
$SID = ($sessionmethod == SESSION_METHOD_GET) ? "sid=" . $session_id : ""; $SID = ($sessionmethod == SESSION_METHOD_GET) ? "sid=" . $session_id : "";
@ -421,6 +446,35 @@ function session_end($session_id, $user_id)
} // session_end() } // session_end()
//
// This checks to see if we're @ the 20 cookie limit
// if we are it re-sends the session id. This isn't a great
// solution but it does work, although resulting in
// more cookies being sent than necessary. Will re-evaluate
// this in 2.2
//
function session_send_cookie($append_name, $set_value, $last_time)
{
global $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
setcookie($board_config['cookie_name'] . $append_name, $set_value, $last_time, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
$cookie_count = 0;
while( list(, $value) = each($HTTP_COOKIE_VARS) )
{
$cookie_count += count($value);
}
if( $cookie_count == 20 )
{
setcookie($board_config['cookie_name'] . "_sid", stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"]), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
return;
}
//
// //
// Append $SID to a url. Borrowed from phplib and modified. This is an // Append $SID to a url. Borrowed from phplib and modified. This is an
// extra routine utilised by the session code above and acts as a wrapper // extra routine utilised by the session code above and acts as a wrapper
@ -431,9 +485,9 @@ function append_sid($url, $non_html_amp = false)
{ {
global $SID; global $SID;
if(!empty($SID) && !eregi("sid=", $url)) if( !empty($SID) && !eregi("sid=", $url) )
{ {
$url .= ( (strpos($url, "?") != false) ? ( ( $non_html_amp ) ? "&" : "&amp;" ) : "?" ) . $SID; $url .= ( ( strpos($url, "?") != false ) ? ( ( $non_html_amp ) ? "&" : "&amp;" ) : "?" ) . $SID;
} }
return($url); return($url);

View file

@ -49,50 +49,34 @@ else
// //
if( $mark_read == "forums" ) if( $mark_read == "forums" )
{ {
if( $userdata['session_last_visit'] ) $sql = "SELECT MAX(post_time) AS last_post
FROM " . POSTS_TABLE;
if(!$result = $db->sql_query($sql))
{ {
$sql = "SELECT f.forum_id, t.topic_id message_die(GENERAL_ERROR, "Could not query new topic information", "", __LINE__, __FILE__, $sql);
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.forum_id = f.forum_id
AND p.post_id = t.topic_last_post_id
AND p.post_time > " . $userdata['session_last_visit'] . "
AND t.topic_moved_id IS NULL";
if(!$t_result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not query new topic information", "", __LINE__, __FILE__, $sql);
}
if( $mark_read_rows = $db->sql_numrows($t_result) )
{
$mark_read_list = $db->sql_fetchrowset($t_result);
for($i = 0; $i < $mark_read_rows; $i++ )
{
$forum_id = $mark_read_list[$i]['forum_id'];
$topic_id = $mark_read_list[$i]['topic_id'];
if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
else
{
if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
}
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' .append_sid("index.$phpEx") . '">')
);
$message = $lang['Forums_marked_read'] . "<br /><br />" . sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a> ");
message_die(GENERAL_MESSAGE, $message);
} }
if( $forum_count = $db->sql_numrows($result) )
{
$mark_read_list = $db->sql_fetchrow($result);
$last_post_time = $mark_read_list['last_post'];
if( $last_post_time > $userdata['session_last_visit'] )
{
setcookie($board_config['cookie_name'] . "_f_all", time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
// session_send_cookie("_f_all", time(), 0);
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' .append_sid("index.$phpEx") . '">')
);
$message = $lang['Forums_marked_read'] . "<br /><br />" . sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a> ");
message_die(GENERAL_MESSAGE, $message);
} }
// //
// End handle marking posts // End handle marking posts
@ -150,7 +134,7 @@ if($total_categories = $db->sql_numrows($q_categories))
FROM " . POSTS_TABLE . " p FROM " . POSTS_TABLE . " p
WHERE p.post_id = f.forum_last_post_id WHERE p.post_id = f.forum_last_post_id
) )
$limit_forums $limit_forums
)"; )";
break; break;
@ -192,8 +176,7 @@ if($total_categories = $db->sql_numrows($q_categories))
WHERE t.forum_id = f.forum_id WHERE t.forum_id = f.forum_id
AND p.post_id = t.topic_last_post_id AND p.post_id = t.topic_last_post_id
AND p.post_time > " . $userdata['session_last_visit'] . " AND p.post_time > " . $userdata['session_last_visit'] . "
AND t.topic_moved_id IS NULL AND t.topic_moved_id IS NULL";
AND t.topic_status <> " . TOPIC_LOCKED;
if(!$new_topic_ids = $db->sql_query($sql)) if(!$new_topic_ids = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Could not query new topic information", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not query new topic information", "", __LINE__, __FILE__, $sql);
@ -256,7 +239,11 @@ if($total_categories = $db->sql_numrows($q_categories))
"L_FORUM_LOCKED" => $lang['Forum_is_locked'], "L_FORUM_LOCKED" => $lang['Forum_is_locked'],
"L_MARK_FORUMS_READ" => $lang['Mark_all_forums'], "L_MARK_FORUMS_READ" => $lang['Mark_all_forums'],
"L_SEARCH_NEW" => $lang['Search_new'], "L_SEARCH_NEW" => $lang['Search_new'],
"L_SEARCH_UNANSWERED" => $lang['Search_unanswered'],
"L_SEARCH_SELF" => $lang['Search_your_posts'],
"U_SEARCH_UNANSWERED" => append_sid("search.".$phpEx."?search_id=unanswered"),
"U_SEARCH_SELF" => append_sid("search.".$phpEx."?search_id=egosearch"),
"U_SEARCH_NEW" => append_sid("search.$phpEx?search_id=newposts"), "U_SEARCH_NEW" => append_sid("search.$phpEx?search_id=newposts"),
"U_MARK_READ" => append_sid("index.$phpEx?mark=forums")) "U_MARK_READ" => append_sid("index.$phpEx?mark=forums"))
); );
@ -276,7 +263,7 @@ if($total_categories = $db->sql_numrows($q_categories))
{ {
$forum_id = $forum_rows[$j]['forum_id']; $forum_id = $forum_rows[$j]['forum_id'];
if( $is_auth_ary[$forum_id]['auth_view'] && ( ($forum_rows[$j]['cat_id'] == $cat_id && $viewcat == -1) || $cat_id == $viewcat) ) if( $is_auth_ary[$forum_id]['auth_view'] && ( ( $forum_rows[$j]['cat_id'] == $cat_id && $viewcat == -1 ) || $cat_id == $viewcat) )
{ {
if(!$gen_cat[$cat_id]) if(!$gen_cat[$cat_id])
{ {
@ -297,23 +284,47 @@ if($total_categories = $db->sql_numrows($q_categories))
$unread_topics = false; $unread_topics = false;
if( count($new_topic_data[$forum_id]) ) if( count($new_topic_data[$forum_id]) )
{ {
while( list($check_topic_id, $check_post_time) = each($new_topic_data[$forum_id]) ) $forum_last_post_time = 0;
while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
{ {
if( !isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $check_topic_id]) ) if( !isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$check_topic_id"]) )
{ {
// echo "NOT SET :: $forum_id :: $check_topic_id <BR>\n";
$unread_topics = true; $unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
} }
else else
{ {
if($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $check_topic_id] < $check_post_time ) if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$check_topic_id"] < $check_post_time )
{ {
// echo "SET :: $forum_id :: $check_topic_id <BR>\n";
$unread_topics = true; $unread_topics = true;
$forum_last_post_time = max($check_post_time, $forum_last_post_time);
} }
} }
} }
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) )
{
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $forum_last_post_time )
{
$unread_topics = false;
}
}
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
{
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $forum_last_post_time )
{
$unread_topics = false;
}
}
} }
$folder_image = ( $unread_topics ) ? "<img src=\"" . $images['forum_new'] . "\" alt=\"" . $lang['New_posts'] . "\" />" : "<img src=\"" . $images['forum'] . "\" alt=\"" . $lang['No_new_posts'] . "\" />"; $folder_image = ( $unread_topics ) ? "<img src=\"" . $images['forum_new'] . "\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />" : "<img src=\"" . $images['forum'] . "\" alt=\"" . $lang['No_new_posts'] . "\" title=\"" . $lang['No_new_posts'] . "\" />";
} }
$posts = $forum_rows[$j]['forum_posts']; $posts = $forum_rows[$j]['forum_posts'];
@ -323,11 +334,11 @@ if($total_categories = $db->sql_numrows($q_categories))
{ {
$last_post_time = create_date($board_config['default_dateformat'], $forum_rows[$j]['post_time'], $board_config['board_timezone']); $last_post_time = create_date($board_config['default_dateformat'], $forum_rows[$j]['post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . "<br />" . $lang['by'] . " "; $last_post = $last_post_time . "<br />";
$last_post .= ( $forum_rows[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_rows[$j]['post_username'] != "" ) ? $forum_rows[$j]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $forum_rows[$j]['user_id']) . "\">" . $forum_rows[$j]['username'] . "</a> "; $last_post .= ( $forum_rows[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_rows[$j]['post_username'] != "" ) ? $forum_rows[$j]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $forum_rows[$j]['user_id']) . "\">" . $forum_rows[$j]['username'] . "</a> ";
$last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $forum_rows[$j]['forum_last_post_id']) . "#" . $forum_rows[$j]['forum_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" border=\"0\" alt=\"" . $lang['View_latest_post'] . "\" /></a>"; $last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $forum_rows[$j]['forum_last_post_id']) . "#" . $forum_rows[$j]['forum_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" border=\"0\" alt=\"" . $lang['View_latest_post'] . "\" title=\"" . $lang['View_latest_post'] . "\" /></a>";
} }
else else
{ {
@ -363,8 +374,8 @@ if($total_categories = $db->sql_numrows($q_categories))
$moderators_links = "&nbsp;"; $moderators_links = "&nbsp;";
} }
$row_color = ( !($count%2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_color = ( !($count % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($count%2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_class = ( !($count % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("catrow.forumrow", array( $template->assign_block_vars("catrow.forumrow", array(
"ROW_COLOR" => "#" . $row_color, "ROW_COLOR" => "#" . $row_color,

View file

@ -92,6 +92,7 @@ $lang['IP_Address'] = "IP Address";
$lang['Select_forum'] = "Select a forum"; $lang['Select_forum'] = "Select a forum";
$lang['View_latest_post'] = "View latest post"; $lang['View_latest_post'] = "View latest post";
$lang['View_newest_post'] = "View newest post";
$lang['Page_of'] = "Page <b>%d</b> of <b>%d</b>"; // Replaces with: Page 1 of 2 for example $lang['Page_of'] = "Page <b>%d</b> of <b>%d</b>"; // Replaces with: Page 1 of 2 for example
$lang['ICQ'] = "ICQ Number"; $lang['ICQ'] = "ICQ Number";
@ -131,9 +132,12 @@ $lang['Guest_users_total'] = "%d Guests";
$lang['Guest_user_total'] = "%d Guest"; $lang['Guest_user_total'] = "%d Guest";
$lang['You_last_visit'] = "You last visited on %s"; // %s replaced by date/time $lang['You_last_visit'] = "You last visited on %s"; // %s replaced by date/time
$lang['Current_time'] = "The time now is %s"; // %s replaced by time
$lang['Search_new'] = "View posts since last visit"; $lang['Search_new'] = "View posts since last visit";
$lang['Search_your_posts'] = "View your posts"; $lang['Search_your_posts'] = "View your posts";
$lang['Search_unanswered'] = "View unanswered posts"; $lang['Search_unanswered'] = "View unanswered posts";
$lang['Register'] = "Register"; $lang['Register'] = "Register";
$lang['Profile'] = "Profile"; $lang['Profile'] = "Profile";
$lang['Edit_profile'] = "Edit your profile"; $lang['Edit_profile'] = "Edit your profile";

View file

@ -24,12 +24,13 @@
// Allow people to reach login page if // Allow people to reach login page if
// board is shut down // board is shut down
// //
define("IN_ADMIN", true); define("IN_LOGIN", true);
$phpbb_root_path = "./"; $phpbb_root_path = "./";
include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . 'common.'.$phpEx);
// //
// Set page ID for session management // Set page ID for session management
// //
@ -69,7 +70,7 @@ if( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($
{ {
$autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0; $autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0;
$session_id = session_begin($rowresult['user_id'], $user_ip, PAGE_INDEX, $session_length, TRUE, $autologin); $session_id = session_begin($rowresult['user_id'], $user_ip, PAGE_INDEX, $session_length, FALSE, $autologin);
if( $session_id ) if( $session_id )
{ {

View file

@ -256,35 +256,106 @@ if( $mode == "searchuser" )
else if( $query_keywords != "" || $query_author != "" || $search_id ) else if( $query_keywords != "" || $query_author != "" || $search_id )
{ {
if( $query_keywords != "" || $query_author != "" || $search_id == "newposts" || $search_id == "egosearch" || $search_id == "unanswered") $search_sql = "";
{
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
$stopword_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_stopwords.txt");
//
// Cycle through options ...
//
if( $search_id == "newposts" || $search_id == "egosearch" || ( $query_author != "" && $query_keywords == "" ) )
{
if( $search_id == "newposts" ) if( $search_id == "newposts" )
{ {
$show_results = "topics"; $sql = "SELECT post_id
$search_time = $userdata['session_last_visit']; FROM " . POSTS_TABLE . "
$sortby = 0; WHERE post_time >= " . $userdata['session_last_visit'] . "
$sortby_dir = "DESC"; ORDER BY post_time DESC";
}
else if( $search_id == "egosearch" )
{
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE poster_id = " . $userdata['user_id'] . "
ORDER BY post_time DESC";
}
else
{
$query_author = str_replace("*", "%", trim($query_author));
$sql = "SELECT p.post_id
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE u.username LIKE '$query_author'
AND p.poster_id = u.user_id
ORDER BY p.post_time DESC";
}
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't obtain matched posts list", "", __LINE__, __FILE__, $sql);
} }
if( $search_id == "egosearch" ) $sql_post_id_in = "";
while( $row = $db->sql_fetchrow($result) )
{ {
$query_author = $userdata['username']; if( $sql_post_id_in != "" )
$show_results = "topics"; {
$search_time = 0; $sql_post_id_in .= ", ";
$sortby = 0; }
$sortby_dir = "DESC"; $sql_post_id_in .= $row['post_id'];
$total_posts++;
} }
if( $search_id == "unanswered" ) if( $sql_post_id_in != "" )
{ {
$show_results = "topics"; $sql = "SELECT topic_id
$search_time = 0; FROM " . POSTS_TABLE . "
$sortby = 0; WHERE post_id IN ($sql_post_id_in)
$sortby_dir = "DESC"; GROUP BY topic_id";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't matched posts", "", __LINE__, __FILE__, $sql);
}
$sql_post_id_in = "";
while( $row = $db->sql_fetchrow($result) )
{
if( $sql_post_id_in != "" )
{
$sql_post_id_in .= ", ";
}
$sql_post_id_in .= $row['topic_id'];
}
$search_sql .= "t.topic_id IN ($sql_post_id_in) ";
} }
else
{
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
}
$show_results = "topics";
$sortby = 0;
$sortby_dir = "DESC";
}
else if( $search_id == "unanswered" )
{
$search_sql = "t.topic_replies = 0 ";
//
// Basic requirements
//
$show_results = "topics";
$sortby = 0;
$sortby_dir = "DESC";
}
else if( $query_keywords != "" || $query_author != "" )
{
$synonym_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_synonyms.txt");
$stopword_array = @file($phpbb_root_path . "language/lang_" . $board_config['default_lang'] . "/search_stopwords.txt");
$cleaned_search = clean_words_search($query_keywords); $cleaned_search = clean_words_search($query_keywords);
$cleaned_search = remove_stop_words($cleaned_search, $stopword_array); $cleaned_search = remove_stop_words($cleaned_search, $stopword_array);
@ -384,14 +455,13 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
} }
} }
//
$sql_fields = ( $show_results == "posts") ? "pt.post_text, pt.post_subject, p.post_id, p.post_time, p.post_username, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_time, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid" : "f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_views, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username" ; // Author name search
//
$sql_from = ( $show_results == "posts") ? FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt" : FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2"; if( $query_author != "" )
{
$sql_where = ( $show_results == "posts") ? "pt.post_id = p.post_id AND f.forum_id = p.forum_id AND p.topic_id = t.topic_id AND p.poster_id = u.user_id" : "f.forum_id = t.forum_id AND u.user_id = t.topic_poster AND p.post_id = t.topic_last_post_id AND u2.user_id = p.poster_id"; $query_author = str_replace("*", "%", trim($query_author));
}
$search_sql = "";
// //
// Keyword search // Keyword search
@ -400,229 +470,255 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
{ {
if( $show_results == "posts" ) if( $show_results == "posts" )
{ {
$search_sql .= "p.post_id IN ($sql_post_id_in) "; $search_sql .= ( $query_author == "" ) ? "p.post_id IN ($sql_post_id_in)" : "p.post_id IN ($sql_post_id_in) AND u.username LIKE '$query_author' ";
}
else if( $search_time )
{
switch(SQL_LAYER)
{ {
case 'mysql': $search_sql .= " AND p.post_time >= $search_time ";
case 'mysql4':
$sql = "SELECT topic_id
FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post_id_in)
GROUP BY topic_id";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't matched posts", "", __LINE__, __FILE__, $sql);
}
$sql_post_id_in = "";
while( $row = $db->sql_fetchrow($result) )
{
if( $sql_post_id_in != "" )
{
$sql_post_id_in .= ", ";
}
$sql_post_id_in .= $row['topic_id'];
}
$search_sql .= "t.topic_id IN ($sql_post_id_in) ";
break;
default:
$search_sql .= "t.topic_id IN (
SELECT topic_id
FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post_id_in)
GROUP BY topic_id )";
break;
} }
} }
}
//
// Author name search
//
if( $query_author != "" )
{
$query_author = str_replace("*", "%", trim($query_author));
if( $show_results == "posts" )
{
$search_sql .= ( $search_sql == "" ) ? "u.username LIKE '$query_author' " : " AND u.username LIKE '$query_author' ";
}
else else
{ {
$search_sql .= ( $search_sql == "" ) ? "us.username LIKE '$query_author' AND us.user_id = p.poster_id " : " AND us.username LIKE '$query_author' AND us.user_id = p.poster_id ";
$sql_from .= ", " . USERS_TABLE . " us ";
}
}
// $search_time_sql = "";
// Unanswered Posts if( $search_time )
//
if( $search_id == "unanswered" )
{
$search_sql .= ( $search_sql == "" ) ? "t.topic_replies = 0 " : "AND t.topic_replies = 0 ";
}
//
// If user is logged in then we'll check to see which (if any) private
// forums they are allowed to view and include them in the search.
//
// If not logged in we explicitly prevent searching of private forums
//
if( $search_sql != "" || $search_id == "newposts" || $search_id == "egosearch" || $search_id == "unanswered" )
{
$sql = "SELECT $sql_fields
FROM $sql_from ";
$sql .= ( $search_id == "newposts" ) ? "WHERE $sql_where" : "WHERE $search_sql AND $sql_where";
if( $search_forum != "all" )
{
$is_auth = auth(AUTH_READ, $search_forum, $userdata);
if( !$is_auth['auth_read'] )
{ {
message_die(GENERAL_MESSAGE, $lang['No_search_match']); $search_time_sql = ( $query_author == "" ) ? "AND post_time >= $search_time " : "AND p.post_time >= $search_time ";
}
if( $query_author == "" )
{
$sql = "SELECT topic_id
FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post_id_in)
$search_time_sql
GROUP BY topic_id";
} }
else else
{ {
$sql .= " AND f.forum_id = $search_forum"; $sql = "SELECT p.topic_id
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id IN ($sql_post_id_in)
AND u.username LIKE '$query_author'
AND p.poster_id = u.user_id
$search_time_sql
GROUP BY p.topic_id";
} }
} $result = $db->sql_query($sql);
else if( !$result )
{
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
if( $search_cat != "all" )
{ {
$sql .= " AND f.cat_id = $search_cat"; message_die(GENERAL_ERROR, "Couldn't matched posts", "", __LINE__, __FILE__, $sql);
} }
$ignore_forum_sql = ""; $sql_post_id_in = "";
while( list($key, $value) = each($is_auth_ary) )
{
if( !$value['auth_read'] )
{
if( $ignore_forum_sql != "" )
{
$ignore_forum_sql .= ", ";
}
$ignore_forum_sql .= $key;
}
}
if( $ignore_forum_sql != "" )
{
$sql .= " AND f.forum_id NOT IN ($ignore_forum_sql) ";
}
}
if( $search_time )
{
$sql .= " AND p.post_time >= $search_time ";
}
$sql .= " ORDER BY " . $sortby_sql[$sortby] . " $sortby_dir";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain search results", "", __LINE__, __FILE__, $sql);
}
$total_match_count = $db->sql_numrows($result);
$searchset = $db->sql_fetchrowset($result);
//
// Clean up search results table
//
$sql = "SELECT session_id
FROM " . SESSIONS_TABLE;
if( $result = $db->sql_query($sql) )
{
$delete_search_id_sql = "";
while( $row = $db->sql_fetchrow($result) ) while( $row = $db->sql_fetchrow($result) )
{ {
if( $delete_search_id_sql != "" ) if( $sql_post_id_in != "" )
{ {
$delete_search_id_sql .= ", "; $sql_post_id_in .= ", ";
} }
$delete_search_id_sql .= "'" . $row['session_id'] . "'"; $sql_post_id_in .= $row['topic_id'];
} }
$search_sql .= "t.topic_id IN ($sql_post_id_in) ";
/*
if( $query_author == "" )
{
$search_sql .= "t.topic_id IN (
SELECT topic_id
FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post_id_in)
$search_time_sql
GROUP BY topic_id )";
}
else
{
$search_sql .= "t.topic_id IN (
SELECT p.topic_id
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id IN ($sql_post_id_in)
AND u.username LIKE '$query_author'
AND p.poster_id = u.user_id
$search_time_sql
GROUP BY p.topic_id )";
}
*/
}
}
else
{
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
}
}
//
// Define common SQL
//
$sql_fields = ( $show_results == "posts") ? "pt.post_text, pt.post_subject, p.post_id, p.post_time, p.post_username, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_views, t.topic_replies, u.username, u.user_id, u.user_sig, u.user_sig_bbcode_uid" : "f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_views, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username" ;
$sql_from = ( $show_results == "posts") ? FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt" : FORUMS_TABLE . " f, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2";
$sql_where = ( $show_results == "posts") ? "pt.post_id = p.post_id AND f.forum_id = p.forum_id AND p.topic_id = t.topic_id AND p.poster_id = u.user_id" : "f.forum_id = t.forum_id AND u.user_id = t.topic_poster AND p.post_id = t.topic_last_post_id AND u2.user_id = p.poster_id";
//
// Build query ...
//
$sql = "SELECT $sql_fields
FROM $sql_from ";
$sql .= "WHERE $search_sql AND $sql_where ";
//
// If user is logged in then we'll check to see which (if any) private
// forums they are allowed to view and include them in the search.
//
// If not logged in we explicitly prevent searching of private forums
//
$auth_sql = "";
if( $search_forum != "all" )
{
$is_auth = auth(AUTH_READ, $search_forum, $userdata);
if( !$is_auth['auth_read'] )
{
message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
}
else
{
$auth_sql = "f.forum_id = $search_forum";
}
}
else
{
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
if( $search_cat != "all" )
{
$auth_sql = "f.cat_id = $search_cat";
}
$ignore_forum_sql = "";
while( list($key, $value) = each($is_auth_ary) )
{
if( !$value['auth_read'] )
{
if( $ignore_forum_sql != "" )
{
$ignore_forum_sql .= ", ";
}
$ignore_forum_sql .= $key;
}
}
if( $ignore_forum_sql != "" )
{
$auth_sql .= ( $auth_sql != "" ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
}
}
//
// Finish building query (for all combinations)
// and run it ...
//
if( $search_sql != "" || $search_id == "newposts" || $search_id == "egosearch" || $search_id == "unanswered" )
{
if( $auth_sql != "" )
{
$sql .= " AND " . $auth_sql;
}
$sql .= " ORDER BY " . $sortby_sql[$sortby] . " $sortby_dir";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain search results", "", __LINE__, __FILE__, $sql);
}
$total_match_count = $db->sql_numrows($result);
$searchset = $db->sql_fetchrowset($result);
//
// Clean up search results table
//
$sql = "SELECT session_id
FROM " . SESSIONS_TABLE;
if( $result = $db->sql_query($sql) )
{
$delete_search_id_sql = "";
while( $row = $db->sql_fetchrow($result) )
{
if( $delete_search_id_sql != "" ) if( $delete_search_id_sql != "" )
{ {
$sql = "DELETE FROM " . SEARCH_TABLE . " $delete_search_id_sql .= ", ";
WHERE session_id NOT IN ($delete_search_id_sql)"; }
if( !$result = $db->sql_query($sql) ) $delete_search_id_sql .= "'" . $row['session_id'] . "'";
{ }
message_die(GENERAL_ERROR, "Couldn't delete old search id sessions", "", __LINE__, __FILE__, $sql);
} if( $delete_search_id_sql != "" )
{
$sql = "DELETE FROM " . SEARCH_TABLE . "
WHERE session_id NOT IN ($delete_search_id_sql)";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete old search id sessions", "", __LINE__, __FILE__, $sql);
} }
} }
}
//
// Store new result data
//
if( $total_match_count )
{
$search_results = "";
for($i = 0; $i < count($searchset); $i++)
{
if( $show_results == "posts")
{
$search_results .= ($search_results != "") ? ", " . $searchset[$i]['post_id'] : $searchset[$i]['post_id'];
}
else
{
$search_results .= ($search_results != "") ? ", " . $searchset[$i]['topic_id'] : $searchset[$i]['topic_id'];
}
}
$per_page = ( $show_results == "posts" ) ? $board_config['posts_per_page'] : $board_config['topics_per_page'];
// //
// Store new result data // Combine both results and search data (apart from original query)
// so we can serialize it and place it in the DB
// //
if( $total_match_count ) $store_search_data = array();
$store_search_data['results'] = $search_results;
$store_search_data['word_array'] = $split_search;
$store_search_data['match_count'] = $total_match_count;
$result_array = serialize($store_search_data);
unset($store_search_data);
unset($search_results);
mt_srand ((double) microtime() * 1000000);
$search_id = mt_rand();
$sql = "UPDATE " . SEARCH_TABLE . "
SET search_id = $search_id, search_array = '$result_array'
WHERE session_id = '" . $userdata['session_id'] . "'";
$result = $db->sql_query($sql);
if( !$result || !$db->sql_affectedrows() )
{ {
$search_results = ""; $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)
for($i = 0; $i < count($searchset); $i++) VALUES($search_id, '" . $userdata['session_id'] . "', '$result_array')";
if( !$result = $db->sql_query($sql) )
{ {
if( $show_results == "posts") message_die(GENERAL_ERROR, "Couldn't insert search results", "", __LINE__, __FILE__, $sql);
{
$search_results .= ($search_results != "") ? ", " . $searchset[$i]['post_id'] : $searchset[$i]['post_id'];
}
else
{
$search_results .= ($search_results != "") ? ", " . $searchset[$i]['topic_id'] : $searchset[$i]['topic_id'];
}
} }
$per_page = ( $show_results == "posts" ) ? $board_config['posts_per_page'] : $board_config['topics_per_page'];
//
// Combine both results and search data (apart from original query)
// so we can serialize it and place it in the DB
//
$store_search_data = array();
$store_search_data['results'] = $search_results;
$store_search_data['word_array'] = $split_search;
$store_search_data['match_count'] = $total_match_count;
$result_array = serialize($store_search_data);
unset($store_search_data);
unset($search_results);
mt_srand ((double) microtime() * 1000000);
$search_id = mt_rand();
$sql = "UPDATE " . SEARCH_TABLE . "
SET search_id = $search_id, search_array = '$result_array'
WHERE session_id = '" . $userdata['session_id'] . "'";
$result = $db->sql_query($sql);
if( !$result || !$db->sql_affectedrows() )
{
$sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)
VALUES($search_id, '" . $userdata['session_id'] . "', '$result_array')";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't insert search results", "", __LINE__, __FILE__, $sql);
}
}
$db->sql_freeresult($result);
}
else
{
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
} }
$db->sql_freeresult($result);
} }
else else
{ {
@ -742,6 +838,8 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
); );
$highlight_active = ""; $highlight_active = "";
$search_string = array();
$replace_string = array();
for($j = 0; $j < count($split_search); $j++ ) for($j = 0; $j < count($split_search); $j++ )
{ {
$split_word = $split_search[$j]; $split_word = $split_search[$j];
@ -750,7 +848,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
{ {
$highlight_active .= " " . $split_word; $highlight_active .= " " . $split_word;
$search_string[] = "#\b(" . preg_quote(str_replace("*", ".*?", $split_word), "#") . ")\b#i"; $search_string[] = "#\b(" . str_replace("\*", ".*?", preg_quote($split_word, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i";
$replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>"; $replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>";
for ($k = 0; $k < count($synonym_array); $k++) for ($k = 0; $k < count($synonym_array); $k++)
@ -759,7 +857,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
if( $replace_synonym == $split_word ) if( $replace_synonym == $split_word )
{ {
$search_string[] = "#\b(" . preg_quote($match_synonym, "#") . ")\b#i"; $search_string[] = "#\b(" . str_replace("\*", ".*?", preg_quote($replace_synonym, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i";
$replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>"; $replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>";
$highlight_active .= " " . $match_synonym; $highlight_active .= " " . $match_synonym;
@ -797,13 +895,27 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
$message = (strlen($message) > $return_chars) ? substr($message, 0, $return_chars) . " ..." : $message; $message = (strlen($message) > $return_chars) ? substr($message, 0, $return_chars) . " ..." : $message;
$message = strip_tags($message); $message = strip_tags($message);
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", "", $message); $message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", "", $message);
if( count($search_string) )
{
$message = preg_replace($search_string, $replace_string, $message);
}
$message = preg_replace("/\[url\]|\[\/url\]/si", "", $message); $message = preg_replace("/\[url\]|\[\/url\]/si", "", $message);
} }
else else
{ {
$user_sig = $searchset[$i]['user_sig']; $user_sig = $searchset[$i]['user_sig'];
$user_sig_bbcode_uid = $searchset[$i]['user_sig_bbcode_uid']; $user_sig_bbcode_uid = $searchset[$i]['user_sig_bbcode_uid'];
$message = make_clickable($message);
if( count($search_string) )
{
$message = preg_replace($search_string, $replace_string, $message);
}
if( !$board_config['allow_html'] ) if( !$board_config['allow_html'] )
{ {
if( $user_sig != "" && $searchset[$i]['enable_sig'] && $userdata['user_allowhtml'] ) if( $user_sig != "" && $searchset[$i]['enable_sig'] && $userdata['user_allowhtml'] )
@ -827,8 +939,6 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message); $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
} }
$message = make_clickable($message);
if( $searchset[$i]['enable_sig'] ) if( $searchset[$i]['enable_sig'] )
{ {
$message .= "<br /><br />_________________<br />" . make_clickable($user_sig); $message .= "<br /><br />_________________<br />" . make_clickable($user_sig);
@ -854,11 +964,8 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
$message = str_replace("\n", "<br />", $message); $message = str_replace("\n", "<br />", $message);
if( count($search_string) )
{
$message = preg_replace($search_string, $replace_string, $message);
}
} }
$template->assign_block_vars("searchresults", array( $template->assign_block_vars("searchresults", array(
"TOPIC_TITLE" => $topic_title, "TOPIC_TITLE" => $topic_title,
"FORUM_NAME" => $searchset[$i]['forum_name'], "FORUM_NAME" => $searchset[$i]['forum_name'],
@ -983,35 +1090,63 @@ else if( $query_keywords != "" || $query_author != "" || $search_id )
} }
} }
if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) && $searchset[$i]['post_time'] > $userdata['session_last_visit'] ) if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ||
isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ||
isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
{ {
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_posts'] . "\" border=\"0\" /></a> "; $unread_topics = true;
}
else if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) )
{
if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{ {
if( $HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id] < $searchset[$i]['post_time'] && $searchset[$i]['post_time'] > $userdata['session_last_visit'] ) if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $topic_rowset[$i]['post_time'] )
{ {
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" />"; $unread_topics = false;
}
}
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_posts'] . "\" border=\"0\" /></a> "; if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) )
} {
else if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $topic_rowset[$i]['post_time'] )
{ {
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $unread_topics = false;
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" />";
$newest_post_img = "";
} }
} }
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
{
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $topic_rowset[$i]['post_time'] )
{
$unread_topics = false;
}
}
if( $unread_topics )
{
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
else else
{ {
$folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" />";
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
$newest_post_img = ""; $newest_post_img = "";
} }
}
else if( $topic_rowset[$i]['post_time'] > $userdata['session_last_visit'] )
{
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
else
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
$newest_post_img = "";
} }
} }

View file

@ -1,13 +1,14 @@
<br clear="all" />
<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center"> <table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
<tr> <tr>
<td align="left" valign="bottom"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td> <td align="left" valign="bottom"><span class="gensmall">{LAST_VISIT_DATE}<br />{CURRENT_TIME}<br /><br /></span><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
<td align="right" class="gensmall"> <td align="right" valign="bottom" class="gensmall">
<!-- BEGIN switch_user_logged_in --> <!-- BEGIN switch_user_logged_in -->
<a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br /> <a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in --> <!-- END switch_user_logged_in -->
<a href="{U_SEARCH_UNANSWERED}" class="gensmall">{L_SEARCH_UNANSWERED}</a><br /> <a href="{U_SEARCH_UNANSWERED}" class="gensmall">{L_SEARCH_UNANSWERED}</a><br /><a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a></td>
<a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br />{LAST_VISIT_DATE}</td>
</tr> </tr>
</table> </table>

View file

@ -112,49 +112,31 @@ if( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
// //
if( $mark_read == "topics" ) if( $mark_read == "topics" )
{ {
if( $userdata['session_last_visit'] ) $sql = "SELECT MAX(post_time) AS last_post
FROM " . POSTS_TABLE . "
WHERE forum_id = $forum_id";
if( !$result = $db->sql_query($sql) )
{ {
$sql = "SELECT t.topic_id, p.post_time message_die(GENERAL_ERROR, "Couldn't obtain forums information.", "", __LINE__, __FILE__, $sql);
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id
AND p.post_id = t.topic_last_post_id
AND p.post_time > " . $userdata['session_last_visit'] . "
AND t.topic_moved_id IS NULL";
if(!$t_result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
}
if( $mark_read_rows = $db->sql_numrows($t_result) )
{
$mark_read_list = $db->sql_fetchrowset($t_result);
for($i = 0; $i < $mark_read_rows; $i++ )
{
$topic_id = $mark_read_list[$i]['topic_id'];
$post_time = $mark_read_list[$i]['post_time'];
if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
else
{
if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
}
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
);
$message = $lang['Topics_marked_read'] . "<br /><br />" . sprintf($lang['Click_return_forum'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a> ");
message_die(GENERAL_MESSAGE, $message);
} }
if( $db->sql_numrows($result) )
{
$row = $db->sql_fetchrow($result);
if( $row['last_post'] > $userdata['session_last_visit'] )
{
setcookie($board_config['cookie_name'] . "_f_$forum_id", time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
// session_send_cookie("_f_$forum_id", time(), 0);
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
);
$message = $lang['Topics_marked_read'] . "<br /><br />" . sprintf($lang['Click_return_forum'], "<a href=\"" . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a> ");
message_die(GENERAL_MESSAGE, $message);
} }
// //
// End handle marking posts // End handle marking posts
@ -449,7 +431,7 @@ if( $total_topics )
if( ( $replies + 1 ) > $board_config['posts_per_page'] ) if( ( $replies + 1 ) > $board_config['posts_per_page'] )
{ {
$goto_page = " [ <img src=\"" . $images['icon_minipost'] . "\" alt=\"" . $lang['Goto_page'] . "\" />" . $lang['Goto_page'] . ": "; $goto_page = " [ <img src=\"" . $images['icon_minipost'] . "\" alt=\"" . $lang['Goto_page'] . "\" title=\"" . $lang['Goto_page'] . "\" />" . $lang['Goto_page'] . ": ";
$times = 1; $times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
@ -483,7 +465,7 @@ if( $total_topics )
$topic_type = $lang['Topic_Moved'] . " "; $topic_type = $lang['Topic_Moved'] . " ";
$topic_id = $topic_rowset[$i]['topic_moved_id']; $topic_id = $topic_rowset[$i]['topic_moved_id'];
$folder_image = "<img src=\"" . $images['folder'] . "\" alt=\"" . $lang['No_new_posts'] . "\" />"; $folder_image = "<img src=\"" . $images['folder'] . "\" alt=\"" . $lang['No_new_posts'] . "\" title=\"" . $lang['No_new_posts'] . "\" />";
$newest_post_img = ""; $newest_post_img = "";
} }
else else
@ -517,35 +499,63 @@ if( $total_topics )
} }
} }
if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) && $topic_rowset[$i]['post_time'] > $userdata['session_last_visit'] ) if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ||
isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ||
isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
{ {
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_posts'] . "\" border=\"0\" /></a> "; $unread_topics = true;
}
else if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) )
{
if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) )
{ {
if( $HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id] < $topic_rowset[$i]['post_time'] ) if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $topic_rowset[$i]['post_time'] )
{ {
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" />"; $unread_topics = false;
}
}
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_posts'] . "\" border=\"0\" /></a> "; if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) )
} {
else if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $topic_rowset[$i]['post_time'] )
{ {
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $unread_topics = false;
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" />";
$newest_post_img = "";
} }
} }
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) )
{
if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $topic_rowset[$i]['post_time'] )
{
$unread_topics = false;
}
}
if( $unread_topics )
{
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
else else
{ {
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" />";
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
$newest_post_img = ""; $newest_post_img = "";
} }
}
else if( $topic_rowset[$i]['post_time'] > $userdata['session_last_visit'] )
{
$folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
$newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
else
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
$folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
$newest_post_img = "";
} }
} }
@ -557,15 +567,14 @@ if( $total_topics )
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']); $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . "<br />" . $lang['by'] . " "; $last_post = $last_post_time . "<br />";
$last_post .= ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $topic_rowset[$i]['id2']) . "\">" . $topic_rowset[$i]['user2'] . "</a> "; $last_post .= ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $topic_rowset[$i]['id2']) . "\">" . $topic_rowset[$i]['user2'] . "</a> ";
$last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $topic_rowset[$i]['topic_last_post_id']) . "#" . $topic_rowset[$i]['topic_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" border=\"0\" alt=\"" . $lang['View_latest_post'] . "\" /></a>"; $last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $topic_rowset[$i]['topic_last_post_id']) . "#" . $topic_rowset[$i]['topic_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" alt=\"" . $lang['View_latest_post'] . "\" title=\"" . $lang['View_latest_post'] . "\" border=\"0\" /></a>";
$views = $topic_rowset[$i]['topic_views']; $views = $topic_rowset[$i]['topic_views'];
$row_color = ( !($i%2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i%2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("topicrow", array( $template->assign_block_vars("topicrow", array(
"FORUM_ID" => $forum_id, "FORUM_ID" => $forum_id,

View file

@ -56,31 +56,37 @@ if( isset($HTTP_GET_VARS["view"]) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{ {
if( $HTTP_GET_VARS["view"] == "newest" ) if( $HTTP_GET_VARS["view"] == "newest" )
{ {
if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name']]) ) if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"]) )
{ {
$sessiondata = unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name']])); $session_id = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_sid"];
$newest_time = $sessiondata['lastvisit']; if( $session_id )
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE topic_id = $topic_id
AND post_time >= $newest_time
ORDER BY 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); $sql = "SELECT p.post_id
} FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s
WHERE topic_id = $topic_id
AND s.session_id = '$session_id'
AND p.post_time >= s.session_last_visit
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)) ) if( !($row = $db->sql_fetchrow($result)) )
{ {
message_die(GENERAL_MESSAGE, $lang['No_new_posts_last_visit']); message_die(GENERAL_MESSAGE, $lang['No_new_posts_last_visit']);
}
else
{
$post_id = $row['post_id'];
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id", true));
}
} }
else else
{ {
$post_id = $row['post_id']; header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id", true));
} }
} }
else else
@ -137,24 +143,23 @@ if( isset($HTTP_GET_VARS["view"]) && empty($HTTP_GET_VARS[POST_POST_URL]) )
// also allows for direct linking to a post (and the calculation of which // also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic) // 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_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"; $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"; $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"; $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 . " $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 . "
FROM $join_sql_table " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
WHERE $join_sql WHERE $join_sql
AND f.forum_id = t.forum_id AND f.forum_id = t.forum_id
$order_sql"; $order_sql";
if( !$result = $db->sql_query($sql) )
if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __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) )
{ {
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', "", __LINE__, __FILE__, $sql); message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', "", __LINE__, __FILE__, $sql);
} }
@ -206,7 +211,7 @@ if(!$is_auth['auth_view'] || !$is_auth['auth_read'])
// a number of problems which will probably end up in this // a number of problems which will probably end up in this
// solution being practically as fast and certainly simpler! // solution being practically as fast and certainly simpler!
// //
if($userdata['user_id'] != ANONYMOUS) if( $userdata['user_id'] != ANONYMOUS )
{ {
$can_watch_topic = TRUE; $can_watch_topic = TRUE;
@ -317,9 +322,9 @@ else
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
$previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']); $previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
if(!empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays'])) if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
{ {
$post_days = (!empty($HTTP_POST_VARS['postdays'])) ? $HTTP_POST_VARS['postdays'] : $HTTP_GET_VARS['postdays']; $post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? $HTTP_POST_VARS['postdays'] : $HTTP_GET_VARS['postdays'];
$min_post_time = time() - ($post_days * 86400); $min_post_time = time() - ($post_days * 86400);
$sql = "SELECT COUNT(post_id) AS num_posts $sql = "SELECT COUNT(post_id) AS num_posts
@ -454,11 +459,28 @@ $post_alt = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked
// //
// Dump out the page header and load viewtopic body template // Dump out the page header and load viewtopic body template
// //
$topic_last_read = ( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) ) ? $HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id] : 0; if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) && isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) )
{
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); $topic_last_read = ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] ) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] : $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"];
}
else if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) )
{
$topic_last_read = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] : $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"];
}
else
{
$topic_last_read = $userdata['session_last_visit'];
}
//
// Set a cookie for this topic
//
setcookie($board_config['cookie_name'] . "_t_$topic_id", time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
//session_send_cookie("_t_$topic_id", time(), 0);
//
// Load templates
//
$template->set_filenames(array( $template->set_filenames(array(
"body" => "viewtopic_body.tpl", "body" => "viewtopic_body.tpl",
"jumpbox" => "jumpbox.tpl") "jumpbox" => "jumpbox.tpl")
@ -514,6 +536,9 @@ if( count($orig_word) )
if( isset($HTTP_GET_VARS['highlight']) ) if( isset($HTTP_GET_VARS['highlight']) )
{ {
$highlight_match = array();
$highlight_replace = array();
// //
// Split words and phrases // Split words and phrases
// //
@ -523,8 +548,8 @@ if( isset($HTTP_GET_VARS['highlight']) )
{ {
if( trim($words[$i]) != "" ) if( trim($words[$i]) != "" )
{ {
$highlight_match[] = "#\b(" . str_replace("\*", ".*?", preg_quote($words[$i], "#")) . ")\b#i"; $highlight_match[] = "#\b(" . str_replace("\*", ".*?", preg_quote($words[$i], "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i";
$highlight_replace[] = "<font color=\"#FF0000\"><b>\\1</b></font>"; $highlight_replace[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>";
} }
} }
@ -726,13 +751,13 @@ for($i = 0; $i < $total_posts; $i++)
switch( $postrow[$i]['user_avatar_type'] ) switch( $postrow[$i]['user_avatar_type'] )
{ {
case USER_AVATAR_UPLOAD: case USER_AVATAR_UPLOAD:
$poster_avatar = ( $board_config['avatar_upload_db'] ) ? "<img src=\"avatar.$phpEx?p=" . $postrow[$i]['post_id'] . "\" alt=\"\" />" : "<img src=\"" . $board_config['avatar_path'] . "/" . $postrow[$i]['user_avatar'] . "\" alt=\"\" />"; $poster_avatar = ( $board_config['avatar_upload_db'] ) ? "<img src=\"avatar.$phpEx?p=" . $postrow[$i]['post_id'] . "\" alt=\"\" />" : "<img src=\"" . $board_config['avatar_path'] . "/" . $postrow[$i]['user_avatar'] . "\" alt=\"\" border=\"\" />";
break; break;
case USER_AVATAR_REMOTE: case USER_AVATAR_REMOTE:
$poster_avatar = "<img src=\"" . $postrow[$i]['user_avatar'] . "\" alt=\"\" />"; $poster_avatar = "<img src=\"" . $postrow[$i]['user_avatar'] . "\" alt=\"\" border=\"\" />";
break; break;
case USER_AVATAR_GALLERY: case USER_AVATAR_GALLERY:
$poster_avatar = "<img src=\"" . $board_config['avatar_gallery_path'] . "/" . $postrow[$i]['user_avatar'] . "\" alt=\"\" />"; $poster_avatar = "<img src=\"" . $board_config['avatar_gallery_path'] . "/" . $postrow[$i]['user_avatar'] . "\" alt=\"\" border=\"\" />";
break; break;
} }
} }
@ -746,11 +771,11 @@ for($i = 0; $i < $total_posts; $i++)
// //
if( $postrow[$i]['post_time'] > $userdata['session_last_visit'] && $postrow[$i]['post_time'] > $topic_last_read ) if( $postrow[$i]['post_time'] > $userdata['session_last_visit'] && $postrow[$i]['post_time'] > $topic_last_read )
{ {
$mini_post_img = '<img src="' . $images['icon_minipost_new'] . '" alt="' . $lang['New_post'] . '" />'; $mini_post_img = '<img src="' . $images['icon_minipost_new'] . '" alt="' . $lang['New_post'] . '" title="' . $lang['New_post'] . '" border="0" />';
} }
else else
{ {
$mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" />'; $mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" title="' . $lang['Post'] . '" border="0" />';
} }
// //
@ -775,10 +800,10 @@ for($i = 0; $i < $total_posts; $i++)
{ {
for($j = 0; $j < count($ranksrow); $j++) for($j = 0; $j < count($ranksrow); $j++)
{ {
if($postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special']) if( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
{ {
$poster_rank = $ranksrow[$j]['rank_title']; $poster_rank = $ranksrow[$j]['rank_title'];
$rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\"><br />" : ""; $rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\" alt=\"\" border=\"0\" /><br />" : "";
} }
} }
} }
@ -786,10 +811,10 @@ for($i = 0; $i < $total_posts; $i++)
{ {
for($j = 0; $j < count($ranksrow); $j++) for($j = 0; $j < count($ranksrow); $j++)
{ {
if($postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && $postrow[$i]['user_posts'] < $ranksrow[$j]['rank_max'] && !$ranksrow[$j]['rank_special']) if( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
{ {
$poster_rank = $ranksrow[$j]['rank_title']; $poster_rank = $ranksrow[$j]['rank_title'];
$rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\"><br />" : ""; $rank_image = ($ranksrow[$j]['rank_image']) ? "<img src=\"" . $ranksrow[$j]['rank_image'] . "\" alt=\"\" border=\"0\" /><br />" : "";
} }
} }
} }
@ -805,22 +830,22 @@ for($i = 0; $i < $total_posts; $i++)
if($poster_id != ANONYMOUS) if($poster_id != ANONYMOUS)
{ {
$profile_img = "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_profile'] . "\" alt=\"" . $lang['Read_profile'] . "\" border=\"0\" /></a>"; $profile_img = "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_profile'] . "\" alt=\"" . $lang['Read_profile'] . "\" title=\"" . $lang['Read_profile'] . "\" border=\"0\" /></a>";
$pm_img = "<a href=\"" . append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"". $images['icon_pm'] . "\" alt=\"" . $lang['Send_private_message'] . "\" border=\"0\" /></a>"; $pm_img = "<a href=\"" . append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"". $images['icon_pm'] . "\" alt=\"" . $lang['Send_private_message'] . "\" title=\"" . $lang['Send_private_message'] . "\" border=\"0\" /></a>";
if( !empty($postrow[$i]['user_viewemail']) ) if( !empty($postrow[$i]['user_viewemail']) )
{ {
$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL ."=" . $poster_id) : "mailto:" . $postrow[$i]['user_email']; $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL ."=" . $poster_id) : "mailto:" . $postrow[$i]['user_email'];
$email_img = "<a href=\"$email_uri\"><img src=\"" . $images['icon_email'] . "\" alt=\"" . $lang['Send_email'] . "\" border=\"0\" /></a>"; $email_img = "<a href=\"$email_uri\"><img src=\"" . $images['icon_email'] . "\" alt=\"" . $lang['Send_email'] . "\" title=\"" . $lang['Send_email'] . "\" border=\"0\" /></a>";
} }
else else
{ {
$email_img = ""; $email_img = "";
} }
$www_img = ($postrow[$i]['user_website']) ? "<a href=\"" . $postrow[$i]['user_website'] . "\" target=\"_userwww\"><img src=\"" . $images['icon_www'] . "\" alt=\"" . $lang['Visit_website'] . "\" border=\"0\" /></a>" : ""; $www_img = ($postrow[$i]['user_website']) ? "<a href=\"" . $postrow[$i]['user_website'] . "\" target=\"_userwww\"><img src=\"" . $images['icon_www'] . "\" alt=\"" . $lang['Visit_website'] . "\" title=\"" . $lang['Visit_website'] . "\" border=\"0\" /></a>" : "";
if( !empty($postrow[$i]['user_icq']) ) if( !empty($postrow[$i]['user_icq']) )
{ {
@ -833,12 +858,12 @@ for($i = 0; $i < $total_posts; $i++)
// //
if( $theme['template_name'] == "subSilver" ) if( $theme['template_name'] == "subSilver" )
{ {
$icq_add_img = '<table width="59" border="0" cellspacing="0" cellpadding="0"><tr><td nowrap="nowrap" class="icqback"><img src="images/spacer.gif" width="3" height="18" alt = "">' . $icq_status_img . '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '"><img src="images/spacer.gif" width="35" height="18" border="0" alt="' . $lang['ICQ'] . '" /></a></td></tr></table>'; $icq_add_img = '<table width="59" border="0" cellspacing="0" cellpadding="0"><tr><td nowrap="nowrap" class="icqback"><img src="images/spacer.gif" width="3" height="18" alt = "" />' . $icq_status_img . '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '"><img src="images/spacer.gif" width="35" height="18" border="0" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" /></a></td></tr></table>';
$icq_status_img = ""; $icq_status_img = "";
} }
else else
{ {
$icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=" . $postrow[$i]['user_icq'] . "\"><img src=\"" . $images['icon_icq'] . "\" alt=\"" . $lang['ICQ'] . "\" border=\"0\" /></a>"; $icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=" . $postrow[$i]['user_icq'] . "\"><img src=\"" . $images['icon_icq'] . "\" alt=\"" . $lang['ICQ'] . "\" title=\"" . $lang['ICQ'] . "\" border=\"0\" /></a>";
} }
} }
else else
@ -847,11 +872,11 @@ for($i = 0; $i < $total_posts; $i++)
$icq_add_img = ""; $icq_add_img = "";
} }
$aim_img = ($postrow[$i]['user_aim']) ? "<a href=\"aim:goim?screenname=" . $postrow[$i]['user_aim'] . "&amp;message=Hello+Are+you+there?\"><img src=\"" . $images['icon_aim'] . "\" border=\"0\" alt=\"" . $lang['AIM'] . "\" /></a>" : ""; $aim_img = ($postrow[$i]['user_aim']) ? "<a href=\"aim:goim?screenname=" . $postrow[$i]['user_aim'] . "&amp;message=Hello+Are+you+there?\"><img src=\"" . $images['icon_aim'] . "\" alt=\"" . $lang['AIM'] . "\" title=\"" . $lang['AIM'] . "\" border=\"0\" /></a>" : "";
$msn_img = ($postrow[$i]['user_msnm']) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_msnm'] . "\" border=\"0\" alt=\"" . $lang['MSNM'] . "\" /></a>" : ""; $msn_img = ($postrow[$i]['user_msnm']) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_msnm'] . "\" alt=\"" . $lang['MSNM'] . "\" title=\"" . $lang['MSNM'] . "\" border=\"0\" /></a>" : "";
$yim_img = ($postrow[$i]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=" . $postrow[$i]['user_yim'] . "&amp;.src=pg\"><img src=\"" . $images['icon_yim'] . "\" border=\"0\" alt=\"" . $lang['YIM'] . "\" /></a>" : ""; $yim_img = ($postrow[$i]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=" . $postrow[$i]['user_yim'] . "&amp;.src=pg\"><img src=\"" . $images['icon_yim'] . "\" alt=\"" . $lang['YIM'] . "\" title=\"" . $lang['YIM'] . "\" border=\"0\" /></a>" : "";
} }
else else
{ {
@ -866,13 +891,13 @@ for($i = 0; $i < $total_posts; $i++)
$yim_img = ""; $yim_img = "";
} }
$quote_img = "<a href=\"" . append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_quote'] . "\" alt=\"" . $lang['Reply_with_quote'] ."\" border=\"0\" /></a>"; $quote_img = "<a href=\"" . append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_quote'] . "\" alt=\"" . $lang['Reply_with_quote'] ."\" title=\"" . $lang['Reply_with_quote'] ."\" border=\"0\" /></a>";
$search_img = "<a href=\"" . append_sid("search.$phpEx?search_author=" . urlencode($poster)) . "\"><img src=\"" . $images['icon_search'] . "\" border=\"0\" /></a>"; $search_img = "<a href=\"" . append_sid("search.$phpEx?search_author=" . urlencode($poster)) . "\"><img src=\"" . $images['icon_search'] . "\" border=\"0\" /></a>";
if( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] ) if( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
{ {
$edit_img = "<a href=\"" . append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_edit'] . "\" alt=\"" . $lang['Edit_delete_post'] . "\" border=\"0\" /></a>"; $edit_img = "<a href=\"" . append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_edit'] . "\" alt=\"" . $lang['Edit_delete_post'] . "\" title=\"" . $lang['Edit_delete_post'] . "\" border=\"0\" /></a>";
} }
else else
{ {
@ -881,9 +906,9 @@ for($i = 0; $i < $total_posts; $i++)
if( $is_auth['auth_mod'] ) if( $is_auth['auth_mod'] )
{ {
$ip_img = "<a href=\"" . append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $topic_id) . "\"><img src=\"" . $images['icon_ip'] . "\" alt=\"" . $lang['View_IP'] . "\" border=\"0\" /></a>"; $ip_img = "<a href=\"" . append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id) . "\"><img src=\"" . $images['icon_ip'] . "\" alt=\"" . $lang['View_IP'] . "\" title=\"" . $lang['View_IP'] . "\" border=\"0\" /></a>";
$delpost_img = "<a href=\"" . append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>"; $delpost_img = "<a href=\"" . append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" title=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>";
} }
else else
{ {
@ -891,7 +916,7 @@ for($i = 0; $i < $total_posts; $i++)
if( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $i == $total_replies - 1 ) if( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $i == $total_replies - 1 )
{ {
$delpost_img = "<a href=\"" . append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>"; $delpost_img = "<a href=\"" . append_sid("posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" title=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>";
} }
else else
{ {
@ -907,6 +932,21 @@ for($i = 0; $i < $total_posts; $i++)
$user_sig = $postrow[$i]['user_sig']; $user_sig = $postrow[$i]['user_sig'];
$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid']; $user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
//
// Note! The order used for parsing the message _is_
// important, moving things around could break any
// output
//
$message = make_clickable($message);
//
// Highlight active words (primarily for search)
//
if( $highlight_active )
{
$message = preg_replace($highlight_match, $highlight_replace, $message);
}
// //
// If the board has HTML off but the post has HTML // If the board has HTML off but the post has HTML
// on then we process it, else leave it alone // on then we process it, else leave it alone
@ -924,39 +964,51 @@ for($i = 0; $i < $total_posts; $i++)
} }
} }
//
// Parse signature for BBCode if reqd.
//
if( $user_sig != "" && $postrow[$i]['enable_sig'] && $user_sig_bbcode_uid != "" ) if( $user_sig != "" && $postrow[$i]['enable_sig'] && $user_sig_bbcode_uid != "" )
{ {
$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $user_sig); $user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $user_sig);
} }
//
// Parse message for BBCode if reqd
//
if( $bbcode_uid != "" ) if( $bbcode_uid != "" )
{ {
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message); $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
} }
if( $highlight_active ) //
{ // Append signature
$message = preg_replace($highlight_match, $highlight_replace, $message); //
}
$message = make_clickable($message);
if( $postrow[$i]['enable_sig'] && $user_sig != "" ) if( $postrow[$i]['enable_sig'] && $user_sig != "" )
{ {
$message .= "<br /><br />_________________<br />" . make_clickable($user_sig); $message .= "<br /><br />_________________<br />" . make_clickable($user_sig);
} }
//
// Replace naughty words
//
if( count($orig_word) ) if( count($orig_word) )
{ {
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject); $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = preg_replace($orig_word, $replacement_word, $message); $message = preg_replace($orig_word, $replacement_word, $message);
} }
//
// Parse smilies
//
if( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] ) if( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
{ {
$message = smilies_pass($message); $message = smilies_pass($message);
} }
//
// Replace newlines (we use this rather than nl2br because
// till recently it wasn't XHTML compliant)
//
$message = str_replace("\n", "<br />", $message); $message = str_replace("\n", "<br />", $message);
// //
@ -1032,19 +1084,19 @@ if( $is_auth['auth_mod'] )
{ {
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"" . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>"); $s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"" . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
$topic_mod = "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete") . "\"><img src=\"" . $images['topic_mod_delete'] . "\" alt = \"" . $lang['Delete_topic'] . "\" border=\"0\" /></a>&nbsp;"; $topic_mod = "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete") . "\"><img src=\"" . $images['topic_mod_delete'] . "\" alt=\"" . $lang['Delete_topic'] . "\" title=\"" . $lang['Delete_topic'] . "\" border=\"0\" /></a>&nbsp;";
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move"). "\"><img src=\"" . $images['topic_mod_move'] . "\" alt = \"" . $lang['Move_topic'] . "\" border=\"0\" /></a>&nbsp;"; $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move"). "\"><img src=\"" . $images['topic_mod_move'] . "\" alt=\"" . $lang['Move_topic'] . "\" title=\"" . $lang['Move_topic'] . "\" border=\"0\" /></a>&nbsp;";
if($forum_row['topic_status'] == TOPIC_UNLOCKED) if($forum_row['topic_status'] == TOPIC_UNLOCKED)
{ {
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock") . "\"><img src=\"" . $images['topic_mod_lock'] . "\" alt = \"" . $lang['Lock_topic'] . "\" border=\"0\" /></a>&nbsp;"; $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock") . "\"><img src=\"" . $images['topic_mod_lock'] . "\" alt=\"" . $lang['Lock_topic'] . "\" title=\"" . $lang['Lock_topic'] . "\" border=\"0\" /></a>&nbsp;";
} }
else else
{ {
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock") . "\"><img src=\"" . $images['topic_mod_unlock'] . "\" alt = \"" . $lang['Unlock_topic'] . "\" border=\"0\" /></a>&nbsp;"; $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock") . "\"><img src=\"" . $images['topic_mod_unlock'] . "\" alt=\"" . $lang['Unlock_topic'] . "\" title=\"" . $lang['Unlock_topic'] . "\" border=\"0\" /></a>&nbsp;";
} }
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split") . "\"><img src=\"" . $images['topic_mod_split'] . "\" alt = \"" . $lang['Split_topic'] . "\" border=\"0\" /></a>&nbsp;"; $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split") . "\"><img src=\"" . $images['topic_mod_split'] . "\" alt=\"" . $lang['Split_topic'] . "\" title=\"" . $lang['Split_topic'] . "\" border=\"0\" /></a>&nbsp;";
} }
// //
@ -1055,12 +1107,12 @@ if( $can_watch_topic )
if( $is_watching_topic ) if( $is_watching_topic )
{ {
$s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\">" . $lang['Stop_watching_topic'] . "</a>"; $s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\">" . $lang['Stop_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>"; $s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" title=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>";
} }
else else
{ {
$s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\">" . $lang['Start_watching_topic'] . "</a>"; $s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\">" . $lang['Start_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>"; $s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" title=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>";
} }
} }
else else