Skip to content

Commit

Permalink
Resolved 0000726: script_basename returns bad result
Browse files Browse the repository at this point in the history
With specific server configuration, script_basename returns bad result.

git-svn-id: http://piwigo.org/svn/trunk@2071 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Jul 24, 2007
1 parent 7f480b6 commit 94c265d
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions include/functions.inc.php
Expand Up @@ -1285,20 +1285,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
Expand All @@ -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 '';
}

/**
Expand Down

0 comments on commit 94c265d

Please sign in to comment.