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