Changeset 1675


Ignore:
Timestamp:
Dec 19, 2006, 8:32:50 AM (17 years ago)
Author:
vdigital
Message:

WEB Service: Some corrections again but still an incomplete version.

Location:
trunk
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web_service.php

    r1674 r1675  
    127127// Key and pos are correct
    128128// &acc=cat/23,25-32&req=landscape&lim=5&tpl=myxml
     129
     130// Requested id list and authorized id list
     131// Both may empty
     132// Both can be build on differents basis cat/tag/list
     133// Both have to be convert in id list format
    129134$req_access ='';
    130135if (isset($_GET['pos']))
     
    144149  $req_list = get_image_ids_for_tags($req_list);
    145150}
    146 echo $def['name'].'<br />';
     151// echo $def['name'].'<br />';
    147152// on the other hand $def['access'], authorized default ids
    148153$def_type = explode('/',$def['access']);
     
    158163}
    159164
    160 // could be no necessary, a surplus but
    161 // Filter on forbidden_categories
     165// could be no necessary, a surplus but we are obliged to
     166// Filter on forbidden_categories (default can have change from creation time)
    162167$list = implode(',',$def_list);
    163168
     
    174179  $ret_ids[] = $row['image_id'];
    175180}
    176 
     181$def_ids = $ret_ids;
     182
     183// Notice: Filtering on forbidden_categories (from requested id list)
     184// is completely superfluous (see few lines below).
     185$req_ids = $req_list;
     186
     187// if no requested ids then is the complete default
     188if (count($req_ids)==0)
     189{
     190  $req_ids = $def_ids;
     191}
     192
     193// Removing requested ids not in authorized access list
     194// if requested ids they must be in the complete default and only those
     195// will be assumed. (Including forbidden... )
     196$final = array();
     197foreach ( $req_ids as $req_id )
     198{
     199  if ( in_array($req_id, $def_ids) )
     200  {
     201    $final[] = $req_id;
     202  }
     203}
     204
     205$final = array_unique ($final); 
     206sort ($final);
     207 
    177208// 77f1180bd215a0edf66939
    178209// web_service.php?key=77f1180bd215&pos=3&acc=list/41,73,142,178,190,204,235-238&req=recent&lim=1&tpl=myxml
    179210
    180 echo 'temporaire<br />';
    181 echo '$req_list' . var_dump($req_list);
    182 
    183 if (count($req_list)==0)
    184 {
    185   $req_list = $def_list;
    186 
     211$request = (isset($_GET['req']))? $_GET['req']:$def['request'];
     212// if type of request is different from the authorized type then force it
     213if ( $def['request'] !== '' and $request !== $def['request'] )
     214
     215{
     216  $request = $def['request'];
     217}
     218// if it is not an official request then force it
     219// (remark that default request can no longer exist
     220// (later an Upgrade, or a remove) so...
     221$official = official_req();
     222if ( !in_array($request, $official ) )
     223{
     224  $request = $official[0]; // default request is the first one
     225}
     226// limit belong default (remember $def['limit'] is always set)
     227$limit = (isset($_GET['limit']))? $_GET['limit']:$def['limit'];
     228$limit = (is_numeric($limit))? $limit:$def['limit'];
     229$limit = ( $limit < $def['limit'] ) ? $limit:$def['limit'];
     230
     231// XML template
     232$tplfile = (isset($_GET['tpl']))? $_GET['tpl']:'default';
     233// FIXME additional controls are maybe needed on $tplfile
     234
     235
     236trigger_action('loc_begin_'.$request);
     237$template->set_filenames(array( $tplfile => 'XML/'. $tplfile .'.tpl'));
     238
     239// Generate the request
     240include(PHPWG_ROOT_PATH. 'services/' .$request. '.php');
     241
     242
     243// +-----------------------------------------------------------------------+
     244// |                       XML/xhtml code display                          |
     245// +-----------------------------------------------------------------------+
     246header('Content-Type: text/xml; charset=UTF-8');
     247//header('Content-Type: text/html; charset='.$lang_info['charset']);
     248$template->parse($tplfile);
     249
     250// echo '<strong>Trace temporaire<strong><br />';
     251// echo '$final:<br />' . var_dump($final);
    187252//
    188   die('FIXME!');
     253die('');
    189254// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME
    190255
    191 // Both may empty
    192 // Both can be build on differents basis cat/tag/list
    193 // Both have to be convert in list
    194 // if no requested ids then is the complete default
    195 // if some requested ids they must be in the complete default and only those
    196 // will be transmitted.
     256//------------------------------------------------------------ log informations
     257pwg_log($request, $stats_id, $tplfile); // or something like that
     258
    197259
    198260
Note: See TracChangeset for help on using the changeset viewer.