diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-20 14:38:49 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-20 14:38:49 +0100 |
commit | 151ba1c919af3316543b1871d3bd56cbb210fdca (patch) | |
tree | 5f8a65b0a074d2bc380267e46bd88e62c1f5cf20 /system/helpers/path_helper.php | |
parent | 6b47711e85671fcfe1bd08ce80d23ca2e91e8e55 (diff) | |
parent | 820999cb0d82c80d6dc5dde133568812c8113e29 (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop-helpers-acc
Diffstat (limited to 'system/helpers/path_helper.php')
-rw-r--r-- | system/helpers/path_helper.php | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 2eb85fefa..c31f0bdc5 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -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; } } |