mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Added the redirect() function for nice and clean redirection.
git-svn-id: file:///svn/phpbb/trunk@2948 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
ac4b54ff4d
commit
369189806b
6 changed files with 44 additions and 62 deletions
|
@ -111,7 +111,19 @@ foreach ($forum_rows as $row)
|
||||||
|
|
||||||
if (isset($subforums[$forum_id]))
|
if (isset($subforums[$forum_id]))
|
||||||
{
|
{
|
||||||
$subforums_list = format_subforums_list($subforums[$forum_id]);
|
foreach ($subforums as $row)
|
||||||
|
{
|
||||||
|
$alist[$row['forum_id']] = $row['forum_name'];
|
||||||
|
}
|
||||||
|
asort($alist);
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
foreach ($alist as $forum_id => $forum_name)
|
||||||
|
{
|
||||||
|
$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
|
||||||
|
}
|
||||||
|
$subforums_list = implode(', ', $links);
|
||||||
|
|
||||||
$l_subforums = (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] . ': ' : $lang['Subforums'] . ': ';
|
$l_subforums = (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] . ': ' : $lang['Subforums'] . ': ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -70,7 +70,7 @@ function get_db_stat($mode)
|
||||||
|
|
||||||
function sql_quote($msg)
|
function sql_quote($msg)
|
||||||
{
|
{
|
||||||
return str_replace('\'', '\'\'', $msg);
|
return str_replace("'", "''", $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_userdata($user)
|
function get_userdata($user)
|
||||||
|
@ -403,9 +403,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
|
||||||
{
|
{
|
||||||
if ( $_GET['unwatch'] == $mode )
|
if ( $_GET['unwatch'] == $mode )
|
||||||
{
|
{
|
||||||
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
|
redirect("login.$phpEx$SID&redirect=view$mode.$phpEx&" . $u_url . "=$match_id&unwatch=forum");
|
||||||
header($header_location . "login.$phpEx$SID&redirect=view$mode.$phpEx&" . $u_url . "=$match_id&unwatch=forum");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -527,29 +525,6 @@ function on_page($num_items, $per_page, $start)
|
||||||
return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) );
|
return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_subforums_list($subforums)
|
|
||||||
{
|
|
||||||
if (empty($subforums))
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
global $phpEx, $SID;
|
|
||||||
foreach ($subforums as $row)
|
|
||||||
{
|
|
||||||
$alist[$row['forum_id']] = $row['forum_name'];
|
|
||||||
}
|
|
||||||
asort($alist);
|
|
||||||
|
|
||||||
$links = array();
|
|
||||||
foreach ($alist as $forum_id => $forum_name)
|
|
||||||
{
|
|
||||||
$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(', ', $links);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain list of naughty words and build preg style replacement arrays for use by the
|
// Obtain list of naughty words and build preg style replacement arrays for use by the
|
||||||
// calling script, note that the vars are passed as references this just makes it easier
|
// calling script, note that the vars are passed as references this just makes it easier
|
||||||
// to return both sets of arrays
|
// to return both sets of arrays
|
||||||
|
@ -574,6 +549,19 @@ function obtain_word_list(&$orig_word, &$replacement_word)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Redirects the user to another page then exits the script nicely
|
||||||
|
//
|
||||||
|
function redirect($location)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$db->sql_close();
|
||||||
|
|
||||||
|
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
|
||||||
|
header($header_location . $location);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is general replacement for die(), allows templated output in users (or default)
|
// This is general replacement for die(), allows templated output in users (or default)
|
||||||
// language, etc. $msg_code can be one of these constants:
|
// language, etc. $msg_code can be one of these constants:
|
||||||
|
|
|
@ -442,9 +442,9 @@ class auth
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if ( !($this->founder = $userdata['user_founder']) )
|
if (!$this->founder = $userdata['user_founder'])
|
||||||
{
|
{
|
||||||
$in_sql = '\'a_\', \'f_list\'';
|
$in_sql = "'a_', 'f_list'";
|
||||||
|
|
||||||
if ( $options )
|
if ( $options )
|
||||||
{
|
{
|
||||||
|
@ -452,7 +452,7 @@ class auth
|
||||||
{
|
{
|
||||||
foreach ( $options as $option )
|
foreach ( $options as $option )
|
||||||
{
|
{
|
||||||
$in_sql .= ', \'' . $option . '\'';
|
$in_sql .= ", '$option'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -468,8 +468,8 @@ class auth
|
||||||
|
|
||||||
// The possible alternative here is to store the options in a file
|
// The possible alternative here is to store the options in a file
|
||||||
// (perhaps with the other config data) and do away with this query.
|
// (perhaps with the other config data) and do away with this query.
|
||||||
$sql = "SELECT auth_option_id, auth_value
|
$sql = 'SELECT auth_option_id, auth_value
|
||||||
FROM " . ACL_OPTIONS_TABLE . "
|
FROM ' . ACL_OPTIONS_TABLE . "
|
||||||
WHERE auth_value IN ($in_sql) $or_sql";
|
WHERE auth_value IN ($in_sql) $or_sql";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ class auth
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
$this->acl_cache($userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,10 @@ $auth = new auth($userdata);
|
||||||
$user = new user($userdata);
|
$user = new user($userdata);
|
||||||
// End session management
|
// End session management
|
||||||
|
|
||||||
//
|
|
||||||
// This appears to work for IIS5 CGI under Win2K. Uses getenv since this doesn't exist for
|
|
||||||
// ISAPI mode and therefore the normal Location redirector is used in preference
|
|
||||||
//
|
|
||||||
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
|
|
||||||
|
|
||||||
extract($_GET);
|
extract($_GET);
|
||||||
extract($_POST);
|
extract($_POST);
|
||||||
|
|
||||||
$redirect = ( !empty($redirect) ) ? $_SERVER['QUERY_STRING'] : '';
|
$redirect = (!empty($redirect)) ? $_SERVER['QUERY_STRING'] : '';
|
||||||
|
|
||||||
// Do the login/logout/form/whatever
|
// Do the login/logout/form/whatever
|
||||||
if ( isset($login) || isset($logout) )
|
if ( isset($login) || isset($logout) )
|
||||||
|
@ -55,8 +49,7 @@ if ( isset($login) || isset($logout) )
|
||||||
//
|
//
|
||||||
if ( $board_config['board_disable'] && !$auth->acl_get('a_') )
|
if ( $board_config['board_disable'] && !$auth->acl_get('a_') )
|
||||||
{
|
{
|
||||||
header($header_location . "index.$phpEx$SID");
|
redirect("index.$phpEx$SID");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$auth->login($username, $password, $autologin) )
|
if ( !$auth->login($username, $password, $autologin) )
|
||||||
|
@ -78,8 +71,7 @@ if ( isset($login) || isset($logout) )
|
||||||
// Redirect to wherever we're supposed to go ...
|
// Redirect to wherever we're supposed to go ...
|
||||||
//
|
//
|
||||||
$redirect_url = ( $redirect ) ? preg_replace('/^.*?redirect=(.*?)&(.*?)$/', '\\1' . $SID . '&\\2', $redirect) : 'index.'.$phpEx;
|
$redirect_url = ( $redirect ) ? preg_replace('/^.*?redirect=(.*?)&(.*?)$/', '\\1' . $SID . '&\\2', $redirect) : 'index.'.$phpEx;
|
||||||
header($header_location . $redirect_url);
|
redirect($redirect_url);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$userdata['user_id'] )
|
if ( !$userdata['user_id'] )
|
||||||
|
@ -105,8 +97,7 @@ if ( !$userdata['user_id'] )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header($header_location . "index.$phpEx$SID");
|
redirect("index.$phpEx$SID");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -76,10 +76,7 @@ if (!$auth->acl_get('f_read', $forum_id))
|
||||||
{
|
{
|
||||||
if ( !$userdata['user_id'] )
|
if ( !$userdata['user_id'] )
|
||||||
{
|
{
|
||||||
$redirect = "f=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
|
redirect("login.$phpEx$SID&redirect=viewforum.$phpEx&f=$forum_id" . ((isset($start)) ? "&start=$start" : ''));
|
||||||
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
|
|
||||||
header($header_location . "login.$phpEx$SID&redirect=viewforum.$phpEx&$redirect");
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user is not authed to read this forum ...
|
// The user is not authed to read this forum ...
|
||||||
|
@ -87,7 +84,7 @@ if (!$auth->acl_get('f_read', $forum_id))
|
||||||
}
|
}
|
||||||
// End of auth check
|
// End of auth check
|
||||||
|
|
||||||
// Build subforum if applicable
|
// Build subforums list if applicable
|
||||||
$type = 'parent';
|
$type = 'parent';
|
||||||
$forum_rows = array();
|
$forum_rows = array();
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,10 @@ if ( empty($topic_id) && empty($post_id) )
|
||||||
// Find topic id if user requested a newer
|
// Find topic id if user requested a newer
|
||||||
// or older topic
|
// or older topic
|
||||||
//
|
//
|
||||||
if ( isset($_GET['view']) && empty($post_id) )
|
if (isset($_GET['view']) && empty($post_id))
|
||||||
{
|
{
|
||||||
if ( $_GET['view'] == 'newest' )
|
if ( $_GET['view'] == 'newest' )
|
||||||
{
|
{
|
||||||
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
|
|
||||||
|
|
||||||
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) )
|
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) )
|
||||||
{
|
{
|
||||||
$session_id = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'];
|
$session_id = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'];
|
||||||
|
@ -70,13 +68,11 @@ if ( isset($_GET['view']) && empty($post_id) )
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = $row['post_id'];
|
$post_id = $row['post_id'];
|
||||||
header($header_location . 'viewtopic.' . $phpEx . '?sid=' . $session_id . '&p=' . $post_id . '#' . $post_id);
|
redirect("viewtopic.$phpEx$SID&p=$post_id#$post_id");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header($header_location . 'index.' . $phpEx);
|
redirect("index.$phpEx$SID");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
else if ( $_GET['view'] == 'next' || $_GET['view'] == 'previous' )
|
else if ( $_GET['view'] == 'next' || $_GET['view'] == 'previous' )
|
||||||
{
|
{
|
||||||
|
@ -169,9 +165,7 @@ if ( !$auth->acl_get('f_read', $forum_id) )
|
||||||
{
|
{
|
||||||
$redirect = ( isset($post_id) ) ? "p=$post_id" : "t=$topic_id";
|
$redirect = ( isset($post_id) ) ? "p=$post_id" : "t=$topic_id";
|
||||||
$redirect .= ( isset($start) ) ? "&start=$start" : '';
|
$redirect .= ( isset($start) ) ? "&start=$start" : '';
|
||||||
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
|
redirect('login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
|
||||||
header($header_location . 'login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message_die(MESSAGE, $lang['Sorry_auth_read']);
|
message_die(MESSAGE, $lang['Sorry_auth_read']);
|
||||||
|
|
Loading…
Add table
Reference in a new issue