mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
fixes #1356 pwg.images.uploadAsync, move auth code to inc/user.inc.php
In order to avoid loading user context as "guest" and then wait to be in ws_images_uploadAsync function to authenticate and load a new user context. This way we deal with "automatic" authentication in the same place (as apache auth or url auth) and we use the more common user context loading mecanism. Making Community compatible is now much easier. To avoid duplicating too many lines of ws.php into inc/user.inc.php, I have moved the init of ws.php into inc/ws_init.inc.php
This commit is contained in:
@@ -17,65 +17,8 @@ if ( !$conf['allow_web_services'] )
|
||||
page_forbidden('Web services are disabled');
|
||||
}
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_init.inc.php');
|
||||
|
||||
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
|
||||
add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
|
||||
|
||||
$requestFormat = 'rest';
|
||||
$responseFormat = null;
|
||||
|
||||
if ( isset($_GET['format']) )
|
||||
{
|
||||
$responseFormat = $_GET['format'];
|
||||
}
|
||||
|
||||
if ( !isset($responseFormat) and isset($requestFormat) )
|
||||
{
|
||||
$responseFormat = $requestFormat;
|
||||
}
|
||||
|
||||
$service = new PwgServer();
|
||||
|
||||
if (!is_null($requestFormat))
|
||||
{
|
||||
$handler = null;
|
||||
switch ($requestFormat)
|
||||
{
|
||||
case 'rest':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php');
|
||||
$handler = new PwgRestRequestHandler();
|
||||
break;
|
||||
}
|
||||
$service->setHandler($requestFormat, $handler);
|
||||
}
|
||||
|
||||
if (!is_null($responseFormat))
|
||||
{
|
||||
$encoder = null;
|
||||
switch ($responseFormat)
|
||||
{
|
||||
case 'rest':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php');
|
||||
$encoder = new PwgRestEncoder();
|
||||
break;
|
||||
case 'php':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php');
|
||||
$encoder = new PwgSerialPhpEncoder();
|
||||
break;
|
||||
case 'json':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php');
|
||||
$encoder = new PwgJsonEncoder();
|
||||
break;
|
||||
case 'xmlrpc':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php');
|
||||
$encoder = new PwgXmlRpcEncoder();
|
||||
break;
|
||||
}
|
||||
$service->setEncoder($responseFormat, $encoder);
|
||||
}
|
||||
|
||||
set_make_full_url();
|
||||
$service->run();
|
||||
|
||||
|
||||
@@ -540,7 +483,7 @@ function ws_addDefaultMethods( $arr )
|
||||
<br>You can update an existing photo if you define an existing image_id.
|
||||
<br>Requires <b>admin</b> credentials.',
|
||||
$ws_functions_root . 'pwg.images.php',
|
||||
array('post_only'=>true)
|
||||
array('admin_only'=>true, 'post_only'=>true)
|
||||
);
|
||||
|
||||
$service->addMethod(
|
||||
|
||||
Reference in New Issue
Block a user