diff options
author | Igor Wiedler <igor@wiedler.ch> | 2010-06-25 13:31:31 +0200 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2010-12-28 22:36:25 +0100 |
commit | eda9fbbb6363cad0f2035b7a1f9fafe27f23832b (patch) | |
tree | c023293935fd985b304c7047337fbbf236ea8644 /phpBB | |
parent | 1e59666ee32fb00c709644f1f66d3c0b662f32a0 (diff) | |
download | forums-eda9fbbb6363cad0f2035b7a1f9fafe27f23832b.tar forums-eda9fbbb6363cad0f2035b7a1f9fafe27f23832b.tar.gz forums-eda9fbbb6363cad0f2035b7a1f9fafe27f23832b.tar.bz2 forums-eda9fbbb6363cad0f2035b7a1f9fafe27f23832b.tar.xz forums-eda9fbbb6363cad0f2035b7a1f9fafe27f23832b.zip |
[ticket/9574] Remove conditional PHP<5.2 code
There is a large amount of conditional code for PHP < 5.2 that can be
removed with phpBB 3.1.
PHPBB3-9574
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/acp/acp_bbcodes.php | 9 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_database.php | 37 | ||||
-rw-r--r-- | phpBB/includes/cache.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mssql.php | 9 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 22 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 4 | ||||
-rw-r--r-- | phpBB/includes/search/fulltext_mysql.php | 9 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewfolder.php | 2 | ||||
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 72 | ||||
-rw-r--r-- | phpBB/install/convertors/functions_phpbb20.php | 2 |
10 files changed, 32 insertions, 136 deletions
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index 9eb594f301..b046424790 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -318,14 +318,11 @@ class acp_bbcodes $utf8 = strpos($bbcode_match, 'INTTEXT') !== false; // make sure we have utf8 support + // PHP may not be linked with the bundled PCRE lib and instead with an older version $utf8_pcre_properties = false; - if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) + if (@preg_match('/\p{L}/u', 'a') !== false) { - // While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version - if (@preg_match('/\p{L}/u', 'a') !== false) - { - $utf8_pcre_properties = true; - } + $utf8_pcre_properties = true; } $fp_match = preg_quote($bbcode_match, '!'); diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index deff7d4a65..96542986d3 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -1007,43 +1007,8 @@ class sqlite_extractor extends base_extractor function write_data($table_name) { global $db; - static $proper; - if (is_null($proper)) - { - $proper = version_compare(PHP_VERSION, '5.1.3', '>='); - } - - if ($proper) - { - $col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name); - } - else - { - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '" . $table_name . "'"; - $table_data = sqlite_single_query($db->db_connect_id, $sql); - $table_data = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', '', $table_data); - $table_data = trim($table_data); - - preg_match('#\((.*)\)#s', $table_data, $matches); - - $table_cols = explode(',', trim($matches[1])); - foreach ($table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - $column_name = preg_replace('/"?([^"]+)"?/', '\1', $entities[0]); - - // Hit a primary key, those are not what we need :D - if (empty($entities[1]) || (strtolower($entities[0]) === 'primary' && strtolower($entities[1]) === 'key')) - { - continue; - } - $col_types[$column_name] = $entities[1]; - } - } + $col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name); $sql = "SELECT * FROM $table_name"; diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php index 52cd3e2404..7c739fa600 100644 --- a/phpBB/includes/cache.php +++ b/phpBB/includes/cache.php @@ -82,7 +82,7 @@ class cache extends acm $result = $db->sql_query($sql); $censors = array(); - $unicode = ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) ? true : false; + $unicode = (@preg_match('/\p{L}/u', 'a') !== false) ? true : false; while ($row = $db->sql_fetchrow($result)) { diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 1188e56ebe..386b0a9a23 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -41,14 +41,7 @@ class dbal_mssql extends dbal @ini_set('mssql.textlimit', 2147483647); @ini_set('mssql.textsize', 2147483647); - if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>='))) - { - $this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link); - } - else - { - $this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword); - } + $this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link); if ($this->db_connect_id && $this->dbname != '') { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b9c4bde1b7..48a9661347 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -394,7 +394,7 @@ function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6) } $output = '$H$'; - $output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)]; + $output .= $itoa64[min($iteration_count_log2 + 5, 30)]; $output .= _hash_encode64($input, 6, $itoa64); return $output; @@ -480,24 +480,12 @@ function _hash_crypt_private($password, $setting, &$itoa64) * consequently in lower iteration counts and hashes that are * quicker to crack (by non-PHP code). */ - if (PHP_VERSION >= 5) - { - $hash = md5($salt . $password, true); - do - { - $hash = md5($hash . $password, true); - } - while (--$count); - } - else + $hash = md5($salt . $password, true); + do { - $hash = pack('H*', md5($salt . $password)); - do - { - $hash = pack('H*', md5($hash . $password)); - } - while (--$count); + $hash = md5($hash . $password, true); } + while (--$count); $output = substr($setting, 0, 12); $output .= _hash_encode64($hash, 16, $itoa64); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8d6ed07aa0..9ab9d6d568 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1490,7 +1490,7 @@ function validate_username($username, $allowed_username = false) $mbstring = $pcre = false; // generic UTF-8 character types supported? - if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) + if (@preg_match('/\p{L}/u', 'a') !== false) { $pcre = true; } @@ -1626,7 +1626,7 @@ function validate_password($password) $pcre = $mbstring = false; // generic UTF-8 character types supported? - if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) + if (@preg_match('/\p{L}/u', 'a') !== false) { $upp = '\p{Lu}'; $low = '\p{Ll}'; diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 6d12495738..22aeca7fee 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -42,13 +42,10 @@ class fulltext_mysql extends search_backend $this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']); - if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) + // PHP may not be linked with the bundled PCRE lib and instead with an older version + if (@preg_match('/\p{L}/u', 'a') !== false) { - // While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version - if (@preg_match('/\p{L}/u', 'a') !== false) - { - $this->pcre_properties = true; - } + $this->pcre_properties = true; } if (function_exists('mb_ereg')) diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 81b2bcaf93..4efa09c3c8 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -282,7 +282,7 @@ function view_folder($id, $mode, $folder_id, $folder) 'subject' => censor_text($row['message_subject']), 'sender' => $row['username'], // ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it. - 'date' => $user->format_date($row['message_time'], (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:s+00:00", true), + 'date' => $user->format_date($row['message_time'], 'c', true), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', 'message' => $message_row['message_text'] ); diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 2247315e04..cac5b4e744 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -109,70 +109,26 @@ if (extension_loaded('mbstring')) /** * UTF-8 aware alternative to strrpos * Find position of last occurrence of a char in a string - * - * Notes: - * - offset for mb_strrpos was added in 5.2.0, we emulate if it is lower */ - if (version_compare(PHP_VERSION, '5.2.0', '>=')) + /** + * UTF-8 aware alternative to strrpos + * @ignore + */ + function utf8_strrpos($str, $needle, $offset = null) { - /** - * UTF-8 aware alternative to strrpos - * @ignore - */ - function utf8_strrpos($str, $needle, $offset = null) + // Emulate behaviour of strrpos rather than raising warning + if (empty($str)) { - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } + return false; + } - if (is_null($offset)) - { - return mb_strrpos($str, $needle); - } - else - { - return mb_strrpos($str, $needle, $offset); - } + if (is_null($offset)) + { + return mb_strrpos($str, $needle); } - } - else - { - /** - * UTF-8 aware alternative to strrpos - * @ignore - */ - function utf8_strrpos($str, $needle, $offset = null) + else { - // offset for mb_strrpos was added in 5.2.0 - if (is_null($offset)) - { - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } - - return mb_strrpos($str, $needle); - } - else - { - if (!is_int($offset)) - { - trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_ERROR); - return false; - } - - $str = mb_substr($str, $offset); - - if (false !== ($pos = mb_strrpos($str, $needle))) - { - return $pos + $offset; - } - - return false; - } + return mb_strrpos($str, $needle, $offset); } } diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 7eaeb51502..1bf62476bd 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -456,7 +456,7 @@ function phpbb_get_birthday($birthday = '') { $birthday = (int) $birthday; - if (!$birthday || $birthday == 999999 || ((version_compare(PHP_VERSION, '5.1.0') < 0) && $birthday < 0)) + if (!$birthday || $birthday == 999999) { return ' 0- 0- 0'; } |