Changeset 2072 for branches


Ignore:
Timestamp:
Jul 24, 2007, 9:16:02 PM (17 years ago)
Author:
rub
Message:

Resolved 0000726: script_basename returns bad result

With specific server configuration, script_basename returns bad result.

Merge BSF 2070:2071 into branch-1_7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_7/include/functions.inc.php

    r1990 r2072  
    12851285
    12861286/**
    1287  * Return is "file_name" argument is candidate to
    1288  * compute script_basename value
    1289  *
    1290  * @param string file_name
    1291  *
    1292  * @return boolean is candidate or not?
    1293  */
    1294 function is_script_basename($file_name)
    1295 {
    1296   $file_name = basename($file_name);
    1297   return !empty($file_name);
    1298 }
    1299 
    1300 /**
    13011287 * Return basename of the current script
    13021288 * Lower case convertion is applied on return value
     
    13091295function script_basename()
    13101296{
    1311   if (is_script_basename($_SERVER['SCRIPT_NAME']))
    1312   {
    1313     $file_name = $_SERVER['SCRIPT_NAME'];
    1314   }
    1315   else if (is_script_basename($_SERVER['SCRIPT_FILENAME']))
    1316   {
    1317     $file_name = $_SERVER['SCRIPT_FILENAME'];
    1318   }
    1319   else
    1320   {
    1321     $file_name = '';
    1322   }
    1323 
    1324   // $_SERVER return lower string following var and systems
    1325   return basename(strtolower($file_name), '.php');
     1297  global $conf;
     1298
     1299  foreach (array('SCRIPT_NAME', 'SCRIPT_FILENAME', 'PHP_SELF') as $value)
     1300  {
     1301    $continue = !empty($_SERVER[$value]);
     1302    if ($continue)
     1303    {
     1304      $filename = strtolower($_SERVER[$value]);
     1305
     1306      if ($conf['php_extension_in_urls'])
     1307      {
     1308        $continue = get_extension($filename) ===  'php';
     1309      }
     1310
     1311      if ($continue)
     1312      {
     1313        $basename = basename($filename, '.php');
     1314        $continue = !empty($basename);
     1315      }
     1316
     1317      if ($continue)
     1318      {
     1319        return $basename;
     1320      }
     1321    }
     1322  }
     1323
     1324  return '';
    13261325}
    13271326
Note: See TracChangeset for help on using the changeset viewer.