From 2f70d58b2243454085035177e4a6ab777a3bf55c Mon Sep 17 00:00:00 2001 From: rvelices Date: Mon, 29 Jan 2007 20:38:08 +0000 Subject: web services: give vincent the calling partner id git-svn-id: http://piwigo.org/svn/trunk@1768 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_functions.inc.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/ws_functions.inc.php') diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index a202e192e..8cbd74987 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -26,6 +26,30 @@ /**** 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 * returns additionnal controls if requested -- cgit v1.2.3