mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
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
This commit is contained in:
@@ -1283,20 +1283,6 @@ function hash_from_query($query, $keyname)
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -1308,21 +1294,34 @@ function is_script_basename($file_name)
|
||||
*/
|
||||
function script_basename()
|
||||
{
|
||||
if (is_script_basename($_SERVER['SCRIPT_NAME']))
|
||||
global $conf;
|
||||
|
||||
foreach (array('SCRIPT_NAME', 'SCRIPT_FILENAME', 'PHP_SELF') as $value)
|
||||
{
|
||||
$file_name = $_SERVER['SCRIPT_NAME'];
|
||||
}
|
||||
else if (is_script_basename($_SERVER['SCRIPT_FILENAME']))
|
||||
{
|
||||
$file_name = $_SERVER['SCRIPT_FILENAME'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$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 '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user