Changeset 1853


Ignore:
Timestamp:
Feb 24, 2007, 12:25:34 AM (17 years ago)
Author:
vdigital
Message:

New / Web Services:

  • ws_checker.php makes its own web service request to control availability
  • config_default.inc.php : comment for cURL support needed for checker
  • ws_function authorize session and getVersion for any partner
  • help review

New Admin Menu: review.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/ws_checker.php

    r1824 r1853  
    5050  $official = array(                  /* Requests are limited to             */
    5151      'categories.'                          /* all categories. methods */
    52     , 'categories.getImages'                 /* <= see */
    53     , 'categories.getList'                   /* <= see */
     52    , 'categories.getImages'
     53    , 'categories.getList'
    5454    , 'images.'                              /* all images. methods */
    55     , 'images.getInfo'                       /* <= see */
     55    , 'images.getInfo'
     56    , 'images.addComment'
     57    , 'images.search'
    5658    , 'tags.'                                /* all tags. methods */
    57     , 'tags.getImages'                       /* <= see */
    58     , 'tags.getList'                         /* <= see */
     59    , 'tags.getImages'
     60    , 'tags.getList'
    5961  );
    6062  if (function_exists('local_req')) {
     
    126128
    127129//--------------------------------------------------------- update informations
    128 
     130$chk_partner = '';
    129131// Is a new access required?
    130132
     
    151153
    152154  pwg_query($query);
     155  $chk_partner = $add_partner;
    153156 
    154157  $template->assign_block_vars(
     
    262265{
    263266  $num++;
     267  $chk_partner = ( $chk_partner == '' ) ? $row['name'] : $chk_partner;
    264268  $template->assign_block_vars(
    265269    'acc_list.access',
     
    346350  }
    347351}
     352if ( $chk_partner !== '' )
     353{
     354  $request = get_absolute_root_url().'ws.php?method=pwg.getVersion&format=rest&'
     355           . "partner=$chk_partner" ;
     356  $session = curl_init($request);
     357  curl_setopt ($session, CURLOPT_POST, true);
     358  curl_setopt($session, CURLOPT_HEADER, true);
     359  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
     360  $response = curl_exec($session);
     361  curl_close($session);
     362  $status_code = array();
     363  preg_match('/\d\d\d/', $response, $status_code);
     364  switch( $status_code[0] ) {
     365        case 200:
     366      $ws_status = l10n('Web Services under control');
     367                break;
     368        case 503:
     369                $ws_status = 'PhpWebGallery Web Services failed and returned an '
     370                 . 'HTTP status of 503. Service is unavailable. An internal '
     371                 . 'problem prevented us from returning data to you.';
     372                break;
     373        case 403:
     374                $ws_status = 'PhpWebGallery Web Services failed and returned an '
     375                 . 'HTTP status of 403. Access is forbidden. You do not have '
     376                 . 'permission to access this resource, or are over '
     377                 . 'your rate limit.';
     378                break;
     379        case 400:
     380                // You may want to fall through here and read the specific XML error
     381                $ws_status = 'PhpWebGallery Web Services failed and returned an '
     382                 . 'HTTP status of 400. Bad request. The parameters passed '
     383                 . 'to the service did not match as expected. The exact '
     384                 . 'error is returned in the XML response.';
     385                break;
     386        default:
     387                $ws_status = 'PhpWebGallery Web Services returned an unexpected HTTP '
     388                 . 'status of:' . $status_code[0];
     389  }
     390  $template->assign_block_vars(
     391    'acc_list.ws_status',
     392     array(
     393       'VALUE'=> $ws_status,
     394     )
     395  );
     396}
    348397
    349398//----------------------------------------------------------- sending html code
  • trunk/include/config_default.inc.php

    r1848 r1853  
    606606$conf['ws_max_images_per_page'] = 500;
    607607
    608 // On Access control false
     608// On Access control false / Admim Web Service need Php cURL extension
    609609// Controls are done on public basis or
    610610// if connected on member authorization basis
  • trunk/include/ws_functions.inc.php

    r1852 r1853  
    6060  }
    6161  if ( !empty($row['request'])
    62       and strpos($methodName, $row['request'])==false )
    63   {
     62      and strpos($methodName, $row['request'])==false
     63      and strpos($methodName, 'session')==false
     64      and strpos($methodName, 'getVersion')==false )
     65  { // session and getVersion are allowed to diagnose any failure reason
    6466    return new PwgError(403, 'Method not allowed');
    6567  }
     
    115117// Behind / we could found img-ids, cat-ids or tag-ids
    116118  $target = $row['access'];
     119  if ( $target == '')
     120  {
     121    return '1=1'; // No controls are requested
     122  }
    117123  list($type, $str_ids) = explode('/',$target); // Find type list
    118124
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1831 r1853  
    538538$lang['Add this access definition'] = 'Add this access definition';
    539539$lang['Web Services availability duration in days'] = 'Web Services availability duration in days';
     540$lang['Web Services under control'] = 'PhpWebGallery Web Services are fully operationals and all requests are under control.';
    540541$lang['special_admin_menu'] = 'Specials';
    541542$lang['pictures_menu'] = 'Pictures';
  • trunk/language/en_UK.iso-8859-1/help/web_service.html

    r1746 r1853  
    3636  <dd>Images limit count: to return to your partner for each request.</dd>
    3737
    38   <dt>Postponed availability </dt>
    39 
    40   <dd>Can start in few days from now. Remember Web Service would be available and enable.</dd>
    41 
    4238  <dt>Duration </dt>
    4339
    4440  <dd>From now, set availability in days. If you postpone over the duration, the service would never be available.</dd>
    45 
    46   <dt>High / Normal </dt>
    47 
    48   <dd>Result contains description for high resolution picture (pwg_high). Normal size picture as well.
    49   If both are set to No. Only thumbnail information will be sent to your partner.</dd>
    5041
    5142  <dt>Comment </dt>
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1831 r1853  
    537537$lang['Add this access definition']= 'Ajouter cette définition d\'accès';
    538538$lang['Web Services availability duration in days'] = 'Durée d\'ouverture des Services Web en jours';
     539$lang['Web Services under control'] = 'Les Services Web de PhpWebGallery sont totalement operationnels et toutes les requêtes sont contrôlées.';
    539540$lang['special_admin_menu'] = 'Spécials';
    540541$lang['pictures_menu'] = 'Images';
     
    556557$lang['Day'] = 'Jour';
    557558$lang['Pages seen'] = 'Pages vues';
    558 //$lang['only'] = 'uniquement';
     559$lang['only'] = 'uniquement';
    559560$lang['Pictures'] = 'Images';
    560561$lang['High quality'] = 'Haute résolution';
  • trunk/language/fr_FR.iso-8859-1/help/web_service.html

    r1746 r1853  
    3737  <dd>Nombre d'images maximum adressées à votre partenaire à chacune de ses requêtes.</dd>
    3838
    39   <dt>Report de disponibilité </dt>
    40 
    41   <dd>La disponibilité peut être décalée de quelques jours à compter de cet instant. N'oubliez pas que les Services doivent être autorisés et actifs le jour venu.</dd>
    42 
    4339  <dt>Durée </dt>
    4440
    4541  <dd>A partir de maintenant, indiquez la disponibilité en jours. Si vous reportez la disponibilité au delà de sa durée, le service ne devrait jamais être rendu.</dd>
    46 
    47   <dt>High / Normal </dt>
    48 
    49   <dd>Résultat containdra les informations relatives aux images en haute résolution (pwg_high). Les images Normal(es) suivent le même principe.
    50   Si les deux sont à "Non", seulement les informations des miniatures seront adressées à votre partenaire.</dd>
    5142
    5243  <dt>Commentaire </dt>
  • trunk/template/yoga/admin.tpl

    r1814 r1853  
    66      <ul>
    77        <li><a href="{U_RETURN}">{lang:home}</a></li>
     8        <li><a href="{U_FAQ}">{lang:instructions}</a></li>
    89        <li><a href="{U_ADMIN}" title="{L_ADMIN_HINT}">{L_ADMIN}</a></li>
    9       </ul>
    10     </dd>
    11   </dl>
    12   <dl>
    13     <dt>{lang:general}</dt>
    14     <dd>
    15       <ul>
    16         <li><a href="{U_FAQ}">{lang:instructions}</a></li>
    17         <li><a href="{U_SITE_MANAGER}">{lang:Site manager}</a></li>
    18         <li><a href="{U_CAT_UPDATE}">{lang:update}</a></li>
    19         <li>
    20           {lang:history}
    21           <ul>
    22             <li><a href="{U_HISTORY_STAT}">{lang:Statistics}</a></li>
    23             <li><a href="{U_HISTORY_SEARCH}">{lang:Search}</a></li>
    24           </ul>
    25         </li>
    2610      </ul>
    2711    </dd>
     
    3822  </dl>
    3923  <dl>
    40     <dt>{lang:special_admin_menu}</dt>
    41     <dd>
    42       <ul>
    43         <li><a href="{U_MAINTENANCE}">{lang:Maintenance}</a></li>
    44         <li><a href="{U_ADVANCED_FEATURE}">{lang:Advanced_features}</a></li>
    45         <li><a href="{U_NOTIFICATION_BY_MAIL}">{lang:nbm_item_notification}</a></li>
    46         <!-- BEGIN web_services -->
    47         <li><a href="{web_services.U_WS_CHECKER}">{lang:web_services}</a></li>
    48         <!-- END web_services -->
    49       </ul>
    50     </dd>
    51   </dl>
    52   <dl>
    5324    <dt>{lang:Categories}</dt>
    5425    <dd>
    5526      <ul>
     27        <li><a href="{U_SITE_MANAGER}">{lang:Site manager}</a></li>
     28        <li><a href="{U_CAT_UPDATE}">{lang:update}</a><br />&nbsp;</li>
    5629        <li><a href="{U_CATEGORIES}">{lang:manage}</a></li>
    5730        <li><a href="{U_MOVE}">{lang:Move}</a></li>
     
    7447        <li><a href="{U_COMMENTS}">{lang:comments}</a></li>
    7548        <li><a href="{U_RATING}">{lang:Rating}</a></li>
     49        <li><a href="{U_TAGS}">{lang:Tags}</a></li>
    7650        <li><a href="{U_CADDIE}">{lang:Caddie}</a></li>
    77         <li><a href="{U_TAGS}">{lang:Tags}</a></li>
    7851      </ul>
    7952    </dd>
     
    8558        <li><a href="{U_USERS}">{lang:users}</a></li>
    8659        <li><a href="{U_GROUPS}">{lang:groups}</a></li>
     60        <li><a href="{U_NOTIFICATION_BY_MAIL}">{lang:nbm_item_notification}</a></li>
    8761      </ul>
    8862    </dd>
    8963  </dl>
    9064  <dl>
    91     <dt>{lang:Plugins}</dt>
     65    <dt>{lang:special_admin_menu}</dt>
    9266    <dd>
    9367      <ul>
     68        <li>
     69          {lang:history}
     70          <ul>
     71            <li><a href="{U_HISTORY_STAT}">{lang:Statistics}</a></li>
     72            <li><a href="{U_HISTORY_SEARCH}">{lang:Search}</a></li>
     73          </ul>
     74        </li>
     75        <li><a href="{U_MAINTENANCE}">{lang:Maintenance}</a></li>
     76        <li><a href="{U_ADVANCED_FEATURE}">{lang:Advanced_features}</a></li>
     77        <!-- BEGIN web_services -->
     78        <li><a href="{web_services.U_WS_CHECKER}">{lang:web_services}</a></li>
     79        <!-- END web_services -->
     80        <li>
     81          {lang:Plugins}
     82          <ul>
    9483<!-- BEGIN plugin_menu -->
    9584<!-- BEGIN menu_item -->
     
    9786<!-- END menu_item -->
    9887<!-- END plugin_menu -->
     88          </ul>
     89        </li>
    9990      </ul>
    10091    </dd>
  • trunk/template/yoga/admin/ws_checker.tpl

    r1833 r1853  
    224224  </fieldset>
    225225</form>
     226<!-- BEGIN ws_status -->
     227    <h3>{acc_list.ws_status.VALUE}</h3>
     228<!-- END ws_status -->
    226229<!-- END acc_list -->
Note: See TracChangeset for help on using the changeset viewer.