From f0092cd1f2ae97a655434cae6b8c69b202314720 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 23 Jan 2009 12:11:45 +0000 Subject: Correctly display future dates (Bug #38755) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9298 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index c7d287181b..f1285c0203 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2050,7 +2050,7 @@ class user extends session } // Show date <= 1 hour ago as 'xx min ago' - // A small tolerence is given for times in the future and times in the future but in the same minute are displayed as '< than a minute ago' + // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) { return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60))); @@ -2062,7 +2062,7 @@ class user extends session $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $date_cache[$format]['zone_offset']; } - if ($date_cache[$format]['is_short'] !== false && !$forcedate) + if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800)) { $day = false; -- cgit v1.2.1 From 0fc07b96cef4c9c5ba2d6fe0299333201d5cfba8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 23 Jan 2009 12:22:51 +0000 Subject: let us change the time zone and dst setting correctly (related to Bug #38775) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9301 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index f1285c0203..5c9bcc4f88 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2036,7 +2036,6 @@ class user extends session // Is the user requesting a friendly date format (i.e. 'Today 12:42')? $date_cache[$format] = array( 'is_short' => strpos($format, '|'), - 'zone_offset' => $this->timezone + $this->dst, 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), 'format_long' => str_replace('|', '', $format), 'lang' => $this->lang['datetime'], @@ -2049,6 +2048,9 @@ class user extends session } } + // Zone offset + $zone_offset = $this->timezone + $this->dst; + // Show date <= 1 hour ago as 'xx min ago' // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) @@ -2058,8 +2060,8 @@ class user extends session if (!$midnight) { - list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $date_cache[$format]['zone_offset'])); - $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $date_cache[$format]['zone_offset']; + list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $zone_offset)); + $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $zone_offset; } if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800)) @@ -2081,11 +2083,11 @@ class user extends session if ($day !== false) { - return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $date_cache[$format]['zone_offset']), $date_cache[$format]['lang'])); + return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $zone_offset), $date_cache[$format]['lang'])); } } - return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $date_cache[$format]['zone_offset']), $date_cache[$format]['lang']); + return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']); } /** -- cgit v1.2.1 From 43540f441d6ec6624812c2d2397552ae084b8001 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 11 Mar 2009 17:47:31 +0000 Subject: for using the same cached file we need to have exact queries. :P git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9366 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 5c9bcc4f88..6112decf09 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1657,7 +1657,8 @@ class user extends session $this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang']; - $sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width + // Same query in style.php + $sql = 'SELECT * FROM ' . STYLES_IMAGESET_DATA_TABLE . ' WHERE imageset_id = ' . $this->theme['imageset_id'] . " AND image_filename <> '' -- cgit v1.2.1 From 3c5b06f8aa65161334ecc00e3e7ec2f9b6e4565d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 16 Mar 2009 16:34:16 +0000 Subject: Fix wrong bot ip check if bot ip was wrongly entered by admin. (Bug #42485) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9374 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6112decf09..a349eb7e14 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -480,6 +480,13 @@ class session foreach (explode(',', $row['bot_ip']) as $bot_ip) { + $bot_ip = trim($bot_ip); + + if (!$bot_ip) + { + continue; + } + if (strpos($this->ip, $bot_ip) === 0) { $bot = (int) $row['user_id']; -- cgit v1.2.1 From 8dfc457858943734f33fd2fb51b492c07b41a4fd Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Mar 2009 12:02:48 +0000 Subject: Do not suppress PHP notices/errors in language packs if DEBUG_EXTRA mode enabled. (Bug #41485) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9383 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index a349eb7e14..49f97f6050 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1534,7 +1534,10 @@ class user extends session // We include common language file here to not load it every time a custom language file is included $lang = &$this->lang; - if ((@include $this->lang_path . $this->lang_name . "/common.$phpEx") === false) + // Do not suppress error if in DEBUG_EXTRA mode + $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); + + if ($include_result === false) { die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened."); } @@ -2008,7 +2011,10 @@ class user extends session $language_filename = $this->lang_path . $this->lang_name . '/' . (($use_help) ? 'help_' : '') . $lang_file . '.' . $phpEx; } - if ((@include $language_filename) === false) + // Do not suppress error if in DEBUG_EXTRA mode + $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); + + if ($include_result === false) { trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); } -- cgit v1.2.1 From a80f7a5ea10b039ec1549d391ecd8431240c640e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Mar 2009 15:23:57 +0000 Subject: Use FQDN for SMTP EHLO/HELO command. (Bug #41025) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9387 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 49f97f6050..b01d0b2281 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -182,7 +182,7 @@ class session else { // Set to OS hostname or localhost - $host = (function_exists('php_uname')) ? php_uname('n') : 'localhost'; + $host = (function_exists('php_uname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : 'localhost'; } } -- cgit v1.2.1 From e6ed42ed4dde41812b88b47c6e5bb5c41402f14c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 28 Mar 2009 18:34:09 +0000 Subject: - Add indicator to be used in code if session was created (user visits the site for the first time) - Correctly count topic views for guests visiting the website the first time by entering the topic directly (Bug #43445) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9411 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index b01d0b2281..9cf19e4302 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -726,6 +726,15 @@ class session // Commented out because it will not allow forums to update correctly // $db->sql_return_on_error(false); + // Something quite important: session_page always holds the *last* page visited, except for the *first* visit. + // We are not able to simply have an empty session_page btw, therefore we need to tell phpBB how to detect this special case. + // If the session id is empty, we have a completely new one and will set an "identifier" here. This identifier is able to be checked later. + if (empty($this->data['session_id'])) + { + // This is a temporary variable, only set for the very first visit + $this->data['session_created'] = true; + } + $this->session_id = $this->data['session_id'] = md5(unique_id()); $sql_ary['session_id'] = (string) $this->session_id; -- cgit v1.2.1 From 77e21fc054abb722522e4694813149770980249a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 17 Apr 2009 15:58:31 +0000 Subject: encode imageset path in user->img (may not fix any other issues regarding style names with spaces) - #28885 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9465 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 9cf19e4302..6980277041 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2180,7 +2180,7 @@ class user extends session return $img_data; } - $img_data['src'] = $phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; + $img_data['src'] = $phpbb_root_path . 'styles/' . rawurlencode($this->theme['imageset_path']) . '/imageset/' . ($this->img_array[$img]['image_lang'] ? $this->img_array[$img]['image_lang'] .'/' : '') . $this->img_array[$img]['image_filename']; $img_data['width'] = $this->img_array[$img]['image_width']; $img_data['height'] = $this->img_array[$img]['image_height']; } -- cgit v1.2.1 From d3f6ce4b4ba04c6041ab20e6860a9082bce50252 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 22 Apr 2009 12:54:33 +0000 Subject: #41575 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9477 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 47 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6980277041..2de20bc364 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -396,6 +396,11 @@ class session WHERE session_id = '" . $db->sql_escape($this->session_id) . "'"; $db->sql_query($sql); } + + if ($this->data['user_id'] != ANONYMOUS && $config['new_member_limit'] && $this->data['user_new'] && $config['new_member_limit'] <= $this->data['user_posts']) + { + $this->leave_newly_registered(); + } } $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; @@ -1392,8 +1397,8 @@ class session $host = htmlspecialchars($this->host); $ref = substr($this->referer, strpos($this->referer, '://') + 3); - - if (!(stripos($ref, $host) === 0)) + + if (!(stripos($ref, $host) === 0) && (!$config['force_server'] || !(stripos($ref, $config['server_name']) === 0))) { return false; } @@ -2253,6 +2258,44 @@ class user extends session return $var; } } + + /** + * Funtion to make the user leave the NEWLY_REGISTERED system group. + * @access public + */ + function leave_newly_registered() + { + global $db; + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED' + AND group_type = " . GROUP_SPECIAL; + $result = $db->sql_query_limit($sql, 1, 0, 7200); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $group_id = (int) $row['group_id']; + $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + AND user_id = {$this->data['user_id']}"; + $db->sql_query($sql); + + // Clear permissions cache of relevant users + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_permissions = '', + user_new = 0, + WHERE user_perm_from = 0 + AND user_id = {$this->data['user_id']}"; + $db->sql_query($sql); + $this->data['user_permissions'] = ''; + + if ($this->data['group_id'] == $group_id) + { + // BLAST! Somebody made the group default + + } + } + } ?> \ No newline at end of file -- cgit v1.2.1 From cc71622def918bce2f3e0dab20f7d9e9b0df5c73 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 22 Apr 2009 13:09:41 +0000 Subject: rollback git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9479 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 47 ++-------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 2de20bc364..6980277041 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -396,11 +396,6 @@ class session WHERE session_id = '" . $db->sql_escape($this->session_id) . "'"; $db->sql_query($sql); } - - if ($this->data['user_id'] != ANONYMOUS && $config['new_member_limit'] && $this->data['user_new'] && $config['new_member_limit'] <= $this->data['user_posts']) - { - $this->leave_newly_registered(); - } } $this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false; @@ -1397,8 +1392,8 @@ class session $host = htmlspecialchars($this->host); $ref = substr($this->referer, strpos($this->referer, '://') + 3); - - if (!(stripos($ref, $host) === 0) && (!$config['force_server'] || !(stripos($ref, $config['server_name']) === 0))) + + if (!(stripos($ref, $host) === 0)) { return false; } @@ -2258,44 +2253,6 @@ class user extends session return $var; } } - - /** - * Funtion to make the user leave the NEWLY_REGISTERED system group. - * @access public - */ - function leave_newly_registered() - { - global $db; - - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED' - AND group_type = " . GROUP_SPECIAL; - $result = $db->sql_query_limit($sql, 1, 0, 7200); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $group_id = (int) $row['group_id']; - $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND user_id = {$this->data['user_id']}"; - $db->sql_query($sql); - - // Clear permissions cache of relevant users - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = '', - user_new = 0, - WHERE user_perm_from = 0 - AND user_id = {$this->data['user_id']}"; - $db->sql_query($sql); - $this->data['user_permissions'] = ''; - - if ($this->data['group_id'] == $group_id) - { - // BLAST! Somebody made the group default - - } - } - } ?> \ No newline at end of file -- cgit v1.2.1 From 696aff3169f105d6c5adf2583d27cd58f955e993 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 22 Apr 2009 13:11:13 +0000 Subject: #41575 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9480 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6980277041..84e74a67fb 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1393,7 +1393,7 @@ class session $host = htmlspecialchars($this->host); $ref = substr($this->referer, strpos($this->referer, '://') + 3); - if (!(stripos($ref, $host) === 0)) + if (!(stripos($ref, $host) === 0) && (!$config['force_server'] || !(stripos($ref, $config['server_name']) === 0))) { return false; } -- cgit v1.2.1 From 6816cf292feb5b2b922efeba697b7b3f46dd25e2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 25 Apr 2009 08:52:11 +0000 Subject: do not use spamhaus XBL list - it has too much false positives due to the dynamic IPs git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9484 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 84e74a67fb..9fbe8fc85b 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1220,7 +1220,7 @@ class session } $dnsbl_check = array( - 'sbl-xbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=', + 'sbl.spamhaus.org' => 'http://www.spamhaus.org/query/bl?ip=', ); if ($mode == 'register') -- cgit v1.2.1 From 7c418dee552c9d6e59a209e807a61aa26723fea9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 28 Apr 2009 08:34:30 +0000 Subject: #44485 - we only send a 503 header if it is a search engine. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9490 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/session.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 9fbe8fc85b..043a637584 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1793,7 +1793,10 @@ class user extends session // Is board disabled and user not an admin or moderator? if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { - header('HTTP/1.1 503 Service Unavailable'); + if ($this->data['is_bot']) + { + header('HTTP/1.1 503 Service Unavailable'); + } $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; trigger_error($message); @@ -1809,7 +1812,10 @@ class user extends session if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { - header('HTTP/1.1 503 Service Unavailable'); + if ($this->data['is_bot']) + { + header('HTTP/1.1 503 Service Unavailable'); + } trigger_error('BOARD_UNAVAILABLE'); } } -- cgit v1.2.1