From 09e2c295e81d0fd55e9871619dacac990c52b81a Mon Sep 17 00:00:00 2001 From: rub Date: Sun, 31 Dec 2006 17:02:36 +0000 Subject: Issue ID 0000529 Fixed. Problem with $_SERVER['SCRIPT_FILENAME'] on IIS server git-svn-id: http://piwigo.org/svn/branches/branch-1_6@1686 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/common.inc.php | 2 +- include/functions.inc.php | 36 ++++++++++++++++++++++++++++++++++++ include/functions_calendar.inc.php | 2 +- include/section_init.inc.php | 4 ++-- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/include/common.inc.php b/include/common.inc.php index 217395a6f..baabfdf72 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -174,7 +174,7 @@ if ($conf['gallery_locked']) } if ($user['is_the_guest'] and !$conf['guest_access'] - and !in_array( basename($_SERVER['SCRIPT_FILENAME']), + and !in_array( script_basename(), array('identification.php', 'password.php', 'register.php' diff --git a/include/functions.inc.php b/include/functions.inc.php index 06847b550..eb4d4adec 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -967,4 +967,40 @@ SELECT param,value } } } + +/** + * Return basename of the current script + * Return value are chnage to loawer case + * + * @param void + * + * @return script basename + */ +function script_basename() +{ + if (!empty($_SERVER['SCRIPT_NAME'])) + { + $file_name = $_SERVER['SCRIPT_NAME']; + } + else if (!empty($_SERVER['PHP_SELF'])) + { + $file_name = $_SERVER['PHP_SELF']; + } + else if (!empty($_SERVER['SCRIPT_FILENAME'])) + { + $file_name = $_SERVER['SCRIPT_FILENAME']; + } + else if (!empty($_SERVER['PATH_TRANSLATED'])) + { + $file_name = $_SERVER['PATH_TRANSLATED']; + } + else + { + $file_name = ''; + } + + // $_SERVER return lower string following var ans systems + return basename(strtolower($file_name)); +} + ?> diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 3bc79cddc..388e0dedb 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -177,7 +177,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; //echo ('
'. var_export($calendar, true) . '
'); $must_show_list = true; // true until calendar generates its own display - if (basename($_SERVER['SCRIPT_FILENAME']) != 'picture.php') + if (script_basename() != 'picture.php') { $template->assign_block_vars('calendar', array()); diff --git a/include/section_init.inc.php b/include/section_init.inc.php index b2bb4c90e..8f2232bb8 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -86,7 +86,7 @@ $tokens = explode( // ); $next_token = 0; -if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php') +if (script_basename() == 'picture.php') { // the first token must be the identifier for the picture if ( isset($_GET['image_id']) and isset($_GET['cat']) and is_numeric($_GET['cat']) ) @@ -625,7 +625,7 @@ if (isset($page['chronology_field'])) $page['cat_nb_images'] = isset($page['items']) ? count($page['items']) : 0; -if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php' +if (script_basename() == 'picture.php' and !isset($page['image_id']) ) { if ( !empty($page['items']) ) -- cgit v1.2.3