Merging revisions #r8346, #r8347 and #r8348

git-svn-id: file:///svn/phpbb/trunk@8349 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-01-29 15:57:56 +00:00
parent e970da6514
commit 1407460895
10 changed files with 117 additions and 90 deletions

View file

@ -132,7 +132,7 @@ if (!defined('PHPBB_INSTALLED'))
// Redirect the user to the installer // Redirect the user to the installer
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
// available as used by the redirect function // available as used by the redirect function
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0; $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
@ -151,7 +151,11 @@ if (!defined('PHPBB_INSTALLED'))
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
{ {
$url .= ':' . $server_port; // HTTP HOST can carry a port number...
if (strpos($server_name, ':') === false)
{
$url .= ':' . $server_port;
}
} }
$url .= $script_path; $url .= $script_path;

View file

@ -105,6 +105,9 @@
<li>[Fix] Stricter checks on smilie packs (Bug #19675)</li> <li>[Fix] Stricter checks on smilie packs (Bug #19675)</li>
<li>[Fix] Gracefully return from cancelling pm drafts (Bug #19675)</li> <li>[Fix] Gracefully return from cancelling pm drafts (Bug #19675)</li>
<li>[Fix] Possible login problems with IE7 if browser check is activated (Bug #20135)</li> <li>[Fix] Possible login problems with IE7 if browser check is activated (Bug #20135)</li>
<li>[Fix] Fix possible database transaction errors if code returns on error and rollback happened (Bug #17025)</li>
<li>[Change] Allow numbers in permission names for modifications, as well as uppercase letters for the request_ part (Bug #20125)</li>
<li>[Fix] Use HTTP_HOST in favor of SERVER_NAME for determining server url for redirection and installation (Bug #19955)</li>
</ul> </ul>
<a name="v30rc8"></a><h3>1.i. Changes since 3.0.RC8</h3> <a name="v30rc8"></a><h3>1.i. Changes since 3.0.RC8</h3>

View file

@ -32,7 +32,7 @@ if (isset($_GET['avatar']))
exit; exit;
} }
unset($dbpasswd); unset($dbpasswd);
// worst-case default // worst-case default
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0'; $browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0';
@ -44,7 +44,7 @@ if (isset($_GET['avatar']))
$avatar_group = true; $avatar_group = true;
$filename = substr($filename, 1); $filename = substr($filename, 1);
} }
// '==' is not a bug - . as the first char is as bad as no dot at all // '==' is not a bug - . as the first char is as bad as no dot at all
if (strpos($filename, '.') == false) if (strpos($filename, '.') == false)
{ {
@ -56,22 +56,22 @@ if (isset($_GET['avatar']))
$db->sql_close(); $db->sql_close();
exit; exit;
} }
$ext = substr(strrchr($filename, '.'), 1); $ext = substr(strrchr($filename, '.'), 1);
$stamp = (int) substr(stristr($filename, '_'), 1); $stamp = (int) substr(stristr($filename, '_'), 1);
$filename = (int) $filename; $filename = (int) $filename;
// let's see if we have to send the file at all // let's see if we have to send the file at all
$last_load = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime(trim($_SERVER['HTTP_IF_MODIFIED_SINCE'])) : false; $last_load = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime(trim($_SERVER['HTTP_IF_MODIFIED_SINCE'])) : false;
if (strpos(strtolower($browser), 'msie 6.0') === false) if (strpos(strtolower($browser), 'msie 6.0') === false)
{ {
if ($last_load !== false && $last_load <= $stamp) if ($last_load !== false && $last_load <= $stamp)
{ {
if (@php_sapi_name() === 'CGI') if (@php_sapi_name() === 'CGI')
{ {
header('Status: 304 Not Modified', true, 304); header('Status: 304 Not Modified', true, 304);
} }
else else
{ {
header('HTTP/1.0 304 Not Modified', true, 304); header('HTTP/1.0 304 Not Modified', true, 304);
} }
@ -79,13 +79,13 @@ if (isset($_GET['avatar']))
header('Pragma: public'); header('Pragma: public');
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000)); header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000));
exit(); exit();
} }
else else
{ {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT');
} }
} }
if (!in_array($ext, array('png', 'gif', 'jpg', 'jpeg'))) if (!in_array($ext, array('png', 'gif', 'jpg', 'jpeg')))
{ {
// no way such an avatar could exist. They are not following the rules, stop the show. // no way such an avatar could exist. They are not following the rules, stop the show.
@ -97,7 +97,7 @@ if (isset($_GET['avatar']))
$db->sql_close(); $db->sql_close();
exit; exit;
} }
if (!$filename) if (!$filename)
{ {
// no way such an avatar could exist. They are not following the rules, stop the show. // no way such an avatar could exist. They are not following the rules, stop the show.
@ -280,7 +280,7 @@ else
{ {
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
} }
redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);
exit; exit;
} }
@ -467,7 +467,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
{ {
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
} }
if ($size) if ($size)
{ {
header("Content-Length: $size"); header("Content-Length: $size");
@ -556,9 +556,9 @@ function download_allowed()
} }
} }
} }
// Check for own server... // Check for own server...
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); $server_name = $user->host;
// Forcing server vars is the only way to specify/override the protocol // Forcing server vars is the only way to specify/override the protocol
if ($config['force_server_vars'] || !$server_name) if ($config['force_server_vars'] || !$server_name)
@ -570,7 +570,7 @@ function download_allowed()
{ {
$allowed = true; $allowed = true;
} }
// Get IP's and Hostnames // Get IP's and Hostnames
if (!$allowed) if (!$allowed)
{ {
@ -620,7 +620,7 @@ function download_allowed()
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
return $allowed; return $allowed;
} }

View file

@ -271,6 +271,13 @@ class dbal
return true; return true;
} }
// Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled)
// This implies we have transaction always set for autocommit db's
if (!$this->transaction)
{
return false;
}
$result = $this->_sql_transaction('commit'); $result = $this->_sql_transaction('commit');
if (!$result) if (!$result)

View file

@ -287,7 +287,7 @@ function phpbb_hash($password)
} }
$random = substr($random, 0, $count); $random = substr($random, 0, $count);
} }
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64); $hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34) if (strlen($hash) == 34)
@ -360,7 +360,7 @@ function _hash_encode64($input, $count, &$itoa64)
} }
$output .= $itoa64[($value >> 12) & 0x3f]; $output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count) if ($i++ >= $count)
{ {
break; break;
@ -723,7 +723,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
unset($tracking_topics['t']); unset($tracking_topics['t']);
unset($tracking_topics['f']); unset($tracking_topics['f']);
$tracking_topics['l'] = base_convert(time() - $config['board_startdate'], 10, 36); $tracking_topics['l'] = base_convert(time() - $config['board_startdate'], 10, 36);
$user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000); $user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000);
$_COOKIE[$config['cookie_name'] . '_track'] = (STRIP) ? addslashes(tracking_serialize($tracking_topics)) : tracking_serialize($tracking_topics); $_COOKIE[$config['cookie_name'] . '_track'] = (STRIP) ? addslashes(tracking_serialize($tracking_topics)) : tracking_serialize($tracking_topics);
@ -1016,7 +1016,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
{ {
$mark_time[$forum_id] = $forum_mark_time[$forum_id]; $mark_time[$forum_id] = $forum_mark_time[$forum_id];
} }
$user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark'];
foreach ($topic_ids as $topic_id) foreach ($topic_ids as $topic_id)
@ -1064,7 +1064,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$last_read[$row['topic_id']] = $row['mark_time']; $last_read[$row['topic_id']] = $row['mark_time'];
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$topic_ids = array_diff($topic_ids, array_keys($last_read)); $topic_ids = array_diff($topic_ids, array_keys($last_read));
if (sizeof($topic_ids)) if (sizeof($topic_ids))
@ -1075,7 +1075,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
AND forum_id " . AND forum_id " .
(($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id"); (($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id");
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$mark_time = array(); $mark_time = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
@ -1346,7 +1346,7 @@ function tracking_unserialize($string, $max_depth = 3)
break; break;
} }
break; break;
case 2: case 2:
switch ($string[$i]) switch ($string[$i])
{ {
@ -1364,7 +1364,7 @@ function tracking_unserialize($string, $max_depth = 3)
break; break;
} }
break; break;
case 3: case 3:
switch ($string[$i]) switch ($string[$i])
{ {
@ -1388,7 +1388,7 @@ function tracking_unserialize($string, $max_depth = 3)
{ {
die('Invalid data supplied'); die('Invalid data supplied');
} }
return $level; return $level;
} }
@ -1606,7 +1606,7 @@ function generate_board_url($without_script_path = false)
{ {
global $config, $user; global $config, $user;
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); $server_name = $user->host;
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
// Forcing server vars is the only way to specify/override the protocol // Forcing server vars is the only way to specify/override the protocol
@ -1630,7 +1630,11 @@ function generate_board_url($without_script_path = false)
if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80))) if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80)))
{ {
$url .= ':' . $server_port; // HTTP HOST can carry a port number...
if (strpos($server_name, ':') === false)
{
$url .= ':' . $server_port;
}
} }
if (!$without_script_path) if (!$without_script_path)
@ -1871,7 +1875,7 @@ function build_url($strip_vars = false)
unset($query[$strip]); unset($query[$strip]);
} }
} }
// Glue the remaining parts together... already urlencoded // Glue the remaining parts together... already urlencoded
foreach ($query as $key => $value) foreach ($query as $key => $value)
{ {
@ -1943,7 +1947,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
{ {
$minimum_time = (int) $config['form_token_mintime']; $minimum_time = (int) $config['form_token_mintime'];
} }
if (isset($_POST['creation_time']) && isset($_POST['form_token'])) if (isset($_POST['creation_time']) && isset($_POST['form_token']))
{ {
$creation_time = abs(request_var('creation_time', 0)); $creation_time = abs(request_var('creation_time', 0));
@ -1954,7 +1958,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
if (($diff >= $minimum_time) && (($diff <= $timespan) || $timespan == -1)) if (($diff >= $minimum_time) && (($diff <= $timespan) || $timespan == -1))
{ {
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid); $key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
if ($key === $token) if ($key === $token)
{ {
@ -2252,7 +2256,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{ {
$err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); $err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
} }
break; break;
} }
} }
@ -2389,7 +2393,7 @@ function login_forum_box($forum_data)
$template->set_filenames(array( $template->set_filenames(array(
'body' => 'login_forum.html') 'body' => 'login_forum.html')
); );
page_footer(); page_footer();
} }
@ -2488,10 +2492,10 @@ function parse_cfg_file($filename, $lines = false)
{ {
$value = substr($value, 1, sizeof($value)-2); $value = substr($value, 1, sizeof($value)-2);
} }
$parsed_items[$key] = $value; $parsed_items[$key] = $value;
} }
return $parsed_items; return $parsed_items;
} }
@ -2518,13 +2522,13 @@ function add_log()
'log_operation' => $action, 'log_operation' => $action,
'log_data' => $data, 'log_data' => $data,
); );
switch ($mode) switch ($mode)
{ {
case 'admin': case 'admin':
$sql_ary['log_type'] = LOG_ADMIN; $sql_ary['log_type'] = LOG_ADMIN;
break; break;
case 'mod': case 'mod':
$sql_ary += array( $sql_ary += array(
'log_type' => LOG_MOD, 'log_type' => LOG_MOD,
@ -2543,7 +2547,7 @@ function add_log()
case 'critical': case 'critical':
$sql_ary['log_type'] = LOG_CRITICAL; $sql_ary['log_type'] = LOG_CRITICAL;
break; break;
default: default:
return false; return false;
} }
@ -2868,9 +2872,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo ' <div class="panel">'; echo ' <div class="panel">';
echo ' <div id="content">'; echo ' <div id="content">';
echo ' <h1>' . $msg_title . '</h1>'; echo ' <h1>' . $msg_title . '</h1>';
echo ' <div>' . $msg_text . '</div>'; echo ' <div>' . $msg_text . '</div>';
echo $l_notify; echo $l_notify;
echo ' </div>'; echo ' </div>';
@ -2882,7 +2886,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo '</div>'; echo '</div>';
echo '</body>'; echo '</body>';
echo '</html>'; echo '</html>';
exit_handler(); exit_handler();
break; break;
@ -2932,7 +2936,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
// We do not want the cron script to be called on error messages // We do not want the cron script to be called on error messages
define('IN_CRON', true); define('IN_CRON', true);
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
{ {
adm_page_footer(); adm_page_footer();
@ -2962,7 +2966,7 @@ function page_header($page_title = '', $display_online_list = true)
{ {
return; return;
} }
define('HEADER_INC', true); define('HEADER_INC', true);
// gzip_compression // gzip_compression
@ -3189,14 +3193,14 @@ function page_header($page_title = '', $display_online_list = true)
// Which timezone? // Which timezone?
$tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone'])); $tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone']));
// Send a proper content-language to the output // Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG']; $user_lang = $user->lang['USER_LANG'];
if (strpos($user_lang, '-x-') !== false) if (strpos($user_lang, '-x-') !== false)
{ {
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
} }
// The following assigns all _common_ variables that may be used at any point in a template. // The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array( $template->assign_vars(array(
'SITENAME' => $config['sitename'], 'SITENAME' => $config['sitename'],
@ -3345,7 +3349,7 @@ function page_footer($run_cron = true)
if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) if (!defined('IN_CRON') && $run_cron && !$config['board_disable'])
{ {
$cron_type = ''; $cron_type = '';
if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
{ {
// Process email queue // Process email queue

View file

@ -59,7 +59,7 @@ class p_master
WHERE module_class = '" . $db->sql_escape($this->p_class) . "' WHERE module_class = '" . $db->sql_escape($this->p_class) . "'
ORDER BY left_id ASC"; ORDER BY left_id ASC";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$rows = array(); $rows = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
@ -114,7 +114,7 @@ class p_master
unset($this->module_cache['modules'][$key]); unset($this->module_cache['modules'][$key]);
continue; continue;
} }
$right_id = false; $right_id = false;
} }
@ -147,7 +147,7 @@ class p_master
{ {
continue; continue;
} }
$right_id = false; $right_id = false;
} }
@ -194,7 +194,7 @@ class p_master
$custom_func = '_module_' . $row['module_basename']; $custom_func = '_module_' . $row['module_basename'];
$names[$row['module_basename'] . '_' . $row['module_mode']][] = true; $names[$row['module_basename'] . '_' . $row['module_mode']][] = true;
$module_row = array( $module_row = array(
'depth' => $depth, 'depth' => $depth,
@ -209,7 +209,7 @@ class p_master
'display' => (int) $row['module_display'], 'display' => (int) $row['module_display'],
'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '', 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '',
'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']),
'langname' => $row['module_langname'], 'langname' => $row['module_langname'],
@ -309,7 +309,7 @@ class p_master
break; break;
default: default:
if (!preg_match('#(?:acl_([a-z_]+)(,\$id)?)|(?:\$id)|(?:aclf_([a-z_]+))|(?:cfg_([a-z_]+))|(?:request_([a-z_]+))#', $token)) if (!preg_match('#(?:acl_([a-z0-9_]+)(,\$id)?)|(?:\$id)|(?:aclf_([a-z0-9_]+))|(?:cfg_([a-z0-9_]+))|(?:request_([a-zA-Z0-9_]+))#', $token))
{ {
$token = ''; $token = '';
} }
@ -325,7 +325,7 @@ class p_master
$forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id; $forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id;
$is_auth = false; $is_auth = false;
eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z_]+)#', '#cfg_([a-z_]+)#', '#request_([a-z_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '!empty($_REQUEST[\'\\1\'])'), $module_auth) . ');'); eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z0-9_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z0-9_]+)#', '#cfg_([a-z0-9_]+)#', '#request_([a-zA-Z0-9_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '!empty($_REQUEST[\'\\1\'])'), $module_auth) . ');');
return $is_auth; return $is_auth;
} }

View file

@ -983,7 +983,7 @@ class bbcode_firstpass extends bbcode
// Is the user trying to link to a php file in this domain and script path? // Is the user trying to link to a php file in this domain and script path?
if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false) if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false)
{ {
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); $server_name = $user->host;
// Forcing server vars is the only way to specify/override the protocol // Forcing server vars is the only way to specify/override the protocol
if ($config['force_server_vars'] || !$server_name) if ($config['force_server_vars'] || !$server_name)
@ -1084,7 +1084,7 @@ class parse_message extends bbcode_firstpass
if ($config['max_' . $mode . '_chars'] > 0) if ($config['max_' . $mode . '_chars'] > 0)
{ {
$msg_len = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)); $msg_len = ($mode == 'post') ? utf8_strlen($this->message) : utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message));
if ((!$msg_len && $mode !== 'sig') || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars']) if ((!$msg_len && $mode !== 'sig') || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars'])
{ {
$this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, $config['max_' . $mode . '_chars']); $this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, $config['max_' . $mode . '_chars']);
@ -1254,12 +1254,11 @@ class parse_message extends bbcode_firstpass
$match = $replace = array(); $match = $replace = array();
// NOTE: obtain_* function? chaching the table contents? // NOTE: obtain_* function? chaching the table contents?
// For now setting the ttl to 10 minutes // For now setting the ttl to 10 minutes
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . SMILIES_TABLE . ' FROM ' . SMILIES_TABLE . '
ORDER BY ' . $db->sql_function('length_varchar', 'code') . ' DESC'; ORDER BY ' . $db->sql_function('length_varchar', 'code') . ' DESC';
$result = $db->sql_query($sql, 600); $result = $db->sql_query($sql, 600);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))

View file

@ -158,7 +158,7 @@ class session
$this->update_session_page = $update_session_page; $this->update_session_page = $update_session_page;
$this->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; $this->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
$this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; $this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$this->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) $_SERVER['HTTP_HOST'] : 'localhost'; $this->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$this->page = $this->extract_current_page($phpbb_root_path); $this->page = $this->extract_current_page($phpbb_root_path);
// if the forwarded for header shall be checked we have to validate its contents // if the forwarded for header shall be checked we have to validate its contents
@ -649,7 +649,7 @@ class session
$this->set_cookie('sid', $this->session_id, $cookie_expire); $this->set_cookie('sid', $this->session_id, $cookie_expire);
unset($cookie_expire); unset($cookie_expire);
$sql = 'SELECT COUNT(session_id) AS sessions $sql = 'SELECT COUNT(session_id) AS sessions
FROM ' . SESSIONS_TABLE . ' FROM ' . SESSIONS_TABLE . '
WHERE session_user_id = ' . (int) $this->data['user_id'] . ' WHERE session_user_id = ' . (int) $this->data['user_id'] . '
@ -777,7 +777,7 @@ class session
global $db, $config; global $db, $config;
$batch_size = 10; $batch_size = 10;
if (!$this->time_now) if (!$this->time_now)
{ {
$this->time_now = time(); $this->time_now = time();
@ -825,7 +825,7 @@ class session
// Less than 10 users, update gc timer ... else we want gc // Less than 10 users, update gc timer ... else we want gc
// called again to delete other sessions // called again to delete other sessions
set_config('session_last_gc', $this->time_now, true); set_config('session_last_gc', $this->time_now, true);
if ($config['max_autologin_time']) if ($config['max_autologin_time'])
{ {
$sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
@ -834,14 +834,14 @@ class session
} }
$this->confirm_gc(); $this->confirm_gc();
} }
return; return;
} }
function confirm_gc($type = 0) function confirm_gc($type = 0)
{ {
global $db, $config; global $db, $config;
$sql = 'SELECT DISTINCT c.session_id $sql = 'SELECT DISTINCT c.session_id
FROM ' . CONFIRM_TABLE . ' c FROM ' . CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id) LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
@ -867,8 +867,8 @@ class session
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
/** /**
* Sets a cookie * Sets a cookie
* *
@ -1479,7 +1479,7 @@ class user extends session
$sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width $sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width
FROM ' . STYLES_IMAGESET_DATA_TABLE . ' FROM ' . STYLES_IMAGESET_DATA_TABLE . '
WHERE imageset_id = ' . $this->theme['imageset_id'] . " WHERE imageset_id = ' . $this->theme['imageset_id'] . "
AND image_filename <> '' AND image_filename <> ''
AND image_lang IN ('" . $db->sql_escape($this->img_lang) . "', '')"; AND image_lang IN ('" . $db->sql_escape($this->img_lang) . "', '')";
$result = $db->sql_query($sql, 3600); $result = $db->sql_query($sql, 3600);

View file

@ -450,7 +450,7 @@ class module
global $db, $template; global $db, $template;
$template->display('body'); $template->display('body');
// Close our DB connection. // Close our DB connection.
if (!empty($db) && is_object($db)) if (!empty($db) && is_object($db))
{ {
@ -493,7 +493,8 @@ class module
*/ */
function redirect($page) function redirect($page)
{ {
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); // HTTP_HOST is having the correct browser url in most cases...
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0; $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
@ -511,7 +512,11 @@ class module
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
{ {
$url .= ':' . $server_port; // HTTP HOST can carry a port number...
if (strpos($server_name, ':') === false)
{
$url .= ':' . $server_port;
}
} }
$url .= $script_path . '/' . $page; $url .= $script_path . '/' . $page;
@ -535,7 +540,7 @@ class module
$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat); $l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
$cat = strtolower($cat); $cat = strtolower($cat);
$url = $this->module_url . "?mode=$cat&amp;language=$language"; $url = $this->module_url . "?mode=$cat&amp;language=$language";
if ($this->mode == $cat) if ($this->mode == $cat)
{ {
$template->assign_block_vars('t_block1', array( $template->assign_block_vars('t_block1', array(

View file

@ -77,7 +77,7 @@ class install_install extends module
case 'database': case 'database':
$this->obtain_database_settings($mode, $sub); $this->obtain_database_settings($mode, $sub);
break; break;
case 'administrator': case 'administrator':
@ -87,7 +87,7 @@ class install_install extends module
case 'config_file': case 'config_file':
$this->create_config_file($mode, $sub); $this->create_config_file($mode, $sub);
break; break;
case 'advanced': case 'advanced':
@ -105,7 +105,7 @@ class install_install extends module
$this->add_language($mode, $sub); $this->add_language($mode, $sub);
$this->add_bots($mode, $sub); $this->add_bots($mode, $sub);
$this->email_admin($mode, $sub); $this->email_admin($mode, $sub);
// Remove the lock file // Remove the lock file
@unlink($phpbb_root_path . 'cache/install_lock'); @unlink($phpbb_root_path . 'cache/install_lock');
@ -184,8 +184,8 @@ class install_install extends module
'S_EXPLAIN' => true, 'S_EXPLAIN' => true,
'S_LEGEND' => false, 'S_LEGEND' => false,
)); ));
// Check for url_fopen // Check for url_fopen
if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on')
{ {
@ -204,8 +204,8 @@ class install_install extends module
'S_EXPLAIN' => true, 'S_EXPLAIN' => true,
'S_LEGEND' => false, 'S_LEGEND' => false,
)); ));
// Check for getimagesize // Check for getimagesize
if (@function_exists('getimagesize')) if (@function_exists('getimagesize'))
{ {
@ -822,7 +822,7 @@ class install_install extends module
$s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
} }
} }
$s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; $s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
@ -927,7 +927,7 @@ class install_install extends module
$config_data .= "@define('DEBUG', true);\n"; $config_data .= "@define('DEBUG', true);\n";
$config_data .= "@define('DEBUG_EXTRA', true);\n"; $config_data .= "@define('DEBUG_EXTRA', true);\n";
$config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
// Attempt to write out the config file directly. If it works, this is the easiest way to do it ... // Attempt to write out the config file directly. If it works, this is the easiest way to do it ...
if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) || is_writable($phpbb_root_path)) if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) || is_writable($phpbb_root_path))
{ {
@ -1038,8 +1038,11 @@ class install_install extends module
$s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
$s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
// HTTP_HOST is having the correct browser url in most cases...
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true; $data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;
$data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name;
$data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT')); $data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'));
$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'); $data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false); $data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false);
@ -1129,7 +1132,9 @@ class install_install extends module
$this->p_master->redirect("index.$phpEx?mode=install"); $this->p_master->redirect("index.$phpEx?mode=install");
} }
$cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); // HTTP_HOST is having the correct browser url in most cases...
$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name;
// Try to come up with the best solution for cookie domain... // Try to come up with the best solution for cookie domain...
if (strpos($cookie_domain, 'www.') === 0) if (strpos($cookie_domain, 'www.') === 0)
@ -1327,11 +1332,11 @@ class install_install extends module
'UPDATE ' . $data['table_prefix'] . "config 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . $db->sql_escape($data['admin_name']) . "' SET config_value = '" . $db->sql_escape($data['admin_name']) . "'
WHERE config_name = 'newest_username'", WHERE config_name = 'newest_username'",
'UPDATE ' . $data['table_prefix'] . "config 'UPDATE ' . $data['table_prefix'] . "config
SET config_value = '" . md5(mt_rand()) . "' SET config_value = '" . md5(mt_rand()) . "'
WHERE config_name = 'avatar_salt'", WHERE config_name = 'avatar_salt'",
'UPDATE ' . $data['table_prefix'] . "users 'UPDATE ' . $data['table_prefix'] . "users
SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . hexdec(crc32($data['board_email1']) . strlen($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "' SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . hexdec(crc32($data['board_email1']) . strlen($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'
WHERE username = 'Admin'", WHERE username = 'Admin'",
@ -1590,7 +1595,7 @@ class install_install extends module
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 4); $_module->move_module_by($row, 'move_up', 4);
// Move permissions intro screen module 4 up... // Move permissions intro screen module 4 up...
@ -1602,7 +1607,7 @@ class install_install extends module
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 4); $_module->move_module_by($row, 'move_up', 4);
// Move manage users screen module 5 up... // Move manage users screen module 5 up...
@ -1614,7 +1619,7 @@ class install_install extends module
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 5); $_module->move_module_by($row, 'move_up', 5);
} }
@ -1629,7 +1634,7 @@ class install_install extends module
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
$_module->move_module_by($row, 'move_down', 4); $_module->move_module_by($row, 'move_down', 4);
} }
@ -1854,7 +1859,7 @@ class install_install extends module
'user_dateformat' => $lang['default_dateformat'], 'user_dateformat' => $lang['default_dateformat'],
'user_allow_massemail' => 0, 'user_allow_massemail' => 0,
); );
$user_id = user_add($user_row); $user_id = user_add($user_row);
if (!$user_id) if (!$user_id)