3 * @author Gaetano Giunta
4 * @copyright (C) 2005-2020 G. Giunta
5 * @license code licensed under the BSD License: see file license.txt
7 * Parses GET/POST variables
9 * @todo switch params for http compression from 0,1,2 to values to be used directly
10 * @todo do some more sanitization of received parameters
13 // work around magic quotes
14 if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
15 function stripslashes_deep($value)
17 $value = is_array($value) ?
18 array_map('stripslashes_deep', $value) :
24 $_GET = array_map('stripslashes_deep', $_GET);
27 $preferredEncodings = 'UTF-8, ASCII, ISO-8859-1, UTF-7, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
28 $inputcharset = mb_detect_encoding(urldecode($_SERVER['REQUEST_URI']), $preferredEncodings);
29 if (isset($_GET['usepost']) && $_GET['usepost'] === 'true') {
31 $inputcharset = mb_detect_encoding(implode('', $_GET), $preferredEncodings);
34 /// @todo if $inputcharset is not UTF8, we should probably re-encode $_GET to make it UTF-8
36 // recover input parameters
42 if (isset($_GET['action'])) {
43 if (isset($_GET['wstype']) && $_GET['wstype'] == '1') {
45 if (isset($_GET['id'])) {
49 $host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error...
50 if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) {
51 $protocol = $_GET['protocol'];
53 if (strpos($host, 'http://') === 0) {
54 $host = substr($host, 7);
55 } elseif (strpos($host, 'https://') === 0) {
56 $host = substr($host, 8);
59 $port = isset($_GET['port']) ? $_GET['port'] : '';
60 $path = isset($_GET['path']) ? $_GET['path'] : '';
61 // in case user forgot initial '/' in xmlrpc server path, add it back
62 if ($path && ($path[0]) != '/') {
66 if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) {
67 $debug = $_GET['debug'];
70 $verifyhost = (isset($_GET['verifyhost']) && ($_GET['verifyhost'] == '1' || $_GET['verifyhost'] == '2')) ? $_GET['verifyhost'] : 0;
71 if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') {
76 $cainfo = isset($_GET['cainfo']) ? $_GET['cainfo'] : '';
77 $proxy = isset($_GET['proxy']) ? $_GET['proxy'] : 0;
78 if (strpos($proxy, 'http://') === 0) {
79 $proxy = substr($proxy, 7);
81 $proxyuser = isset($_GET['proxyuser']) ? $_GET['proxyuser'] : '';
82 $proxypwd = isset($_GET['proxypwd']) ? $_GET['proxypwd'] : '';
83 $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0;
84 if (!is_numeric($timeout)) {
87 $action = $_GET['action'];
89 $method = isset($_GET['method']) ? $_GET['method'] : '';
90 $methodsig = isset($_GET['methodsig']) ? $_GET['methodsig'] : 0;
91 $payload = isset($_GET['methodpayload']) ? $_GET['methodpayload'] : '';
92 $alt_payload = isset($_GET['altmethodpayload']) ? $_GET['altmethodpayload'] : '';
94 if (isset($_GET['run']) && $_GET['run'] == 'now') {
98 $username = isset($_GET['username']) ? $_GET['username'] : '';
99 $password = isset($_GET['password']) ? $_GET['password'] : '';
101 $authtype = (isset($_GET['authtype']) && ($_GET['authtype'] == '2' || $_GET['authtype'] == '8')) ? $_GET['authtype'] : 1;
103 if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) {
104 $requestcompression = $_GET['requestcompression'];
106 $requestcompression = 0;
108 if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) {
109 $responsecompression = $_GET['responsecompression'];
111 $responsecompression = 0;
114 $clientcookies = isset($_GET['clientcookies']) ? $_GET['clientcookies'] : '';
134 $requestcompression = 0;
135 $responsecompression = 0;
139 // check input for known XMLRPC attacks against this or other libs
140 function payload_is_safe($input)