mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-08 17:25:53 +03:00
web services: give vincent the calling partner id
git-svn-id: http://piwigo.org/svn/trunk@1768 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
3b11eb39cf
commit
2f70d58b22
4 changed files with 47 additions and 9 deletions
|
@ -563,8 +563,11 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder."
|
||||||
{
|
{
|
||||||
return new PwgError(WS_ERR_MISSING_PARAM, 'Missing parameters: '.implode(',',$missing_params));
|
return new PwgError(WS_ERR_MISSING_PARAM, 'Missing parameters: '.implode(',',$missing_params));
|
||||||
}
|
}
|
||||||
|
$result = trigger_event('ws_invoke_allowed', true, $methodName, $params);
|
||||||
$result = call_user_func_array($callback, array($params, &$this) );
|
if ( strtolower( get_class($result) )!='pwgerror')
|
||||||
|
{
|
||||||
|
$result = call_user_func_array($callback, array($params, &$this) );
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,30 @@
|
||||||
|
|
||||||
/**** IMPLEMENTATION OF WEB SERVICE METHODS ***********************************/
|
/**** IMPLEMENTATION OF WEB SERVICE METHODS ***********************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event handler for method invocation security check. Should return a PwgError
|
||||||
|
* if the preconditions are not satifsied for method invocation.
|
||||||
|
*/
|
||||||
|
function ws_isInvokeAllowed($res, $methodName, $params)
|
||||||
|
{
|
||||||
|
global $conf, $calling_partner_id;
|
||||||
|
if ( !$conf['ws_access_control'])
|
||||||
|
{
|
||||||
|
return $res; // No controls are requested
|
||||||
|
}
|
||||||
|
$query = '
|
||||||
|
SELECT * FROM '.WEB_SERVICES_ACCESS_TABLE."
|
||||||
|
WHERE `name` = '$calling_partner_id'
|
||||||
|
AND NOW() <= end; ";
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$row = mysql_fetch_assoc($result);
|
||||||
|
if ( empty($row) )
|
||||||
|
{
|
||||||
|
return new PwgError(403, 'Partner id does not exist');
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ws_add_controls
|
* ws_add_controls
|
||||||
* returns additionnal controls if requested
|
* returns additionnal controls if requested
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | branch : BSF (Best So Far)
|
||||||
// | file : $URL: svn+ssh://rvelices@svn.gna.org/svn/phpwebgallery/trunk/action.php $
|
// | file : $Id$
|
||||||
// | last update : $Date: 2006-12-21 18:49:12 -0500 (Thu, 21 Dec 2006) $
|
// | last update : $Date$
|
||||||
// | last modifier : $Author: rvelices $
|
// | last modifier : $Author$
|
||||||
// | revision : $Rev: 1678 $
|
// | revision : $Rev$
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | This program is free software; you can redistribute it and/or modify |
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
// | it under the terms of the GNU General Public License as published by |
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
@ -33,8 +33,8 @@ class PwgRestRequestHandler
|
||||||
$param_array = $service->isPost() ? $_POST : $_GET;
|
$param_array = $service->isPost() ? $_POST : $_GET;
|
||||||
foreach ($param_array as $name => $value)
|
foreach ($param_array as $name => $value)
|
||||||
{
|
{
|
||||||
if ($name=='format')
|
if ($name=='format' or $name=='partner')
|
||||||
continue;
|
continue; // ignore - special keys
|
||||||
if ($name=='method')
|
if ($name=='method')
|
||||||
{
|
{
|
||||||
$method = $value;
|
$method = $value;
|
||||||
|
|
13
ws.php
13
ws.php
|
@ -29,6 +29,9 @@ define ('PHPWG_ROOT_PATH', './');
|
||||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||||
include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* event handler that registers standard methods with the web service
|
||||||
|
*/
|
||||||
function ws_addDefaultMethods( $arr )
|
function ws_addDefaultMethods( $arr )
|
||||||
{
|
{
|
||||||
include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php');
|
||||||
|
@ -106,11 +109,19 @@ function ws_addDefaultMethods( $arr )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_event_handler('ws_add_methods', 'ws_addDefaultMethods' );
|
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
|
||||||
|
|
||||||
|
|
||||||
|
add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
|
||||||
|
|
||||||
|
$calling_partner_id = '';
|
||||||
$requestFormat = null;
|
$requestFormat = null;
|
||||||
$responseFormat = null;
|
$responseFormat = null;
|
||||||
|
|
||||||
|
if ( isset($_GET['partner']) )
|
||||||
|
{
|
||||||
|
$calling_partner_id = $_GET['partner'];
|
||||||
|
}
|
||||||
if ( isset($_GET['format']) )
|
if ( isset($_GET['format']) )
|
||||||
{
|
{
|
||||||
$responseFormat = $_GET['format'];
|
$responseFormat = $_GET['format'];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue