Skip to content

Commit

Permalink
Issue 0000529:
Browse files Browse the repository at this point in the history
Enhance computing method of script_basename function.

http://forum.phpwebgallery.net/viewtopic.php?pid=58258#p58258

git-svn-id: http://piwigo.org/svn/trunk@1989 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Apr 29, 2007
1 parent 877564c commit 24bbf97
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions include/functions.inc.php
Expand Up @@ -1283,6 +1283,20 @@ 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 @@ -1294,11 +1308,11 @@ function hash_from_query($query, $keyname)
*/
function script_basename()
{
if (!empty($_SERVER['SCRIPT_NAME']))
if (is_script_basename($_SERVER['SCRIPT_NAME']))
{
$file_name = $_SERVER['SCRIPT_NAME'];
}
else if (!empty($_SERVER['SCRIPT_FILENAME']))
else if (is_script_basename($_SERVER['SCRIPT_FILENAME']))
{
$file_name = $_SERVER['SCRIPT_FILENAME'];
}
Expand Down

0 comments on commit 24bbf97

Please sign in to comment.