From f800d4fb40468fbf255ac78ccd2da82544f8d557 Mon Sep 17 00:00:00 2001 From: vdigital Date: Fri, 23 Feb 2007 23:25:34 +0000 Subject: 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 --- admin/ws_checker.php | 61 ++++++++++++++++++++++--- include/config_default.inc.php | 2 +- include/ws_functions.inc.php | 10 +++- language/en_UK.iso-8859-1/admin.lang.php | 1 + language/en_UK.iso-8859-1/help/web_service.html | 9 ---- language/fr_FR.iso-8859-1/admin.lang.php | 3 +- language/fr_FR.iso-8859-1/help/web_service.html | 9 ---- template/yoga/admin.tpl | 55 ++++++++++------------ 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 @@
Images limit count: to return to your partner for each request.
-
Postponed availability
- -
Can start in few days from now. Remember Web Service would be available and enable.
-
Duration
From now, set availability in days. If you postpone over the duration, the service would never be available.
-
High / Normal
- -
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.
-
Comment
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 $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 @@
Nombre d'images maximum adressées à votre partenaire à chacune de ses requêtes.
-
Report de disponibilité
- -
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.
-
Durée
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.
-
High / Normal
- -
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.
-
Commentaire
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 @@
-
- -
-
{lang:general}
-
-
@@ -36,23 +20,12 @@ -
-
{lang:special_admin_menu}
-
- -
-
{lang:Categories}
@@ -84,18 +57,36 @@
-
{lang:Plugins}
+
{lang:special_admin_menu}
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 @@ + +

{acc_list.ws_status.VALUE}

+ -- cgit v1.2.3