diff options
author | rub <rub@piwigo.org> | 2007-07-24 19:16:02 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2007-07-24 19:16:02 +0000 |
commit | d958a19ed57a3300bc90df42e3351255352a7d45 (patch) | |
tree | dd7d74ab7da23d3314276e57ab559f188bd108d7 /include | |
parent | e78758a25cb0cd34350ae5aa681323f20fce600a (diff) |
Resolved 0000726: script_basename returns bad result
With specific server configuration, script_basename returns bad result.
Merge BSF 2070:2071 into branch-1_7
git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2072 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.inc.php | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php index becace1a4..1ced5e435 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1284,20 +1284,6 @@ function hash_from_query($query, $keyname) } /** - * Return is "file_name" argument is candidate to - * compute script_basename value - * - * @param string file_name - * - * @return boolean is candidate or not? - */ -function is_script_basename($file_name) -{ - $file_name = basename($file_name); - return !empty($file_name); -} - -/** * Return basename of the current script * Lower case convertion is applied on return value * Return value is without file extention ".php" @@ -1308,21 +1294,34 @@ function is_script_basename($file_name) */ function script_basename() { - if (is_script_basename($_SERVER['SCRIPT_NAME'])) - { - $file_name = $_SERVER['SCRIPT_NAME']; - } - else if (is_script_basename($_SERVER['SCRIPT_FILENAME'])) - { - $file_name = $_SERVER['SCRIPT_FILENAME']; - } - else + global $conf; + + foreach (array('SCRIPT_NAME', 'SCRIPT_FILENAME', 'PHP_SELF') as $value) { - $file_name = ''; + $continue = !empty($_SERVER[$value]); + if ($continue) + { + $filename = strtolower($_SERVER[$value]); + + if ($conf['php_extension_in_urls']) + { + $continue = get_extension($filename) === 'php'; + } + + if ($continue) + { + $basename = basename($filename, '.php'); + $continue = !empty($basename); + } + + if ($continue) + { + return $basename; + } + } } - // $_SERVER return lower string following var and systems - return basename(strtolower($file_name), '.php'); + return ''; } /** |