From 89338828264a6b50e0eb63c449a96f14f0f84076 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:03:37 +0700 Subject: Path helper improvement --- system/helpers/path_helper.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 2eb85fefa..1b9bdae75 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -58,21 +58,15 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath') AND @realpath($path) !== FALSE) - { - $path = realpath($path); - } - - // Add a trailing slash - $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; + $realpath = realpath($path); - // Make sure the path exists - if ($check_existance == TRUE && ! is_dir($path)) + if ( ! $realpath) { - show_error('Not a valid path: '.$path); + return $check_existance ? show_error('Not a valid path: '.$path) : $path; } - return $path; + // Add a trailing slash, if this is a directory + return is_dir($realpath) ? rtrim($realpath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $realpath; } } -- cgit v1.2.3-24-g4f1b From 4a7dd98ffd1d21f2b14b9eefa70e6cae2f9aa92d Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:33:55 +0700 Subject: Left the function_exists due some security restriction in some hosting environment --- system/helpers/path_helper.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 1b9bdae75..9c0af44c1 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.2.4 or newer + * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE * @@ -58,7 +58,14 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - $realpath = realpath($path); + if (function_exists('realpath')) + { + $realpath = realpath($path); + } + else + { + $realpath = (is_dir($path) or is_file($path)) ? $path : FALSE; + } if ( ! $realpath) { -- cgit v1.2.3-24-g4f1b From 7164cda9ab8aea8fc26aad21dd78c9f06839dec7 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Mon, 12 Mar 2012 21:36:04 +0700 Subject: Minimal PHP version annotation --- system/helpers/path_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 9c0af44c1..8c4730d73 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 * -- cgit v1.2.3-24-g4f1b From fc49a657af78b0fb248cc666b162dc894e3e04ba Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 13 Mar 2012 03:27:58 +0700 Subject: Extra --- system/helpers/path_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 8c4730d73..e4fc6f157 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -58,13 +58,13 @@ if ( ! function_exists('set_realpath')) } // Resolve the path - if (function_exists('realpath')) + if (function_exists('realpath') && @realpath($path) !== FALSE) { $realpath = realpath($path); } else { - $realpath = (is_dir($path) or is_file($path)) ? $path : FALSE; + $realpath = (is_dir($path) OR is_file($path)) ? $path : FALSE; } if ( ! $realpath) -- cgit v1.2.3-24-g4f1b