From bbf09989b02dfaee9c3fa57b01c4a5766018a5b7 Mon Sep 17 00:00:00 2001 From: Vic D'Elfant Date: Mon, 7 Jan 2008 13:50:56 +0000 Subject: Same goes for the 3_0_0 branch... Fixed a problem caused by "-x-" variations of a translation, such as fr-x-strict and de-x-sie. We're now sending the main language code to the output so it will at least be a valid language code git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8312 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bf00beb2e1..6f11170172 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3301,6 +3301,13 @@ function page_header($page_title = '', $display_online_list = true) // Which 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 + $user_lang = $user->lang['USER_LANG']; + if (strpos($user_lang, '-x-') !== false) + { + $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. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -3356,7 +3363,7 @@ function page_header($page_title = '', $display_online_list = true) 'S_REGISTERED_USER' => $user->data['is_registered'], 'S_IS_BOT' => $user->data['is_bot'], 'S_USER_PM_POPUP' => $user->optionget('popuppm'), - 'S_USER_LANG' => $user->lang['USER_LANG'], + 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], -- cgit v1.2.1 From c7821700dd36899a53b8afe9f859d7a40a23e7b4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 29 Jan 2008 15:49:15 +0000 Subject: #19955 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8348 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6f11170172..017dfa5c68 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -287,7 +287,7 @@ function phpbb_hash($password) } $random = substr($random, 0, $count); } - + $hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64); if (strlen($hash) == 34) @@ -360,7 +360,7 @@ function _hash_encode64($input, $count, &$itoa64) } $output .= $itoa64[($value >> 12) & 0x3f]; - + if ($i++ >= $count) { break; @@ -836,7 +836,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ unset($tracking_topics['t']); unset($tracking_topics['f']); $tracking_topics['l'] = base_convert(time() - $config['board_startdate'], 10, 36); - + $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); @@ -1129,7 +1129,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ { $mark_time[$forum_id] = $forum_mark_time[$forum_id]; } - + $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; foreach ($topic_ids as $topic_id) @@ -1177,7 +1177,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis $last_read[$row['topic_id']] = $row['mark_time']; } $db->sql_freeresult($result); - + $topic_ids = array_diff($topic_ids, array_keys($last_read)); if (sizeof($topic_ids)) @@ -1188,7 +1188,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis AND forum_id " . (($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id"); $result = $db->sql_query($sql); - + $mark_time = array(); while ($row = $db->sql_fetchrow($result)) { @@ -1459,7 +1459,7 @@ function tracking_unserialize($string, $max_depth = 3) break; } break; - + case 2: switch ($string[$i]) { @@ -1477,7 +1477,7 @@ function tracking_unserialize($string, $max_depth = 3) break; } break; - + case 3: switch ($string[$i]) { @@ -1501,7 +1501,7 @@ function tracking_unserialize($string, $max_depth = 3) { die('Invalid data supplied'); } - + return $level; } @@ -1719,7 +1719,7 @@ function generate_board_url($without_script_path = false) { 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'); // Forcing server vars is the only way to specify/override the protocol @@ -1743,7 +1743,11 @@ function generate_board_url($without_script_path = false) 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) @@ -1984,7 +1988,7 @@ function build_url($strip_vars = false) unset($query[$strip]); } } - + // Glue the remaining parts together... already urlencoded foreach ($query as $key => $value) { @@ -2056,7 +2060,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg { $minimum_time = (int) $config['form_token_mintime']; } - + if (isset($_POST['creation_time']) && isset($_POST['form_token'])) { $creation_time = abs(request_var('creation_time', 0)); @@ -2067,7 +2071,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg if (($diff >= $minimum_time) && (($diff <= $timespan) || $timespan == -1)) { $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); if ($key === $token) { @@ -2365,7 +2369,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']], '', ''); } - + break; } } @@ -2502,7 +2506,7 @@ function login_forum_box($forum_data) $template->set_filenames(array( 'body' => 'login_forum.html') ); - + page_footer(); } @@ -2601,10 +2605,10 @@ function parse_cfg_file($filename, $lines = false) { $value = substr($value, 1, sizeof($value)-2); } - + $parsed_items[$key] = $value; } - + return $parsed_items; } @@ -2631,13 +2635,13 @@ function add_log() 'log_operation' => $action, 'log_data' => $data, ); - + switch ($mode) { case 'admin': $sql_ary['log_type'] = LOG_ADMIN; break; - + case 'mod': $sql_ary += array( 'log_type' => LOG_MOD, @@ -2656,7 +2660,7 @@ function add_log() case 'critical': $sql_ary['log_type'] = LOG_CRITICAL; break; - + default: return false; } @@ -2981,9 +2985,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo '
'; echo '
'; echo '

' . $msg_title . '

'; - + echo '
' . $msg_text . '
'; - + echo $l_notify; echo '
'; @@ -2995,7 +2999,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo '
'; echo ''; echo ''; - + exit_handler(); break; @@ -3045,7 +3049,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // We do not want the cron script to be called on error messages define('IN_CRON', true); - + if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) { adm_page_footer(); @@ -3075,7 +3079,7 @@ function page_header($page_title = '', $display_online_list = true) { return; } - + define('HEADER_INC', true); // gzip_compression @@ -3300,14 +3304,14 @@ function page_header($page_title = '', $display_online_list = true) // Which 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 $user_lang = $user->lang['USER_LANG']; if (strpos($user_lang, '-x-') !== false) { $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. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -3453,7 +3457,7 @@ function page_footer($run_cron = true) if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) { $cron_type = ''; - + if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) { // Process email queue -- cgit v1.2.1 From 325ff1fa1b0f75b7da6a6abbc9d6bbf032bcdedf Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 30 Jan 2008 16:01:15 +0000 Subject: One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.) Although i somehow mistakingly got #20445 and #15249 into it. :/ Removing s_watching_img from watch_topic_forum() function (Bug #20445) Changing order for post review if more than one post affected (Bug #15249) Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479) Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738) Tiny code fixes (Bug #20165, #20025, #19795, #14804) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 017dfa5c68..e31b8d5294 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1359,7 +1359,7 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti while ($row = $db->sql_fetchrow($result)) { - if (!in_array(base_convert($row['topic_id'], 10, 36), array_keys($check_forum))) + if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)])) { $unread = true; break; @@ -2308,7 +2308,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // Something failed, determine what... if ($result['status'] == LOGIN_BREAK) { - trigger_error($result['error_msg'], E_USER_ERROR); + trigger_error($result['error_msg']); } // Special cases... determine @@ -2423,7 +2423,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', )); - page_header($user->lang['LOGIN']); + page_header($user->lang['LOGIN'], false); $template->set_filenames(array( 'body' => 'login_body.html') @@ -2966,14 +2966,14 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo ''; echo ''; echo '' . $msg_title . ''; - echo ''; echo ''; echo ''; @@ -3344,7 +3344,6 @@ function page_header($page_title = '', $display_online_list = true) 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup'), 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), - 'U_MEMBERSLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), 'U_VIEWONLINE' => ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"), @@ -3380,6 +3379,7 @@ function page_header($page_title = '', $display_online_list = true) 'S_DISPLAY_PM' => ($config['allow_privmsg'] && $user->data['is_registered'] && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false, 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, + 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', -- cgit v1.2.1 From f24069d32c39d21037503b0c5d645a5929291f69 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 30 Jan 2008 19:30:58 +0000 Subject: Fixing realpath issues for provider returning the passed value instead of disabling it. This fixes issues with confirm boxes for those hosted on Network Solutions for example. - #20435 many thanks to the reporter for allowing me to debug this on his server. :) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8355 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 281 +++++++++++++++++++++++-------------------- 1 file changed, 148 insertions(+), 133 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e31b8d5294..385a1ea72e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -523,177 +523,175 @@ if (!function_exists('stripos')) } } -if (!function_exists('realpath')) +/** +* Checks if a path ($path) is absolute or relative +* +* @param string $path Path to check absoluteness of +* @return boolean +*/ +function is_absolute($path) { - /** - * Checks if a path ($path) is absolute or relative - * - * @param string $path Path to check absoluteness of - * @return boolean - */ - function is_absolute($path) - { - return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false; - } + return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false; +} - /** - * @author Chris Smith - * @copyright 2006 Project Minerva Team - * @param string $path The path which we should attempt to resolve. - * @return mixed - */ - function phpbb_realpath($path) - { - // Now to perform funky shizzle +/** +* @author Chris Smith +* @copyright 2006 Project Minerva Team +* @param string $path The path which we should attempt to resolve. +* @return mixed +*/ +function phpbb_own_realpath($path) +{ + // Now to perform funky shizzle + + // Switch to use UNIX slashes + $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); + $path_prefix = ''; - // Switch to use UNIX slashes - $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); - $path_prefix = ''; + // Determine what sort of path we have + if (is_absolute($path)) + { + $absolute = true; - // Determine what sort of path we have - if (is_absolute($path)) + if ($path[0] == '/') + { + // Absolute path, *NIX style + $path_prefix = ''; + } + else { + // Absolute path, Windows style + // Remove the drive letter and colon + $path_prefix = $path[0] . ':'; + $path = substr($path, 2); + } + } + else + { + // Relative Path + // Prepend the current working directory + if (function_exists('getcwd')) + { + // This is the best method, hopefully it is enabled! + $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path; $absolute = true; - - if ($path[0] == '/') + if (preg_match('#^[a-z]:#i', $path)) { - // Absolute path, *NIX style - $path_prefix = ''; + $path_prefix = $path[0] . ':'; + $path = substr($path, 2); } else { - // Absolute path, Windows style - // Remove the drive letter and colon - $path_prefix = $path[0] . ':'; - $path = substr($path, 2); + $path_prefix = ''; } } + else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME'])) + { + // Warning: If chdir() has been used this will lie! + // Warning: This has some problems sometime (CLI can create them easily) + $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path; + $absolute = true; + $path_prefix = ''; + } else { - // Relative Path - // Prepend the current working directory - if (function_exists('getcwd')) - { - // This is the best method, hopefully it is enabled! - $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path; - $absolute = true; - if (preg_match('#^[a-z]:#i', $path)) - { - $path_prefix = $path[0] . ':'; - $path = substr($path, 2); - } - else - { - $path_prefix = ''; - } - } - else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME'])) - { - // Warning: If chdir() has been used this will lie! - // Warning: This has some problems sometime (CLI can create them easily) - $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path; - $absolute = true; - $path_prefix = ''; - } - else - { - // We have no way of getting the absolute path, just run on using relative ones. - $absolute = false; - $path_prefix = '.'; - } + // We have no way of getting the absolute path, just run on using relative ones. + $absolute = false; + $path_prefix = '.'; } + } - // Remove any repeated slashes - $path = preg_replace('#/{2,}#', '/', $path); + // Remove any repeated slashes + $path = preg_replace('#/{2,}#', '/', $path); - // Remove the slashes from the start and end of the path - $path = trim($path, '/'); + // Remove the slashes from the start and end of the path + $path = trim($path, '/'); - // Break the string into little bits for us to nibble on - $bits = explode('/', $path); + // Break the string into little bits for us to nibble on + $bits = explode('/', $path); - // Remove any . in the path, renumber array for the loop below - $bits = array_values(array_diff($bits, array('.'))); + // Remove any . in the path, renumber array for the loop below + $bits = array_values(array_diff($bits, array('.'))); - // Lets get looping, run over and resolve any .. (up directory) - for ($i = 0, $max = sizeof($bits); $i < $max; $i++) + // Lets get looping, run over and resolve any .. (up directory) + for ($i = 0, $max = sizeof($bits); $i < $max; $i++) + { + // @todo Optimise + if ($bits[$i] == '..' ) { - // @todo Optimise - if ($bits[$i] == '..' ) + if (isset($bits[$i - 1])) { - if (isset($bits[$i - 1])) - { - if ($bits[$i - 1] != '..') - { - // We found a .. and we are able to traverse upwards, lets do it! - unset($bits[$i]); - unset($bits[$i - 1]); - $i -= 2; - $max -= 2; - $bits = array_values($bits); - } - } - else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute + if ($bits[$i - 1] != '..') { - // We have an absolute path trying to descend above the root of the filesystem - // ... Error! - return false; + // We found a .. and we are able to traverse upwards, lets do it! + unset($bits[$i]); + unset($bits[$i - 1]); + $i -= 2; + $max -= 2; + $bits = array_values($bits); } } + else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute + { + // We have an absolute path trying to descend above the root of the filesystem + // ... Error! + return false; + } } + } - // Prepend the path prefix - array_unshift($bits, $path_prefix); + // Prepend the path prefix + array_unshift($bits, $path_prefix); - $resolved = ''; + $resolved = ''; - $max = sizeof($bits) - 1; + $max = sizeof($bits) - 1; - // Check if we are able to resolve symlinks, Windows cannot. - $symlink_resolve = (function_exists('readlink')) ? true : false; + // Check if we are able to resolve symlinks, Windows cannot. + $symlink_resolve = (function_exists('readlink')) ? true : false; - foreach ($bits as $i => $bit) + foreach ($bits as $i => $bit) + { + if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit"))) { - if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit"))) - { - // Path Exists - if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit"))) - { - // Resolved a symlink. - $resolved = $link . (($i == $max) ? '' : '/'); - continue; - } - } - else + // Path Exists + if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit"))) { - // Something doesn't exist here! - // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic - // return false; + // Resolved a symlink. + $resolved = $link . (($i == $max) ? '' : '/'); + continue; } - $resolved .= $bit . (($i == $max) ? '' : '/'); } - - // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it - // because we must be inside that basedir, the question is where... - // @internal The slash in is_dir() gets around an open_basedir restriction - if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved))) + else { - return false; + // Something doesn't exist here! + // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic + // return false; } + $resolved .= $bit . (($i == $max) ? '' : '/'); + } - // Put the slashes back to the native operating systems slashes - $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved); + // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it + // because we must be inside that basedir, the question is where... + // @internal The slash in is_dir() gets around an open_basedir restriction + if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved))) + { + return false; + } - // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($resolved, -1) == DIRECTORY_SEPARATOR) - { - return substr($resolved, 0, -1); - } + // Put the slashes back to the native operating systems slashes + $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved); - return $resolved; // We got here, in the end! + // Check for DIRECTORY_SEPARATOR at the end (and remove it!) + if (substr($resolved, -1) == DIRECTORY_SEPARATOR) + { + return substr($resolved, 0, -1); } + + return $resolved; // We got here, in the end! } -else + +if (!function_exists('realpath')) { /** * A wrapper for realpath @@ -701,15 +699,32 @@ else */ function phpbb_realpath($path) { - $path = realpath($path); + return phpbb_own_realpath($path); + } +} +else +{ + /** + * A wrapper for realpath + */ + function phpbb_realpath($path) + { + $realpath = realpath($path); + + // Strangely there are provider not disabling realpath but returning strange values. :o + // We at least try to cope with them. + if ($realpath === $path || $realpath === false) + { + return phpbb_own_realpath($path); + } // Check for DIRECTORY_SEPARATOR at the end (and remove it!) - if (substr($path, -1) == DIRECTORY_SEPARATOR) + if (substr($realpath, -1) == DIRECTORY_SEPARATOR) { - return substr($path, 0, -1); + $realpath = substr($realpath, 0, -1); } - return $path; + return $realpath; } } -- cgit v1.2.1 From 0a5c435102dbdfce9b773c5ba4c0a91e42141108 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 11:26:23 +0000 Subject: Fix Custom BBCode {EMAIL}-Token usage - #21155 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8387 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 385a1ea72e..43499e0eea 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2756,7 +2756,7 @@ function get_preg_expression($mode) switch ($mode) { case 'email': - return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*[a-z]+'; + return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; break; case 'bbcode_htm': -- cgit v1.2.1 From 6accc46024d436e69802793956653412cde8f404 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 13:18:33 +0000 Subject: some language/style/code fixes (refer to the diff of the changelog) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8389 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 43499e0eea..a220bd33c6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -198,6 +198,26 @@ function unique_id($extra = 'c') return substr($val, 4, 16); } +/** +* Return formatted string for filesizes +*/ +function get_formatted_filesize($bytes, $add_size_lang = true) +{ + global $user; + + if ($bytes >= pow(2, 20)) + { + return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2); + } + + if ($bytes >= pow(2, 10)) + { + return ($add_size_lang) ? round($bytes / 1024, 2) . ' ' . $user->lang['KIB'] : round($bytes / 1024, 2); + } + + return ($add_size_lang) ? ($bytes) . ' ' . $user->lang['BYTES'] : ($bytes); +} + /** * Determine whether we are approaching the maximum execution time. Should be called once * at the beginning of the script in which it's used. @@ -3451,7 +3471,7 @@ function page_footer($run_cron = true) { global $base_memory_usage; $memory_usage -= $base_memory_usage; - $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']); + $memory_usage = get_formatted_filesize($memory_usage); $debug_output .= ' | Memory Usage: ' . $memory_usage; } -- cgit v1.2.1 From 19c7d7b88172915572e93f2643e34d5f1a79344c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 27 Feb 2008 15:11:07 +0000 Subject: and the API git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8409 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a220bd33c6..2e3da4c204 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2082,7 +2082,7 @@ function add_form_key($form_name) * @param bool $trigger If true, the function will triger an error when encountering an invalid form * @param int $minimum_time The minimum acceptable age for a submitted form in seconds */ -function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false, $minimum_time = false) +function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false) { global $config, $user; @@ -2091,10 +2091,6 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg // we enforce a minimum value of half a minute here. $timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']); } - if ($minimum_time === false) - { - $minimum_time = (int) $config['form_token_mintime']; - } if (isset($_POST['creation_time']) && isset($_POST['form_token'])) { @@ -2103,7 +2099,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg $diff = (time() - $creation_time); - if (($diff >= $minimum_time) && (($diff <= $timespan) || $timespan == -1)) + if (($diff <= $timespan) || $timespan === -1) { $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; -- cgit v1.2.1 From 540879ae41c5f58e693350d8af8c005380417aa3 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 27 Feb 2008 15:25:06 +0000 Subject: git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8412 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2e3da4c204..e4e5d7b335 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2080,7 +2080,6 @@ function add_form_key($form_name) * @param int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting. * @param string $return_page The address for the return link * @param bool $trigger If true, the function will triger an error when encountering an invalid form -* @param int $minimum_time The minimum acceptable age for a submitted form in seconds */ function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false) { -- cgit v1.2.1 From b7ef95ed091580df66da23fc1bca403758645fc3 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 17 Mar 2008 16:25:07 +0000 Subject: This should get rid of the filesorts and temp tables on index (with topic read tracking as exception). Updater still needs testing. Not yet merged to 3.1 #22715 - thanks HoL git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8436 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 337 ++++++++++++++++++++++++++----------------- 1 file changed, 206 insertions(+), 131 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e4e5d7b335..69a9cd5fcc 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3099,188 +3099,263 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } /** -* Generate page header +* Queries the session table to get information about online guests +* @param int $forum_id Limits the search to the forum with this id +* @return int The number of active distinct guest sessions */ -function page_header($page_title = '', $display_online_list = true) +function obtain_guest_count($forum_id = 0) { - global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; - - if (defined('HEADER_INC')) + global $db, $config; + + if ($forum_id) { - return; - } - - define('HEADER_INC', true); - - // gzip_compression - if ($config['gzip_compress']) + $reading_sql = ' AND s.session_forum_id = ' . (int) $f; + } + else { - if (@extension_loaded('zlib') && !headers_sent()) - { - ob_start('ob_gzhandler'); - } + $reading_sql = ''; } + $time = (time() - (intval($config['load_online_time']) * 60)); + + // Get number of online guests - // Generate logged in/logged out status - if ($user->data['user_id'] != ANONYMOUS) + if ($db->sql_layer === 'sqlite') { - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id); - $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); + $sql = 'SELECT COUNT(session_ip) as num_guests + FROM ( + SELECT DISTINCT s.session_ip + FROM ' . SESSIONS_TABLE . ' s + WHERE s.session_user_id = ' . ANONYMOUS . ' + AND s.session_time >= ' . ($time - ((int) ($time % 60))) . + $reading_sql . + ')'; } else { - $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'); - $l_login_logout = $user->lang['LOGIN']; + $sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests + FROM ' . SESSIONS_TABLE . ' s + WHERE s.session_user_id = ' . ANONYMOUS . ' + AND s.session_time >= ' . ($time - ((int) ($time % 60))) . + $reading_sql; } + $result = $db->sql_query($sql, 60); + $guests_online = (int) $db->sql_fetchfield('num_guests'); + $db->sql_freeresult($result); + + return $guests_online; +} - // Last visit date/time - $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; - - // Get users online list ... if required - $l_online_users = $online_userlist = $l_online_record = ''; +/** +* Queries the session table to get information about online users +* @param int $forum_id Limits the search to the forum with this id +* @return array An array containing the ids of online, hidden and visible users, as well as statistical info +*/ +function obtain_users_online($forum_id = 0) +{ + global $db, $config, $user; + $logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0; + $reading_sql = $prev_session_ip = ''; - if ($config['load_online'] && $config['load_online_time'] && $display_online_list) + if ($forum_id !== 0) { - $logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0; - $prev_session_ip = $reading_sql = ''; - - if (!empty($_REQUEST['f'])) - { - $f = request_var('f', 0); + $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; + } + $online_users = array( + 'online_users' => array(), + 'hidden_users' => array(), + 'total_online' => 0, + 'visible_online' => 0, + 'hidden_online' => 0, + 'guests_online' => 0, + ); + if ($config['load_online_guests']) + { + $online_users['guests_online'] = obtain_guest_count($forum_id); + } + + // a little discrete magic to cache this for 30 seconds + $time = (time() - (intval($config['load_online_time']) * 60)); + $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline + FROM ' . SESSIONS_TABLE . ' s + WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . + $reading_sql . + ' AND s.session_user_id <> ' . ANONYMOUS; + $result = $db->sql_query($sql, 30); - $reading_sql = ' AND s.session_page ' . $db->sql_like_expression("{$db->any_char}_f_={$f}x{$db->any_char}"); - } + while ($row = $db->sql_fetchrow($result)) + { - // Get number of online guests - if (!$config['load_online_guests']) + // Skip multiple sessions for one user + if (!isset($online_users['online_users'][$row['session_user_id']])) { - if ($db->sql_layer === 'sqlite') + $online_users['online_users'][$row['session_user_id']] = $row['session_user_id']; + if ($row['session_viewonline']) { - $sql = 'SELECT COUNT(session_ip) as num_guests - FROM ( - SELECT DISTINCT s.session_ip - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - $reading_sql . - ')'; + $online_users['visible_online']++; } else { - $sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests - FROM ' . SESSIONS_TABLE . ' s - WHERE s.session_user_id = ' . ANONYMOUS . ' - AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . - $reading_sql; + $online_users['hidden_users'][$row['session_user_id']] = $row['session_user_id']; + $online_users['hidden_online']++; } - $result = $db->sql_query($sql); - $guests_online = (int) $db->sql_fetchfield('num_guests'); - $db->sql_freeresult($result); } + } + $online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online']; + $db->sql_freeresult($result); + + return $online_users; +} - $sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_viewonline - FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s - WHERE s.session_time >= ' . (time() - (intval($config['load_online_time']) * 60)) . - $reading_sql . - ((!$config['load_online_guests']) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . ' - AND u.user_id = s.session_user_id - ORDER BY u.username_clean ASC, s.session_ip ASC'; - $result = $db->sql_query($sql); +/** +* Uses the result of obtain_users_online to generate a localized, readable representation. +* @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics +* @param int $forum_id Indicate that the data is limited to one forum and not global. +* @return array An array containing the string for output to the template +*/ +function obtain_users_online_string($online_users, $forum_id = 0) +{ + global $db, $user, $auth; + $user_online_link = $online_userlist = ''; + + if (count($online_users['online_users'])) + { + $sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour + FROM ' . USERS_TABLE . ' u + WHERE ' . $db->sql_in_set('u.user_id', $online_users['online_users']) . ' + ORDER BY u.username_clean ASC'; + $result = $db->sql_query($sql, 100); while ($row = $db->sql_fetchrow($result)) { // User is logged in and therefore not a guest if ($row['user_id'] != ANONYMOUS) { - // Skip multiple sessions for one user - if ($row['user_id'] != $prev_user_id) + if (isset($online_users['hidden_users'][$row['user_id']])) { - if ($row['session_viewonline']) - { - $logged_visible_online++; - } - else - { - $row['username'] = '' . $row['username'] . ''; - $logged_hidden_online++; - } - - if (($row['session_viewonline']) || $auth->acl_get('u_viewonline')) - { - $user_online_link = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']); - $online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link; - } + $row['username'] = '' . $row['username'] . ''; } - $prev_user_id = $row['user_id']; - } - else - { - // Skip multiple sessions for one user - if ($row['session_ip'] != $prev_session_ip) + if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline')) { - $guests_online++; + $user_online_link = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']); + $online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link; } } - - $prev_session_ip = $row['session_ip']; } $db->sql_freeresult($result); + } - if (!$online_userlist) - { - $online_userlist = $user->lang['NO_ONLINE_USERS']; - } + if (!$online_userlist) + { + $online_userlist = $user->lang['NO_ONLINE_USERS']; + } - if (empty($_REQUEST['f'])) - { - $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; - } - else + if ($forum_id === 0) + { + $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; + } + else + { + $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS']; + $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); + } + + // Build online listing + $vars_online = array( + 'ONLINE' => array('total_online', 'l_t_user_s'), + 'REG' => array('visible_online', 'l_r_user_s'), + 'HIDDEN' => array('hidden_online', 'l_h_user_s'), + 'GUEST' => array('guests_online', 'l_g_user_s') + ); + + foreach ($vars_online as $l_prefix => $var_ary) + { + switch ($online_users[$var_ary[0]]) { - $l_online = ($guests_online == 1) ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS']; - $online_userlist = sprintf($l_online, $online_userlist, $guests_online); + case 0: + ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL']; + break; + + case 1: + ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL']; + break; + + default: + ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL']; + break; } + } + unset($vars_online); - $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; + $l_online_users = sprintf($l_t_user_s, $online_users['total_online']); + $l_online_users .= sprintf($l_r_user_s, $online_users['visible_online']); + $l_online_users .= sprintf($l_h_user_s, $online_users['hidden_online']); + $l_online_users .= sprintf($l_g_user_s, $online_users['guests_online']); - if ($total_online_users > $config['record_online_users']) + return array( + 'online_userlist' => $online_userlist, + 'l_online_users' => $l_online_users, + ); +} + + +/** +* Generate page header +*/ +function page_header($page_title = '', $display_online_list = true) +{ + global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; + + if (defined('HEADER_INC')) + { + return; + } + + define('HEADER_INC', true); + + // gzip_compression + if ($config['gzip_compress']) + { + if (@extension_loaded('zlib') && !headers_sent()) { - set_config('record_online_users', $total_online_users, true); - set_config('record_online_date', time(), true); + ob_start('ob_gzhandler'); } + } + + // Generate logged in/logged out status + if ($user->data['user_id'] != ANONYMOUS) + { + $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id); + $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); + } + else + { + $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'); + $l_login_logout = $user->lang['LOGIN']; + } - // Build online listing - $vars_online = array( - 'ONLINE' => array('total_online_users', 'l_t_user_s'), - 'REG' => array('logged_visible_online', 'l_r_user_s'), - 'HIDDEN' => array('logged_hidden_online', 'l_h_user_s'), - 'GUEST' => array('guests_online', 'l_g_user_s') - ); + // Last visit date/time + $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; - foreach ($vars_online as $l_prefix => $var_ary) - { - switch (${$var_ary[0]}) - { - case 0: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL']; - break; + // Get users online list ... if required + $l_online_users = $online_userlist = $l_online_record = ''; - case 1: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL']; - break; + if ($config['load_online'] && $config['load_online_time'] && $display_online_list) + { + + $f = request_var('f', 0); + $f = max($f, 0); + $online_users = obtain_users_online($f); + $user_online_strings = obtain_users_online_string($online_users, $f); + $l_online_users = $user_online_strings['l_online_users']; + $online_userlist = $user_online_strings['online_userlist']; + $total_online_users = $online_users['total_online']; - default: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL']; - break; - } + if ($total_online_users > $config['record_online_users']) + { + set_config('record_online_users', $total_online_users, true); + set_config('record_online_date', time(), true); } - unset($vars_online); - - $l_online_users = sprintf($l_t_user_s, $total_online_users); - $l_online_users .= sprintf($l_r_user_s, $logged_visible_online); - $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); - $l_online_users .= sprintf($l_g_user_s, $guests_online); $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); -- cgit v1.2.1 From afba17e5620891c54b606e218163a5845262bada Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 17 Mar 2008 22:17:35 +0000 Subject: meh git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8437 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 69a9cd5fcc..6d05ddabe5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3109,7 +3109,7 @@ function obtain_guest_count($forum_id = 0) if ($forum_id) { - $reading_sql = ' AND s.session_forum_id = ' . (int) $f; + $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; } else { -- cgit v1.2.1 From 221001a6dc86c7cd9246b6614adb24c1d88c0067 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 10:14:37 +0000 Subject: - some changes to the recent session change - display errors on inserting sessions - fix database updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8438 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6d05ddabe5..886ea7197f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3154,12 +3154,13 @@ function obtain_users_online($forum_id = 0) { global $db, $config, $user; $logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0; - $reading_sql = $prev_session_ip = ''; + $reading_sql = ''; if ($forum_id !== 0) { $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; } + $online_users = array( 'online_users' => array(), 'hidden_users' => array(), @@ -3168,6 +3169,7 @@ function obtain_users_online($forum_id = 0) 'hidden_online' => 0, 'guests_online' => 0, ); + if ($config['load_online_guests']) { $online_users['guests_online'] = obtain_guest_count($forum_id); @@ -3175,6 +3177,7 @@ function obtain_users_online($forum_id = 0) // a little discrete magic to cache this for 30 seconds $time = (time() - (intval($config['load_online_time']) * 60)); + $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline FROM ' . SESSIONS_TABLE . ' s WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . @@ -3184,7 +3187,6 @@ function obtain_users_online($forum_id = 0) while ($row = $db->sql_fetchrow($result)) { - // Skip multiple sessions for one user if (!isset($online_users['online_users'][$row['session_user_id']])) { @@ -3217,7 +3219,7 @@ function obtain_users_online_string($online_users, $forum_id = 0) global $db, $user, $auth; $user_online_link = $online_userlist = ''; - if (count($online_users['online_users'])) + if (sizeof($online_users['online_users'])) { $sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour FROM ' . USERS_TABLE . ' u @@ -3225,15 +3227,21 @@ function obtain_users_online_string($online_users, $forum_id = 0) ORDER BY u.username_clean ASC'; $result = $db->sql_query($sql, 100); + $userlist_array = array(); while ($row = $db->sql_fetchrow($result)) { - // User is logged in and therefore not a guest - if ($row['user_id'] != ANONYMOUS) + // Skip multiple sessions for one user + if ($row['user_id'] != $prev_user_id) { if (isset($online_users['hidden_users'][$row['user_id']])) { $row['username'] = '' . $row['username'] . ''; } + else + { + $row['username'] = '' . $row['username'] . ''; + $logged_hidden_online++; + } if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline')) { @@ -3342,11 +3350,11 @@ function page_header($page_title = '', $display_online_list = true) if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { - $f = request_var('f', 0); $f = max($f, 0); $online_users = obtain_users_online($f); $user_online_strings = obtain_users_online_string($online_users, $f); + $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; $total_online_users = $online_users['total_online']; @@ -3414,7 +3422,7 @@ function page_header($page_title = '', $display_online_list = true) $user_lang = $user->lang['USER_LANG']; 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. -- cgit v1.2.1 From 2138667953c04edab862de7ec9019989e5eef157 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 10:21:27 +0000 Subject: hmm, still bugs there git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8439 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 886ea7197f..79d20f1c8e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3153,9 +3153,8 @@ function obtain_guest_count($forum_id = 0) function obtain_users_online($forum_id = 0) { global $db, $config, $user; - $logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0; - $reading_sql = ''; + $reading_sql = ''; if ($forum_id !== 0) { $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; @@ -3217,8 +3216,10 @@ function obtain_users_online($forum_id = 0) function obtain_users_online_string($online_users, $forum_id = 0) { global $db, $user, $auth; + $user_online_link = $online_userlist = ''; - + $prev_user_id = 0; + if (sizeof($online_users['online_users'])) { $sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour @@ -3239,8 +3240,7 @@ function obtain_users_online_string($online_users, $forum_id = 0) } else { - $row['username'] = '' . $row['username'] . ''; - $logged_hidden_online++; + $row['username'] = $row['username']; } if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline')) -- cgit v1.2.1 From d1d12ec9861deaf4b850cd1168182471c2712512 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 11:10:56 +0000 Subject: grr git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8440 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 79d20f1c8e..283ab94cf3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3238,10 +3238,6 @@ function obtain_users_online_string($online_users, $forum_id = 0) { $row['username'] = '' . $row['username'] . ''; } - else - { - $row['username'] = $row['username']; - } if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline')) { -- cgit v1.2.1 From a3b98e510e63a270985d478c4a5a2f43cbbcead6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 11:58:34 +0000 Subject: i somehow mixed my local copy with the changes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8442 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 283ab94cf3..0b79cffda3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3159,7 +3159,7 @@ function obtain_users_online($forum_id = 0) { $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; } - +$config['load_online_time'] = 500000; $online_users = array( 'online_users' => array(), 'hidden_users' => array(), @@ -3182,21 +3182,21 @@ function obtain_users_online($forum_id = 0) WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . $reading_sql . ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql, 30); + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { // Skip multiple sessions for one user if (!isset($online_users['online_users'][$row['session_user_id']])) { - $online_users['online_users'][$row['session_user_id']] = $row['session_user_id']; + $online_users['online_users'][$row['session_user_id']] = (int) $row['session_user_id']; if ($row['session_viewonline']) { $online_users['visible_online']++; } else { - $online_users['hidden_users'][$row['session_user_id']] = $row['session_user_id']; + $online_users['hidden_users'][$row['session_user_id']] = (int) $row['session_user_id']; $online_users['hidden_online']++; } } @@ -3218,21 +3218,19 @@ function obtain_users_online_string($online_users, $forum_id = 0) global $db, $user, $auth; $user_online_link = $online_userlist = ''; - $prev_user_id = 0; if (sizeof($online_users['online_users'])) { - $sql = 'SELECT u.username, u.username_clean, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour - FROM ' . USERS_TABLE . ' u - WHERE ' . $db->sql_in_set('u.user_id', $online_users['online_users']) . ' - ORDER BY u.username_clean ASC'; - $result = $db->sql_query($sql, 100); + $sql = 'SELECT username, username_clean, user_id, user_type, user_allow_viewonline, user_colour + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $online_users['online_users']) . ' + ORDER BY username_clean ASC'; + $result = $db->sql_query($sql); - $userlist_array = array(); while ($row = $db->sql_fetchrow($result)) { - // Skip multiple sessions for one user - if ($row['user_id'] != $prev_user_id) + // User is logged in and therefore not a guest + if ($row['user_id'] != ANONYMOUS) { if (isset($online_users['hidden_users'][$row['user_id']])) { -- cgit v1.2.1 From 6da288aace3df1e2fcf4c06c8a467cf29922f07d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 12:03:33 +0000 Subject: i think i will stop committing thinks today. :/ git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8443 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0b79cffda3..5622b2dd6c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3159,7 +3159,7 @@ function obtain_users_online($forum_id = 0) { $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; } -$config['load_online_time'] = 500000; + $online_users = array( 'online_users' => array(), 'hidden_users' => array(), @@ -3182,7 +3182,7 @@ $config['load_online_time'] = 500000; WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . $reading_sql . ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql); + $result = $db->sql_query($sql, 30); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From 274bd147ca29d61db26d3a0e5c717f4a5ab36d3d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 13:49:54 +0000 Subject: Allow & and | in local part of email addresses - #22995 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8447 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5622b2dd6c..e61df309b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2771,7 +2771,7 @@ function get_preg_expression($mode) switch ($mode) { case 'email': - return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; + return '(?:[a-z0-9\'\.\-_\+\|]|&)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; break; case 'bbcode_htm': -- cgit v1.2.1 From 976e83351a2c7e784e4968722dee40f59e6932b1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 27 Mar 2008 13:17:58 +0000 Subject: #24105 - Quite compliacted lang changes, translators will complain :| git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8474 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e61df309b3..6363dd0264 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3215,7 +3215,7 @@ function obtain_users_online($forum_id = 0) */ function obtain_users_online_string($online_users, $forum_id = 0) { - global $db, $user, $auth; + global $config, $db, $user, $auth; $user_online_link = $online_userlist = ''; @@ -3256,34 +3256,45 @@ function obtain_users_online_string($online_users, $forum_id = 0) { $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; } - else + else if ($config['load_online_guests']) { $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS']; $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); } - + else + { + $online_userlist = sprintf($user->lang['BROWSING_FORUM'], $online_userlist); + } // Build online listing $vars_online = array( - 'ONLINE' => array('total_online', 'l_t_user_s'), - 'REG' => array('visible_online', 'l_r_user_s'), - 'HIDDEN' => array('hidden_online', 'l_h_user_s'), - 'GUEST' => array('guests_online', 'l_g_user_s') + 'ONLINE' => array('total_online', 'l_t_user_s', 0), + 'REG' => array('visible_online', 'l_r_user_s', !$config['load_online_guests']), + 'HIDDEN' => array('hidden_online', 'l_h_user_s', $config['load_online_guests']), + 'GUEST' => array('guests_online', 'l_g_user_s', 0) ); foreach ($vars_online as $l_prefix => $var_ary) { + if ($var_ary[2]) + { + $l_suffix = '_AND'; + } + else + { + $l_suffix = ''; + } switch ($online_users[$var_ary[0]]) { case 0: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL']; + ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL' . $l_suffix]; break; case 1: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL']; + ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL' . $l_suffix]; break; default: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL']; + ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL' . $l_suffix]; break; } } @@ -3292,7 +3303,13 @@ function obtain_users_online_string($online_users, $forum_id = 0) $l_online_users = sprintf($l_t_user_s, $online_users['total_online']); $l_online_users .= sprintf($l_r_user_s, $online_users['visible_online']); $l_online_users .= sprintf($l_h_user_s, $online_users['hidden_online']); - $l_online_users .= sprintf($l_g_user_s, $online_users['guests_online']); + + if ($config['load_online_guests']) + { + $l_online_users .= sprintf($l_g_user_s, $online_users['guests_online']); + } + + return array( 'online_userlist' => $online_userlist, -- cgit v1.2.1 From b2521b83b1a5c35c4c5df9c90515eb3d90cdab4d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 27 Mar 2008 16:17:54 +0000 Subject: some corrections to let the update work flawlessly. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8475 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6363dd0264..2388ae66b4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3116,8 +3116,8 @@ function obtain_guest_count($forum_id = 0) $reading_sql = ''; } $time = (time() - (intval($config['load_online_time']) * 60)); - - // Get number of online guests + + // Get number of online guests if ($db->sql_layer === 'sqlite') { -- cgit v1.2.1 From ab8177a0338c0d9746d87d97c5b3d9c9b7086aef Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Apr 2008 11:41:58 +0000 Subject: suppress ob_flush() output and flush() at the end (within my tests this solved blank pages on some setups and do not affect gzip compression). git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8491 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2388ae66b4..1baa7abd9a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2945,7 +2945,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { if (@extension_loaded('zlib') && !headers_sent()) { - ob_flush(); + @ob_flush(); } } @@ -3662,6 +3662,9 @@ function exit_handler() } } + // As a pre-caution... some setups display a blank page if the flush() is not there. + @flush(); + exit; } -- cgit v1.2.1 From 5a13f125a61601f2e47b32a4d94ef9c1e0b9e3db Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 10 Apr 2008 15:51:09 +0000 Subject: Remove caching. Ideally, this owuld depend on the current load git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8501 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1baa7abd9a..b6237020f1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3182,7 +3182,7 @@ function obtain_users_online($forum_id = 0) WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . $reading_sql . ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql, 30); + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From 18e7a58f155446c2efd072dd0934565a33a81e66 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 21 Apr 2008 13:05:49 +0000 Subject: did i ever mention that i hate php's handling of buffers (or i simply do not understand them) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8519 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b6237020f1..67ef220c8d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3652,7 +3652,7 @@ function garbage_collection() */ function exit_handler() { - global $phpbb_hook; + global $phpbb_hook, $config; if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__)) { @@ -3663,7 +3663,7 @@ function exit_handler() } // As a pre-caution... some setups display a blank page if the flush() is not there. - @flush(); + (!$config['gzip_compress']) ? @flush() : @ob_flush(); exit; } -- cgit v1.2.1 From 89474a8e3abc4d453b05656faa7048ad10e3320a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 21 Apr 2008 13:36:32 +0000 Subject: we slowly get to it git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8523 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 67ef220c8d..600506d08f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2941,6 +2941,12 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) { // flush the content, else we get a white page if output buffering is on + if (strtolower(@ini_get('output_buffering')) !== 'off') + { + @ob_end_flush(); + } + + // Another quick fix for those having gzip compression enabled if ($config['gzip_compress']) { if (@extension_loaded('zlib') && !headers_sent()) -- cgit v1.2.1 From d0cd2152ff810e2cf724ea206b9a0934e08795e2 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 2 Jun 2008 17:15:43 +0000 Subject: give the ACP a login screen git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8581 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 51 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 600506d08f..f45bfa57b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2234,7 +2234,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { - global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; + global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path, $config; $err = ''; @@ -2243,6 +2243,16 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { $user->setup(); } + + if (defined('ADMIN_START')) + { + // Set custom template for admin area + $template->set_custom_template($phpbb_admin_path . 'style', 'admin'); + $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); + + // the acp template is never stored in the database + $user->theme['template_storedb'] = false; + } // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) @@ -2447,20 +2457,43 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, + 'S_ACP_LOGIN' => defined('ADMIN_START'), 'USERNAME' => ($admin) ? $user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', )); - - page_header($user->lang['LOGIN'], false); - - $template->set_filenames(array( - 'body' => 'login_body.html') - ); + + if (defined('ADMIN_START')) + { + $template->set_filenames(array( + 'body' => 'acp_login.html') + ); + $template->assign_block_vars('t_block1', array( + 'L_TITLE' => $user->lang['LOGIN'], + 'S_SELECTED' => true, + 'U_TITLE' => '', + )); + adm_page_header($user->lang['LOGIN'], false); + } + else + { + $template->set_filenames(array( + 'body' => 'login_body.html') + ); + page_header($user->lang['LOGIN'], false); + } + make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - - page_footer(); + if (defined('ADMIN_START') && isset($user->data['session_admin']) && $user->data['session_admin']) + { + adm_page_footer(); + } + else + { + page_footer(); + } + } /** -- cgit v1.2.1 From 3116f279a16dd8f927c0cb9e2e605afa5a9dfdd7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 3 Jun 2008 16:29:56 +0000 Subject: a little polish git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8585 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f45bfa57b3..f000236027 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2420,7 +2420,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // If we are not within the admin directory we use the page dir... $redirect = ''; - if (!$admin) + if (!$admin && !defined('ADMIN_START')) { $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : ''; } @@ -2453,7 +2453,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_LOGIN_ACTION' => (!$admin) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory + 'S_LOGIN_ACTION' => (!$admin && !defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, @@ -3095,7 +3095,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if (!defined('HEADER_INC')) { - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) + if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])) { adm_page_header($msg_title); } @@ -3119,7 +3119,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // We do not want the cron script to be called on error messages define('IN_CRON', true); - if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) + if (defined('ADMIN_START') || (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])) { adm_page_footer(); } -- cgit v1.2.1 From 80f123acb32eaf4c7a0766ddca916f42f4b01bbe Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 4 Jun 2008 11:40:53 +0000 Subject: Too much for a minor; sorry git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8591 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 59 ++++++++++---------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f000236027..600506d08f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2234,7 +2234,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { - global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path, $config; + global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; $err = ''; @@ -2243,16 +2243,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { $user->setup(); } - - if (defined('ADMIN_START')) - { - // Set custom template for admin area - $template->set_custom_template($phpbb_admin_path . 'style', 'admin'); - $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); - - // the acp template is never stored in the database - $user->theme['template_storedb'] = false; - } // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !$auth->acl_get('a_')) @@ -2420,7 +2410,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // If we are not within the admin directory we use the page dir... $redirect = ''; - if (!$admin && !defined('ADMIN_START')) + if (!$admin) { $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : ''; } @@ -2453,47 +2443,24 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_LOGIN_ACTION' => (!$admin && !defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory + 'S_LOGIN_ACTION' => (!$admin) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, - 'S_ACP_LOGIN' => defined('ADMIN_START'), 'USERNAME' => ($admin) ? $user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', )); - - if (defined('ADMIN_START')) - { - $template->set_filenames(array( - 'body' => 'acp_login.html') - ); - $template->assign_block_vars('t_block1', array( - 'L_TITLE' => $user->lang['LOGIN'], - 'S_SELECTED' => true, - 'U_TITLE' => '', - )); - adm_page_header($user->lang['LOGIN'], false); - } - else - { - $template->set_filenames(array( - 'body' => 'login_body.html') - ); - page_header($user->lang['LOGIN'], false); - } - + + page_header($user->lang['LOGIN'], false); + + $template->set_filenames(array( + 'body' => 'login_body.html') + ); make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); - if (defined('ADMIN_START') && isset($user->data['session_admin']) && $user->data['session_admin']) - { - adm_page_footer(); - } - else - { - page_footer(); - } - + + page_footer(); } /** @@ -3095,7 +3062,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if (!defined('HEADER_INC')) { - if (defined('ADMIN_START') || (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_header($msg_title); } @@ -3119,7 +3086,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // We do not want the cron script to be called on error messages define('IN_CRON', true); - if (defined('ADMIN_START') || (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(); } -- cgit v1.2.1 From 374093d6152ff9ff2b232311bfeeafca43a27915 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 4 Jun 2008 13:39:15 +0000 Subject: ok, well, my team is allowed to give me some slappage. :/ I now changed this sooo often and never realised the code portion is absolute rubbish... with ini_get returning something completely different. Now, this should work (at least for PHP 5.2.x) - tested all 16 possible combinations of triggering errors before and after headers sent, with and without gzip compression, with and without output buffering. Now, please work for others too... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8594 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 600506d08f..ba12fd6e4e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2941,15 +2941,15 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) { // flush the content, else we get a white page if output buffering is on - if (strtolower(@ini_get('output_buffering')) !== 'off') + if ((int) @ini_get('output_buffering') === 1 || strtolower(@ini_get('output_buffering')) === 'on') { - @ob_end_flush(); + @ob_flush(); } - // Another quick fix for those having gzip compression enabled + // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;) if ($config['gzip_compress']) { - if (@extension_loaded('zlib') && !headers_sent()) + if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level()) { @ob_flush(); } -- cgit v1.2.1 From cd058dd9fe9f86aedb1d864ae78a17cd41003987 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 6 Jun 2008 11:27:51 +0000 Subject: Some xenophobia git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8611 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ba12fd6e4e..43e89c10fa 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1829,7 +1829,10 @@ function redirect($url, $return = false) } else if (!empty($url_parts['scheme']) && !empty($url_parts['host'])) { - // Full URL + if ($url_parts['host'] !== $user->host) + { + $url = generate_board_url(true); + } } else if ($url[0] == '/') { @@ -2045,11 +2048,14 @@ function meta_refresh($time, $url) global $template; $url = redirect($url, true); + $url = str_replace('&', '&', $url); // For XHTML compatibility we change back & to & $template->assign_vars(array( - 'META' => '') + 'META' => '') ); + + return $url; } //Form validation @@ -2331,7 +2337,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa return; } - meta_refresh(3, $redirect); + $redirect = meta_refresh(3, $redirect); trigger_error($message . '

' . sprintf($l_redirect, '', '')); } -- cgit v1.2.1 From a7dd393ef155e10bf8f0a33c37dba5b2fb36b2c9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 8 Jun 2008 15:34:04 +0000 Subject: typo git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8622 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 43e89c10fa..861449d787 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1831,7 +1831,7 @@ function redirect($url, $return = false) { if ($url_parts['host'] !== $user->host) { - $url = generate_board_url(true); + $url = generate_board_url(); } } else if ($url[0] == '/') -- cgit v1.2.1 From 406895a1ad75167829740deac3f08779104838fb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 9 Jun 2008 17:05:52 +0000 Subject: #27395 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8636 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 861449d787..0b6e4aafed 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1778,7 +1778,7 @@ function generate_board_url($without_script_path = false) if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80))) { - // HTTP HOST can carry a port number... + // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true) if (strpos($server_name, ':') === false) { $url .= ':' . $server_port; @@ -2054,7 +2054,7 @@ function meta_refresh($time, $url) $template->assign_vars(array( 'META' => '') ); - + return $url; } @@ -3118,16 +3118,16 @@ function msg_handler($errno, $msg_text, $errfile, $errline) function obtain_guest_count($forum_id = 0) { global $db, $config; - + if ($forum_id) { $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; - } + } else { $reading_sql = ''; } - $time = (time() - (intval($config['load_online_time']) * 60)); + $time = (time() - (intval($config['load_online_time']) * 60)); // Get number of online guests @@ -3153,7 +3153,7 @@ function obtain_guest_count($forum_id = 0) $result = $db->sql_query($sql, 60); $guests_online = (int) $db->sql_fetchfield('num_guests'); $db->sql_freeresult($result); - + return $guests_online; } @@ -3185,16 +3185,16 @@ function obtain_users_online($forum_id = 0) { $online_users['guests_online'] = obtain_guest_count($forum_id); } - + // a little discrete magic to cache this for 30 seconds - $time = (time() - (intval($config['load_online_time']) * 60)); + $time = (time() - (intval($config['load_online_time']) * 60)); $sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline FROM ' . SESSIONS_TABLE . ' s WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) . $reading_sql . ' AND s.session_user_id <> ' . ANONYMOUS; - $result = $db->sql_query($sql); + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { @@ -3215,7 +3215,7 @@ function obtain_users_online($forum_id = 0) } $online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online']; $db->sql_freeresult($result); - + return $online_users; } -- cgit v1.2.1 From 4444e48d2e020f67ec95474e6ace413768b85df3 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 9 Jun 2008 22:30:27 +0000 Subject: Regular expression for email matching in posts will no longer die on long words git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8641 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0b6e4aafed..198004957c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2777,7 +2777,7 @@ function get_preg_expression($mode) switch ($mode) { case 'email': - return '(?:[a-z0-9\'\.\-_\+\|]|&)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; + return '(?:[a-z0-9\'\.\-_\+\|]++|&)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; break; case 'bbcode_htm': -- cgit v1.2.1 From 26f51cf5b386c20ecfbbed539aa6e4e0cabef377 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 10 Jun 2008 12:54:30 +0000 Subject: added two comments to describe the functions use-case git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8643 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 198004957c..c7026ce44c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1801,6 +1801,7 @@ function generate_board_url($without_script_path = false) /** * Redirects the user to another page then exits the script nicely +* This function is intended for urls within the board. It's not meant to redirect to cross-domains. */ function redirect($url, $return = false) { @@ -1829,6 +1830,7 @@ function redirect($url, $return = false) } else if (!empty($url_parts['scheme']) && !empty($url_parts['host'])) { + // Attention: only able to redirect within the same domain (yourdomain.com -> www.yourdomain.com will not work) if ($url_parts['host'] !== $user->host) { $url = generate_board_url(); -- cgit v1.2.1 From 31c97676ade8dc18d79f07e749cc38b1186cf7be Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 12 Jun 2008 14:40:03 +0000 Subject: remove the $Id$ line there and instead add valuable information. Oh, and did not know the phpass project catched our implementation of their code. :) Nice to see. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8651 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c7026ce44c..40eb3fa823 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -255,7 +255,7 @@ function still_on_time($extra_time = 15) /** * -* @version Version 0.1 / $Id$ +* @version Version 0.1 / slightly modified for phpBB 3.0.x (using $H$ as hash type identifier) * * Portable PHP password hashing framework. * -- cgit v1.2.1 From 11f27bee84447bf769e10fc7d099bb34209e9c2d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 21 Jun 2008 16:05:02 +0000 Subject: further checks on maximum storage length git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8667 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 40eb3fa823..50e8b8b7fb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -822,7 +822,7 @@ function tz_select($default = '', $truncate = false) { if ($truncate) { - $zone_trunc = truncate_string($zone, 50, false, '...'); + $zone_trunc = truncate_string($zone, 50, 255, false, '...'); } else { -- cgit v1.2.1 From 81886c0eae6857d0b00ffbf1ed8c40ace8e88d57 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 28 Jun 2008 15:07:37 +0000 Subject: New parameter for redirect() to circumvent the cross-domain check. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8674 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 50e8b8b7fb..be3dac3449 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1802,8 +1802,12 @@ function generate_board_url($without_script_path = false) /** * Redirects the user to another page then exits the script nicely * This function is intended for urls within the board. It's not meant to redirect to cross-domains. +* +* @param string $url The url to redirect to +* @param bool $return If true, do not redirect but return the sanitized URL. Default is no return. +* @param bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. */ -function redirect($url, $return = false) +function redirect($url, $return = false, $disable_cd_check = false) { global $db, $cache, $config, $user, $phpbb_root_path; @@ -1830,8 +1834,8 @@ function redirect($url, $return = false) } else if (!empty($url_parts['scheme']) && !empty($url_parts['host'])) { - // Attention: only able to redirect within the same domain (yourdomain.com -> www.yourdomain.com will not work) - if ($url_parts['host'] !== $user->host) + // Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work) + if (!$disable_cd_check && $url_parts['host'] !== $user->host) { $url = generate_board_url(); } -- cgit v1.2.1 From e23fbf48a75432d21347d7d784f729d09e44230a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 28 Jun 2008 17:07:50 +0000 Subject: Bug #29635 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8675 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index be3dac3449..8c194f4fc2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2884,7 +2884,7 @@ function phpbb_checkdnsrr($host, $type = '') } // @exec('nslookup -retry=1 -timout=1 -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output); - @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output); + @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host) . '.', $output); // If output is empty, the nslookup failed if (empty($output)) @@ -2910,7 +2910,8 @@ function phpbb_checkdnsrr($host, $type = '') } else if (function_exists('checkdnsrr')) { - return (checkdnsrr($host, $type)) ? true : false; + // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain) + return (checkdnsrr($host . '.', $type)) ? true : false; } return NULL; -- cgit v1.2.1 From 8904d95d59d14d00fd3cfaf93a357ad68d608586 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 28 Jul 2008 13:26:20 +0000 Subject: tiny alterations/bugfixes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8691 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8c194f4fc2..3f4d2743fc 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -320,6 +320,11 @@ function phpbb_hash($password) /** * Check for correct password +* +* @param string $password The password in plain text +* @param string $hash The stored password hash +* +* @return bool Returns true if the password is correct, false if not. */ function phpbb_check_hash($password, $hash) { -- cgit v1.2.1 From b7fe9f7b8a336c5718686b39b8cdff40e300aff1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 30 Jul 2008 13:56:13 +0000 Subject: cleaning tpl fallbacks up git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8733 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3f4d2743fc..a8e6faa65c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3531,6 +3531,7 @@ function page_header($page_title = '', $display_online_list = true) 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', + 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path'])) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : '', 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", -- cgit v1.2.1 From 2389388c4629b9c1fecc72e8c2007522f9a18721 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 1 Aug 2008 14:29:18 +0000 Subject: fix cookie secure detection... hopefully git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8737 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a8e6faa65c..baff79330e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1771,6 +1771,7 @@ function generate_board_url($without_script_path = false) $script_path = $config['script_path']; $url = $server_protocol . $server_name; + $cookie_secure = $config['cookie_secure']; } else { @@ -1781,7 +1782,7 @@ function generate_board_url($without_script_path = false) $script_path = $user->page['root_script_path']; } - if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80))) + if ($server_port && (($cookie_secure && $server_port <> 443) || (!$cookie_secure && $server_port <> 80))) { // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true) if (strpos($server_name, ':') === false) -- cgit v1.2.1 From 068096531f297d188afea88190cd838ccae662cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 16 Aug 2008 19:06:18 +0000 Subject: the chmod change i already had within the changelog (by mistake). This should further secure writable directories and created files. Installation need to be tested on different hosts. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8763 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 102 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index baff79330e..35a928d0b7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -459,6 +459,108 @@ function _hash_crypt_private($password, $setting, &$itoa64) return $output; } +/** +* Global function for chmodding directories and files. +* This function supports different modes to distinguish between writeable/non-writeable. +* The function sets the appropiate execute bit on directories +* +* Supported modes are: +* +* rread (600): Restrictive, only able to be read/write by the apache/site user. +* Used for files which only need to be accessible by phpBB itself and should never be accessible from the outside/web. +* read (644): Read-only permission for the site group/everyone. Used for ordinary files. +* write (664): Write-permission for the site group, read permission for everyone. Used for writeable files. +* write-all (666): Write-permission for everyone. Should only be used for temporary files. +* +* rwrite (0660): Write-permission only for the site user/group. Used for files phpBB need to write to but within the cache/store/files directory. +* +* NOTE: If rwrite (restrictive write) is used, the function makes sure the file is writable by calling is_writable. If it is not, it falls back to 'write' +* and then to 'write-all' to make sure the file is writable on every host setup. +* NOTE: If rread (restrictive read) is used, the function makes sure the file is readable by calling is_readable. If it is not, it falls back to 'sread' (internal mode 640) and then to 'read'. +* +* @param $filename The file/directory to be chmodded +* @param $mode The mode to set. +* @return True on success, false if the mode was not set +*/ +function phpbb_chmod($filename, $mode = 'read') +{ + switch ($mode) + { + case 'rread': + $chmod = 0600; + break; + + // System-read, only used internally + case 'sread': + $chmod = 0640; + break; + + case 'rwrite': + $chmod = 0660; + break; + + case 'write': + $chmod = 0664; + break; + + case 'write-all': + $chmod = 0666; + break; + + case 'read': + default: + $chmod = 0644; + break; + } + + // Return if the file no longer exist + if (!file_exists($filename)) + { + return false; + } + + // Add the execute bit if it is a directory + if (is_dir($filename)) + { + // This line sets the correct execute bit on those "3-bits" being defined. 0644 becomes 0755 for example. + $chmod |= ($chmod & 7) ? 73 : (($chmod & 56) ? 72 : 64); + } + + // Set mode + $result = @chmod($filename, $chmod); + + // Check for is_writable + if ($mode == 'rwrite') + { + // We are in rwrite mode, so, make sure the file is writable + if (!is_writable($filename)) + { + $result = phpbb_chmod($filename, 'write'); + + if (!is_writable($filename)) + { + $result = phpbb_chmod($filename, 'write-all'); + } + } + } + + // Check for is_readable + if ($mode == 'rread') + { + if (!is_readable($filename)) + { + $result = phpbb_chmod($filename, 'sread'); + + if (!is_readable($filename)) + { + $result = phpbb_chmod($filename, 'read'); + } + } + } + + return $result; +} + // Compatibility functions if (!function_exists('array_combine')) -- cgit v1.2.1 From f56391d5f7d2170397759e26962925635e6a8263 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 21 Aug 2008 15:41:12 +0000 Subject: as per evil3, some more anti-CSRF git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8775 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 35a928d0b7..57423af6b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2174,6 +2174,37 @@ function meta_refresh($time, $url) //Form validation + +/** +* Add a secret hash for use in links/GET requests +* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply +* @param int $length The length of the key to generate +* @return sting the hash + +*/ +function generate_link_hash($link_name) +{ + global $user; + if (!isset($user->data["hash_$link_name"])) + { + $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8); + } + return $user->data["hash_$link_name"]; +} + + +/** +* checks a link hash - for GET requests +* @param string $token the submitted token +* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply +* @param int $length The length of the key to check +* @return boolean true if all is fine +*/ +function check_link_hash($token, $link_name) +{ + return $token === generate_link_hash($link_name); +} + /** * Add a secret token to the form (requires the S_FORM_TOKEN template variable) * @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply -- cgit v1.2.1 From 88c324a2a3d705cd44ce749af44079849ca091e7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 22 Aug 2008 11:00:54 +0000 Subject: comments git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8778 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 57423af6b3..05eef16819 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2177,9 +2177,8 @@ function meta_refresh($time, $url) /** * Add a secret hash for use in links/GET requests -* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply -* @param int $length The length of the key to generate -* @return sting the hash +* @param string $link_name The name of the link; has to match the name used in check_link_hash, otherwise no restrictions apply +* @return string the hash */ function generate_link_hash($link_name) @@ -2196,8 +2195,7 @@ function generate_link_hash($link_name) /** * checks a link hash - for GET requests * @param string $token the submitted token -* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply -* @param int $length The length of the key to check +* @param string $link_name The name of the link * @return boolean true if all is fine */ function check_link_hash($token, $link_name) -- cgit v1.2.1 From 6c763cd8b65c1b63d57fb0f176d2c98a44076df1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 22 Aug 2008 12:52:48 +0000 Subject: change the way we do chmodd'ing. I know, my implementation really sucked... good we have motivated community members who point this out. ;) Thanks to faw for providing a way better function and for discussing and also abiding to our needs. :) LEW21 should maybe credited too... he gave the inspiration without knowing it. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8780 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 166 ++++++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 66 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 05eef16819..aaae41787a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -460,102 +460,136 @@ function _hash_crypt_private($password, $setting, &$itoa64) } /** -* Global function for chmodding directories and files. -* This function supports different modes to distinguish between writeable/non-writeable. -* The function sets the appropiate execute bit on directories +* Global function for chmodding directories and files for internal use +* This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. +* The function determines owner and group from common.php file and sets the same to the provided file. +* The function uses bit fields to build the permissions. +* The function sets the appropiate execute bit on directories. * -* Supported modes are: +* Supported constants representing bit fields are: * -* rread (600): Restrictive, only able to be read/write by the apache/site user. -* Used for files which only need to be accessible by phpBB itself and should never be accessible from the outside/web. -* read (644): Read-only permission for the site group/everyone. Used for ordinary files. -* write (664): Write-permission for the site group, read permission for everyone. Used for writeable files. -* write-all (666): Write-permission for everyone. Should only be used for temporary files. +* CHMOD_ALL - all permissions (7) +* CHMOD_READ - read permission (4) +* CHMOD_WRITE - write permission (2) +* CHMOD_EXECUTE - execute permission (1) * -* rwrite (0660): Write-permission only for the site user/group. Used for files phpBB need to write to but within the cache/store/files directory. -* -* NOTE: If rwrite (restrictive write) is used, the function makes sure the file is writable by calling is_writable. If it is not, it falls back to 'write' -* and then to 'write-all' to make sure the file is writable on every host setup. -* NOTE: If rread (restrictive read) is used, the function makes sure the file is readable by calling is_readable. If it is not, it falls back to 'sread' (internal mode 640) and then to 'read'. +* NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. * * @param $filename The file/directory to be chmodded -* @param $mode The mode to set. -* @return True on success, false if the mode was not set +* @param $perms Permissions to set +* @return true on success, otherwise false +* +* @author faw, phpBB Group */ -function phpbb_chmod($filename, $mode = 'read') +function phpbb_chmod($filename, $perms = CHMOD_READ) { - switch ($mode) + // Return if the file no longer exists. + if (!file_exists($filename)) { - case 'rread': - $chmod = 0600; - break; + return false; + } - // System-read, only used internally - case 'sread': - $chmod = 0640; - break; + if (!function_exists('fileowner') || !function_exists('filegroup')) + { + $file_uid = $file_gid = false; + $common_php_owner = $common_php_group = false; + } + else + { + global $phpbb_root_path, $phpEx; - case 'rwrite': - $chmod = 0660; - break; + // Determine owner/group of common.php file and the filename we want to change here + $common_php_owner = fileowner($phpbb_root_path . 'common.' . $phpEx); + $common_php_group = filegroup($phpbb_root_path . 'common.' . $phpEx); - case 'write': - $chmod = 0664; - break; + $file_uid = fileowner($filename); + $file_gid = filegroup($filename); - case 'write-all': - $chmod = 0666; - break; + // Try to set the owner to the same common.php has + if ($common_php_owner !== $file_uid && $common_php_owner !== false && $file_uid !== false) + { + // Will most likely not work + if (@chown($filename, $common_php_owner)); + { + $file_uid = fileowner($filename); + } + } - case 'read': - default: - $chmod = 0644; - break; + // Try to set the group to the same common.php has + if ($common_php_group !== $file_gid && $common_php_group !== false && $file_gid !== false) + { + if (@chgrp($filename, $common_php_group)); + { + $file_gid = filegroup($filename); + } + } } - // Return if the file no longer exist - if (!file_exists($filename)) + // And the owner and the groups PHP is running under. + $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; + $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; + + // Who is PHP? + if ($file_uid === false || $file_gid === false || $php_uid === false || $php_gids === false) { - return false; + $php = null; + } + else if ($file_uid == $php_uid /* && $common_php_owner !== false && $common_php_owner === $file_uid*/) + { + $php = 'owner'; + } + else if (in_array($file_gid, $php_gids)) + { + $php = 'group'; + } + else + { + $php = 'other'; } - // Add the execute bit if it is a directory + // Owner always has read/write permission + $owner = CHMOD_READ | CHMOD_WRITE; if (is_dir($filename)) { - // This line sets the correct execute bit on those "3-bits" being defined. 0644 becomes 0755 for example. - $chmod |= ($chmod & 7) ? 73 : (($chmod & 56) ? 72 : 64); - } + $owner |= CHMOD_EXECUTE; - // Set mode - $result = @chmod($filename, $chmod); + // Only add execute bit to the permission if the dir needs to be readable + if ($perms & CHMOD_READ) + { + $perms |= CHMOD_EXECUTE; + } + } - // Check for is_writable - if ($mode == 'rwrite') + switch ($php) { - // We are in rwrite mode, so, make sure the file is writable - if (!is_writable($filename)) - { - $result = phpbb_chmod($filename, 'write'); + case null: + case 'owner': + $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); - if (!is_writable($filename)) + if (!is_null($php) || (!is_readable($filename) && is_writable($filename))) { - $result = phpbb_chmod($filename, 'write-all'); + break; } - } - } - // Check for is_readable - if ($mode == 'rread') - { - if (!is_readable($filename)) - { - $result = phpbb_chmod($filename, 'sread'); + case 'group': + $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); - if (!is_readable($filename)) + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { - $result = phpbb_chmod($filename, 'read'); + break; } - } + + case 'other': + $result = @chmod($filename, ($owner << 6) + ($perms << 3) + ($perms << 0)); + + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) + { + break; + } + + default: + return false; + break; } return $result; -- cgit v1.2.1 From 4d7b9b76fafece5273c78a69027451ed2d28d705 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Aug 2008 17:23:40 +0000 Subject: some changes for proper code documentation git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8783 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index aaae41787a..d69aa3b7cd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2228,7 +2228,7 @@ function generate_link_hash($link_name) /** * checks a link hash - for GET requests -* @param string $token the submitted token +* @param string $token the submitted token * @param string $link_name The name of the link * @return boolean true if all is fine */ -- cgit v1.2.1 From 2cd45dd574b736ebb54a913c101fb9dc4ab5f415 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Aug 2008 17:24:40 +0000 Subject: fix a small glitch in phpbb_chmod git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8784 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d69aa3b7cd..b3fbd94159 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -566,7 +566,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'owner': $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); - if (!is_null($php) || (!is_readable($filename) && is_writable($filename))) + if (!is_null($php) || (is_readable($filename) && is_writable($filename))) { break; } -- cgit v1.2.1 From dc49e0fdffe41cbf44363eb6af23503558a94d86 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 24 Aug 2008 11:35:17 +0000 Subject: fix installation by defining our needed CHMOD_READ and CHMOD_WRITE constants. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8787 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b3fbd94159..5fcaece0d6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3131,7 +3131,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;) - if ($config['gzip_compress']) + if (!empty($config['gzip_compress'])) { if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level()) { @@ -3854,7 +3854,7 @@ function exit_handler() } // As a pre-caution... some setups display a blank page if the flush() is not there. - (!$config['gzip_compress']) ? @flush() : @ob_flush(); + (empty($config['gzip_compress'])) ? @flush() : @ob_flush(); exit; } -- cgit v1.2.1 From 528cf7de0f0e72a9ca3e6ba3813b578606bee40b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 1 Sep 2008 21:33:12 +0000 Subject: Show users posts in queue in acp and profile + link to mcp git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8801 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5fcaece0d6..e96583f75f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2218,10 +2218,12 @@ function meta_refresh($time, $url) function generate_link_hash($link_name) { global $user; + if (!isset($user->data["hash_$link_name"])) { $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8); } + return $user->data["hash_$link_name"]; } @@ -2244,16 +2246,18 @@ function check_link_hash($token, $link_name) function add_form_key($form_name) { global $config, $template, $user; + $now = time(); $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; $token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid); $s_fields = build_hidden_fields(array( - 'creation_time' => $now, - 'form_token' => $token, + 'creation_time' => $now, + 'form_token' => $token, )); + $template->assign_vars(array( - 'S_FORM_TOKEN' => $s_fields, + 'S_FORM_TOKEN' => $s_fields, )); } @@ -2279,23 +2283,26 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg $creation_time = abs(request_var('creation_time', 0)); $token = request_var('form_token', ''); - $diff = (time() - $creation_time); + $diff = time() - $creation_time; - if (($diff <= $timespan) || $timespan === -1) + // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)... + if ($diff && ($diff <= $timespan || $timespan === -1)) { $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); + if ($key === $token) { return true; } } } + if ($trigger) { trigger_error($user->lang['FORM_INVALID'] . $return_page); } + return false; } -- cgit v1.2.1 From e5162e7496c2ae9ef5e5a874dab8e0a0409f3d74 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Sep 2008 19:09:52 +0000 Subject: Extra slash is included in the redirect url when redirecting to the forum root directory. Closes #33605 Fix small mistake in CHANGELOG git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8832 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e96583f75f..a68ada3540 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2044,7 +2044,7 @@ function redirect($url, $return = false, $disable_cd_check = false) $url = substr($url, 1); } - $url = $dir . '/' . $url; + $url = (!empty($dir) ? $dir . '/' : '') . $url; $url = generate_board_url() . '/' . $url; } } -- cgit v1.2.1 From cd1aad477992a3816be285143a40e257be5b638c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 18 Sep 2008 14:17:08 +0000 Subject: Set secure cookie for style switcher if required. (Bug #19625) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8874 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a68ada3540..3f269cfc2a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3717,8 +3717,10 @@ function page_header($page_title = '', $display_online_list = true) 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : "{$phpbb_root_path}style.$phpEx?sid=$user->session_id&id=" . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], 'T_STYLESHEET_NAME' => $user->theme['theme_name'], - 'SITE_LOGO_IMG' => $user->img('site_logo')) - ); + 'SITE_LOGO_IMG' => $user->img('site_logo'), + + 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), + )); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); -- cgit v1.2.1 From eef41d039edecdb80b52a4122dacd874d0e1b807 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 29 Sep 2008 16:55:23 +0000 Subject: check fields properly not being set sometimes. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8956 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3f269cfc2a..fc3257dfd8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3587,7 +3587,7 @@ function page_header($page_title = '', $display_online_list = true) $s_privmsg_new = false; // Obtain number of new private messages if user is logged in - if (isset($user->data['is_registered']) && $user->data['is_registered']) + if (!empty($user->data['is_registered'])) { if ($user->data['user_new_privmsg']) { @@ -3684,8 +3684,8 @@ function page_header($page_title = '', $display_online_list = true) 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, 'S_BOARD_DISABLED' => ($config['board_disable']) ? true : false, - 'S_REGISTERED_USER' => $user->data['is_registered'], - 'S_IS_BOT' => $user->data['is_bot'], + 'S_REGISTERED_USER' => (!empty($user->data['is_registered'])) ? true : false, + 'S_IS_BOT' => (!empty($user->data['is_bot'])) ? true : false, 'S_USER_PM_POPUP' => $user->optionget('popuppm'), 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => (isset($user->data['session_browser'])) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], @@ -3697,7 +3697,7 @@ function page_header($page_title = '', $display_online_list = true) 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0, 'S_DISPLAY_SEARCH' => (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1), - 'S_DISPLAY_PM' => ($config['allow_privmsg'] && $user->data['is_registered'] && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false, + 'S_DISPLAY_PM' => ($config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false, 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, @@ -3774,7 +3774,7 @@ function page_footer($run_cron = true) 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', - 'U_ACP' => ($auth->acl_get('a_') && $user->data['is_registered']) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '') + 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '') ); // Call cron-type script -- cgit v1.2.1 From 77cf8e50d9e1b37cdd5ba5bb409ce6ac09fba394 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 30 Sep 2008 09:49:20 +0000 Subject: further adjustments to exit; statements force E_USER_ERROR to exit *always* - it is always a fatal error which should stop every execution happening git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8957 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index fc3257dfd8..0c5daa9231 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3228,6 +3228,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo ''; exit_handler(); + + // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here. + exit; break; case E_USER_WARNING: -- cgit v1.2.1 From 2c1d80c75a3f41517090004e59f1e04a21437cc8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 2 Oct 2008 12:04:12 +0000 Subject: Remove NUL-Bytes directly in request_var() for strings and within the custom DBAL sql_escape() functions (MSSQL, Firebird, Oracle) (reported by AdhostMikeSw) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8967 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0c5daa9231..862314aba9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -32,7 +32,7 @@ function set_var(&$result, $var, $type, $multibyte = false) if ($type == 'string') { - $result = trim(htmlspecialchars(str_replace(array("\r\n", "\r"), array("\n", "\n"), $result), ENT_COMPAT, 'UTF-8')); + $result = trim(htmlspecialchars(str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result), ENT_COMPAT, 'UTF-8')); if (!empty($result)) { -- cgit v1.2.1 From 253f18632242a113c97a3e5d70ee6f65c3f9ce84 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 9 Oct 2008 14:17:02 +0000 Subject: - Do not show link to user/group profiles if user has no permission to view the linked page and gets a denied message anyway. (Bug #15088) - Do not display last post link and sort display options for search engines. (Bug #15088) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8987 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 862314aba9..fabb1e1aa3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3681,7 +3681,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), - 'U_TEAM' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), + 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, -- cgit v1.2.1 From d14303299549f65867829cb4812df919e5de8fc7 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 10 Nov 2008 16:24:18 +0000 Subject: inheritance is reflexive git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9057 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index fabb1e1aa3..b96024e4e3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3707,7 +3707,7 @@ function page_header($page_title = '', $display_online_list = true) 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', - 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path'])) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : '', + 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", -- cgit v1.2.1 From a3cbc3d671b9941e0859bd5e5694a115fde59a57 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Nov 2008 11:48:33 +0000 Subject: Let's face it - the most common setup we see with phpBB is having group-specific settings for external users (FTP, whatever). Changed phpbb_chmod() to set the group bit, even if the PHP user is the owner. (somehow this sounds complicated, i hope you get the idea). git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9131 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b96024e4e3..d6f112e8d6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -462,7 +462,7 @@ function _hash_crypt_private($password, $setting, &$itoa64) /** * Global function for chmodding directories and files for internal use * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. -* The function determines owner and group from common.php file and sets the same to the provided file. +* The function determines owner and group from common.php file and sets the same to the provided file. Permissions are mapped to the group, user always has rw(x) permission. * The function uses bit fields to build the permissions. * The function sets the appropiate execute bit on directories. * @@ -532,7 +532,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) // Who is PHP? if ($file_uid === false || $file_gid === false || $php_uid === false || $php_gids === false) { - $php = null; + $php = NULL; } else if ($file_uid == $php_uid /* && $common_php_owner !== false && $common_php_owner === $file_uid*/) { @@ -564,12 +564,15 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) { case null: case 'owner': + /* ATTENTION: if php is owner or NULL we set it to group here. This is the most failsafe combination for the vast majority of server setups. + $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); if (!is_null($php) || (is_readable($filename) && is_writable($filename))) { break; } + */ case 'group': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); -- cgit v1.2.1 From 5474fcc4ea5c0cdf3ed89c1238ec8a7a700405b4 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 1 Dec 2008 17:04:11 +0000 Subject: Fix potential issues with the stat cache and phpbb_chmod() git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9144 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d6f112e8d6..edb6d8ea5e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -511,6 +511,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) // Will most likely not work if (@chown($filename, $common_php_owner)); { + clearstatcache(false, $filename); $file_uid = fileowner($filename); } } @@ -520,6 +521,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) { if (@chgrp($filename, $common_php_group)); { + clearstatcache(false, $filename); $file_gid = filegroup($filename); } } @@ -568,6 +570,8 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); + clearstatcache(false, $filename); + if (!is_null($php) || (is_readable($filename) && is_writable($filename))) { break; @@ -577,6 +581,8 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'group': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); + clearstatcache(false, $filename); + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { break; @@ -585,6 +591,8 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'other': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + ($perms << 0)); + clearstatcache(false, $filename); + if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { break; -- cgit v1.2.1 From 30021ca5bce07eecaaee807baf5170482d2efa13 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 1 Dec 2008 17:27:59 +0000 Subject: stupid PHP manual :@ the two parameters to clearstatcache() are 5.3 only. Fix r9144 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9146 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index edb6d8ea5e..f92b4f91ab 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -511,7 +511,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) // Will most likely not work if (@chown($filename, $common_php_owner)); { - clearstatcache(false, $filename); + clearstatcache(); $file_uid = fileowner($filename); } } @@ -521,7 +521,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) { if (@chgrp($filename, $common_php_group)); { - clearstatcache(false, $filename); + clearstatcache(); $file_gid = filegroup($filename); } } @@ -570,7 +570,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); - clearstatcache(false, $filename); + clearstatcache(); if (!is_null($php) || (is_readable($filename) && is_writable($filename))) { @@ -581,7 +581,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'group': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); - clearstatcache(false, $filename); + clearstatcache(); if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { @@ -591,7 +591,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) case 'other': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + ($perms << 0)); - clearstatcache(false, $filename); + clearstatcache(); if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) { -- cgit v1.2.1 From 353b7edc9abad9ceb0d9dc929e3efd9e2d75ee79 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Dec 2008 16:23:32 +0000 Subject: Slight performance increase for common parameter calls to append_sid() (Bug #37555 - Patch by BartVB) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9150 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f92b4f91ab..3ed71add61 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1831,30 +1831,45 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) } } - // Assign sid if session id is not specified - if ($session_id === false) - { - $session_id = $_SID; - } - - $amp_delim = ($is_amp) ? '&' : '&'; - $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; - - // Appending custom url parameter? - $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + $params_is_array = is_array($params); + // Get anchor $anchor = ''; if (strpos($url, '#') !== false) { list($url, $anchor) = explode('#', $url, 2); $anchor = '#' . $anchor; } - else if (!is_array($params) && strpos($params, '#') !== false) + else if (!$params_is_array && strpos($params, '#') !== false) { list($params, $anchor) = explode('#', $params, 2); $anchor = '#' . $anchor; } + // Handle really simple cases quickly + if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor) + { + if ($params === false) + { + return $url; + } + + $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&'); + return $url . ($params !== false ? $url_delim. $params : ''); + } + + // Assign sid if session id is not specified + if ($session_id === false) + { + $session_id = $_SID; + } + + $amp_delim = ($is_amp) ? '&' : '&'; + $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; + + // Appending custom url parameter? + $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + // Use the short variant if possible ;) if ($params === false) { -- cgit v1.2.1 From 9ad79023b1bb6b088dc1426bb26f5f8675ee1ee2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Dec 2008 17:02:56 +0000 Subject: Add same redirect disable_cd_check parameter to meta_refresh - #38065 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9153 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3ed71add61..55c4cc5b51 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2216,12 +2216,17 @@ function build_url($strip_vars = false) /** * Meta refresh assignment +* Adds META template variable with meta http tag. +* +* @param int $time Time in seconds for meta refresh tag +* @param string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned +* @param bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false. */ -function meta_refresh($time, $url) +function meta_refresh($time, $url, $disable_cd_check = false) { global $template; - $url = redirect($url, true); + $url = redirect($url, true, $disable_cd_check); $url = str_replace('&', '&', $url); // For XHTML compatibility we change back & to & -- cgit v1.2.1 From d8263b86bbd0ed217c7e65a169fd6ff3c9a6a111 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 27 Jan 2009 17:54:35 +0000 Subject: remove the cache for the session lookups. Actually, the disk reads/writes are more expensive than the sql queries. At phpbb.com for example this results in excessive disk access and more than 1000 cache files. This is not acceptable. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9308 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 55c4cc5b51..bbeaca9d1d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3369,7 +3369,7 @@ function obtain_guest_count($forum_id = 0) AND s.session_time >= ' . ($time - ((int) ($time % 60))) . $reading_sql; } - $result = $db->sql_query($sql, 60); + $result = $db->sql_query($sql); $guests_online = (int) $db->sql_fetchfield('num_guests'); $db->sql_freeresult($result); -- cgit v1.2.1 From 0da1f535406fb9b3d788541bb4eb8ff56b1ea259 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 7 Feb 2009 20:56:49 +0000 Subject: Tiny change to accept back slashes for Windows paths, phpBB passes forward slashes but other code might not git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9316 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bbeaca9d1d..65bf1f9c65 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -703,7 +703,7 @@ if (!function_exists('stripos')) */ function is_absolute($path) { - return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false; + return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:[/\\\]#i', $path))) ? true : false; } /** -- cgit v1.2.1 From 233e62f0b5033e84964fff95d79497ba62a52f23 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 18 Mar 2009 18:09:14 +0000 Subject: backport 3.2 version of phpbb_chmod() - need to be tested further... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9394 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 128 +++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 52 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 65bf1f9c65..248a478145 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -461,8 +461,9 @@ function _hash_crypt_private($password, $setting, &$itoa64) /** * Global function for chmodding directories and files for internal use +* * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. -* The function determines owner and group from common.php file and sets the same to the provided file. Permissions are mapped to the group, user always has rw(x) permission. +* The function determines owner and group from common.php file and sets the same to the provided file. * The function uses bit fields to build the permissions. * The function sets the appropiate execute bit on directories. * @@ -475,76 +476,103 @@ function _hash_crypt_private($password, $setting, &$itoa64) * * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. * -* @param $filename The file/directory to be chmodded -* @param $perms Permissions to set -* @return true on success, otherwise false +* @param string $filename The file/directory to be chmodded +* @param int $perms Permissions to set * +* @return bool true on success, otherwise false * @author faw, phpBB Group */ function phpbb_chmod($filename, $perms = CHMOD_READ) { + static $_chmod_info; + // Return if the file no longer exists. if (!file_exists($filename)) { return false; } - if (!function_exists('fileowner') || !function_exists('filegroup')) - { - $file_uid = $file_gid = false; - $common_php_owner = $common_php_group = false; - } - else + // Determine some common vars + if (empty($_chmod_info)) { - global $phpbb_root_path, $phpEx; + if (!function_exists('fileowner') || !function_exists('filegroup')) + { + // No need to further determine owner/group - it is unknown + $_chmod_info['process'] = false; + } + else + { + global $phpbb_root_path, $phpEx; - // Determine owner/group of common.php file and the filename we want to change here - $common_php_owner = fileowner($phpbb_root_path . 'common.' . $phpEx); - $common_php_group = filegroup($phpbb_root_path . 'common.' . $phpEx); + // Determine owner/group of common.php file and the filename we want to change here + $common_php_owner = fileowner($phpbb_root_path . 'common.' . $phpEx); + $common_php_group = filegroup($phpbb_root_path . 'common.' . $phpEx); - $file_uid = fileowner($filename); - $file_gid = filegroup($filename); + // And the owner and the groups PHP is running under. + $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; + $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; - // Try to set the owner to the same common.php has - if ($common_php_owner !== $file_uid && $common_php_owner !== false && $file_uid !== false) - { - // Will most likely not work - if (@chown($filename, $common_php_owner)); + // If we are unable to get owner/group, then do not try to set them by guessing + if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group) { - clearstatcache(); - $file_uid = fileowner($filename); + $_chmod_info['process'] = false; } - } - - // Try to set the group to the same common.php has - if ($common_php_group !== $file_gid && $common_php_group !== false && $file_gid !== false) - { - if (@chgrp($filename, $common_php_group)); + else { - clearstatcache(); - $file_gid = filegroup($filename); + $_chmod_info = array( + 'process' => true, + 'common_owner' => $common_php_owner, + 'common_group' => $common_php_group, + 'php_uid' => $php_uid, + 'php_gids' => $php_gids, + ); } } } - // And the owner and the groups PHP is running under. - $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; - $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; - - // Who is PHP? - if ($file_uid === false || $file_gid === false || $php_uid === false || $php_gids === false) - { - $php = NULL; - } - else if ($file_uid == $php_uid /* && $common_php_owner !== false && $common_php_owner === $file_uid*/) + if ($_chmod_info['process']) { - $php = 'owner'; + // Change owner + if (@chown($filename, $_chmod_info['common_owner'])) + { + clearstatcache(); + $file_uid = fileowner($filename); + } + + // Change group + if (@chgrp($filename, $_chmod_info['common_group'])) + { + clearstatcache(); + $file_gid = filegroup($filename); + } + + // If the file_uid/gid now match the one from common.php we can process further, else we are not able to change something + if ($file_uid != $_chmod_info['common_owner'] || $file_gid != $_chmod_info['common_group']) + { + $_chmod_info['process'] = false; + } } - else if (in_array($file_gid, $php_gids)) + + // Still able to process? + if ($_chmod_info['process']) { - $php = 'group'; + if ($file_uid == $_chmod_info['php_uid']) + { + $php = 'owner'; + } + else if (in_array($file_gid, $_chmod_info['php_gids'])) + { + $php = 'group'; + } + else + { + // Since we are setting the everyone bit anyway, no need to do expensive operations + $_chmod_info['process'] = false; + } } - else + + // We are not able to determine or change something + if (!$_chmod_info['process']) { $php = 'other'; } @@ -564,26 +592,22 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) switch ($php) { - case null: case 'owner': - /* ATTENTION: if php is owner or NULL we set it to group here. This is the most failsafe combination for the vast majority of server setups. - $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); clearstatcache(); - if (!is_null($php) || (is_readable($filename) && is_writable($filename))) + if (is_readable($filename) && is_writable($filename)) { break; } - */ case 'group': $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); clearstatcache(); - if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) + if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) { break; } @@ -593,7 +617,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) clearstatcache(); - if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))) + if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) { break; } -- cgit v1.2.1 From e461162847b1ac9287870de680e8dbd17e9f2fc1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 19 Mar 2009 17:01:59 +0000 Subject: Fix race condition for updating post/topic/etc. counter. (reported by BartVB) please do not try such fixes at home - the correct solution would be to create a second config table with integer columns. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9398 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 248a478145..30d3e50be8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -164,6 +164,37 @@ function set_config($config_name, $config_value, $is_dynamic = false) } } +/** +* Set dynamic config value with arithmetic operation. +*/ +function set_config_count($config_name, $increment, $is_dynamic = false) +{ + global $db, $cache; + + switch ($db->sql_layer) + { + case 'firebird': + $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)'; + break; + + case 'postgres': + $sql_update = 'int4(config_value) + ' . (int) $increment; + break; + + // MySQL, SQlite, mssql, mssql_odbc, oracle + default: + $sql_update = 'config_value + ' . (int) $increment; + break; + } + + $db->sql_query('UPDATE ' . CONFIG_TABLE . ' SET config_value = ' . $sql_update . " WHERE config_name = '" . $db->sql_escape($config_name) . "'"); + + if (!$is_dynamic) + { + $cache->destroy('config'); + } +} + /** * Generates an alphanumeric random string of given length */ -- cgit v1.2.1 From 06c4fbf81fdc66cc3eea11628b35f5c4ebbbaaba Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 19 Mar 2009 19:24:47 +0000 Subject: SQL optimisations git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9399 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 30d3e50be8..f38e0afc26 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1120,7 +1120,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $sql_update = array(); while ($row = $db->sql_fetchrow($result)) { - $sql_update[] = $row['forum_id']; + $sql_update[] = (int) $row['forum_id']; } $db->sql_freeresult($result); -- cgit v1.2.1 From 45b22fd31f52fbdc884217efc573ccd13bdde92a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 28 Mar 2009 15:18:53 +0000 Subject: fix unkown variable problem. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9410 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f38e0afc26..a5d3be7461 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -563,6 +563,9 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) if ($_chmod_info['process']) { + $file_uid = fileowner($filename); + $file_gid = filegroup($filename); + // Change owner if (@chown($filename, $_chmod_info['common_owner'])) { -- cgit v1.2.1 From cda9e5e9ec0dfe9c3e0a04809ffc5d0099020046 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 09:11:08 +0000 Subject: a language alteration for captchas. Added min/max captcha chars constants and changed the length from 5-8 to 4-7 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9437 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a5d3be7461..832738395f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2632,7 +2632,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $db->sql_query($sql); // Generate code - $code = gen_rand_string(mt_rand(5, 8)); + $code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $confirm_id = md5(unique_id($user->ip)); $seed = hexdec(substr(unique_id(), 4, 10)); -- cgit v1.2.1 From 9512b82e1d2779ab39b46424cd9ad8f4b5f6c0f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 18 Apr 2009 18:40:15 +0000 Subject: #43755 - also return GiB sizes for get_formatted_filesize(), patch by nickvergessen git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9474 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 832738395f..be5e661d44 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -236,6 +236,11 @@ function get_formatted_filesize($bytes, $add_size_lang = true) { global $user; + if ($bytes >= pow(2, 30)) + { + return ($add_size_lang) ? round($bytes / 1024 / 1024 / 1024, 2) . ' ' . $user->lang['GIB'] : round($bytes / 1024 / 1024 / 1024, 2); + } + if ($bytes >= pow(2, 20)) { return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2); @@ -3240,6 +3245,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); echo '[phpBB Debug] PHP Notice: in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; + // echo '

BACKTRACE
' . get_backtrace() . '
' . "\n"; } return; -- cgit v1.2.1 From 928fc7be976cabd45770728a3d496778a030de1e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 May 2009 16:11:40 +0000 Subject: suppress warnings (stat failed). Though may be good to know... why! git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9519 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index be5e661d44..476565452c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -541,8 +541,8 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) global $phpbb_root_path, $phpEx; // Determine owner/group of common.php file and the filename we want to change here - $common_php_owner = fileowner($phpbb_root_path . 'common.' . $phpEx); - $common_php_group = filegroup($phpbb_root_path . 'common.' . $phpEx); + $common_php_owner = @fileowner($phpbb_root_path . 'common.' . $phpEx); + $common_php_group = @filegroup($phpbb_root_path . 'common.' . $phpEx); // And the owner and the groups PHP is running under. $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; @@ -568,21 +568,21 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) if ($_chmod_info['process']) { - $file_uid = fileowner($filename); - $file_gid = filegroup($filename); + $file_uid = @fileowner($filename); + $file_gid = @filegroup($filename); // Change owner if (@chown($filename, $_chmod_info['common_owner'])) { clearstatcache(); - $file_uid = fileowner($filename); + $file_uid = @fileowner($filename); } // Change group if (@chgrp($filename, $_chmod_info['common_group'])) { clearstatcache(); - $file_gid = filegroup($filename); + $file_gid = @filegroup($filename); } // If the file_uid/gid now match the one from common.php we can process further, else we are not able to change something -- cgit v1.2.1 From b776d02682492077a4fafd8835d7c4a17e50762d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 2 Jun 2009 14:12:23 +0000 Subject: Okay, a first ci of the new captcha plugins. We'll add dynamic template includes later, as well as documentation on how to use this. I'm prepared to get yelled at for bugs (oh, I know that there are plenty); but please blame spammers for broken styles and MODs. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9524 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 476565452c..58601be65b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2520,6 +2520,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; + if (!class_exists('phpbb_captcha_factory')) + { + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + } + $err = ''; // Make sure user->setup() has been called @@ -2630,34 +2635,14 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { case LOGIN_ERROR_ATTEMPTS: - // Show confirm image - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_LOGIN; - $db->sql_query($sql); - - // Generate code - $code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); - $confirm_id = md5(unique_id($user->ip)); - $seed = hexdec(substr(unique_id(), 4, 10)); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_LOGIN); + $captcha->reset(); - // compute $seed % 0x7fffffff - $seed -= 0x7fffffff * floor($seed / 0x7fffffff); - - $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $confirm_id, - 'session_id' => (string) $user->session_id, - 'confirm_type' => (int) CONFIRM_LOGIN, - 'code' => (string) $code, - 'seed' => (int) $seed) - ); - $db->sql_query($sql); $template->assign_vars(array( 'S_CONFIRM_CODE' => true, - 'CONFIRM_ID' => $confirm_id, - 'CONFIRM_IMAGE' => '', - 'L_LOGIN_CONFIRM_EXPLAIN' => sprintf($user->lang['LOGIN_CONFIRM_EXPLAIN'], '', ''), + 'CONFIRM' => $captcha->get_template(''), )); $err = $user->lang[$result['error_msg']]; -- cgit v1.2.1 From be8457d3c418441317177bfcdf7378410ac28d55 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 3 Jun 2009 10:19:17 +0000 Subject: Correctly determine writable status of files on Windows operating system. #39035 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9528 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 58601be65b..78905beff6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -669,6 +669,67 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) return $result; } +/** + * Test if a file/directory is writable + * + * This function calls the native is_writable() when not running under + * Windows and it is not disabled. + * + * @param string $file Path to perform write test on + * @return bool True when the path is writable, otherwise false. + */ +function phpbb_is_writable($file) +{ + if (substr(PHP_OS, 0, 3) === 'WIN' || !function_exists('is_writable')) + { + if (file_exists($file)) + { + // Canonicalise path to absolute path + $file = phpbb_realpath($file); + + if (is_dir($file)) + { + // Test directory by creating a file inside the directory + $result = @tempnam($file, 'i_w'); + + if (is_string($result) && file_exists($result)) + { + unlink($result); + + // Ensure the file is actually in the directory (returned realpathed) + return (strpos($result, $file) === 0) ? true : false; + } + } + else + { + $handle = @fopen($file, 'r+'); + + if (is_resource($handle)) + { + fclose($handle); + return true; + } + } + } + else + { + // file does not exist test if we can write to the directory + + $dir = dirname($file); + + if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir)) + { + return true; + } + } + return false; + } + else + { + return is_writable($file); + } +} + // Compatibility functions if (!function_exists('array_combine')) -- cgit v1.2.1 From a539fca62b10f53a5f5dadf07f9ab07340fdabf9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 7 Jun 2009 11:34:01 +0000 Subject: some corrections, only very minor things. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9554 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 78905beff6..f958a204b6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -670,17 +670,17 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) } /** - * Test if a file/directory is writable - * - * This function calls the native is_writable() when not running under - * Windows and it is not disabled. - * - * @param string $file Path to perform write test on - * @return bool True when the path is writable, otherwise false. - */ +* Test if a file/directory is writable +* +* This function calls the native is_writable() when not running under +* Windows and it is not disabled. +* +* @param string $file Path to perform write test on +* @return bool True when the path is writable, otherwise false. +*/ function phpbb_is_writable($file) { - if (substr(PHP_OS, 0, 3) === 'WIN' || !function_exists('is_writable')) + if (strtolower(substr(PHP_OS, 0, 3)) === 'win' || !function_exists('is_writable')) { if (file_exists($file)) { @@ -714,7 +714,6 @@ function phpbb_is_writable($file) else { // file does not exist test if we can write to the directory - $dir = dirname($file); if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir)) @@ -722,6 +721,7 @@ function phpbb_is_writable($file) return true; } } + return false; } else @@ -2585,7 +2585,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); } - + $err = ''; // Make sure user->setup() has been called @@ -2700,14 +2700,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha->init(CONFIRM_LOGIN); $captcha->reset(); - $template->assign_vars(array( 'S_CONFIRM_CODE' => true, 'CONFIRM' => $captcha->get_template(''), )); $err = $user->lang[$result['error_msg']]; - break; case LOGIN_ERROR_PASSWORD_CONVERT: -- cgit v1.2.1 From e71bae0e7ad7817e06fb786c3420a1a2158df8cc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Jun 2009 13:56:40 +0000 Subject: Fix dynamic config update routine error if firebird is used (Bug #46315) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9574 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f958a204b6..188c8ee5e3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -174,7 +174,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false) switch ($db->sql_layer) { case 'firebird': - $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)'; + $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))'; break; case 'postgres': -- cgit v1.2.1 From 863d7a7614a09dac545d3c3201e67c3beddb3960 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Jun 2009 14:41:03 +0000 Subject: First ATOM Feed commit/integration - Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9575 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 188c8ee5e3..94f2adc5bd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3775,6 +3775,9 @@ function page_header($page_title = '', $display_online_list = true) $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); } + $forum_id = request_var('f', 0); + $topic_id = request_var('t', 0); + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -3822,6 +3825,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', + 'U_FEED' => generate_board_url() . "/feed.$phpEx", 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS) ? true : false, 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, @@ -3843,6 +3847,15 @@ function page_header($page_title = '', $display_online_list = true) 'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => ($s_privmsg_new) ? 1 : 0, 'S_REGISTER_ENABLED' => ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false, + 'S_FORUM_ID' => $forum_id, + 'S_TOPIC_ID' => $topic_id, + + 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, + 'S_ENABLE_FEEDS_NEWS' => ($config['feed_news_id'] != '') ? true : false, + 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, + 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, + 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_id && strpos($user->page['page_name'], 'viewforum') !== false) ? true : false, + 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && $topic_id && strpos($user->page['page_name'], 'viewtopic') !== false) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', -- cgit v1.2.1 From c6c6841cfbc0b5e342fb2dc5cbdea1834c4b47e9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 17 Jun 2009 13:29:26 +0000 Subject: Use dynamic includes, fix some style bugs, make the old default captcha family backwards compatible to 3.0.5 styles git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9609 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 94f2adc5bd..e55a76fbb0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2702,7 +2702,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $template->assign_vars(array( 'S_CONFIRM_CODE' => true, - 'CONFIRM' => $captcha->get_template(''), + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); $err = $user->lang[$result['error_msg']]; -- cgit v1.2.1 From 433de350c0fa2e1e09c23e6f5f29f118222d2df8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 20 Jun 2009 18:45:16 +0000 Subject: - [Feature] New "Newly Registered Users" group for assigning permissions to newly registered users. They will be removed from this group once they reach a defineable amount of posts. - [Feature] Ability to define if the "Newly Registered Users" group will be assigned as the default group to newly registered users. As a coincidence also Bug #46535 got fixed. Additionally the error message displayed with trigger_error() if accessing the private message tab in the ucp is now displayed inline in addition to a slightly different message for newly registered users to let them know that access permissions may be lifted over time. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9636 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e55a76fbb0..7b4f991965 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3795,6 +3795,7 @@ function page_header($page_title = '', $display_online_list = true) 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], + 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, -- cgit v1.2.1 From 5ea9f6e3fc82ba39bbfde03b61a868d3c7b94f45 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 20 Jun 2009 22:38:39 +0000 Subject: Fix bug #31975 - Enhance obtain_users_online_string to be able to return user-lists for other session-items Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9638 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 59 ++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7b4f991965..c5216f7f6f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3439,16 +3439,17 @@ function msg_handler($errno, $msg_text, $errfile, $errline) /** * Queries the session table to get information about online guests -* @param int $forum_id Limits the search to the forum with this id +* @param int $item_id Limits the search to the item with this id +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return int The number of active distinct guest sessions */ -function obtain_guest_count($forum_id = 0) +function obtain_guest_count($item_id = 0, $item = 'forum') { global $db, $config; - if ($forum_id) + if ($item_id) { - $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; + $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } else { @@ -3486,17 +3487,18 @@ function obtain_guest_count($forum_id = 0) /** * Queries the session table to get information about online users -* @param int $forum_id Limits the search to the forum with this id +* @param int $item_id Limits the search to the item with this id +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return array An array containing the ids of online, hidden and visible users, as well as statistical info */ -function obtain_users_online($forum_id = 0) +function obtain_users_online($item_id = 0, $item = 'forum') { global $db, $config, $user; $reading_sql = ''; - if ($forum_id !== 0) + if ($item !== 0) { - $reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id; + $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } $online_users = array( @@ -3510,7 +3512,7 @@ function obtain_users_online($forum_id = 0) if ($config['load_online_guests']) { - $online_users['guests_online'] = obtain_guest_count($forum_id); + $online_users['guests_online'] = obtain_guest_count($item_id, $item); } // a little discrete magic to cache this for 30 seconds @@ -3549,14 +3551,17 @@ function obtain_users_online($forum_id = 0) /** * Uses the result of obtain_users_online to generate a localized, readable representation. * @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics -* @param int $forum_id Indicate that the data is limited to one forum and not global. +* @param int $item_id Indicate that the data is limited to one item and not global +* @param string $item The name of the item which is stored in the session table as session_{$item}_id * @return array An array containing the string for output to the template */ -function obtain_users_online_string($online_users, $forum_id = 0) +function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum') { global $config, $db, $user, $auth; $user_online_link = $online_userlist = ''; + // Need caps version of $item for language-strings + $item_caps = strtoupper($item); if (sizeof($online_users['online_users'])) { @@ -3591,18 +3596,18 @@ function obtain_users_online_string($online_users, $forum_id = 0) $online_userlist = $user->lang['NO_ONLINE_USERS']; } - if ($forum_id === 0) + if ($item_id === 0) { $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist; } else if ($config['load_online_guests']) { - $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS']; + $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_' . $item_caps . '_GUEST'] : $user->lang['BROWSING_' . $item_caps . '_GUESTS']; $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); } else { - $online_userlist = sprintf($user->lang['BROWSING_FORUM'], $online_userlist); + $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); } // Build online listing $vars_online = array( @@ -3700,10 +3705,28 @@ function page_header($page_title = '', $display_online_list = true) if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { - $f = request_var('f', 0); - $f = max($f, 0); - $online_users = obtain_users_online($f); - $user_online_strings = obtain_users_online_string($online_users, $f); + /** + * Load online data: + * For obtaining another session column use the following code, whereby the column is session_{$item}_id. + * Put the code directly after $item = 'forum'; + * + * + * $my_item_id = request_var('my_item_id', 0); + * + * if ($my_item_id > 0) + * { + * // would revolve to the column session_myitem_id in the SESSIONS_TABLE + * $item = 'myitem'; + * $item_id = $my_item_id; + * } + * + */ + + $item_id = max(request_var('f', 0), 0); + $item = 'forum'; + + $online_users = obtain_users_online($item_id, $item); + $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); $l_online_users = $user_online_strings['l_online_users']; $online_userlist = $user_online_strings['online_userlist']; -- cgit v1.2.1 From f056e205add6b956b2e63a28a1d0b4062671c490 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 21 Jun 2009 10:40:52 +0000 Subject: rename user_id in confirm_box to confirm_uid. We are able to do this because confirm_box is completely transparent to the outside. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9641 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c5216f7f6f..dd82f9e53d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2496,7 +2496,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($check && $confirm) { - $user_id = request_var('user_id', 0); + $user_id = request_var('confirm_uid', 0); $session_id = request_var('sess', ''); $confirm_key = request_var('confirm_key', ''); @@ -2518,10 +2518,10 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo } $s_hidden_fields = build_hidden_fields(array( - 'user_id' => $user->data['user_id'], - 'sess' => $user->session_id, - 'sid' => $user->session_id) - ); + 'confirm_uid' => $user->data['user_id'], + 'sess' => $user->session_id, + 'sid' => $user->session_id, + )); // generate activation key $confirm_key = gen_rand_string(10); -- cgit v1.2.1 From eb72e526b804844839555314914049eec75f1398 Mon Sep 17 00:00:00 2001 From: Gabriel Vazquez Date: Sun, 21 Jun 2009 16:00:42 +0000 Subject: Fixed bug #43125 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9648 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dd82f9e53d..14e1dde92f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2261,17 +2261,12 @@ function reapply_sid($url) } // Remove previously added sid - if (strpos($url, '?sid=') !== false) + if (strpos($url, 'sid=') !== false) { - $url = preg_replace('/(\?)sid=[a-z0-9]+(&|&)?/', '\1', $url); - } - else if (strpos($url, '&sid=') !== false) - { - $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); - } - else if (strpos($url, '&sid=') !== false) - { - $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url); + // All kind of links + $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); + // if the sid was the first param, make the old second as first ones + $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); } return append_sid($url); -- cgit v1.2.1 From bfcf6a1de5181a0b26b247f8cb9e181b8c83ff90 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 22 Jun 2009 14:36:04 +0000 Subject: Fix bug #46765 - View unread posts Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9653 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 14e1dde92f..12b9363ec4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3840,6 +3840,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), + 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), -- cgit v1.2.1 From f9bbf10a80c7a22a1ff59e30eef1cf9873e46516 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Jun 2009 10:08:18 +0000 Subject: - Fix XHTML for r9666 - Utilize $captcha->solved property - Only validate captcha once to retain captcha mode over switching from/to agreement page git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9668 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 12b9363ec4..30bdc9abce 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2265,7 +2265,7 @@ function reapply_sid($url) { // All kind of links $url = preg_replace('/(\?)?(&|&)?sid=[a-z0-9]+/', '', $url); - // if the sid was the first param, make the old second as first ones + // if the sid was the first param, make the old second as first ones $url = preg_replace("/$phpEx(&|&)+?/", "$phpEx?", $url); } @@ -3844,6 +3844,8 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), + 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), + 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.$phpEx", -- cgit v1.2.1 From 1c0df0dc91dcfb603cfb653e7daaf03257ac5495 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 25 Jun 2009 17:57:57 +0000 Subject: revert r9653 because it does not work as advertised (a load of bugs and not really what we wanted... back to the drawing board ;)) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9674 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 30bdc9abce..25bef4557a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3840,7 +3840,6 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), - 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), -- cgit v1.2.1 From a6f088992b4d75df91df75f8d183a12f9fa12777 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 7 Jul 2009 15:18:11 +0000 Subject: Fix bug #47785 - Fetch requested cookie variables directly from cookie super global. This should fix a problem with phpBB installations on PHP 5.3 Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9728 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 25bef4557a..29f4186a5d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -71,12 +71,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) $_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name]; } - if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) + $super_global = ($cookie) ? '_COOKIE' : '_REQUEST'; + if (!isset($$super_global[$var_name]) || is_array($$super_global[$var_name]) != is_array($default)) { return (is_array($default)) ? array() : $default; } - $var = $_REQUEST[$var_name]; + $var = $$super_global[$var_name]; if (!is_array($default)) { $type = gettype($default); -- cgit v1.2.1 From 48e3b6deaab11bd4f04132aed514430aef8696f7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 7 Jul 2009 15:36:24 +0000 Subject: Fix r9728 - It does actually not work that way. ;-) Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9729 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 29f4186a5d..c6f6084918 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -72,12 +72,12 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) } $super_global = ($cookie) ? '_COOKIE' : '_REQUEST'; - if (!isset($$super_global[$var_name]) || is_array($$super_global[$var_name]) != is_array($default)) + if (!isset($GLOBALS[$super_global][$var_name]) || is_array($GLOBALS[$super_global][$var_name]) != is_array($default)) { return (is_array($default)) ? array() : $default; } - $var = $$super_global[$var_name]; + $var = $GLOBALS[$super_global][$var_name]; if (!is_array($default)) { $type = gettype($default); -- cgit v1.2.1 From 61453bb2aba7c1acfedab0ea600c9d13ee751976 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Wed, 8 Jul 2009 14:30:01 +0000 Subject: Fixed Bug #24075 - GZIP status is not showed up correctly in debug mode Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9737 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c6f6084918..60fe6a454f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3927,7 +3927,7 @@ function page_footer($run_cron = true) $db->sql_report('display'); } - $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); + $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) { -- cgit v1.2.1 From 54ee31972af4f84e09ad5b12ca512e5712bbd87a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 11 Jul 2009 10:05:20 +0000 Subject: Fix bug #47775 - Properly convert and show filesize information Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9748 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 71 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 60fe6a454f..84bbb964de 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -232,27 +232,82 @@ function unique_id($extra = 'c') /** * Return formatted string for filesizes +* +* @param int $value filesize in bytes +* @param bool $string_only true if language string should be returned +* @param array $allowed_units only allow these units (data array indexes) +* +* @return mixed data array if $string_only is false +* @author bantu */ -function get_formatted_filesize($bytes, $add_size_lang = true) +function get_formatted_filesize($value, $string_only = true, $allowed_units = false) { global $user; - if ($bytes >= pow(2, 30)) + $available_units = array( + 'gb' => array( + 'min' => 1073741824, // pow(2, 30) + 'index' => 3, + 'si_unit' => 'GB', + 'iec_unit' => 'GIB', + ), + 'mb' => array( + 'min' => 1048576, // pow(2, 20) + 'index' => 2, + 'si_unit' => 'MB', + 'iec_unit' => 'MIB', + ), + 'kb' => array( + 'min' => 1024, // pow(2, 10) + 'index' => 1, + 'si_unit' => 'KB', + 'iec_unit' => 'KIB', + ), + 'b' => array( + 'min' => 0, + 'index' => 0, + 'si_unit' => 'BYTES', // Language index + 'iec_unit' => 'BYTES', // Language index + ), + ); + + foreach ($available_units as $si_identifier => $unit_info) { - return ($add_size_lang) ? round($bytes / 1024 / 1024 / 1024, 2) . ' ' . $user->lang['GIB'] : round($bytes / 1024 / 1024 / 1024, 2); + if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) + { + continue; + } + + if ($value >= $unit_info['min']) + { + $unit_info['si_identifier'] = $si_identifier; + + break; + } } + unset($available_units); - if ($bytes >= pow(2, 20)) + for ($i = 0; $i < $unit_info['index']; $i++) { - return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2); + $value /= 1024; } + $value = round($value, 2); - if ($bytes >= pow(2, 10)) + // Lookup units in language dictionary + $unit_info['si_unit'] = (isset($user->lang[$unit_info['si_unit']])) ? $user->lang[$unit_info['si_unit']] : $unit_info['si_unit']; + $unit_info['iec_unit'] = (isset($user->lang[$unit_info['iec_unit']])) ? $user->lang[$unit_info['iec_unit']] : $unit_info['iec_unit']; + + // Default to IEC + $unit_info['unit'] = $unit_info['iec_unit']; + + if (!$string_only) { - return ($add_size_lang) ? round($bytes / 1024, 2) . ' ' . $user->lang['KIB'] : round($bytes / 1024, 2); + $unit_info['value'] = $value; + + return $unit_info; } - return ($add_size_lang) ? ($bytes) . ' ' . $user->lang['BYTES'] : ($bytes); + return $value . ' ' . $unit_info['unit']; } /** -- cgit v1.2.1 From 51748b00ed8e6b709f1a7df59570e8ecee6783d5 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 14 Jul 2009 14:46:38 +0000 Subject: Fix bug #46765 - View unread posts Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9755 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 84bbb964de..74f7e31bee 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3896,6 +3896,7 @@ function page_header($page_title = '', $display_online_list = true) 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unanswered'), + 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders'), @@ -4119,4 +4120,94 @@ function phpbb_user_session_handler() return; } +/* +* Get list of unread topics +* only for registered users and non-cookie tracking this function is used +*/ +function get_unread_topics_list($user_id = false, $sql_extra = '') +{ + global $config, $db, $user; + + if($user_id === false) + { + $user_id = $user->data['user_id']; + } + + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); + $tracked_forums_list = array(); + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = {$user_id}"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = $row['forum_id']; + } + $db->sql_freeresult($result); + + // Get list of the unread topics - on topics tracking as the first step + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + WHERE t.topic_id = tt.topic_id + AND t.topic_last_post_time >= tt.mark_time + AND tt.user_id = {$user_id} + $sql_extra"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + if($row['topic_last_post_time'] == $row['mark_time']) + { + // Check if there're read topics for the forums having unread ones + $read_topics_list[$row['topic_id']] = $row['mark_time']; + } + else + { + $unread_topics_list[$row['topic_id']] = $row['mark_time']; + } + } + $db->sql_freeresult($result); + + // Get the full list of the tracked topics + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = {$user_id} + $sql_extra"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " + WHERE topic_last_post_time > {$user->data['user_lastmark']} + AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' + AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql_extra"; + $result = $db->sql_query_limit($sql, 1000); + while($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + // We do not implement unread topics list for cookie based tracking + // because it would require expensive database queries + } + + return $unread_topics_list; +} + ?> \ No newline at end of file -- cgit v1.2.1 From e3866c939d78b925844cd61d6ad567988f24e42d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 Jul 2009 20:35:53 +0000 Subject: Feature Bug #43375 - Ability to delete warnings and keep warnings permanently Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9758 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74f7e31bee..eaaa8aaf6a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4025,7 +4025,7 @@ function page_footer($run_cron = true) // Tidy the cache $cron_type = 'tidy_cache'; } - else if (time() - $config['warnings_gc'] > $config['warnings_last_gc']) + else if ($config['warnings_last_gc'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } -- cgit v1.2.1 From ba08191a7027969eabaa03c4369f8d9bae4fd7a6 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Sat, 18 Jul 2009 09:44:03 +0000 Subject: - PHP4 compatibility git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9776 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index eaaa8aaf6a..5b0a2340b5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3306,6 +3306,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = $msg_long_text; } + if (!defined('E_DEPRECATED')) + { + define('E_DEPRECATED', 8192); + } + switch ($errno) { case E_NOTICE: @@ -3481,6 +3486,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; + + // PHP4 comptibility + case E_DEPRECATED: + return true; + break; } // If we notice an error not handled here we pass this back to PHP by returning false -- cgit v1.2.1 From 0fe2b41cfca76b51eb14cc687f2a978b0f4a4da0 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 18 Jul 2009 10:02:06 +0000 Subject: #42925 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9777 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5b0a2340b5..d1a560f96d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1164,7 +1164,7 @@ function tz_select($default = '', $truncate = false) if (is_numeric($offset)) { $selected = ($offset == $default) ? ' selected="selected"' : ''; - $tz_select .= ''; + $tz_select .= ''; } } -- cgit v1.2.1 From d61afd3509de3823c4f405fc95f8f799f073c505 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 18 Jul 2009 23:29:25 +0000 Subject: Ensure user errors are displayed regardless of PHP settings. #47505 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9785 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d1a560f96d..2dd28b2ffe 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3295,7 +3295,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text; // Do not display notices if we suppress them via @ - if (error_reporting() == 0) + if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) { return; } -- cgit v1.2.1 From 818b252f208b92157b56b101aac555eb1efb8cee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 22 Jul 2009 11:47:37 +0000 Subject: fix r9758 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9828 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2dd28b2ffe..1a791ebff9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4035,7 +4035,7 @@ function page_footer($run_cron = true) // Tidy the cache $cron_type = 'tidy_cache'; } - else if ($config['warnings_last_gc'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) + else if ($config['warnings_expire_days'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } -- cgit v1.2.1 From ba37fa4f49c17047da9aeeb8ada5efaf1030e795 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sun, 26 Jul 2009 10:16:52 +0000 Subject: Fix r9755 for #46765 Authorised by: ToonArmy git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9855 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1a791ebff9..2d86b233f7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4138,7 +4138,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') { global $config, $db, $user; - if($user_id === false) + if ($user_id === false) { $user_id = $user->data['user_id']; } @@ -4150,25 +4150,28 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') { // List of the tracked forums (not ideal, hope the better way will be found) // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user_id}"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $tracked_forums_list[] = $row['forum_id']; } $db->sql_freeresult($result); - + // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id AND t.topic_last_post_time >= tt.mark_time AND tt.user_id = {$user_id} - $sql_extra"; + $sql_extra + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - if($row['topic_last_post_time'] == $row['mark_time']) + if ($row['topic_last_post_time'] == $row['mark_time']) { // Check if there're read topics for the forums having unread ones $read_topics_list[$row['topic_id']] = $row['mark_time']; @@ -4179,33 +4182,41 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } } $db->sql_freeresult($result); - + // Get the full list of the tracked topics $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); // Get list of the unread topics - on forums tracking as the second step // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft WHERE t.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " AND ft.user_id = {$user_id} - $sql_extra"; + $sql_extra + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $unread_topics_list[$row['topic_id']] = $row['mark_time']; } $db->sql_freeresult($result); - + + // Refresh the full list of the tracked topics + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . " WHERE topic_last_post_time > {$user->data['user_lastmark']} AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " - $sql_extra"; + $sql_extra + ORDER BY topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; } -- cgit v1.2.1 From a0acfb6a3fce9a547d19c28ac99654275152ac98 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 11:39:28 +0000 Subject: Minor captcha API change - disable display of plugin by returning false in get_template. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9869 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2d86b233f7..4badd69e9f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2752,7 +2752,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha->reset(); $template->assign_vars(array( - 'S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); -- cgit v1.2.1 From d2420fe5550454871e784be846849d3e57dde5e8 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 28 Jul 2009 14:34:12 +0000 Subject: Fix r9855 for #46765 Authorised by: bantu git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9882 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4badd69e9f..639e9aa899 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4210,7 +4210,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . " WHERE topic_last_post_time > {$user->data['user_lastmark']} - AND " . $db->sql_in_set('topic_id', array_keys($unread_topics_list), true, true) . ' + AND " . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " $sql_extra ORDER BY topic_last_post_time DESC"; -- cgit v1.2.1 From e2d24413b6323ec1863b01413082ef7f7daa739b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 14:56:39 +0000 Subject: More small adjustments to get_unread_topics_list(). #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9883 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 639e9aa899..289f7f084f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4139,7 +4139,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') if ($user_id === false) { - $user_id = $user->data['user_id']; + $user_id = (int) $user->data['user_id']; } $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); @@ -4151,11 +4151,12 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') // This list is to fetch later the forums user never read (fully) before $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user_id}"; + WHERE user_id = $user_id"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $tracked_forums_list[] = $row['forum_id']; + $tracked_forums_list[] = (int) $row['forum_id']; } $db->sql_freeresult($result); @@ -4164,20 +4165,21 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id AND t.topic_last_post_time >= tt.mark_time - AND tt.user_id = {$user_id} + AND tt.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { if ($row['topic_last_post_time'] == $row['mark_time']) { // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = $row['mark_time']; + $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; } else { - $unread_topics_list[$row['topic_id']] = $row['mark_time']; + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; } } $db->sql_freeresult($result); @@ -4192,13 +4194,14 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') WHERE t.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = {$user_id} + AND ft.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = $row['mark_time']; + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; } $db->sql_freeresult($result); @@ -4208,16 +4211,17 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') // And the last step - find unread topics were not found before (that can mean a user has never read some forums) $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . " - WHERE topic_last_post_time > {$user->data['user_lastmark']} - AND " . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' + FROM ' . TOPICS_TABLE . ' + WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " $sql_extra ORDER BY topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); + while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = $user->data['user_lastmark']; + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; } $db->sql_freeresult($result); } -- cgit v1.2.1 From da0da0dd8990b11b4005c290ab448fb0dc175454 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 15:30:47 +0000 Subject: Move get_unread_topics_list() up in functions.php, added some documentation. Related to #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9884 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 216 ++++++++++++++++++++++--------------------- 1 file changed, 111 insertions(+), 105 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 289f7f084f..3aaa6fbcab 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1644,6 +1644,117 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis return $last_read; } +/** +* Get list of unread topics +* only for registered users and non-cookie tracking +* +* @param int $user_id User ID (or false for currect user) +* @param string $sql_extra Extra WHERE SQL statement +* +* @return array[int][int] Topic ids as keys, mark_time of topic as value +* @author rxu +*/ +function get_unread_topics_list($user_id = false, $sql_extra = '') +{ + global $config, $db, $user; + + if ($user_id === false) + { + $user_id = (int) $user->data['user_id']; + } + + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); + $tracked_forums_list = array(); + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + // Get list of the unread topics - on topics tracking as the first step + $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt + WHERE t.topic_id = tt.topic_id + AND t.topic_last_post_time >= tt.mark_time + AND tt.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['topic_last_post_time'] == $row['mark_time']) + { + // Check if there're read topics for the forums having unread ones + $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + else + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + } + $db->sql_freeresult($result); + + // Get the full list of the tracked topics + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + $db->sql_freeresult($result); + + // Refresh the full list of the tracked topics + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql_extra + ORDER BY topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, 1000); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + // We do not implement unread topics list for cookie based tracking + // because it would require expensive database queries + } + + return $unread_topics_list; +} + /** * Check for read forums and update topic tracking info accordingly * @@ -4129,109 +4240,4 @@ function phpbb_user_session_handler() return; } -/* -* Get list of unread topics -* only for registered users and non-cookie tracking this function is used -*/ -function get_unread_topics_list($user_id = false, $sql_extra = '') -{ - global $config, $db, $user; - - if ($user_id === false) - { - $user_id = (int) $user->data['user_id']; - } - - $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = array(); - - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt - WHERE t.topic_id = tt.topic_id - AND t.topic_last_post_time >= tt.mark_time - AND tt.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['topic_last_post_time'] == $row['mark_time']) - { - // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - else - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - } - $db->sql_freeresult($result); - - // Get the full list of the tracked topics - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); - - // Refresh the full list of the tracked topics - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " - $sql_extra - ORDER BY topic_last_post_time DESC"; - $result = $db->sql_query_limit($sql, 1000); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; - } - $db->sql_freeresult($result); - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - // We do not implement unread topics list for cookie based tracking - // because it would require expensive database queries - } - - return $unread_topics_list; -} - ?> \ No newline at end of file -- cgit v1.2.1 From 8880e86f7b93c8b03e4f788c6abc17b429b390e7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 20:29:34 +0000 Subject: Fix tiny typo in r9884, #46765. Thanks rxu. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9885 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3aaa6fbcab..241bed408f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1648,7 +1648,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * Get list of unread topics * only for registered users and non-cookie tracking * -* @param int $user_id User ID (or false for currect user) +* @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement * * @return array[int][int] Topic ids as keys, mark_time of topic as value -- cgit v1.2.1 From 73a6f7263b02ed694d986967a162f2359f89f709 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 13:52:37 +0000 Subject: Adjust build_url() to not prepend $phpbb_root_path if path returned from redirect() is an URL. This fixes redirect issues with some installations and bridges. (Bug #47535) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9907 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 241bed408f..d147872c34 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2284,7 +2284,7 @@ function redirect($url, $return = false, $disable_cd_check = false) $url = str_replace('&', '&', $url); // Determine which type of redirect we need to handle... - $url_parts = parse_url($url); + $url_parts = @parse_url($url); if ($url_parts === false) { @@ -2497,6 +2497,18 @@ function build_url($strip_vars = false) $redirect .= ($query) ? '?' . $query : ''; } + // We need to be cautious here. + // On some situations, the redirect path is an absolute URL, sometimes a relative path + // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location, + // else we use the URL directly. + $url_parts = @parse_url($redirect); + + // URL + if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host'])) + { + return str_replace('&', '&', $redirect); + } + return $phpbb_root_path . str_replace('&', '&', $redirect); } @@ -3596,7 +3608,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; - + // PHP4 comptibility case E_DEPRECATED: return true; -- cgit v1.2.1 From ccbbaba91d0314144932c2916229818b0ac71c4e Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 4 Aug 2009 15:34:04 +0000 Subject: add the option to place image debugging information to the log git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9920 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d147872c34..6549ba9b0d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3465,8 +3465,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // remove complete path to installation, with the risk of changing backslashes meant to be there $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); - echo '[phpBB Debug] PHP Notice: in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; + + // we are writing an image - the user won't see the debug, so let's place it in the log + if (defined('IMAGE_OUTPUT')) + { + add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text); + } // echo '

BACKTRACE
' . get_backtrace() . '
' . "\n"; } -- cgit v1.2.1 From b6690e51f9a125380cea86f23138ab95db7b51da Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 4 Aug 2009 15:57:38 +0000 Subject: and for pseudocron too (to conisder: log db errors to debug faulty cron jobs) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9923 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6549ba9b0d..13864848a8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3468,7 +3468,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) echo '[phpBB Debug] PHP Notice: in file ' . $errfile . ' on line ' . $errline . ': ' . $msg_text . '
' . "\n"; // we are writing an image - the user won't see the debug, so let's place it in the log - if (defined('IMAGE_OUTPUT')) + if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) { add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text); } @@ -3614,7 +3614,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) exit_handler(); break; - // PHP4 comptibility + // PHP4 compatibility case E_DEPRECATED: return true; break; -- cgit v1.2.1 From 4e9ce7060edad3361db224996adb5a87bf083b69 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 5 Aug 2009 12:02:18 +0000 Subject: log general errors in cron, images and when debug is enabled git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9924 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 13864848a8..e797b279c9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3505,6 +3505,14 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; } } + + if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) + { + // let's avoid loops + $db->sql_return_on_error(true); + add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $msg_text); + $db->sql_return_on_error(false); + } garbage_collection(); -- cgit v1.2.1 From 914687075da7769583e2752701121deee61ff525 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Wed, 5 Aug 2009 12:51:48 +0000 Subject: Fix bug #15729 - Global announcements marked as read if all new topics in forum are viewed Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9926 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e797b279c9..23ed190bcd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1227,7 +1227,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Add 0 to forums array to mark global announcements correctly - $forum_id[] = 0; + // $forum_id[] = 0; if ($config['load_db_lastread'] && $user->data['is_registered']) { -- cgit v1.2.1 From dedddfabedf357cda8606a6bc6c49ac48028bc07 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 09:19:47 +0000 Subject: change item to item_id; related to #49485 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9958 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 23ed190bcd..6c651b2b86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3692,7 +3692,7 @@ function obtain_users_online($item_id = 0, $item = 'forum') global $db, $config, $user; $reading_sql = ''; - if ($item !== 0) + if ($item_id !== 0) { $reading_sql = ' AND s.session_' . $item . '_id = ' . (int) $item_id; } -- cgit v1.2.1 From 2d0d35db48b0c3aae9952e1cf805beebe222958c Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 12 Aug 2009 10:30:37 +0000 Subject: populate who is online only where required git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9961 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6c651b2b86..4f88ee9625 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3861,7 +3861,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' /** * Generate page header */ -function page_header($page_title = '', $display_online_list = true) +function page_header($page_title = '', $display_online_list = true, $forum_id = 0) { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; @@ -3917,10 +3917,18 @@ function page_header($page_title = '', $display_online_list = true) * } * */ - - $item_id = max(request_var('f', 0), 0); + + if ($forum_id) + { + $item_id = max($forum_id, 0); + } + else + { + $item_id = 0; + } + + // workaround legacy code $item = 'forum'; - $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); -- cgit v1.2.1 From 09ad10a734c0993f9465e6ac3463951251602fc6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Aug 2009 15:00:47 +0000 Subject: ok, i am very sorry, but this needs to be fixed. Generally, our config table is not really suited for holding large datasets. Because feed settings for the forums to enable news feeds and excluded forums rely on the forums itself we have decided to introduce a forum_options table where custom options can be stored. Additionally, for this to work across all DBMS we support, we added a new method to the DBAL for the bitwise AND operator. Also moved the forum/topic feed template variable to the location where they belong to (forum and topic view) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9965 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 57 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4f88ee9625..49e9f41704 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3505,7 +3505,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $l_notify = '

Please notify the board administrator or webmaster: ' . $config['board_contact'] . '

'; } } - + if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) { // let's avoid loops @@ -3857,6 +3857,40 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' ); } +/** +* Get option bitfield from custom data +* +* @param int $bit The bit/value to get +* @param int $data Current bitfield to check +* @return bool Returns true if value of constant is set in bitfield, else false +*/ +function phpbb_optionget($bit, $data) +{ + return ($data & 1 << (int) $bit) ? true : false; +} + +/** +* Set option bitfield +* +* @param int $bit The bit/value to set/unset +* @param bool $set True if option should be set, false if option should be unset. +* @param int $data Current bitfield to change +* +* @return int The new bitfield +*/ +function phpbb_optionset($bit, $set, $data) +{ + if ($set && !($data & 1 << $bit)) + { + $data += 1 << $bit; + } + else if (!$set && ($data & 1 << $bit)) + { + $data -= 1 << $bit; + } + + return $data; +} /** * Generate page header @@ -3917,7 +3951,7 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = * } * */ - + if ($forum_id) { $item_id = max($forum_id, 0); @@ -3926,7 +3960,7 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = { $item_id = 0; } - + // workaround legacy code $item = 'forum'; $online_users = obtain_users_online($item_id, $item); @@ -4005,6 +4039,19 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); + $s_feed_news = false; + + // Get option for news + if ($config['feed_enable']) + { + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); + $result = $db->sql_query_limit($sql, 1, 0, 600); + $s_feed_news = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + } + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -4082,11 +4129,9 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = 'S_TOPIC_ID' => $topic_id, 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, - 'S_ENABLE_FEEDS_NEWS' => ($config['feed_news_id'] != '') ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, - 'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_id && strpos($user->page['page_name'], 'viewforum') !== false) ? true : false, - 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && $topic_id && strpos($user->page['page_name'], 'viewtopic') !== false) ? true : false, + 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', -- cgit v1.2.1 From ee1ae00e033e376b717756d152c461b014da053a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 15 Aug 2009 14:18:19 +0000 Subject: r9961 - also set item name in page_header parameter for better implementation of #31975 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9991 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 49e9f41704..2f8a3ddda6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3895,7 +3895,7 @@ function phpbb_optionset($bit, $set, $data) /** * Generate page header */ -function page_header($page_title = '', $display_online_list = true, $forum_id = 0) +function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $user, $auth, $phpEx, $phpbb_root_path; @@ -3937,32 +3937,10 @@ function page_header($page_title = '', $display_online_list = true, $forum_id = { /** * Load online data: - * For obtaining another session column use the following code, whereby the column is session_{$item}_id. - * Put the code directly after $item = 'forum'; - * - * - * $my_item_id = request_var('my_item_id', 0); - * - * if ($my_item_id > 0) - * { - * // would revolve to the column session_myitem_id in the SESSIONS_TABLE - * $item = 'myitem'; - * $item_id = $my_item_id; - * } - * + * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id. */ + $item_id = max($item_id, 0); - if ($forum_id) - { - $item_id = max($forum_id, 0); - } - else - { - $item_id = 0; - } - - // workaround legacy code - $item = 'forum'; $online_users = obtain_users_online($item_id, $item); $user_online_strings = obtain_users_online_string($online_users, $item_id, $item); -- cgit v1.2.1 From f0ebe145e1d31d11c753bdc404803c3d1be94343 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Aug 2009 09:45:22 +0000 Subject: Fix r9961 - populate who is online only where required Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10000 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2f8a3ddda6..d1883907dd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2706,7 +2706,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo } else { - page_header((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]); + page_header(((!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title]), false); } $template->set_filenames(array( @@ -3028,7 +3028,7 @@ function login_forum_box($forum_data) $template->assign_var('LOGIN_ERROR', $user->lang['WRONG_PASSWORD']); } - page_header($user->lang['LOGIN']); + page_header($user->lang['LOGIN'], false); $template->assign_vars(array( 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) @@ -3592,7 +3592,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } else { - page_header($msg_title); + page_header($msg_title, false); } } -- cgit v1.2.1 From 300f6868afc4ee53d97d289f85a0383b88ba377e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 13:21:44 +0000 Subject: i am very very sorry for this hackish approach... (ability to skip add_log calls) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10003 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d1883907dd..02bd24b246 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3150,6 +3150,14 @@ function add_log() { global $db, $user; + // In phpBB 3.1.x i want to have logging in a class to be able to control it + // For now, we need a quite hakish approach to circumvent logging for some actions + // @todo implement cleanly + if (!empty($GLOBALS['skip_add_log'])) + { + return false; + } + $args = func_get_args(); $mode = array_shift($args); -- cgit v1.2.1 From 45f570038426f36d547dcdc23ef631bd48a7dc6e Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Mon, 17 Aug 2009 13:28:28 +0000 Subject: Add unread posts search support for cookie-based tracking Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10005 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 59 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 02bd24b246..8f263f08e4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1646,7 +1646,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis /** * Get list of unread topics -* only for registered users and non-cookie tracking * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement @@ -1664,7 +1663,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = array(); + $tracked_forums_list = $mark_time = array(); if ($config['load_db_lastread'] && $user->data['is_registered']) { @@ -1748,8 +1747,60 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - // We do not implement unread topics list for cookie based tracking - // because it would require expensive database queries + global $tracking_topics; + + if (!isset($tracking_topics) || !sizeof($tracking_topics)) + { + $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); + } + + if (!$user->data['is_registered']) + { + $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; + } + else + { + $user_lastmark = $user->data['user_lastmark']; + } + + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . $user_lastmark . " + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + + $result = $db->sql_query_limit($sql, 1000); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_id = (int) $row['forum_id']; + $topic_id = (int) $row['topic_id']; + $topic_id36 = base_convert($topic_id, 10, 36); + + if (isset($tracking_topics['t'][$topic_id36])) + { + $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; + if ($row['topic_last_post_time'] > $last_read[$topic_id]) + { + $unread_topics_list[$topic_id] = $last_read[$topic_id]; + } + } + else if (isset($tracking_topics['f'][$forum_id])) + { + $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; + if ($row['topic_last_post_time'] > $mark_time[$forum_id]) + { + $unread_topics_list[$topic_id] = $mark_time[$forum_id]; + } + } + else + { + $unread_topics_list[$topic_id] = $user_lastmark; + } + + } + $db->sql_freeresult($result); } return $unread_topics_list; -- cgit v1.2.1 From f7009291e20969421f90ab81eed1347a4d977501 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 14:45:14 +0000 Subject: Ability to define constant PHPBB_USE_BOARD_URL_PATH to use board url for images/avatars/ranks/imageset... This feature does not change anything for those not using the constant and this feature is also quite in-flux. We need to test this with some applications and bridges and there may be other locations able to benefit from it. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10008 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8f263f08e4..00af5146cf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4089,6 +4089,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $db->sql_freeresult($result); } + // Determine board url - we may need it later + $board_url = generate_board_url() . '/'; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -4112,6 +4116,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $phpbb_root_path, + 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], @@ -4170,21 +4175,34 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, - 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', - 'T_TEMPLATE_PATH' => "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', - 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$phpbb_root_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template', - 'T_IMAGESET_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset', - 'T_IMAGESET_LANG_PATH' => "{$phpbb_root_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/", - 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/", - 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/", - 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", - 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", - 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : "{$phpbb_root_path}style.$phpEx?sid=$user->session_id&id=" . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], + 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', + 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', + 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', + 'T_IMAGESET_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset', + 'T_IMAGESET_LANG_PATH' => "{$web_path}styles/" . $user->theme['imageset_path'] . '/imageset/' . $user->data['user_lang'], + 'T_IMAGES_PATH' => "{$web_path}images/", + 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", + 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", + 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", + 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", + 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", + 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", + 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], + 'T_THEME_NAME' => $user->theme['theme_path'], + 'T_TEMPLATE_NAME' => $user->theme['template_path'], + 'T_SUPER_TEMPLATE_NAME' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? $user->theme['template_inherit_path'] : $user->theme['template_path'], + 'T_IMAGESET_NAME' => $user->theme['imageset_path'], + 'T_IMAGESET_LANG_NAME' => $user->data['user_lang'], + 'T_IMAGES' => 'images', + 'T_SMILIES' => $config['smilies_path'], + 'T_AVATAR' => $config['avatar_path'], + 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], + 'T_ICONS' => $config['icons_path'], + 'T_RANKS' => $config['ranks_path'], + 'T_UPLOAD' => $config['upload_path'], + 'SITE_LOGO_IMG' => $user->img('site_logo'), 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), -- cgit v1.2.1 From 2c02367dc05b048fe52329e5fd400b7c51ae1b1b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 15:45:07 +0000 Subject: no need to call generate_board_url() twice - r10008 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10009 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 00af5146cf..172b6a7467 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1796,7 +1796,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } else { - $unread_topics_list[$topic_id] = $user_lastmark; + $unread_topics_list[$topic_id] = $user_lastmark; } } @@ -4091,7 +4091,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url . '/' : $phpbb_root_path; // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( -- cgit v1.2.1 From bfee2c4c67e942d54e1560cd3f099fe7e19b7a59 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 15:47:07 +0000 Subject: i know, i know, no need to hrm me. :P - r10009 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10010 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 172b6a7467..12272b152c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4091,7 +4091,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url . '/' : $phpbb_root_path; + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( -- cgit v1.2.1 From d2d5ecef8d5fba02747b57e58bb89360100ea021 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 18 Aug 2009 14:51:08 +0000 Subject: Better tracking of global announcements Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10018 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 12272b152c..6750772ebb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1730,13 +1730,13 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . " + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " $sql_extra - ORDER BY topic_last_post_time DESC"; + ORDER BY t.topic_last_post_time DESC"; $result = $db->sql_query_limit($sql, 1000); while ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From fffb25ace4893498b6f6fc87c51ec58341828cd9 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sun, 23 Aug 2009 11:12:22 +0000 Subject: More unread posts search adjustment. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10045 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 108 +++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 50 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6750772ebb..820a03fe64 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1649,11 +1649,12 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement +* @param string $sql_limit Limits the size of unread topics list * * @return array[int][int] Topic ids as keys, mark_time of topic as value * @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '') +function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = 1001) { global $config, $db, $user; @@ -1667,32 +1668,18 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') if ($config['load_db_lastread'] && $user->data['is_registered']) { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - // Get list of the unread topics - on topics tracking as the first step $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt WHERE t.topic_id = tt.topic_id - AND t.topic_last_post_time >= tt.mark_time AND tt.user_id = $user_id $sql_extra ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { - if ($row['topic_last_post_time'] == $row['mark_time']) + if ($row['topic_last_post_time'] <= $row['mark_time']) { // Check if there're read topics for the forums having unread ones $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; @@ -1704,46 +1691,67 @@ function get_unread_topics_list($user_id = false, $sql_extra = '') } $db->sql_freeresult($result); - // Get the full list of the tracked topics + // Get the full list of the tracked topics and unread topics count $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + $unread_list_count = sizeof($unread_topics_list); + + if ($unread_list_count < $sql_limit) + { + // Get list of the unread topics - on forums tracking as the second step + // We don't take in account topics tracked before + $sql = 'SELECT t.topic_id, ft.mark_time + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft + WHERE t.forum_id = ft.forum_id + AND t.topic_last_post_time > ft.mark_time + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " + AND ft.user_id = $user_id + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + } + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); + // Refresh the full list of the tracked topics and unread topics count + unset($tracked_topics_list); + $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + $unread_list_count = sizeof($unread_topics_list); - // Refresh the full list of the tracked topics - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); + if ($unread_list_count < $sql_limit) + { + // List of the tracked forums (not ideal, hope the better way will be found) + // This list is to fetch later the forums user never read (fully) before + $sql = 'SELECT forum_id + FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query($sql); - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " - $sql_extra - ORDER BY t.topic_last_post_time DESC"; - $result = $db->sql_query_limit($sql, 1000); + while ($row = $db->sql_fetchrow($result)) + { + $tracked_forums_list[] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + // And the last step - find unread topics were not found before (that can mean a user has never read some forums) + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' + AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' + AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " + $sql_extra + ORDER BY t.topic_last_post_time DESC"; + $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); + + while ($row = $db->sql_fetchrow($result)) + { + $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + } + $db->sql_freeresult($result); + } } - $db->sql_freeresult($result); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { -- cgit v1.2.1 From 48b54bb29e12ec0dc052a688ccc5c18856675d97 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 25 Aug 2009 10:02:24 +0000 Subject: Adjustement for r10050, related to Bug #50185 Use internal S_TAB_INDEX instead of DEFINE git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10055 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 820a03fe64..79ea8978ee 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4120,6 +4120,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], + 'S_TAB_INDEX' => 1, + 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, -- cgit v1.2.1 From fa754d1576466f7ca8a483e72b5b1e1d47a4b1ad Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Tue, 25 Aug 2009 13:52:35 +0000 Subject: One more unread posts search adjustment. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10057 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 79ea8978ee..f5e494ae4c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1649,12 +1649,13 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * * @param int $user_id User ID (or false for current user) * @param string $sql_extra Extra WHERE SQL statement -* @param string $sql_limit Limits the size of unread topics list +* @param string $sql_sort ORDER BY SQL sorting statement +* @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query * * @return array[int][int] Topic ids as keys, mark_time of topic as value * @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = 1001) +function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) { global $config, $db, $user; @@ -1663,6 +1664,11 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = $user_id = (int) $user->data['user_id']; } + if (empty($sql_sort)) + { + $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; + } + $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); $tracked_forums_list = $mark_time = array(); @@ -1674,7 +1680,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = WHERE t.topic_id = tt.topic_id AND tt.user_id = $user_id $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) @@ -1706,7 +1712,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " AND ft.user_id = $user_id $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); while ($row = $db->sql_fetchrow($result)) @@ -1742,7 +1748,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); while ($row = $db->sql_fetchrow($result)) @@ -1776,9 +1782,9 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra - ORDER BY t.topic_last_post_time DESC"; + $sql_sort"; - $result = $db->sql_query_limit($sql, 1000); + $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From f1bd295ce6c92e219d20ac684835cd7aa4ce803b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 27 Aug 2009 09:10:28 +0000 Subject: Change of r10055, which itself was: Adjustement for r10050, related to Bug #50185 Instead of S_TAB_INDEX we now use a method suggested by nickvergessen - we simply DEFINE the tabindex for the captcha depending on where it is included. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10058 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f5e494ae4c..e23278a0f2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4126,8 +4126,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], - 'S_TAB_INDEX' => 1, - 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, -- cgit v1.2.1 From c52f05b3329c9c79ecbc3184bd65cdbe4644ebcd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Aug 2009 09:26:43 +0000 Subject: Fix Bug #49195 - Queries on un-indexed column user_email Added function to generate email-hash. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10060 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e23278a0f2..17fb351630 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -551,6 +551,14 @@ function _hash_crypt_private($password, $setting, &$itoa64) return $output; } +/** +* Hash email +*/ +function phpbb_email_hash($email) +{ + return crc32(strtolower($email)) . strlen($email); +} + /** * Global function for chmodding directories and files for internal use * -- cgit v1.2.1 From f26b9e42c0f56a75950283d47f3ab356399f6639 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 28 Aug 2009 11:39:45 +0000 Subject: Send service unavailable response code for E_USER_ERROR git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10061 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 17fb351630..d6ca262ab8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3595,6 +3595,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $db->sql_return_on_error(false); } + // Do not send 200 OK, but service unavailable on errors + header('HTTP/1.1 503 Service Unavailable'); + garbage_collection(); // Try to not call the adm page data... -- cgit v1.2.1 From 5e2e08b05dc11992c3c56c45cc93e6d12ff6ae7d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 17:13:28 +0000 Subject: Simplified login_box() and redirection after login. S_LOGIN_ACTION can now be used on every page. (Bug #50285) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10067 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d6ca262ab8..c6a6d354ce 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2978,28 +2978,18 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa } } - if (!$redirect) - { - // We just use what the session code determined... - // If we are not within the admin directory we use the page dir... - $redirect = ''; - - if (!$admin) - { - $redirect .= ($user->page['page_dir']) ? $user->page['page_dir'] . '/' : ''; - } - - $redirect .= $user->page['page_name'] . (($user->page['query_string']) ? '?' . htmlspecialchars($user->page['query_string']) : ''); - } - // Assign credential for username/password pair $credential = ($admin) ? md5(unique_id()) : false; $s_hidden_fields = array( - 'redirect' => $redirect, 'sid' => $user->session_id, ); + if ($redirect) + { + $s_hidden_fields['redirect'] = $redirect; + } + if ($admin) { $s_hidden_fields['credential'] = $credential; @@ -3017,7 +3007,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, - 'S_LOGIN_ACTION' => (!$admin) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id), // Needs to stay index.$phpEx because we are within the admin directory 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, @@ -4195,6 +4184,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, + 'S_LOGIN_ACTION' => (!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())) : append_sid("index.$phpEx", false, true, $user->session_id) . '&redirect=' . urlencode(str_replace('&', '&', build_url())), + 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, -- cgit v1.2.1 From c492016ace472b5a8e432fbf2bf8f391d690b642 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 31 Aug 2009 09:31:30 +0000 Subject: Addition to r10060: Add function documentation. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10071 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c6a6d354ce..6d67f87096 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -552,7 +552,11 @@ function _hash_crypt_private($password, $setting, &$itoa64) } /** -* Hash email +* Hashes an email address to a big integer +* +* @param string $email Email address +* +* @return string Big Integer */ function phpbb_email_hash($email) { -- cgit v1.2.1 From 714aa8b09a62994ad4777d30064b72c90e84b442 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 11:39:59 +0000 Subject: Only embed cron.php if there is no cron lock present to reduce overhead. (Bug #45725 - Patch by TerryE) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10082 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6d67f87096..f18514096f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4284,7 +4284,26 @@ function page_footer($run_cron = true) ); // Call cron-type script + $call_cron = false; if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) + { + $call_cron = true; + + // Any old lock present? + if (!empty($config['cron_lock'])) + { + $cron_time = explode(' ', $config['cron_lock']); + + // If 1 hour lock is present we do not call cron.php + if ($cron_time[0] + 3600 >= time()) + { + $call_cron = false; + } + } + } + + // Call cron job? + if ($call_cron) { $cron_type = ''; -- cgit v1.2.1 From 6134b641e395f1abd0a4fc71c50470ab93dea07e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 1 Sep 2009 18:37:51 +0000 Subject: Save some calls here, since page_footer(true) gets called quite often. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10087 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f18514096f..96ecf739ed 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4288,6 +4288,7 @@ function page_footer($run_cron = true) if (!defined('IN_CRON') && $run_cron && !$config['board_disable']) { $call_cron = true; + $time_now = (!empty($user->time_now) && is_int($user->time_now)) ? $user->time_now : time(); // Any old lock present? if (!empty($config['cron_lock'])) @@ -4295,7 +4296,7 @@ function page_footer($run_cron = true) $cron_time = explode(' ', $config['cron_lock']); // If 1 hour lock is present we do not call cron.php - if ($cron_time[0] + 3600 >= time()) + if ($cron_time[0] + 3600 >= $time_now) { $call_cron = false; } @@ -4307,31 +4308,31 @@ function page_footer($run_cron = true) { $cron_type = ''; - if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) + if ($time_now - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) { // Process email queue $cron_type = 'queue'; } - else if (method_exists($cache, 'tidy') && time() - $config['cache_gc'] > $config['cache_last_gc']) + else if (method_exists($cache, 'tidy') && $time_now - $config['cache_gc'] > $config['cache_last_gc']) { // Tidy the cache $cron_type = 'tidy_cache'; } - else if ($config['warnings_expire_days'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) + else if ($config['warnings_expire_days'] && ($time_now - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } - else if (time() - $config['database_gc'] > $config['database_last_gc']) + else if ($time_now - $config['database_gc'] > $config['database_last_gc']) { // Tidy the database $cron_type = 'tidy_database'; } - else if (time() - $config['search_gc'] > $config['search_last_gc']) + else if ($time_now - $config['search_gc'] > $config['search_last_gc']) { // Tidy the search $cron_type = 'tidy_search'; } - else if (time() - $config['session_gc'] > $config['session_last_gc']) + else if ($time_now - $config['session_gc'] > $config['session_last_gc']) { $cron_type = 'tidy_sessions'; } -- cgit v1.2.1 From 73baf42558b70acf7b2e194a84172778374a1c6e Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Wed, 2 Sep 2009 05:12:23 +0000 Subject: Fixed bugs #43145, #44375, #44415 and #43045 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10088 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 96ecf739ed..8957633ec7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3006,7 +3006,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', - 'U_RESEND_ACTIVATION' => ($config['require_activation'] != USER_ACTIVATION_NONE && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', + 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), -- cgit v1.2.1 From 4c6360f5b5766900c5d86e5522be1a622f15b345 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 3 Sep 2009 13:59:31 +0000 Subject: #50675 ; also don't reset the captcha on login git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10094 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8957633ec7..69d764b7aa 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2082,7 +2082,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add } $on_page = floor($start_item / $per_page) + 1; - $url_delim = (strpos($base_url, '?') === false) ? '?' : '&'; + $url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); $page_string = ($on_page == 1) ? '1' : '1'; @@ -2949,7 +2949,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); - $captcha->reset(); + // $captcha->reset(); $template->assign_vars(array( 'CAPTCHA_TEMPLATE' => $captcha->get_template(), -- cgit v1.2.1 From 1d37a633cdd1047d19d760e637a2d0221daa6264 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 7 Sep 2009 00:38:20 +0000 Subject: Adjustments to r10005: Use request_var() to get cookie data. Some more adjustments to get_unread_topics_list() Related to report: #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10113 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 69d764b7aa..be1208fb2e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1671,10 +1671,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { global $config, $db, $user; - if ($user_id === false) - { - $user_id = (int) $user->data['user_id']; - } + $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; if (empty($sql_sort)) { @@ -1697,14 +1694,16 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { + $topic_id = (int) $row['topic_id']; + if ($row['topic_last_post_time'] <= $row['mark_time']) { // Check if there're read topics for the forums having unread ones - $read_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $read_topics_list[$topic_id] = (int) $row['mark_time']; } else { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $unread_topics_list[$topic_id] = (int) $row['mark_time']; } } $db->sql_freeresult($result); @@ -1729,7 +1728,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = (int) $row['mark_time']; + $unread_topics_list[(int) $row['topic_id']] = (int) $row['mark_time']; } $db->sql_freeresult($result); @@ -1765,7 +1764,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { - $unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark']; + $unread_topics_list[(int) $row['topic_id']] = (int) $user->data['user_lastmark']; } $db->sql_freeresult($result); } @@ -1775,9 +1774,9 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { global $tracking_topics; - if (!isset($tracking_topics) || !sizeof($tracking_topics)) + if (empty($tracking_topics)) { - $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = request_var($config['cookie_name'] . '_track', '', false, true); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); } @@ -1787,7 +1786,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' } else { - $user_lastmark = $user->data['user_lastmark']; + $user_lastmark = (int) $user->data['user_lastmark']; } $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time @@ -1795,7 +1794,6 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) @@ -1824,7 +1822,6 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' { $unread_topics_list[$topic_id] = $user_lastmark; } - } $db->sql_freeresult($result); } -- cgit v1.2.1 From bb8e42fa5f1c524ec17d20b4925d0f71494f202f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 7 Sep 2009 15:48:15 +0000 Subject: Fix retrieval of unread topics list. The old queries were too heavy, using temporary and filesort and actually only based on topics being retrieved before. Instead now use one query which is also a lot faster and yields the same results. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10118 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 104 +++++++++++-------------------------------- 1 file changed, 25 insertions(+), 79 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index be1208fb2e..3a5a018a86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1683,92 +1683,38 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' if ($config['load_db_lastread'] && $user->data['is_registered']) { - // Get list of the unread topics - on topics tracking as the first step - $sql = 'SELECT t.topic_id, t.topic_last_post_time, tt.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt - WHERE t.topic_id = tt.topic_id - AND tt.user_id = $user_id - $sql_extra - $sql_sort"; + // Get list of the unread topics + $sql_array = array( + 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', + + 'FROM' => array(TOPICS_TABLE => 't'), + + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), + 'ON' => 't.topic_id = tt.topic_id AND t.topic_last_post_time > tt.mark_time AND tt.user_id = ' . $user_id, + ), + array( + 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), + 'ON' => 't.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ft.user_id = ' . $user_id, + ), + ), + + 'WHERE' => "((tt.topic_id OR ft.forum_id) + OR t.topic_last_post_time > {$user->data['user_lastmark']}) + $sql_extra + $sql_sort", + ); + + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $sql_limit); while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - - if ($row['topic_last_post_time'] <= $row['mark_time']) - { - // Check if there're read topics for the forums having unread ones - $read_topics_list[$topic_id] = (int) $row['mark_time']; - } - else - { - $unread_topics_list[$topic_id] = (int) $row['mark_time']; - } + $unread_topics_list[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; } $db->sql_freeresult($result); - - // Get the full list of the tracked topics and unread topics count - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - $unread_list_count = sizeof($unread_topics_list); - - if ($unread_list_count < $sql_limit) - { - // Get list of the unread topics - on forums tracking as the second step - // We don't take in account topics tracked before - $sql = 'SELECT t.topic_id, ft.mark_time - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TRACK_TABLE . ' ft - WHERE t.forum_id = ft.forum_id - AND t.topic_last_post_time > ft.mark_time - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . " - AND ft.user_id = $user_id - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[(int) $row['topic_id']] = (int) $row['mark_time']; - } - $db->sql_freeresult($result); - - // Refresh the full list of the tracked topics and unread topics count - unset($tracked_topics_list); - $tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list)); - $unread_list_count = sizeof($unread_topics_list); - - if ($unread_list_count < $sql_limit) - { - // List of the tracked forums (not ideal, hope the better way will be found) - // This list is to fetch later the forums user never read (fully) before - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $tracked_forums_list[] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - // And the last step - find unread topics were not found before (that can mean a user has never read some forums) - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . ' - AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . ' - AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . " - $sql_extra - $sql_sort"; - $result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count)); - - while ($row = $db->sql_fetchrow($result)) - { - $unread_topics_list[(int) $row['topic_id']] = (int) $user->data['user_lastmark']; - } - $db->sql_freeresult($result); - } - } } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { -- cgit v1.2.1 From d85493ab16658387d603ca0d949e65bc3ea1533c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 8 Sep 2009 08:53:01 +0000 Subject: Rename get_unread_topics_list() to get_unread_topics(). Cleanup: Remove some stuff we no longer need. Related to report #46765 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10120 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3a5a018a86..21d4963aa7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1665,22 +1665,21 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query * * @return array[int][int] Topic ids as keys, mark_time of topic as value -* @author rxu */ -function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) +function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) { global $config, $db, $user; $user_id = ($user_id === false) ? (int) $user->data['user_id'] : (int) $user_id; + // Data array we're going to return + $unread_topics = array(); + if (empty($sql_sort)) { $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; } - $tracked_topics_list = $unread_topics_list = $read_topics_list = array(); - $tracked_forums_list = $mark_time = array(); - if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics @@ -1712,7 +1711,8 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - $unread_topics_list[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; + + $unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; } $db->sql_freeresult($result); } @@ -1750,29 +1750,31 @@ function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = ' if (isset($tracking_topics['t'][$topic_id36])) { - $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; - if ($row['topic_last_post_time'] > $last_read[$topic_id]) + $last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; + + if ($row['topic_last_post_time'] > $last_read) { - $unread_topics_list[$topic_id] = $last_read[$topic_id]; + $unread_topics[$topic_id] = $last_read; } } else if (isset($tracking_topics['f'][$forum_id])) { - $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; - if ($row['topic_last_post_time'] > $mark_time[$forum_id]) + $mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; + + if ($row['topic_last_post_time'] > $mark_time) { - $unread_topics_list[$topic_id] = $mark_time[$forum_id]; + $unread_topics[$topic_id] = $mark_time; } } else { - $unread_topics_list[$topic_id] = $user_lastmark; + $unread_topics[$topic_id] = $user_lastmark; } } $db->sql_freeresult($result); } - return $unread_topics_list; + return $unread_topics; } /** -- cgit v1.2.1 From 5537393f76cf56d21f39b863425f3ddb5c500808 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 8 Sep 2009 10:36:22 +0000 Subject: Further adjust unread tracking query, should work now for user last mark times less than forum/topic mark times. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10121 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 21d4963aa7..24dd58c116 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1683,6 +1683,8 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics + $last_mark = $user->data['user_lastmark']; + $sql_array = array( 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', @@ -1691,16 +1693,23 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s 'LEFT_JOIN' => array( array( 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => 't.topic_id = tt.topic_id AND t.topic_last_post_time > tt.mark_time AND tt.user_id = ' . $user_id, + 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id AND tt.mark_time > $last_mark", ), array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 't.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ft.user_id = ' . $user_id, + 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id AND ft.mark_time > $last_mark", ), ), - 'WHERE' => "((tt.topic_id OR ft.forum_id) - OR t.topic_last_post_time > {$user->data['user_lastmark']}) + 'WHERE' => " + ( + (tt.mark_time AND t.topic_last_post_time > tt.mark_time) OR + (tt.mark_time IS NULL AND ft.mark_time AND t.topic_last_post_time > ft.mark_time) OR + ( + ((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark)) + AND t.topic_last_post_time > $last_mark + ) + ) $sql_extra $sql_sort", ); @@ -1711,8 +1720,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; - - $unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; + $unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark); } $db->sql_freeresult($result); } -- cgit v1.2.1 From ab971c59be9eefe86bd53bad5858c6427ccc57eb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Sep 2009 08:44:34 +0000 Subject: Fix bug #51075 introduced in r10121. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10129 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 24dd58c116..092a5d5d86 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1703,8 +1703,8 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s 'WHERE' => " ( - (tt.mark_time AND t.topic_last_post_time > tt.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time AND t.topic_last_post_time > ft.mark_time) OR + (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR + (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR ( ((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark)) AND t.topic_last_post_time > $last_mark -- cgit v1.2.1 From 36dc2d6e2dc6f213c47fd5dcd4f8fbedb4e068b3 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 15 Sep 2009 13:10:59 +0000 Subject: Fix login for passworded forums - Bug #51265 Was a regression from r10067 for Bug #50285 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10147 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 092a5d5d86..310bf903c1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3050,6 +3050,7 @@ function login_forum_box($forum_data) page_header($user->lang['LOGIN'], false); $template->assign_vars(array( + 'S_LOGIN_ACTION' => build_url(array('f')), 'S_HIDDEN_FIELDS' => build_hidden_fields(array('f' => $forum_data['forum_id']))) ); -- cgit v1.2.1 From b27e96cf62399013646439ff352ebbc558e1e2c6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 16 Sep 2009 07:51:26 +0000 Subject: move up the feed code because MODs often use this location which results in more unneccessary conflicts. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10149 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 310bf903c1..747b624548 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4035,16 +4035,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } } - // Which 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 - $user_lang = $user->lang['USER_LANG']; - if (strpos($user_lang, '-x-') !== false) - { - $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-')); - } - $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); @@ -4065,6 +4055,16 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $board_url = generate_board_url() . '/'; $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; + // Which 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 + $user_lang = $user->lang['USER_LANG']; + if (strpos($user_lang, '-x-') !== false) + { + $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. $template->assign_vars(array( 'SITENAME' => $config['sitename'], -- cgit v1.2.1 From 5382eb441d1dcf7c5bc2a1a49a4924d51fb151f5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 20 Sep 2009 18:50:35 +0000 Subject: remove unnecessary query parts... thanks to asinshesq for pointing it out. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10172 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 747b624548..e787932441 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1693,11 +1693,11 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s 'LEFT_JOIN' => array( array( 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), - 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id AND tt.mark_time > $last_mark", + 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id", ), array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id AND ft.mark_time > $last_mark", + 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id", ), ), @@ -1705,10 +1705,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s ( (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR - ( - ((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark)) - AND t.topic_last_post_time > $last_mark - ) + (tt.mark_time IS NULL AND ft.mark_time IS NULL AND t.topic_last_post_time > $last_mark) ) $sql_extra $sql_sort", -- cgit v1.2.1 From 978f707fd12698875e20b945f2bb30c82c6888c5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 14 Nov 2009 19:12:12 +0000 Subject: [Fix] Force full date for board online record date. Authorised by: bantu git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10266 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e787932441..812b672c5c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3959,7 +3959,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; // Get users online list ... if required - $l_online_users = $online_userlist = $l_online_record = ''; + $l_online_users = $online_userlist = $l_online_record = $l_online_time = ''; if ($config['load_online'] && $config['load_online_time'] && $display_online_list) { @@ -3982,15 +3982,11 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 set_config('record_online_date', time(), true); } - $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])); + $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); } - else - { - $l_online_time = ''; - } $l_privmsgs_text = $l_privmsgs_text_unread = ''; $s_privmsg_new = false; -- cgit v1.2.1 From e2fe61b7df1300b659e7671db17835603647e818 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 11 Dec 2009 20:49:53 +0000 Subject: Restore user language choice to compiled stylesheets. Broken by r10008 #54035 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10319 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 812b672c5c..690fed83e8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4154,7 +4154,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), + 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], true, $user->session_id), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], -- cgit v1.2.1 From d096696ef2b269b973a8772643bb4bf9b1a12b80 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 13 Dec 2009 14:59:03 +0000 Subject: #54145 - move redirect parameter back to POST to avoid mod_security triggers git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10332 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 690fed83e8..55b7a07a0b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4135,7 +4135,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, - 'S_LOGIN_ACTION' => (!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())) : append_sid("index.$phpEx", false, true, $user->session_id) . '&redirect=' . urlencode(str_replace('&', '&', build_url())), + 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)), + 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, -- cgit v1.2.1 From 4dae08997a0d28b5bf8b5978635fc7a8c01dbe04 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 13 Dec 2009 15:10:06 +0000 Subject: whitespaces git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10335 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 55b7a07a0b..396267432a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4136,7 +4136,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)), - 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), + 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, -- cgit v1.2.1 From d0c596a5eaab7439a3b32af8b9a14c12f9ae18e2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Dec 2009 19:21:41 +0000 Subject: Add ability to disable overall (aka board-wide) feed. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10363 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 396267432a..6b26b5aa7b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4139,6 +4139,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, + 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, -- cgit v1.2.1 From ad7e3ccf4c8d233744cd7408f42484405f7d9c48 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 27 Dec 2009 00:48:52 +0000 Subject: Integrate active topics feed. Some language adjustments and rearrangements. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10382 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6b26b5aa7b..9c294c81af 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4141,7 +4141,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, 'S_ENABLE_FEEDS_FORUMS' => ($config['feed_overall_forums']) ? true : false, - 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_overall_topics']) ? true : false, + 'S_ENABLE_FEEDS_TOPICS' => ($config['feed_topics_new']) ? true : false, + 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false, 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', -- cgit v1.2.1 From 77af6caed7300c7498016b4b3d30d31f2bcca730 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 19 Jan 2010 19:08:51 +0000 Subject: [Feature] Ability to use HTTP authentication in ATOM feeds by passing the GET parameter auth=http git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10430 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 97 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9c294c81af..af94f3f041 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3920,6 +3920,103 @@ function phpbb_optionset($bit, $set, $data) return $data; } +/** +* Login using http authenticate. +* +* @param array $param Parameter array, see $param_defaults array. +* +* @return void +*/ +function phpbb_http_login($param) +{ + global $auth, $user; + global $config; + + $param_defaults = array( + 'auth_message' => '', + + 'autologin' => false, + 'viewonline' => true, + 'admin' => false, + ); + + // Overwrite default values with passed values + $param = array_merge($param_defaults, $param); + + // User is already logged in + // We will not overwrite his session + if (!empty($user->data['is_registered'])) + { + return; + } + + // $_SERVER keys to check + $username_keys = array( + 'PHP_AUTH_USER', + 'Authorization', + 'REMOTE_USER', 'REDIRECT_REMOTE_USER', + 'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION', + 'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION', + 'AUTH_USER', + ); + + $password_keys = array( + 'PHP_AUTH_PW', + 'REMOTE_PASSWORD', + 'AUTH_PASSWORD', + ); + + $username = null; + foreach ($username_keys as $k) + { + if (isset($_SERVER[$k])) + { + $username = $_SERVER[$k]; + break; + } + } + + $password = null; + foreach ($password_keys as $k) + { + if (isset($_SERVER[$k])) + { + $password = $_SERVER[$k]; + break; + } + } + + // Decode encoded information (IIS, CGI, FastCGI etc.) + if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0) + { + list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2); + } + + if (!is_null($username) && !is_null($password)) + { + set_var($username, $username, 'string', true); + set_var($password, $password, 'string', true); + + $auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']); + + if ($auth_result['status'] == LOGIN_SUCCESS) + { + return; + } + } + + // Prepend sitename to auth_message + $param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message']; + + // We should probably filter out non-ASCII characters - RFC2616 + $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']); + + header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"'); + header('HTTP/1.0 401 Unauthorized'); + + trigger_error('NOT_AUTHORISED'); +} + /** * Generate page header */ -- cgit v1.2.1 From 04ce664604592623f72c12edc34994cc65a4d010 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 20 Jan 2010 01:05:36 +0000 Subject: Trigger error right away if user has exceeded login attempts instead of asking for the authentication data over and over again without accepting it even if it is correct. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10432 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index af94f3f041..823c71dbf0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4003,6 +4003,11 @@ function phpbb_http_login($param) { return; } + else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS) + { + header('HTTP/1.0 401 Unauthorized'); + trigger_error('NOT_AUTHORISED'); + } } // Prepend sitename to auth_message -- cgit v1.2.1 From 4bb3266cc62003d5bd6fafda03a5582ea06250e9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 7 Feb 2010 00:27:00 +0000 Subject: Bug #57345 - No longer return the character O in generated random strings and passwords. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10480 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 823c71dbf0..23221c69ea 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -202,7 +202,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false) function gen_rand_string($num_chars = 8) { $rand_str = unique_id(); - $rand_str = str_replace('0', 'Z', strtoupper(base_convert($rand_str, 16, 35))); + $rand_str = str_replace(array('0', 'O'), array('Z', 'Y'), strtoupper(base_convert($rand_str, 16, 34))); return substr($rand_str, 0, $num_chars); } -- cgit v1.2.1 From 30b83896a1718400307de7d531c16a152c0f6668 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 18 Feb 2010 01:17:30 +0000 Subject: Fix Bug #57755 - Make user_email_hash() function independent from system's architecture. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10499 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 23221c69ea..913b1c0fa0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -556,11 +556,11 @@ function _hash_crypt_private($password, $setting, &$itoa64) * * @param string $email Email address * -* @return string Big Integer +* @return string Unsigned Big Integer */ function phpbb_email_hash($email) { - return crc32(strtolower($email)) . strlen($email); + return sprintf('%u', crc32(strtolower($email))) . strlen($email); } /** -- cgit v1.2.1 From e01171ca85e09b10a93337c9a88022545dee23c1 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 22 Feb 2010 00:57:01 +0000 Subject: General errors can't be logged if there isn't a database connection, introduced in r9924 #57975 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10518 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 913b1c0fa0..364c8f4e9e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3531,7 +3531,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } } - if (defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) + if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) { // let's avoid loops $db->sql_return_on_error(true); -- cgit v1.2.1 From 9e64c3bd84b9b595da54c6463e068ca8b84e1ee0 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 25 Feb 2010 00:18:30 +0000 Subject: Bug #56965 - Allow redirect() to redirect across directories. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10536 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 364c8f4e9e..38f910974a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2336,6 +2336,19 @@ function redirect($url, $return = false, $disable_cd_check = false) // Relative uri $pathinfo = pathinfo($url); + if (!$disable_cd_check && !file_exists($pathinfo['dirname'])) + { + $url = str_replace('../', '', $url); + $pathinfo = pathinfo($url); + + if (!file_exists($pathinfo['dirname'])) + { + // fallback to "last known user page" + $url = generate_board_url() . '/' . $user->page['page']; + break; + } + } + // Is the uri pointing to the current directory? if ($pathinfo['dirname'] == '.') { -- cgit v1.2.1