diff options
Diffstat (limited to 'system/core')
-rw-r--r--[-rwxr-xr-x] | system/core/Benchmark.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/CodeIgniter.php | 4 | ||||
-rw-r--r-- | system/core/Common.php | 40 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Config.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Exceptions.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Hooks.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Input.php | 20 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Lang.php | 0 | ||||
-rw-r--r-- | system/core/Loader.php | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Model.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Output.php | 27 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Router.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/Security.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | system/core/URI.php | 28 |
14 files changed, 81 insertions, 40 deletions
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index 2fabdf46e..2fabdf46e 100755..100644 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index b3e984d4d..8159b19f5 100755..100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -73,9 +73,9 @@ */ set_error_handler('_exception_handler'); - if ( ! is_php('5.3')) + if ( ! is_php('5.4')) { - @set_magic_quotes_runtime(0); // Kill magic quotes + @ini_set('magic_quotes_runtime', 0); // Kill magic quotes } /* diff --git a/system/core/Common.php b/system/core/Common.php index 8af7d6323..1708653e7 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -44,13 +44,13 @@ if ( ! function_exists('is_php')) /** * Determines if the current version of PHP is greater then the supplied value * - * Since there are a few places where we conditionally test for PHP > 5 + * Since there are a few places where we conditionally test for PHP > 5.3 * we'll set a static variable. * * @param string * @return bool TRUE if the current version is $version or higher */ - function is_php($version = '5.0.0') + function is_php($version = '5.3.0') { static $_is_php; $version = (string) $version; @@ -233,18 +233,18 @@ if ( ! function_exists('get_config')) $file_path = APPPATH.'config/config.php'; $found = FALSE; - if (file_exists($file_path)) + if (file_exists($file_path)) { $found = TRUE; require($file_path); } // Is the config file in the environment folder? - if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + if (defined('ENVIRONMENT') && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { - require($file_path); - } - elseif ( ! $found) + require($file_path); + } + elseif ( ! $found) { set_status_header(503); exit('The configuration file does not exist.'); @@ -304,6 +304,32 @@ if ( ! function_exists('config_item')) // ------------------------------------------------------------------------ +if ( ! function_exists('get_mimes')) +{ + /** + * Returns the MIME types array from config/mimes.php + * + * @return array + */ + function &get_mimes() + { + static $_mimes = array(); + + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + $_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + $_mimes = include(APPPATH.'config/mimes.php'); + } + + return $_mimes; + } +} + +// ------------------------------------------------------------------------ + if ( ! function_exists('show_error')) { /** diff --git a/system/core/Config.php b/system/core/Config.php index 3de1bcb96..3de1bcb96 100755..100644 --- a/system/core/Config.php +++ b/system/core/Config.php diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 8c32085fe..8c32085fe 100755..100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 29fd88201..29fd88201 100755..100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php diff --git a/system/core/Input.php b/system/core/Input.php index 73f46ba6a..162e40c85 100755..100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -376,14 +376,26 @@ class CI_Input { /** * Validate IP Address * - * Updated version suggested by Geert De Deckere - * * @param string + * @param string 'ipv4' or 'ipv6' * @return bool */ - public function valid_ip($ip) + public function valid_ip($ip, $which = '') { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + switch (strtolower($which)) + { + case 'ipv4': + $which = FILTER_FLAG_IPV4; + break; + case 'ipv6': + $which = FILTER_FLAG_IPV6; + break; + default: + $which = NULL; + break; + } + + return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which); } // -------------------------------------------------------------------- diff --git a/system/core/Lang.php b/system/core/Lang.php index 3001f1b13..3001f1b13 100755..100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php diff --git a/system/core/Loader.php b/system/core/Loader.php index 09e948714..94739c74a 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -668,7 +668,7 @@ class CI_Loader { * @param bool * @return void */ - public function add_package_path($path, $view_cascade=TRUE) + public function add_package_path($path, $view_cascade = TRUE) { $path = rtrim($path, '/').'/'; diff --git a/system/core/Model.php b/system/core/Model.php index 9bc9f879f..9bc9f879f 100755..100644 --- a/system/core/Model.php +++ b/system/core/Model.php diff --git a/system/core/Output.php b/system/core/Output.php index b5484ac81..8a0f14e02 100755..100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -64,7 +64,7 @@ class CI_Output { * * @var array */ - public $mime_types = array(); + public $mimes = array(); /** * Mime-type for the current page @@ -110,14 +110,7 @@ class CI_Output { $this->_zlib_oc = (bool) @ini_get('zlib.output_compression'); // Get mime types for later - if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - $this->mime_types = include APPPATH.'config/'.ENVIRONMENT.'/mimes.php'; - } - else - { - $this->mime_types = include APPPATH.'config/mimes.php'; - } + $this->mimes =& get_mimes(); log_message('debug', 'Output Class Initialized'); } @@ -213,16 +206,16 @@ class CI_Output { * @param string extension of the file we're outputting * @return void */ - public function set_content_type($mime_type) + public function set_content_type($mime_type, $charset = NULL) { if (strpos($mime_type, '/') === FALSE) { $extension = ltrim($mime_type, '.'); // Is this extension supported? - if (isset($this->mime_types[$extension])) + if (isset($this->mimes[$extension])) { - $mime_type =& $this->mime_types[$extension]; + $mime_type =& $this->mimes[$extension]; if (is_array($mime_type)) { @@ -233,7 +226,13 @@ class CI_Output { $this->mime_type = $mime_type; - $header = 'Content-Type: '.$mime_type; + if (empty($charset)) + { + $charset = config_item('charset'); + } + + $header = 'Content-Type: '.$mime_type + .(empty($charset) ? NULL : '; charset='.strtolower($charset)); $this->headers[] = array($header, TRUE); return $this; @@ -388,7 +387,7 @@ class CI_Output { if ($this->parse_exec_vars === TRUE) { - $memory = function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2).'MB' : '0'; + $memory = round(memory_get_usage() / 1024 / 1024, 2).'MB'; $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output); } diff --git a/system/core/Router.php b/system/core/Router.php index 5bc053045..5bc053045 100755..100644 --- a/system/core/Router.php +++ b/system/core/Router.php diff --git a/system/core/Security.php b/system/core/Security.php index 4593a1090..4593a1090 100755..100644 --- a/system/core/Security.php +++ b/system/core/Security.php diff --git a/system/core/URI.php b/system/core/URI.php index a575bc36e..a997525ee 100755..100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -119,7 +119,7 @@ class CI_URI { } // No PATH_INFO?... What about QUERY_STRING? - $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); + $path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); if (trim($path, '/') !== '') { $this->_set_uri_string($path); @@ -163,7 +163,7 @@ class CI_URI { * @param string * @return void */ - public function _set_uri_string($str) + protected function _set_uri_string($str) { // Filter out control characters $str = remove_invisible_characters($str, FALSE); @@ -177,8 +177,8 @@ class CI_URI { /** * Detects the URI * - * This function will detect the URI automatically and fix the query string - * if necessary. + * This function will detect the URI automatically + * and fix the query string if necessary. * * @return string */ @@ -189,23 +189,27 @@ class CI_URI { return ''; } - $uri = $_SERVER['REQUEST_URI']; - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) { - $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) { - $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + $uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME']))); + } + else + { + $uri = $_SERVER['REQUEST_URI']; } // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. - if (strncmp($uri, '?/', 2) === 0) + if (strpos($uri, '?/') === 0) { $uri = substr($uri, 2); } - $parts = preg_split('#\?#i', $uri, 2); + + $parts = explode('?', $uri, 2); $uri = $parts[0]; if (isset($parts[1])) { @@ -223,7 +227,7 @@ class CI_URI { return '/'; } - $uri = parse_url($uri, PHP_URL_PATH); + $uri = parse_url('pseudo://hostname/'.$uri, PHP_URL_PATH); // Do some final cleaning of the URI and return it return str_replace(array('//', '../'), '/', trim($uri, '/')); |