diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-20 14:48:00 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-20 14:48:00 +0100 |
commit | 31cf46eaec3b4613d5b46f9caed8bdd346b581cc (patch) | |
tree | 047b9d74def6254639b3d9b2833f36336dc99f8a /system/helpers/path_helper.php | |
parent | b68e70b2cd81f83fd038ca2c2d00fde210a8ee0e (diff) | |
parent | 733921ecc4da80f08a9d50ff0fb05bccf23de09d (diff) |
Merge upstream branch
Diffstat (limited to 'system/helpers/path_helper.php')
-rw-r--r-- | system/helpers/path_helper.php | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index cd87a73eb..c31f0bdc5 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Path Helpers * @@ -51,28 +49,24 @@ if ( ! function_exists('set_realpath')) { function set_realpath($path, $check_existance = FALSE) { - // Security check to make sure the path is NOT a URL. No remote file inclusion! - if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path)) + // Security check to make sure the path is NOT a URL. No remote file inclusion! + if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path)) { show_error('The path you submitted must be a local server path, not a URL'); } // Resolve the path - if (function_exists('realpath') AND @realpath($path) !== FALSE) + if (function_exists('realpath') && @realpath($path) !== FALSE) { $path = realpath($path); } - - // Add a trailing slash - $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; - - // Make sure the path exists - if ($check_existance == TRUE && ! is_dir($path)) + elseif ($check_existance && ! is_dir($path) && ! is_file($path)) { show_error('Not a valid path: '.$path); } - return $path; + // Add a trailing slash, if this is a directory + return is_dir($path) ? rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path; } } |