From cc12d640519a673d1a422cc608ca6ec1a59ef46e Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 17 Sep 2008 01:48:31 +0000 Subject: - fix status header (web services + IE6 min display) - sql optims in feed /notification - dont send cookie for 10 years from admin/history.php git-svn-id: http://piwigo.org/svn/trunk@2543 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_cookie.inc.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'include/functions_cookie.inc.php') diff --git a/include/functions_cookie.inc.php b/include/functions_cookie.inc.php index 159a5b538..66b66221f 100644 --- a/include/functions_cookie.inc.php +++ b/include/functions_cookie.inc.php @@ -36,15 +36,15 @@ function cookie_path() { // mod_rewrite is activated for upper level directories. we must set the // cookie to the path shown in the browser otherwise it will be discarded. - if - ( + if + ( isset($_SERVER['PATH_INFO']) and !empty($_SERVER['PATH_INFO']) and ($_SERVER['REDIRECT_URL'] !== $_SERVER['PATH_INFO']) and (substr($_SERVER['REDIRECT_URL'],-strlen($_SERVER['PATH_INFO'])) == $_SERVER['PATH_INFO']) ) { - $scr = substr($_SERVER['REDIRECT_URL'], 0, + $scr = substr($_SERVER['REDIRECT_URL'], 0, strlen($_SERVER['REDIRECT_URL'])-strlen($_SERVER['PATH_INFO'])); } else @@ -64,7 +64,7 @@ function cookie_path() { $scr .= '/'; } - + if ( substr(PHPWG_ROOT_PATH,0,3)=='../') { // this is maybe a plugin inside pwg directory // TODO - what if it is an external script outside PWG ? @@ -87,12 +87,20 @@ function cookie_path() * @return boolean true on success * @see pwg_get_cookie_var */ -function pwg_set_cookie_var($var, $value) +function pwg_set_cookie_var($var, $value, $expire=null) { - $_COOKIE['pwg_'.$var] = $value; - return - setcookie('pwg_'.$var, $value, - strtotime('+10 years'), cookie_path()); + if ($value==null or $expire===0) + { + unset($_COOKIE['pwg_'.$var]); + return setcookie('pwg_'.$var, false, 0, cookie_path()); + + } + else + { + $_COOKIE['pwg_'.$var] = $value; + $expire = is_numeric($expire) ? $expire : strtotime('+10 years'); + return setcookie('pwg_'.$var, $value, $expire, cookie_path()); + } } /** -- cgit v1.2.3