diff --git a/admin/history.php b/admin/history.php index 02b321055..222deaaf1 100644 --- a/admin/history.php +++ b/admin/history.php @@ -116,7 +116,8 @@ if (isset($_POST['submit'])) $search['fields']['display_thumbnail'] = $_POST['display_thumbnail']; // Display choise are also save to one cookie - pwg_set_cookie_var('history_display_thumbnail', $_POST['display_thumbnail']); + $cookie_val = ($_POST['display_thumbnail']!=$display_thumbnails[2] and in_array($_POST['display_thumbnail'], $display_thumbnails)) ? $_POST['display_thumbnail']:null; + pwg_set_cookie_var('history_display_thumbnail', $cookie_val, strtotime('+1 month') ); // TODO manage inconsistency of having $_POST['image_id'] and // $_POST['filename'] simultaneously diff --git a/include/common.inc.php b/include/common.inc.php index 1ddebfc9b..a8f661dca 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -223,6 +223,7 @@ if ($conf['gallery_locked']) @header('Retry-After: 900'); echo l10n('gallery_locked_message') .'.'; + echo str_repeat( ' ', 512); //IE6 doesn't error output if below a size exit(); } } 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()); + } } /** diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index ca07a1e16..2b3994aa8 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -585,16 +585,17 @@ function access_denied() get_root_url().'identification.php?redirect=' .urlencode(urlencode($_SERVER['REQUEST_URI'])); + set_status_header(401); if ( isset($user) and !is_a_guest() ) { echo '
'; + echo str_repeat( ' ', 512); //IE6 doesn't error output if below a size exit(); } else { - set_status_header(401); redirect_html($login_url); } } @@ -677,7 +678,7 @@ $btrace_msg \n"; @set_status_header(500); - echo $display.str_repeat( ' ', 300); //IE doesn't error output if below a size + echo $display.str_repeat( ' ', 300); //IE6 doesn't error output if below a size if ( function_exists('ini_set') ) {// if possible turn off error display (we display it) @@ -754,6 +755,7 @@ function set_status_header($code, $text='') case 403: $text='Forbidden';break; case 404: $text='Not found';break; case 500: $text='Server error';break; + case 501: $text='Not implemented';break; case 503: $text='Service unavailable';break; } } diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php index 259a34613..32d3ed9c7 100644 --- a/include/functions_notification.inc.php +++ b/include/functions_notification.inc.php @@ -35,7 +35,7 @@ * * @return string sql where */ -function get_std_sql_where_restrict_filter($prefix_condition, $force_one_condition = false) +function get_std_sql_where_restrict_filter($prefix_condition, $img_field='ic.image_id', $force_one_condition = false) { return get_sql_condition_FandF ( @@ -43,7 +43,7 @@ function get_std_sql_where_restrict_filter($prefix_condition, $force_one_conditi ( 'forbidden_categories' => 'ic.category_id', 'visible_categories' => 'ic.category_id', - 'visible_images' => 'ic.image_id' + 'visible_images' => $img_field ), $prefix_condition, $force_one_condition @@ -89,7 +89,7 @@ function custom_notification_query($action, $type, $start, $end) FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id WHERE date_available > \''.$start.'\' AND date_available <= \''.$end.'\' - '.get_std_sql_where_restrict_filter('AND').' + '.get_std_sql_where_restrict_filter('AND', 'id').' ;'; break; case 'updated_categories': @@ -97,7 +97,7 @@ function custom_notification_query($action, $type, $start, $end) FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id WHERE date_available > \''.$start.'\' AND date_available <= \''.$end.'\' - '.get_std_sql_where_restrict_filter('AND').' + '.get_std_sql_where_restrict_filter('AND', 'id').' ;'; break; case 'new_users': @@ -434,13 +434,13 @@ function get_recent_post_dates($max_dates, $max_elements, $max_cats) { global $conf, $user; - $where_sql = get_std_sql_where_restrict_filter('WHERE', true); + $where_sql = get_std_sql_where_restrict_filter('WHERE', 'i.id', true); $query = ' SELECT date_available, COUNT(DISTINCT id) nb_elements, COUNT(DISTINCT category_id) nb_cats - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id + FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id '.$where_sql.' GROUP BY date_available ORDER BY date_available DESC @@ -459,7 +459,7 @@ SELECT date_available, { // get some thumbnails ... $query = ' SELECT DISTINCT id, path, name, tn_ext, file - FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id + FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id '.$where_sql.' AND date_available="'.$dates[$i]['date_available'].'" AND tn_ext IS NOT NULL diff --git a/include/ws_core.inc.php b/include/ws_core.inc.php index cc1c1c756..24f10f114 100644 --- a/include/ws_core.inc.php +++ b/include/ws_core.inc.php @@ -35,7 +35,7 @@ define( 'WS_PARAM_ACCEPT_ARRAY', 0x010000 ); define( 'WS_PARAM_FORCE_ARRAY', 0x030000 ); define( 'WS_PARAM_OPTIONAL', 0x040000 ); -define( 'WS_ERR_INVALID_METHOD', 1001 ); +define( 'WS_ERR_INVALID_METHOD', 501 ); define( 'WS_ERR_MISSING_PARAM', 1002 ); define( 'WS_ERR_INVALID_PARAM', 1003 ); @@ -47,12 +47,15 @@ define( 'WS_XML_CONTENT', 'content_xml_'); */ class PwgError { - var $_code; - var $_codeText; + private $_code; + private $_codeText; function PwgError($code, $codeText) { - set_status_header($code, $codeText); + if ($code>=400 and $code<600) + { + set_status_header($code, $codeText); + } $this->_code = $code; $this->_codeText = $codeText; @@ -80,7 +83,7 @@ class PwgNamedArray * @param xmlAttributes array of sub-item attributes that will be encoded as * xml attributes instead of xml child elements */ - function PwgNamedArray(&$arr, $itemName, $xmlAttributes=array() ) + function PwgNamedArray($arr, $itemName, $xmlAttributes=array() ) { $this->_content = $arr; $this->_itemName = $itemName; @@ -133,52 +136,6 @@ class PwgNamedStruct } -/** - * Replace array_walk_recursive() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_walk_recursive - * @author Tom Buskens