mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[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
This commit is contained in:
parent
1e59666ee3
commit
eda9fbbb63
10 changed files with 33 additions and 137 deletions
|
@ -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, '!');
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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 != '')
|
||||
{
|
||||
|
|
|
@ -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($salt . $password, true);
|
||||
do
|
||||
{
|
||||
$hash = md5($hash . $password, true);
|
||||
}
|
||||
while (--$count);
|
||||
}
|
||||
else
|
||||
{
|
||||
$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);
|
||||
|
|
|
@ -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}';
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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']
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
if (is_null($offset))
|
||||
{
|
||||
return mb_strrpos($str, $needle);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mb_strrpos($str, $needle, $offset);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* UTF-8 aware alternative to strrpos
|
||||
* @ignore
|
||||
*/
|
||||
function utf8_strrpos($str, $needle, $offset = null)
|
||||
|
||||
if (is_null($offset))
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mb_strrpos($str, $needle, $offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue