aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2002-10-09 19:50:48 +0000
committerLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2002-10-09 19:50:48 +0000
commit369189806bf4bf85fe0409e6f66919ab4f4b70cd (patch)
tree988680c7700c818b42e2170a9d7d887efa3c812b
parentac4b54ff4dea78aaeec015685b1c02a66449f1f1 (diff)
downloadforums-369189806bf4bf85fe0409e6f66919ab4f4b70cd.tar
forums-369189806bf4bf85fe0409e6f66919ab4f4b70cd.tar.gz
forums-369189806bf4bf85fe0409e6f66919ab4f4b70cd.tar.bz2
forums-369189806bf4bf85fe0409e6f66919ab4f4b70cd.tar.xz
forums-369189806bf4bf85fe0409e6f66919ab4f4b70cd.zip
Added the redirect() function for nice and clean redirection.
git-svn-id: file:///svn/phpbb/trunk@2948 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/forums_display.php14
-rw-r--r--phpBB/includes/functions.php42
-rw-r--r--phpBB/includes/session.php12
-rw-r--r--phpBB/login.php17
-rw-r--r--phpBB/viewforum.php7
-rw-r--r--phpBB/viewtopic.php14
6 files changed, 44 insertions, 62 deletions
diff --git a/phpBB/includes/forums_display.php b/phpBB/includes/forums_display.php
index e9e7a2ac45..e71746bcb7 100644
--- a/phpBB/includes/forums_display.php
+++ b/phpBB/includes/forums_display.php
@@ -111,7 +111,19 @@ foreach ($forum_rows as $row)
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'] . ': ';
}
else
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index b45eced074..dda7a3c393 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -70,7 +70,7 @@ function get_db_stat($mode)
function sql_quote($msg)
{
- return str_replace('\'', '\'\'', $msg);
+ return str_replace("'", "''", $msg);
}
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 )
{
- $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . "login.$phpEx$SID&redirect=view$mode.$phpEx&" . $u_url . "=$match_id&unwatch=forum");
- exit;
+ redirect("login.$phpEx$SID&redirect=view$mode.$phpEx&" . $u_url . "=$match_id&unwatch=forum");
}
}
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) );
}
-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
// calling script, note that the vars are passed as references this just makes it easier
// to return both sets of arrays
@@ -575,6 +550,19 @@ function obtain_word_list(&$orig_word, &$replacement_word)
}
//
+// 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)
// language, etc. $msg_code can be one of these constants:
//
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index ed2bc840a8..0dd9ebd8e1 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -442,9 +442,9 @@ class auth
{
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 )
{
@@ -452,7 +452,7 @@ class auth
{
foreach ( $options as $option )
{
- $in_sql .= ', \'' . $option . '\'';
+ $in_sql .= ", '$option'";
}
}
else
@@ -468,8 +468,8 @@ class auth
// The possible alternative here is to store the options in a file
// (perhaps with the other config data) and do away with this query.
- $sql = "SELECT auth_option_id, auth_value
- FROM " . ACL_OPTIONS_TABLE . "
+ $sql = 'SELECT auth_option_id, auth_value
+ FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_value IN ($in_sql) $or_sql";
$result = $db->sql_query($sql);
@@ -527,7 +527,7 @@ class auth
}
*/
}
-
+$this->acl_cache($userdata);
return;
}
diff --git a/phpBB/login.php b/phpBB/login.php
index b6f9e54554..ab62485cab 100644
--- a/phpBB/login.php
+++ b/phpBB/login.php
@@ -32,16 +32,10 @@ $auth = new auth($userdata);
$user = new user($userdata);
// 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($_POST);
-$redirect = ( !empty($redirect) ) ? $_SERVER['QUERY_STRING'] : '';
+$redirect = (!empty($redirect)) ? $_SERVER['QUERY_STRING'] : '';
// Do the login/logout/form/whatever
if ( isset($login) || isset($logout) )
@@ -55,8 +49,7 @@ if ( isset($login) || isset($logout) )
//
if ( $board_config['board_disable'] && !$auth->acl_get('a_') )
{
- header($header_location . "index.$phpEx$SID");
- exit;
+ redirect("index.$phpEx$SID");
}
if ( !$auth->login($username, $password, $autologin) )
@@ -78,8 +71,7 @@ if ( isset($login) || isset($logout) )
// Redirect to wherever we're supposed to go ...
//
$redirect_url = ( $redirect ) ? preg_replace('/^.*?redirect=(.*?)&(.*?)$/', '\\1' . $SID . '&\\2', $redirect) : 'index.'.$phpEx;
- header($header_location . $redirect_url);
- exit;
+ redirect($redirect_url);
}
if ( !$userdata['user_id'] )
@@ -105,8 +97,7 @@ if ( !$userdata['user_id'] )
}
else
{
- header($header_location . "index.$phpEx$SID");
- exit;
+ redirect("index.$phpEx$SID");
}
?> \ No newline at end of file
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 14b2454996..b84fac6855 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -76,10 +76,7 @@ if (!$auth->acl_get('f_read', $forum_id))
{
if ( !$userdata['user_id'] )
{
- $redirect = "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;
+ redirect("login.$phpEx$SID&redirect=viewforum.$phpEx&f=$forum_id" . ((isset($start)) ? "&start=$start" : ''));
}
// 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
-// Build subforum if applicable
+// Build subforums list if applicable
$type = 'parent';
$forum_rows = array();
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 125360ca00..b74ebe7b85 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -41,12 +41,10 @@ if ( empty($topic_id) && empty($post_id) )
// Find topic id if user requested a newer
// or older topic
//
-if ( isset($_GET['view']) && empty($post_id) )
+if (isset($_GET['view']) && empty($post_id))
{
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']) )
{
$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'];
- header($header_location . 'viewtopic.' . $phpEx . '?sid=' . $session_id . '&p=' . $post_id . '#' . $post_id);
- exit;
+ redirect("viewtopic.$phpEx$SID&p=$post_id#$post_id");
}
}
- header($header_location . 'index.' . $phpEx);
- exit;
+ redirect("index.$phpEx$SID");
}
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($start) ) ? "&start=$start" : '';
- $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
- header($header_location . 'login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
- exit;
+ redirect('login.' . $phpEx . $SID . '&redirect=viewtopic.' . $phpEx . '&' . $redirect);
}
message_die(MESSAGE, $lang['Sorry_auth_read']);