summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-07-28 15:40:12 +0200
committerAndrey Andreev <narf@devilix.net>2016-07-28 15:40:12 +0200
commita838279625becfba98ccb7635d35c67297129c42 (patch)
tree6ddf87407a88b84dc90503d5e7ac68c40cd07d66 /system/libraries
parent1748567f5442409d6a8c1e795f56599caff8296e (diff)
Remove dead code written for PHP 5.2
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Email.php9
-rw-r--r--system/libraries/Encryption.php6
-rw-r--r--system/libraries/Form_validation.php13
-rw-r--r--system/libraries/Migration.php5
-rw-r--r--system/libraries/Session/drivers/Session_files_driver.php15
-rw-r--r--system/libraries/Upload.php41
6 files changed, 22 insertions, 67 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index be89d6569..5049578ed 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1514,14 +1514,7 @@ class CI_Email {
// which only works with "\n".
if ($this->crlf === "\r\n")
{
- if (is_php('5.3'))
- {
- return quoted_printable_encode($str);
- }
- elseif (function_exists('imap_8bit'))
- {
- return imap_8bit($str);
- }
+ return quoted_printable_encode($str);
}
// Reduce multiple spaces & remove nulls
diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php
index a10a5c20c..06284c2ed 100644
--- a/system/libraries/Encryption.php
+++ b/system/libraries/Encryption.php
@@ -152,10 +152,8 @@ class CI_Encryption {
public function __construct(array $params = array())
{
$this->_drivers = array(
- 'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
- // While OpenSSL is available for PHP 5.3.0, an IV parameter
- // for the encrypt/decrypt functions is only available since 5.3.3
- 'openssl' => (is_php('5.3.3') && extension_loaded('openssl'))
+ 'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
+ 'openssl' => extension_loaded('openssl')
);
if ( ! $this->_drivers['mcrypt'] && ! $this->_drivers['openssl'])
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 04445f5b7..25dc0d41e 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1216,18 +1216,7 @@ class CI_Form_validation {
$str = 'ipv6.host'.substr($str, strlen($matches[1]) + 2);
}
- $str = 'http://'.$str;
-
- // There's a bug affecting PHP 5.2.13, 5.3.2 that considers the
- // underscore to be a valid hostname character instead of a dash.
- // Reference: https://bugs.php.net/bug.php?id=51192
- if (version_compare(PHP_VERSION, '5.2.13', '==') OR version_compare(PHP_VERSION, '5.3.2', '=='))
- {
- sscanf($str, 'http://%[^/]', $host);
- $str = substr_replace($str, strtr($host, array('_' => '-', '-' => '_')), 7, strlen($host));
- }
-
- return (filter_var($str, FILTER_VALIDATE_URL) !== FALSE);
+ return (filter_var('http://'.$str, FILTER_VALIDATE_URL) !== FALSE);
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 316c94ae3..3e2107e83 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -288,10 +288,7 @@ class CI_Migration {
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
return FALSE;
}
- // method_exists() returns true for non-public methods,
- // while is_callable() can't be used without instantiating.
- // Only get_class_methods() satisfies both conditions.
- elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class))))
+ elseif ( ! is_callable(array($class, $method)))
{
$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
return FALSE;
diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php
index 57c3777a2..bf4df8b20 100644
--- a/system/libraries/Session/drivers/Session_files_driver.php
+++ b/system/libraries/Session/drivers/Session_files_driver.php
@@ -149,18 +149,9 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
// which re-reads session data
if ($this->_file_handle === NULL)
{
- // Just using fopen() with 'c+b' mode would be perfect, but it is only
- // available since PHP 5.2.6 and we have to set permissions for new files,
- // so we'd have to hack around this ...
- if (($this->_file_new = ! file_exists($this->_file_path.$session_id)) === TRUE)
- {
- if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
- {
- log_message('error', "Session: File '".$this->_file_path.$session_id."' doesn't exist and cannot be created.");
- return $this->_failure;
- }
- }
- elseif (($this->_file_handle = fopen($this->_file_path.$session_id, 'r+b')) === FALSE)
+ $this->_file_new = ! file_exists($this->_file_path.$session_id);
+
+ if (($this->_file_handle = fopen($this->_file_path.$session_id, 'c+b')) === FALSE)
{
log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
return $this->_failure;
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 056f6de1e..a8cf75264 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1086,13 +1086,7 @@ class CI_Upload {
if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
{
$memory_limit *= 1024 * 1024;
-
- // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
- // into scientific notation. number_format() ensures this number is an integer
- // http://bugs.php.net/bug.php?id=43053
-
- $memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', '');
-
+ $memory_limit = (int) ceil(filesize($file) + $memory_limit);
ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
}
@@ -1207,28 +1201,21 @@ class CI_Upload {
// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
- /* Fileinfo extension - most reliable method
- *
- * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the
- * more convenient FILEINFO_MIME_TYPE flag doesn't exist.
- */
- if (function_exists('finfo_file'))
+ // Fileinfo extension - most reliable method
+ $finfo = @finfo_open(FILEINFO_MIME);
+ if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
{
- $finfo = @finfo_open(FILEINFO_MIME);
- if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
+ $mime = @finfo_file($finfo, $file['tmp_name']);
+ finfo_close($finfo);
+
+ /* According to the comments section of the PHP manual page,
+ * it is possible that this function returns an empty string
+ * for some files (e.g. if they don't exist in the magic MIME database)
+ */
+ if (is_string($mime) && preg_match($regexp, $mime, $matches))
{
- $mime = @finfo_file($finfo, $file['tmp_name']);
- finfo_close($finfo);
-
- /* According to the comments section of the PHP manual page,
- * it is possible that this function returns an empty string
- * for some files (e.g. if they don't exist in the magic MIME database)
- */
- if (is_string($mime) && preg_match($regexp, $mime, $matches))
- {
- $this->file_type = $matches[1];
- return;
- }
+ $this->file_type = $matches[1];
+ return;
}
}