From e0869b39a37a2db4ba88070d52e58307e721b336 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 25 Sep 2011 10:59:41 +0800 Subject: [ticket/9008] Incorrect unread topic tracking for unapproved topics PHPBB3-9008 --- phpBB/includes/functions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 628f8ee123..c0581c1b1b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1880,7 +1880,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s */ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) { - global $db, $tracking_topics, $user, $config; + global $db, $tracking_topics, $user, $config, $auth; // Determine the users last forum mark time if not given. if ($mark_time_forum === false) @@ -1903,6 +1903,10 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti } } + // Handle update of unapproved topics info. + // Only update for moderators having m_approve permission for the forum. + $sql_update_unapproved = ($auth->acl_get('m_approve', $forum_id)) ? '': 'AND t.topic_approved = 1'; + // Check the forum for any left unread topics. // If there are none, we mark the forum as read. if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -1918,7 +1922,8 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ') WHERE t.forum_id = ' . $forum_id . ' AND t.topic_last_post_time > ' . $mark_time_forum . ' - AND t.topic_moved_id = 0 + AND t.topic_moved_id = 0 ' . + $sql_update_unapproved . ' AND (tt.topic_id IS NULL OR tt.mark_time < t.topic_last_post_time) GROUP BY t.forum_id'; $result = $db->sql_query_limit($sql, 1); @@ -1942,7 +1947,8 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $forum_id . ' AND topic_last_post_time > ' . $mark_time_forum . ' - AND topic_moved_id = 0'; + AND topic_moved_id = 0 ' . + $sql_update_unapproved; $result = $db->sql_query($sql); $check_forum = $tracking_topics['tf'][$forum_id]; -- cgit v1.2.1 From 56c6476233646e7c735aa4e3b98c4a6b62df5c7d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 15:12:56 -0700 Subject: [ticket/10390] Allow option for jQuery to be hosted by a remote CDN Add an option to the ACP so admins can choose to host jQuery from the local version shipped with phpBB, or via a popular CDN. PHPBB3-10390 --- phpBB/includes/functions.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5ccb9edd07..af07938879 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4569,6 +4569,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_STYLESHEET_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css', 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css', 'T_STYLESHEET_NAME' => $user->theme['theme_name'], + 'T_JQUERY_LINK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? remote_jquery_url($config['load_jquery_host']) : "{$web_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? true : false, 'T_THEME_NAME' => $user->theme['theme_path'], 'T_THEME_LANG_NAME' => $user->data['user_lang'], @@ -4767,3 +4769,30 @@ function phpbb_pcre_utf8_support() } return $utf8_pcre_properties; } + +/** +* Build jQuery URL for remote CDNs +* Reference: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery +* +* @return string Returns url to a jQuery library +*/ +function remote_jquery_url($host) +{ + switch($host) + { + case 'google': + // Google uses a 1.5.0, 1.5.1 format (it is always a three numbered version) + return '//ajax.googleapis.com/ajax/libs/jquery/' . ((strlen(JQUERY_VERSION) == 3) ? JQUERY_VERSION . '.0' : JQUERY_VERSION) . '/jquery.min.js'; + break; + + case 'microsoft': + // Microsoft uses a 1.5, 1.5.1 format + return 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + break; + + case 'jquery': + // jQuery uses a 1.5, 1.5.1 format + return 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; + break; + } +} -- cgit v1.2.1 From abb0f3f96d2fecfe2af2bde539a2b9d3a577e421 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 18:16:25 -0700 Subject: [ticket/10390] Improve the jQuery CDN url generation function Per p's comments, return the remote url from a variable instead of using multiple returns. Also put the logic for creating Google's version on its own line, and count the version number's dots instead of length so it will be less likely to break if jQuery goes to version 1.10. PHPBB3-10390 --- phpBB/includes/functions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index af07938879..83cadf426d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4781,18 +4781,21 @@ function remote_jquery_url($host) switch($host) { case 'google': - // Google uses a 1.5.0, 1.5.1 format (it is always a three numbered version) - return '//ajax.googleapis.com/ajax/libs/jquery/' . ((strlen(JQUERY_VERSION) == 3) ? JQUERY_VERSION . '.0' : JQUERY_VERSION) . '/jquery.min.js'; + // Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases) + $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; + // HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS + $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; break; case 'microsoft': // Microsoft uses a 1.5, 1.5.1 format - return 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + $url = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; break; case 'jquery': // jQuery uses a 1.5, 1.5.1 format - return 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; + $url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; break; } + return $url; } -- cgit v1.2.1 From c6a2d81bd359711aeb9dc36478977e779d3bdfe9 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 11:13:16 -0700 Subject: [ticket/10390] Drop http protocol for Microsoft's CDN option Like Google, Microsoft supports both http and https protocols, so we can drop the protocol alltogether from the url so the Microsoft CDN will work on both HTTP or HTTPS sites without issue. Also I cleaned up some of the comments here. PHPBB3-10390 --- phpBB/includes/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 83cadf426d..8cdafbd95e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4773,6 +4773,8 @@ function phpbb_pcre_utf8_support() /** * Build jQuery URL for remote CDNs * Reference: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery +* HTTP protocols intentionally omitted for Google and Microsoft - its the best +* way to reference third party content that is available via both HTTP and HTTPS * * @return string Returns url to a jQuery library */ @@ -4781,15 +4783,14 @@ function remote_jquery_url($host) switch($host) { case 'google': - // Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases) + // Google uses a 1.5.0, 1.5.1 format (we need to add a .0 to new 1.X releases) $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; - // HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; break; case 'microsoft': // Microsoft uses a 1.5, 1.5.1 format - $url = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + $url = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; break; case 'jquery': -- cgit v1.2.1 From 2dca3c3c278e99cfd6cdbea7149063d160e4cc11 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 20:26:32 -0700 Subject: [ticket/10390] Serve jQuery from Google CDN Yes/No button in ACP jQuery will now be available via remote CDN from Google. Microsoft and jQuery CDNs have been removed, so we can simplify this option for the user. Default mode is NO so the copy of jQuery included with phpBB is served by default. PHPBB3-10390 --- phpBB/includes/functions.php | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8cdafbd95e..d769ce0374 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4569,8 +4569,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_STYLESHEET_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css', 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css', 'T_STYLESHEET_NAME' => $user->theme['theme_name'], - 'T_JQUERY_LINK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? remote_jquery_url($config['load_jquery_host']) : "{$web_path}assets/javascript/jquery.js", - 'S_JQUERY_FALLBACK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? true : false, + 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, 'T_THEME_NAME' => $user->theme['theme_path'], 'T_THEME_LANG_NAME' => $user->data['user_lang'], @@ -4769,34 +4769,3 @@ function phpbb_pcre_utf8_support() } return $utf8_pcre_properties; } - -/** -* Build jQuery URL for remote CDNs -* Reference: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery -* HTTP protocols intentionally omitted for Google and Microsoft - its the best -* way to reference third party content that is available via both HTTP and HTTPS -* -* @return string Returns url to a jQuery library -*/ -function remote_jquery_url($host) -{ - switch($host) - { - case 'google': - // Google uses a 1.5.0, 1.5.1 format (we need to add a .0 to new 1.X releases) - $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; - $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; - break; - - case 'microsoft': - // Microsoft uses a 1.5, 1.5.1 format - $url = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; - break; - - case 'jquery': - // jQuery uses a 1.5, 1.5.1 format - $url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; - break; - } - return $url; -} -- cgit v1.2.1 From 12882084d4ce686fe43f3935f16078c4e818cde3 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 4 Oct 2011 11:55:25 +0300 Subject: [ticket/10397] Pagination inconsistency fix Fixing inconsistency in code generated by generate_pagination() PHPBB3-10397 --- 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 c2b099d48a..8017c379f3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2127,7 +2127,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add $start_cnt = min(max(1, $on_page - 4), $total_pages - 5); $end_cnt = max(min($total_pages, $on_page + 4), 6); - $page_string .= ($start_cnt > 1) ? ' ... ' : $seperator; + $page_string .= ($start_cnt > 1) ? ' ... ' : $seperator; for ($i = $start_cnt + 1; $i < $end_cnt; $i++) { @@ -2138,7 +2138,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add } } - $page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator; + $page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator; } else { -- cgit v1.2.1 From bb616b4135fba145c961f26a4ff612d6579b6b17 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 14 Oct 2011 02:02:17 +0200 Subject: [ticket/10412] Replace memory_get_usage with memory_get_peak_usage PHPBB3-10412 --- phpBB/includes/functions.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8f41e18db6..688c7f2000 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4627,15 +4627,13 @@ function page_footer($run_cron = true) if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) { - if (function_exists('memory_get_usage')) + if (function_exists('memory_get_peak_usage')) { - if ($memory_usage = memory_get_usage()) + if ($memory_usage = memory_get_peak_usage()) { - global $base_memory_usage; - $memory_usage -= $base_memory_usage; $memory_usage = get_formatted_filesize($memory_usage); - $debug_output .= ' | Memory Usage: ' . $memory_usage; + $debug_output .= ' | Peak Memory Usage: ' . $memory_usage; } } -- cgit v1.2.1 From 3302305cd4a499603784aa87a40f5170d62a4f26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Nov 2011 16:11:32 +0100 Subject: [ticket/9066] Move regex into get_preg_expression function and add tests PHPBB3-9066 --- phpBB/includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c2b099d48a..e477b0454e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3486,6 +3486,10 @@ function get_preg_expression($mode) $inline = ($mode == 'relative_url') ? ')' : ''; return "(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?"; break; + + case 'table_prefix': + return '#^[a-zA-Z][a-zA-Z0-9_]*$#'; + break; } return ''; -- cgit v1.2.1