diff options
author | vdigital <vdigital@piwigo.org> | 2007-02-23 23:25:34 +0000 |
---|---|---|
committer | vdigital <vdigital@piwigo.org> | 2007-02-23 23:25:34 +0000 |
commit | f800d4fb40468fbf255ac78ccd2da82544f8d557 (patch) | |
tree | 1498f742bf9667bf3e8e76e875f2a5b1028eee84 | |
parent | cb2408a82c9bc93bef177dc33a8981bc36800839 (diff) |
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.
git-svn-id: http://piwigo.org/svn/trunk@1853 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | admin/ws_checker.php | 61 | ||||
-rw-r--r-- | include/config_default.inc.php | 2 | ||||
-rw-r--r-- | include/ws_functions.inc.php | 10 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/admin.lang.php | 1 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/help/web_service.html | 9 | ||||
-rw-r--r-- | language/fr_FR.iso-8859-1/admin.lang.php | 3 | ||||
-rw-r--r-- | language/fr_FR.iso-8859-1/help/web_service.html | 9 | ||||
-rw-r--r-- | template/yoga/admin.tpl | 55 | ||||
-rw-r--r-- | template/yoga/admin/ws_checker.tpl | 3 |
9 files changed, 93 insertions, 60 deletions
diff --git a/admin/ws_checker.php b/admin/ws_checker.php index 411b3cad9..cec12d4e9 100644 --- a/admin/ws_checker.php +++ b/admin/ws_checker.php @@ -49,13 +49,15 @@ function official_req() { $official = array( /* Requests are limited to */ 'categories.' /* all categories. methods */ - , 'categories.getImages' /* <= see */ - , 'categories.getList' /* <= see */ + , 'categories.getImages' + , 'categories.getList' , 'images.' /* all images. methods */ - , 'images.getInfo' /* <= see */ + , 'images.getInfo' + , 'images.addComment' + , 'images.search' , 'tags.' /* all tags. methods */ - , 'tags.getImages' /* <= see */ - , 'tags.getList' /* <= see */ + , 'tags.getImages' + , 'tags.getList' ); if (function_exists('local_req')) { $local = local_req(); @@ -125,7 +127,7 @@ check_status(ACCESS_ADMINISTRATOR); $req_type_list = official_req(); //--------------------------------------------------------- update informations - +$chk_partner = ''; // Is a new access required? if (isset($_POST['wsa_submit'])) @@ -150,6 +152,7 @@ VALUES (' . " '$add_request', '$add_limit', '$add_comment' );"; pwg_query($query); + $chk_partner = $add_partner; $template->assign_block_vars( 'update_result', @@ -261,6 +264,7 @@ if ( $acc_list > 0 ) while ($row = mysql_fetch_array($result)) { $num++; + $chk_partner = ( $chk_partner == '' ) ? $row['name'] : $chk_partner; $template->assign_block_vars( 'acc_list.access', array( @@ -345,6 +349,51 @@ foreach ($conf['ws_durations'] as $value) { ); } } +if ( $chk_partner !== '' ) +{ + $request = get_absolute_root_url().'ws.php?method=pwg.getVersion&format=rest&' + . "partner=$chk_partner" ; + $session = curl_init($request); + curl_setopt ($session, CURLOPT_POST, true); + curl_setopt($session, CURLOPT_HEADER, true); + curl_setopt($session, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($session); + curl_close($session); + $status_code = array(); + preg_match('/\d\d\d/', $response, $status_code); + switch( $status_code[0] ) { + case 200: + $ws_status = l10n('Web Services under control'); + break; + case 503: + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 503. Service is unavailable. An internal ' + . 'problem prevented us from returning data to you.'; + break; + case 403: + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 403. Access is forbidden. You do not have ' + . 'permission to access this resource, or are over ' + . 'your rate limit.'; + break; + case 400: + // You may want to fall through here and read the specific XML error + $ws_status = 'PhpWebGallery Web Services failed and returned an ' + . 'HTTP status of 400. Bad request. The parameters passed ' + . 'to the service did not match as expected. The exact ' + . 'error is returned in the XML response.'; + break; + default: + $ws_status = 'PhpWebGallery Web Services returned an unexpected HTTP ' + . 'status of:' . $status_code[0]; + } + $template->assign_block_vars( + 'acc_list.ws_status', + array( + 'VALUE'=> $ws_status, + ) + ); +} //----------------------------------------------------------- sending html code diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 6fd1b0b26..3c3d0e7e0 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -605,7 +605,7 @@ $conf['allow_web_services'] = true; // Maximum number of images to be returned foreach call to the web service $conf['ws_max_images_per_page'] = 500; -// On Access control false +// On Access control false / Admim Web Service need Php cURL extension // Controls are done on public basis or // if connected on member authorization basis $conf['ws_access_control'] = false; diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index c68d5d195..e19966673 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -59,8 +59,10 @@ SELECT * FROM '.WEB_SERVICES_ACCESS_TABLE." return new PwgError(403, 'Partner id does not exist or is expired'); } if ( !empty($row['request']) - and strpos($methodName, $row['request'])==false ) - { + and strpos($methodName, $row['request'])==false + and strpos($methodName, 'session')==false + and strpos($methodName, 'getVersion')==false ) + { // session and getVersion are allowed to diagnose any failure reason return new PwgError(403, 'Method not allowed'); } @@ -114,6 +116,10 @@ $result = pwg_query($query); // 3 cases: list, cat or tag // Behind / we could found img-ids, cat-ids or tag-ids $target = $row['access']; + if ( $target == '') + { + return '1=1'; // No controls are requested + } list($type, $str_ids) = explode('/',$target); // Find type list // (array) 1,2,21,3,22,4,5,9-12,6,11,12,13,2,4,6, diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php index 2d95aaf0c..859ab6719 100644 --- a/language/en_UK.iso-8859-1/admin.lang.php +++ b/language/en_UK.iso-8859-1/admin.lang.php @@ -537,6 +537,7 @@ $lang['Returned images limit'] = 'Returned images limit'; $lang['Comment to identify your partner clearly'] = 'Comment to identify your partner clearly'; $lang['Add this access definition'] = 'Add this access definition'; $lang['Web Services availability duration in days'] = 'Web Services availability duration in days'; +$lang['Web Services under control'] = 'PhpWebGallery Web Services are fully operationals and all requests are under control.'; $lang['special_admin_menu'] = 'Specials'; $lang['pictures_menu'] = 'Pictures'; $lang['note_check_exif'] = '%s must be to set to false in your config_local.inc.php file because exif are not supported.'; diff --git a/language/en_UK.iso-8859-1/help/web_service.html b/language/en_UK.iso-8859-1/help/web_service.html index ca86df8e2..4e71c13bf 100644 --- a/language/en_UK.iso-8859-1/help/web_service.html +++ b/language/en_UK.iso-8859-1/help/web_service.html @@ -35,19 +35,10 @@ <dd>Images limit count: to return to your partner for each request.</dd>
- <dt>Postponed availability </dt>
-
- <dd>Can start in few days from now. Remember Web Service would be available and enable.</dd>
-
<dt>Duration </dt>
<dd>From now, set availability in days. If you postpone over the duration, the service would never be available.</dd>
- <dt>High / Normal </dt>
-
- <dd>Result contains description for high resolution picture (pwg_high). Normal size picture as well.
- If both are set to No. Only thumbnail information will be sent to your partner.</dd>
-
<dt>Comment </dt>
<dd>Let you describe who's behind this Web Service, be clear enough.
diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php index 08b1c1e92..ee335985e 100644 --- a/language/fr_FR.iso-8859-1/admin.lang.php +++ b/language/fr_FR.iso-8859-1/admin.lang.php @@ -536,6 +536,7 @@ $lang['Returned images limit'] = 'Limite de transmision'; $lang['Comment to identify your partner clearly'] = 'Commentaire vous permettant d\'identifier votre partenaire facilement'; $lang['Add this access definition']= 'Ajouter cette définition d\'accès'; $lang['Web Services availability duration in days'] = 'Durée d\'ouverture des Services Web en jours'; +$lang['Web Services under control'] = 'Les Services Web de PhpWebGallery sont totalement operationnels et toutes les requêtes sont contrôlées.'; $lang['special_admin_menu'] = 'Spécials'; $lang['pictures_menu'] = 'Images'; $lang['note_check_exif'] = '%s doit être mis à "false" dans votre fichier config_local.inc.php parce que l\'exif n\'est pas supporté.'; @@ -555,7 +556,7 @@ $lang['Year'] = 'Année'; $lang['Month'] = 'Mois'; $lang['Day'] = 'Jour'; $lang['Pages seen'] = 'Pages vues'; -//$lang['only'] = 'uniquement'; +$lang['only'] = 'uniquement'; $lang['Pictures'] = 'Images'; $lang['High quality'] = 'Haute résolution'; $lang['time'] = 'heure'; diff --git a/language/fr_FR.iso-8859-1/help/web_service.html b/language/fr_FR.iso-8859-1/help/web_service.html index 2e6f8199c..944ff4b34 100644 --- a/language/fr_FR.iso-8859-1/help/web_service.html +++ b/language/fr_FR.iso-8859-1/help/web_service.html @@ -36,19 +36,10 @@ <dd>Nombre d'images maximum adressées à votre partenaire à chacune de ses requêtes.</dd>
- <dt>Report de disponibilité </dt>
-
- <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>
-
<dt>Durée </dt>
<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>
- <dt>High / Normal </dt>
-
- <dd>Résultat containdra les informations relatives aux images en haute résolution (pwg_high). Les images Normal(es) suivent le même principe.
- Si les deux sont à "Non", seulement les informations des miniatures seront adressées à votre partenaire.</dd>
-
<dt>Commentaire </dt>
<dd>Vous permet de décrire qui se trouve derrière ce Service Web, de façon plus claire pour vous.
diff --git a/template/yoga/admin.tpl b/template/yoga/admin.tpl index 3dca4cbf6..9fc63321b 100644 --- a/template/yoga/admin.tpl +++ b/template/yoga/admin.tpl @@ -5,24 +5,8 @@ <dd> <ul> <li><a href="{U_RETURN}">{lang:home}</a></li> - <li><a href="{U_ADMIN}" title="{L_ADMIN_HINT}">{L_ADMIN}</a></li> - </ul> - </dd> - </dl> - <dl> - <dt>{lang:general}</dt> - <dd> - <ul> <li><a href="{U_FAQ}">{lang:instructions}</a></li> - <li><a href="{U_SITE_MANAGER}">{lang:Site manager}</a></li> - <li><a href="{U_CAT_UPDATE}">{lang:update}</a></li> - <li> - {lang:history} - <ul> - <li><a href="{U_HISTORY_STAT}">{lang:Statistics}</a></li> - <li><a href="{U_HISTORY_SEARCH}">{lang:Search}</a></li> - </ul> - </li> + <li><a href="{U_ADMIN}" title="{L_ADMIN_HINT}">{L_ADMIN}</a></li> </ul> </dd> </dl> @@ -37,22 +21,11 @@ </dd> </dl> <dl> - <dt>{lang:special_admin_menu}</dt> - <dd> - <ul> - <li><a href="{U_MAINTENANCE}">{lang:Maintenance}</a></li> - <li><a href="{U_ADVANCED_FEATURE}">{lang:Advanced_features}</a></li> - <li><a href="{U_NOTIFICATION_BY_MAIL}">{lang:nbm_item_notification}</a></li> - <!-- BEGIN web_services --> - <li><a href="{web_services.U_WS_CHECKER}">{lang:web_services}</a></li> - <!-- END web_services --> - </ul> - </dd> - </dl> - <dl> <dt>{lang:Categories}</dt> <dd> <ul> + <li><a href="{U_SITE_MANAGER}">{lang:Site manager}</a></li> + <li><a href="{U_CAT_UPDATE}">{lang:update}</a><br /> </li> <li><a href="{U_CATEGORIES}">{lang:manage}</a></li> <li><a href="{U_MOVE}">{lang:Move}</a></li> <li><a href="{U_CAT_UPLOAD}">{lang:upload}</a></li> @@ -73,8 +46,8 @@ <li><a href="{U_THUMBNAILS}">{lang:thumbnails}</a></li> <li><a href="{U_COMMENTS}">{lang:comments}</a></li> <li><a href="{U_RATING}">{lang:Rating}</a></li> - <li><a href="{U_CADDIE}">{lang:Caddie}</a></li> <li><a href="{U_TAGS}">{lang:Tags}</a></li> + <li><a href="{U_CADDIE}">{lang:Caddie}</a></li> </ul> </dd> </dl> @@ -84,18 +57,36 @@ <ul> <li><a href="{U_USERS}">{lang:users}</a></li> <li><a href="{U_GROUPS}">{lang:groups}</a></li> + <li><a href="{U_NOTIFICATION_BY_MAIL}">{lang:nbm_item_notification}</a></li> </ul> </dd> </dl> <dl> - <dt>{lang:Plugins}</dt> + <dt>{lang:special_admin_menu}</dt> <dd> <ul> + <li> + {lang:history} + <ul> + <li><a href="{U_HISTORY_STAT}">{lang:Statistics}</a></li> + <li><a href="{U_HISTORY_SEARCH}">{lang:Search}</a></li> + </ul> + </li> + <li><a href="{U_MAINTENANCE}">{lang:Maintenance}</a></li> + <li><a href="{U_ADVANCED_FEATURE}">{lang:Advanced_features}</a></li> + <!-- BEGIN web_services --> + <li><a href="{web_services.U_WS_CHECKER}">{lang:web_services}</a></li> + <!-- END web_services --> + <li> + {lang:Plugins} + <ul> <!-- BEGIN plugin_menu --> <!-- BEGIN menu_item --> <li><a href="{plugin_menu.menu_item.URL}">{plugin_menu.menu_item.NAME}</a></li> <!-- END menu_item --> <!-- END plugin_menu --> + </ul> + </li> </ul> </dd> </dl> diff --git a/template/yoga/admin/ws_checker.tpl b/template/yoga/admin/ws_checker.tpl index d4365155f..db11059b1 100644 --- a/template/yoga/admin/ws_checker.tpl +++ b/template/yoga/admin/ws_checker.tpl @@ -223,4 +223,7 @@ </fieldset>
</form>
+<!-- BEGIN ws_status -->
+ <h3>{acc_list.ws_status.VALUE}</h3>
+<!-- END ws_status -->
<!-- END acc_list -->
|