diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-20 13:49:56 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-20 13:49:56 +0100 |
commit | 87230286b2948cf580e21f426824a974210d7595 (patch) | |
tree | 3f0098f4f8b65ff61d60a333351d847387670596 /system/helpers/path_helper.php | |
parent | 5e18e891a14400a96f9b4af36925457b79b62005 (diff) | |
parent | 6ea625e7f31b65838f1829408d37ac26009c79bc (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; } } |