aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvdigital <vdigital@piwigo.org>2006-12-16 12:14:59 +0000
committervdigital <vdigital@piwigo.org>2006-12-16 12:14:59 +0000
commit43399d359b1ffdebe48cc7948d103167e1be02fc (patch)
tree0ddf0bc332cc21c3c2c4005db357a122ce33215d
parent3d32716fc5d6e7d59b6277af69988ee11db62c30 (diff)
Externalization of common functions of web service.
git-svn-id: http://piwigo.org/svn/trunk@1670 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/ws_checker.php100
-rw-r--r--include/functions.inc.php1
-rw-r--r--web_service.php13
3 files changed, 10 insertions, 104 deletions
diff --git a/admin/ws_checker.php b/admin/ws_checker.php
index 82a188181..3c83d1735 100644
--- a/admin/ws_checker.php
+++ b/admin/ws_checker.php
@@ -25,106 +25,6 @@
// | USA. |
// +-----------------------------------------------------------------------+
-// +-----------------------------------------------------------------------+
-// | functions |
-// +-----------------------------------------------------------------------+
-
-// Function to migrate be useful for ws
-function official_req()
-{
-return array(
- 'random' /* Random order */
- , 'list' /* list on MBt & z0rglub request */
- , 'maxviewed' /* hit > 0 and hit desc order */
- , 'recent' /* recent = Date_available desc order */
- , 'highrated' /* avg_rate > 0 and desc order */
- , 'oldest' /* Date_available asc order */
- , 'lessviewed' /* hit asc order */
- , 'lowrated' /* avg_rate asc order */
- , 'undescribed' /* description missing */
- , 'unnamed' /* new name missing */
- , 'portraits' /* width < height (portrait oriented) */
- , 'landscapes' /* width > height (landscape oriented) */
- , 'squares' /* width ~ height (square form) */
-);
-}
-
-function expand_id_list($ids)
-{
- $tid = array();
- foreach ( $ids as $id )
- {
- if ( is_numeric($id) )
- {
- $tid[] = (int) $id;
- }
- else
- {
- $range = explode( '-', $id );
- if ( is_numeric($range[0]) and is_numeric($range[1]) )
- {
- $from = min($range[0],$range[1]);
- $to = max($range[0],$range[1]);
- for ($i = $from; $i <= $to; $i++)
- {
- $tid[] = (int) $i;
- }
- }
- }
- }
- $result = array_unique ($tid); // remove duplicates...
- sort ($result);
- return $result;
-}
-
-function check_target($list)
-{
- if ( $list !== '' )
- {
- $type = explode('/',$list); // Find type list
- if ( !in_array($type[0],array('list','cat','tag') ) )
- {
- $type[0] = 'list'; // Assume an id list
- }
- $ids = explode( ',',$type[1] );
- $list = $type[0] . '/';
-
- // 1,2,21,3,22,4,5,9-12,6,11,12,13,2,4,6,
-
- $result = expand_id_list( $ids );
-
- // 1,2,3,4,5,6,9,10,11,12,13,21,22,
- // I would like
- // 1-6,9-13,21-22
- $serial[] = $result[0]; // To be shifted
- foreach ($result as $k => $id)
- {
- $next_less_1 = (isset($result[$k + 1]))? $result[$k + 1] - 1:-1;
- if ( $id == $next_less_1 and end($serial)=='-' )
- { // nothing to do
- }
- elseif ( $id == $next_less_1 )
- {
- $serial[]=$id;
- $serial[]='-';
- }
- else
- {
- $serial[]=$id; // end serie or non serie
- }
- }
- $null = array_shift($serial); // remove first value
- $list .= array_shift($serial); // add the real first one
- $separ = ',';
- foreach ($serial as $id)
- {
- $list .= ($id=='-') ? '' : $separ . $id;
- $separ = ($id=='-') ? '-':','; // add comma except if hyphen
- }
- }
- return $list;
-}
-
// Next evolution...
// Out of parameter WS management
// The remainer objective is to check
diff --git a/include/functions.inc.php b/include/functions.inc.php
index e62960ad2..10c5d36cd 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -34,6 +34,7 @@ include_once( PHPWG_ROOT_PATH .'include/functions_html.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_tag.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_url.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_webserv.inc.php' );
//----------------------------------------------------------- generic functions
diff --git a/web_service.php b/web_service.php
index 8146e43b6..5553a376d 100644
--- a/web_service.php
+++ b/web_service.php
@@ -120,11 +120,16 @@ if (isset($_SERVER["HTTP_REFERER"]) and
-// FIXME
-
+// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME
// Check keywords
-//
+// Key and pos are correct
+// &acc=cat/23,25-32&req=landscape&lim=5&tpl=myxml
+
+
+
+
+
// Check requested XML template
//
@@ -140,7 +145,7 @@ if (isset($_SERVER["HTTP_REFERER"]) and
-
+// Old code below
//------------ Main security strategy ---------------------
$partner_id = 'default';