Changeset 2543


Ignore:
Timestamp:
Sep 17, 2008, 3:48:31 AM (16 years ago)
Author:
rvelices
Message:
  • fix status header (web services + IE6 min display)
  • sql optims in feed /notification
  • dont send cookie for 10 years from admin/history.php
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r2530 r2543  
    117117  $search['fields']['display_thumbnail'] = $_POST['display_thumbnail'];
    118118  // Display choise are also save to one cookie
    119   pwg_set_cookie_var('history_display_thumbnail', $_POST['display_thumbnail']);
     119  $cookie_val = ($_POST['display_thumbnail']!=$display_thumbnails[2] and in_array($_POST['display_thumbnail'], $display_thumbnails)) ? $_POST['display_thumbnail']:null;
     120  pwg_set_cookie_var('history_display_thumbnail', $cookie_val, strtotime('+1 month') );
    120121
    121122  // TODO manage inconsistency of having $_POST['image_id'] and
  • trunk/include/common.inc.php

    r2502 r2543  
    224224    echo l10n('gallery_locked_message')
    225225      .'<a href="'.get_absolute_root_url(false).'identification.php">.</a>';
     226    echo str_repeat( ' ', 512); //IE6 doesn't error output if below a size
    226227    exit();
    227228  }
  • trunk/include/functions_cookie.inc.php

    r2339 r2543  
    3737    // mod_rewrite is activated for upper level directories. we must set the
    3838    // cookie to the path shown in the browser otherwise it will be discarded.
    39     if 
    40       ( 
     39    if
     40      (
    4141        isset($_SERVER['PATH_INFO']) and !empty($_SERVER['PATH_INFO']) and
    4242        ($_SERVER['REDIRECT_URL'] !== $_SERVER['PATH_INFO']) and
     
    4545      )
    4646    {
    47       $scr = substr($_SERVER['REDIRECT_URL'], 0, 
     47      $scr = substr($_SERVER['REDIRECT_URL'], 0,
    4848        strlen($_SERVER['REDIRECT_URL'])-strlen($_SERVER['PATH_INFO']));
    4949    }
     
    6565    $scr .= '/';
    6666  }
    67  
     67
    6868  if ( substr(PHPWG_ROOT_PATH,0,3)=='../')
    6969  { // this is maybe a plugin inside pwg directory
     
    8888 * @see pwg_get_cookie_var
    8989 */
    90 function pwg_set_cookie_var($var, $value)
     90function pwg_set_cookie_var($var, $value, $expire=null)
    9191{
    92   $_COOKIE['pwg_'.$var] = $value;
    93   return
    94     setcookie('pwg_'.$var, $value,
    95       strtotime('+10 years'), cookie_path());
     92  if ($value==null or $expire===0)
     93  {
     94    unset($_COOKIE['pwg_'.$var]);
     95    return setcookie('pwg_'.$var, false, 0, cookie_path());
     96
     97  }
     98  else
     99  {
     100    $_COOKIE['pwg_'.$var] = $value;
     101    $expire = is_numeric($expire) ? $expire : strtotime('+10 years');
     102    return setcookie('pwg_'.$var, $value, $expire, cookie_path());
     103  }
    96104}
    97105
  • trunk/include/functions_html.inc.php

    r2502 r2543  
    586586      .urlencode(urlencode($_SERVER['REQUEST_URI']));
    587587
     588  set_status_header(401);
    588589  if ( isset($user) and !is_a_guest() )
    589590  {
     
    591592    echo '<a href="'.get_root_url().'identification.php">'.l10n('identification').'</a>&nbsp;';
    592593    echo '<a href="'.make_index_url().'">'.l10n('home').'</a></div>';
     594    echo str_repeat( ' ', 512); //IE6 doesn't error output if below a size
    593595    exit();
    594596  }
    595597  else
    596598  {
    597     set_status_header(401);
    598599    redirect_html($login_url);
    599600  }
     
    678679
    679680  @set_status_header(500);
    680   echo $display.str_repeat( ' ', 300); //IE doesn't error output if below a size
     681  echo $display.str_repeat( ' ', 300); //IE6 doesn't error output if below a size
    681682
    682683  if ( function_exists('ini_set') )
     
    755756      case 404: $text='Not found';break;
    756757      case 500: $text='Server error';break;
     758      case 501: $text='Not implemented';break;
    757759      case 503: $text='Service unavailable';break;
    758760    }
  • trunk/include/functions_notification.inc.php

    r2335 r2543  
    3636 * @return string sql where
    3737 */
    38 function get_std_sql_where_restrict_filter($prefix_condition, $force_one_condition = false)
     38function get_std_sql_where_restrict_filter($prefix_condition, $img_field='ic.image_id', $force_one_condition = false)
    3939{
    4040  return get_sql_condition_FandF
     
    4444                'forbidden_categories' => 'ic.category_id',
    4545                'visible_categories' => 'ic.category_id',
    46                 'visible_images' => 'ic.image_id'
     46                'visible_images' => $img_field
    4747              ),
    4848            $prefix_condition,
     
    9090  WHERE date_available > \''.$start.'\'
    9191    AND date_available <= \''.$end.'\'
    92       '.get_std_sql_where_restrict_filter('AND').'
     92      '.get_std_sql_where_restrict_filter('AND', 'id').'
    9393;';
    9494      break;
     
    9898  WHERE date_available > \''.$start.'\'
    9999    AND date_available <= \''.$end.'\'
    100       '.get_std_sql_where_restrict_filter('AND').'
     100      '.get_std_sql_where_restrict_filter('AND', 'id').'
    101101;';
    102102      break;
     
    435435  global $conf, $user;
    436436
    437   $where_sql = get_std_sql_where_restrict_filter('WHERE', true);
     437  $where_sql = get_std_sql_where_restrict_filter('WHERE', 'i.id', true);
    438438
    439439  $query = '
     
    441441      COUNT(DISTINCT id) nb_elements,
    442442      COUNT(DISTINCT category_id) nb_cats
    443   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
     443  FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
    444444  '.$where_sql.'
    445445  GROUP BY date_available
     
    460460      $query = '
    461461SELECT DISTINCT id, path, name, tn_ext, file
    462   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
     462  FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
    463463  '.$where_sql.'
    464464    AND date_available="'.$dates[$i]['date_available'].'"
  • trunk/include/ws_core.inc.php

    r2521 r2543  
    3636define( 'WS_PARAM_OPTIONAL',      0x040000 );
    3737
    38 define( 'WS_ERR_INVALID_METHOD',  1001 );
     38define( 'WS_ERR_INVALID_METHOD',  501 );
    3939define( 'WS_ERR_MISSING_PARAM',   1002 );
    4040define( 'WS_ERR_INVALID_PARAM',   1003 );
     
    4848class PwgError
    4949{
    50   var $_code;
    51   var $_codeText;
     50  private $_code;
     51  private $_codeText;
    5252
    5353  function PwgError($code, $codeText)
    5454  {
    55     set_status_header($code, $codeText);
     55    if ($code>=400 and $code<600)
     56    {
     57      set_status_header($code, $codeText);
     58    }
    5659
    5760    $this->_code = $code;
     
    8184   *      xml attributes instead of xml child elements
    8285   */
    83   function PwgNamedArray(&$arr, $itemName, $xmlAttributes=array() )
     86  function PwgNamedArray($arr, $itemName, $xmlAttributes=array() )
    8487  {
    8588    $this->_content = $arr;
     
    135138
    136139/**
    137  * Replace array_walk_recursive()
    138  *
    139  * @category    PHP
    140  * @package     PHP_Compat
    141  * @link        http://php.net/function.array_walk_recursive
    142  * @author      Tom Buskens <ortega@php.net>
    143  * @author      Aidan Lister <aidan@php.net>
    144  * @version     $Revision$
    145  * @since       PHP 5
    146  * @require     PHP 4.0.6 (is_callable)
    147  */
    148 if (!function_exists('array_walk_recursive')) {
    149     function array_walk_recursive(&$input, $funcname)
    150     {
    151         if (!is_callable($funcname)) {
    152             if (is_array($funcname)) {
    153                 $funcname = $funcname[0] . '::' . $funcname[1];
    154             }
    155             user_error('array_walk_recursive() Not a valid callback ' . $user_func,
    156                 E_USER_WARNING);
    157             return;
    158         }
    159 
    160         if (!is_array($input)) {
    161             user_error('array_walk_recursive() The argument should be an array',
    162                 E_USER_WARNING);
    163             return;
    164         }
    165 
    166         $args = func_get_args();
    167 
    168         foreach ($input as $key => $item) {
    169             if (is_array($item)) {
    170                 array_walk_recursive($item, $funcname, $args);
    171                 $input[$key] = $item;
    172             } else {
    173                 $args[0] = &$item;
    174                 $args[1] = &$key;
    175                 call_user_func_array($funcname, $args);
    176                 $input[$key] = $item;
    177             }
    178         }
    179     }
    180 }
    181 
    182 /**
    183140 * Abstract base class for request handlers.
    184141 */
     
    210167   * NOT consecutive integers starting with 0)
    211168   */
    212   function is_struct(&$data)
     169  static function is_struct(&$data)
    213170  {
    214171    if (is_array($data) )
     
    226183   * usually called by every response encoder, except rest xml.
    227184   */
    228   function flattenResponse(&$response)
     185  static function flattenResponse(&$response)
    229186  {
    230187    PwgResponseEncoder::_mergeAttributesAndContent($response);
     
    240197  }
    241198
    242   /*private*/ function _remove_named_callback(&$value, $key)
     199  private static function _remove_named_callback(&$value, $key)
    243200  {
    244201    do
     
    252209  }
    253210
    254   /*private*/ function _mergeAttributesAndContent(&$value)
     211  private static function _mergeAttributesAndContent(&$value)
    255212  {
    256213    if ( !is_array($value) )
     
    311268  }
    312269
    313   /*private*/ function _removeNamedArray(&$value)
     270  private static function _removeNamedArray(&$value)
    314271  {
    315272    if ( strtolower( get_class($value) ) =='pwgnamedarray')
     
    321278  }
    322279
    323   /*private*/ function _removeNamedStruct(&$value)
     280  private static function _removeNamedStruct(&$value)
    324281  {
    325282    if ( strtolower( get_class($value) ) =='pwgnamedstruct')
     
    389346    if ( is_null($this->_requestHandler) )
    390347    {
    391       $this->sendResponse(
    392         new PwgError(400, 'Unknown request format')
    393         );
     348      $this->sendResponse( new PwgError(400, 'Unknown request format') );
    394349      return;
    395350    }
     
    584539   * WS reflection method implementation: lists all available methods
    585540   */
    586   /*static*/ function ws_getMethodList($params, &$service)
     541  static function ws_getMethodList($params, &$service)
    587542  {
    588543    return array('methods' => new PwgNamedArray( array_keys($service->_methods),'method' ) );
     
    592547   * WS reflection method implementation: gets information about a given method
    593548   */
    594   /*static*/ function ws_getMethodDetails($params, &$service)
     549  static function ws_getMethodDetails($params, &$service)
    595550  {
    596551    $methodName = $params['methodName'];
Note: See TracChangeset for help on using the changeset viewer.