aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2007-07-24 19:14:11 +0000
committerrub <rub@piwigo.org>2007-07-24 19:14:11 +0000
commit94c265d0cd6866fac7f6a1606348a5a0032614be (patch)
tree3098619b61b42143c08e9f7548dbf12dadfa48d3 /include/functions.inc.php
parent7f480b6ec63af411953063ca29c43bc428193fe6 (diff)
Resolved 0000726: script_basename returns bad result
With specific server configuration, script_basename returns bad result. git-svn-id: http://piwigo.org/svn/trunk@2071 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php51
1 files changed, 25 insertions, 26 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 6488bec6b..ebd657e59 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1286,20 +1286,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"
@@ -1310,21 +1296,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 '';
}
/**