Skip to content
Snippets Groups Projects
Commit 75c06fc2 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3299, fixes #3300, fixes #3301, fixes #3302, fixes #3303

Closes #3299, #3300, #3301, #3302, and #3303

Merge request studip/studip!2267
parent 27359406
Branches
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "22c8ced6418b6f7255376553aa8bac48", "content-hash": "b39a0d6902b667c47851b3899c5884fc",
"packages": [ "packages": [
{ {
"name": "algo26-matthias/idna-convert", "name": "algo26-matthias/idna-convert",
...@@ -2183,42 +2183,44 @@ ...@@ -2183,42 +2183,44 @@
}, },
{ {
"name": "phpxmlrpc/extras", "name": "phpxmlrpc/extras",
"version": "0.6.3", "version": "1.0.0-beta2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/gggeek/phpxmlrpc-extras.git", "url": "https://github.com/gggeek/phpxmlrpc-extras.git",
"reference": "63b53c9bece968f87ddfc058d4bf9e3cd5ae9930" "reference": "4bf48852955f7b4698b37ae91cce83c49f658b4c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/gggeek/phpxmlrpc-extras/zipball/63b53c9bece968f87ddfc058d4bf9e3cd5ae9930", "url": "https://api.github.com/repos/gggeek/phpxmlrpc-extras/zipball/4bf48852955f7b4698b37ae91cce83c49f658b4c",
"reference": "63b53c9bece968f87ddfc058d4bf9e3cd5ae9930", "reference": "4bf48852955f7b4698b37ae91cce83c49f658b4c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"phpxmlrpc/phpxmlrpc": ">=2.1.0" "php": "^5.3.0 || ^7.0 || ^8.0",
"phpxmlrpc/phpxmlrpc": "^4.6.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": ">=4.0.0" "ext-curl": "*",
"phpunit/phpunit": "^4.8 || ^5.0 || ^8.5.12",
"phpunit/phpunit-selenium": "*",
"phpxmlrpc/jsonrpc": "^1.0.0-beta1",
"yoast/phpunit-polyfills": "*"
},
"suggest": {
"phpxmlrpc/jsonrpc": "Needed for the SonOfAjax demo",
"phpxmlrpc/jsxmlrpc": "Used the Ajax Server component. NB: better installed via NPM or used directly from CDN!"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"classmap": [ "psr-4": {
"adodb/drivers/", "PhpXmlRpc\\Extras\\": "src/"
"adodb/lib/", }
"ajax/ajaxmlrpc.inc",
"jsonrpc/jsonrpc.inc",
"jsonrpc/jsonrpcs.inc",
"proxy/proxyxmlrpcs.inc",
"xmlrpc_extension_api/xmlrpc_extension_api.inc",
"docxmlrpcserver/docxmlrpcs.inc"
]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
], ],
"description": "A collection of extensions, addons and other stuff that might be of use for development of xml-rpc (and jsonrpc, soap) based applications", "description": "A collection of server-side addons that might be of use for development of xml-rpc (and json-rpc) based applications",
"homepage": "https://github.com/gggeek/phpxmlrpc-extras", "homepage": "https://github.com/gggeek/phpxmlrpc-extras",
"keywords": [ "keywords": [
"jsonrpc", "jsonrpc",
...@@ -2227,44 +2229,45 @@ ...@@ -2227,44 +2229,45 @@
], ],
"support": { "support": {
"issues": "https://github.com/gggeek/phpxmlrpc-extras/issues", "issues": "https://github.com/gggeek/phpxmlrpc-extras/issues",
"source": "https://github.com/gggeek/phpxmlrpc-extras/tree/0.6.3" "source": "https://github.com/gggeek/phpxmlrpc-extras/tree/1.0.0-beta2"
}, },
"time": "2020-12-23T16:41:17+00:00" "time": "2023-01-19T14:20:38+00:00"
}, },
{ {
"name": "phpxmlrpc/phpxmlrpc", "name": "phpxmlrpc/phpxmlrpc",
"version": "4.4.3", "version": "4.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/gggeek/phpxmlrpc.git", "url": "https://github.com/gggeek/phpxmlrpc.git",
"reference": "eea038c58b32b35df93cbf5e96cf186321dd09d7" "reference": "7103864975ca0b930574cabc8b4593093ee4432e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/gggeek/phpxmlrpc/zipball/eea038c58b32b35df93cbf5e96cf186321dd09d7", "url": "https://api.github.com/repos/gggeek/phpxmlrpc/zipball/7103864975ca0b930574cabc8b4593093ee4432e",
"reference": "eea038c58b32b35df93cbf5e96cf186321dd09d7", "reference": "7103864975ca0b930574cabc8b4593093ee4432e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-xml": "*", "ext-xml": "*",
"php": ">=5.3.0" "php": "^5.4.0 || ^7.0 || ^8.0"
},
"conflict": {
"phpxmlrpc/extras": "<= 0.6.3"
}, },
"require-dev": { "require-dev": {
"docbook/docbook-xsl": "^1.79",
"ext-curl": "*", "ext-curl": "*",
"ext-dom": "*", "ext-dom": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-xsl": "*", "phpunit/phpunit": "^4.8 || ^5.0 || ^8.5.14",
"indeyets/pake": "^1.99",
"phpunit/phpunit": "^5.0 || ^8.5.12",
"phpunit/phpunit-selenium": "*", "phpunit/phpunit-selenium": "*",
"yoast/phpunit-polyfills": "*" "yoast/phpunit-polyfills": "*"
}, },
"suggest": { "suggest": {
"ext-curl": "Needed for HTTPS and HTTP 1.1 support, NTLM Auth etc...", "ext-curl": "Needed for HTTPS, HTTP2 and HTTP 1.1 support, NTLM Auth etc...",
"ext-mbstring": "Needed to allow reception of requests/responses in character sets other than ASCII,LATIN-1,UTF-8", "ext-mbstring": "Needed to allow reception of requests/responses in character sets other than ASCII,LATIN-1,UTF-8",
"ext-zlib": "Needed for sending compressed requests and receiving compressed responses, if cURL is not available", "ext-zlib": "Needed for sending compressed requests and receiving compressed responses, if cURL is not available",
"sami/sami": "Required for doc generation using pake. Version constraints: ^3.3 || ^4.1" "phpxmlrpc/extras": "Adds more featured Server classes, including self-documenting and ajax-enabled servers",
"phpxmlrpc/jsonrpc": "Adds support for the JSON-RPC protocol"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
...@@ -2280,13 +2283,14 @@ ...@@ -2280,13 +2283,14 @@
"homepage": "https://gggeek.github.io/phpxmlrpc/", "homepage": "https://gggeek.github.io/phpxmlrpc/",
"keywords": [ "keywords": [
"webservices", "webservices",
"xml-rpc",
"xmlrpc" "xmlrpc"
], ],
"support": { "support": {
"issues": "https://github.com/gggeek/phpxmlrpc/issues", "issues": "https://github.com/gggeek/phpxmlrpc/issues",
"source": "https://github.com/gggeek/phpxmlrpc/tree/4.4.3" "source": "https://github.com/gggeek/phpxmlrpc/tree/4.10.0"
}, },
"time": "2020-12-16T23:25:16+00:00" "time": "2023-02-11T17:10:30+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",
...@@ -7343,7 +7347,9 @@ ...@@ -7343,7 +7347,9 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"phpxmlrpc/extras": 10
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
......
...@@ -23,10 +23,6 @@ require_once 'vendor/studip_ws/soap_dispatcher.php'; ...@@ -23,10 +23,6 @@ require_once 'vendor/studip_ws/soap_dispatcher.php';
require_once 'vendor/studip_ws/studip_ws.php'; require_once 'vendor/studip_ws/studip_ws.php';
require_once 'vendor/studip_ws/xmlrpc_dispatcher.php'; require_once 'vendor/studip_ws/xmlrpc_dispatcher.php';
# requiring jsonrpc_dispatcher
require_once 'vendor/studip_ws/studip_ws.php';
require_once 'vendor/studip_ws/jsonrpc_dispatcher.php';
# requiring all the webservices # requiring all the webservices
require_once 'lib/webservices/services/access_controlled_webservice.php'; require_once 'lib/webservices/services/access_controlled_webservice.php';
require_once 'lib/webservices/services/user_webservice.php'; require_once 'lib/webservices/services/user_webservice.php';
......
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/*
* jsonrpc.php - JSON-RPC Backend for Stud.IP web services
*
* Copyright (C) 2006 - Marcus Lunzenauer <mlunzena@uos.de>
*
* 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 the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
require '../lib/bootstrap.php';
require '../lib/webservices/webservices_bootstrap.php';
# create server
$dispatcher = new Studip_Ws_JsonrpcDispatcher($AVAILABLE_SERVICES);
$server = new jsonrpc_server($dispatcher->get_dispatch_map(), 0);
# $server->setDebug(3);
# $server->compress_response = FALSE;
# start server
$server->service();
...@@ -15,11 +15,14 @@ ...@@ -15,11 +15,14 @@
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
*/ */
use PhpXmlRpc\Extras\XmlrpcSmartyTemplate;
use PhpXmlRpc\PhpXmlRpc;
require '../lib/bootstrap.php'; require '../lib/bootstrap.php';
require '../lib/webservices/webservices_bootstrap.php'; require '../lib/webservices/webservices_bootstrap.php';
// Bootstrap documenting server // Bootstrap documenting server
class StudipDocumentingXmlRpcServer extends documenting_xmlrpc_server class StudipDocumentingXmlRpcServer extends \PhpXmlRpc\Extras\SelfDocumentingServer
{ {
public function checkAuth() public function checkAuth()
{ {
...@@ -45,27 +48,35 @@ class StudipDocumentingXmlRpcServer extends documenting_xmlrpc_server ...@@ -45,27 +48,35 @@ class StudipDocumentingXmlRpcServer extends documenting_xmlrpc_server
return parent::service($data, $return_payload, $doctype); return parent::service($data, $return_payload, $doctype);
} }
public function generateDocs($server, $doctype='html', $lang='en', $editorpath='') public function generateDocs($doctype='html', $lang='en', $editorpath='')
{ {
if ($doctype === 'html' && isset($_GET['methodName'])) { if ($doctype === 'html' && isset($_GET['methodName'])) {
$_GET['methodName'] = preg_replace('/[^a-zA-Z0-9_.:\/]/', '', $_GET['methodName']); $_GET['methodName'] = preg_replace('/[^a-zA-Z0-9_.:\/]/', '', $_GET['methodName']);
} }
parent::generateDocs($server, $doctype, $lang, $editorpath); $documentationGenerator = new StudipServerDocumentor(new XmlrpcSmartyTemplate(null));
return $documentationGenerator->generateDocs($this, $doctype, $lang, $editorpath);
} }
}
public function __get($key) class StudipServerDocumentor extends \PhpXmlRpc\Extras\ServerDocumentor
{
public static function templates()
{ {
if ($key === 'dmap') { return array_merge(parent::templates(), [
return $this->allow_system_funcs 'docheader' => '<!DOCTYPE html>
? array_merge($this->dmap, $this->getSystemDispatchMap()) <html lang="{$lang}">
: $this->dmap; <head>
} <meta name="generator" content="' . PhpXmlRpc::$xmlrpcName . '" />
<link href="assets/stylesheets/webservices.css" type="text/css" rel="stylesheet" />
{$extras}
<title>{$title}</title>
</head>
<body>',
]);
} }
} }
$GLOBALS['_xmlrpcs_dmap'] = [];
$GLOBALS['xmlrpcdocparts']['html']['docheader'] .= '<link href="assets/stylesheets/webservices.css" type="text/css" rel="stylesheet">';
# create server # create server
$dispatcher = new Studip_Ws_XmlrpcDispatcher($AVAILABLE_SERVICES); $dispatcher = new Studip_Ws_XmlrpcDispatcher($AVAILABLE_SERVICES);
......
<?php
/*
* jsonrpc_dispatcher.php - <short-description>
*
* Copyright (C) 2006 - Marcus Lunzenauer <mlunzena@uos.de>
*
* 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 the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
/**
* <ClassDescription>
*
* @package studip
* @subpackage ws
*
* @author mlunzena
* @copyright (c) Authors
* @version $Id: jsonrpc_dispatcher.php 3888 2006-09-06 13:27:19Z mlunzena $
*/
class Studip_Ws_JsonrpcDispatcher extends Studip_Ws_Dispatcher {
/**
* <MethodDescription>
*
* @param type <description>
*
* @return type <description>
*/
function dispatch($msg = NULL) {
# ensure correct invocation
if (is_null($msg) || !is_a($msg, 'jsonrpcmsg'))
return $this->throw_exception('functions_parameters_type must not be '.
'phpvals.');
# get decoded parameters
$len = $msg->getNumParams();
$argument_array = array();
for ($i = 0; $i < $len; ++$i)
$argument_array[] = php_jsonrpc_decode($msg->getParam($i));
# return result
return new jsonrpcresp(
php_jsonrpc_encode($this->invoke($msg->method(), $argument_array)));
}
/**
* <MethodDescription>
*
* @param type <description>
*
* @return type <description>
*/
function throw_exception($message/*, ...*/) {
$args = func_get_args();
return new jsonrpcresp(0, $GLOBALS['xmlrpcerruser'] + 1,
vsprintf(array_shift($args), $args));
}
/**
* Class method that composes the dispatch map from the available methods.
*
* @return array This service's dispatch map.
*
*/
function get_dispatch_map() {
$dispatch_map = array();
foreach ($this->api_methods as $method_name => $method)
$dispatch_map[$method_name] = $this->map_method($method);
return $dispatch_map;
}
/**
* <MethodDescription>
*
* @param type <description>
*
* @return type <description>
*/
function map_method($method) {
# TODO validate method
## 1. function
$function = array(&$this, 'dispatch');
## 2. signature
$signature = array(array());
# return value
$signature[0][] = $this->translate_type($method->returns);
# arguments
foreach ($method->expects as $type)
$signature[0][] = $this->translate_type($type);
## 3. docstring
$docstring = $method->description;
return compact('function', 'signature', 'docstring');
}
/**
* <MethodDescription>
*
* @param type <description>
*
* @return type <description>
*/
function translate_type($type0) {
switch ($type = Studip_Ws_Type::get_type($type0)) {
case STUDIP_WS_TYPE_INT:
return $GLOBALS['xmlrpcInt'];
case STUDIP_WS_TYPE_STRING:
return $GLOBALS['xmlrpcString'];
case STUDIP_WS_TYPE_BASE64:
return $GLOBALS['xmlrpcBase64'];
case STUDIP_WS_TYPE_BOOL:
return $GLOBALS['xmlrpcBoolean'];
case STUDIP_WS_TYPE_FLOAT:
return $GLOBALS['xmlrpcDouble'];
case STUDIP_WS_TYPE_NULL:
return $GLOBALS['xmlrpcBoolean'];
case STUDIP_WS_TYPE_ARRAY:
return $GLOBALS['xmlrpcArray'];
case STUDIP_WS_TYPE_STRUCT:
return $GLOBALS['xmlrpcStruct'];
}
trigger_error(sprintf('Type %s could not be found.',
var_export($type, TRUE)),
E_USER_ERROR);
return $GLOBALS['xmlrpcString'];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment