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
11 * @todo move parameters away from global namespace
14 // work around magic quotes
15 if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
16 function stripslashes_deep($value)
18 $value = is_array($value) ?
19 array_map('stripslashes_deep', $value) :
25 $_GET = array_map('stripslashes_deep', $_GET);
28 $preferredEncodings = 'UTF-8, ASCII, ISO-8859-1, UTF-7, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
29 $inputcharset = mb_detect_encoding(urldecode($_SERVER['REQUEST_URI']), $preferredEncodings);
30 if (isset($_GET['usepost']) && $_GET['usepost'] === 'true') {
32 $inputcharset = mb_detect_encoding(implode('', $_GET), $preferredEncodings);
35 /// @todo if $inputcharset is not UTF8, we should probably re-encode $_GET to make it UTF-8
37 // recover input parameters
43 if (isset($_GET['action'])) {
44 if (isset($_GET['wstype']) && $_GET['wstype'] == '1') {
46 if (isset($_GET['id'])) {
50 $host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error...
51 if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) {
52 $protocol = $_GET['protocol'];
54 if (strpos($host, 'http://') === 0) {
55 $host = substr($host, 7);
56 } elseif (strpos($host, 'https://') === 0) {
57 $host = substr($host, 8);
60 $port = isset($_GET['port']) ? $_GET['port'] : '';
61 $path = isset($_GET['path']) ? $_GET['path'] : '';
62 // in case user forgot initial '/' in xmlrpc server path, add it back
63 if ($path && ($path[0]) != '/') {
67 if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) {
68 $debug = $_GET['debug'];
71 $verifyhost = (isset($_GET['verifyhost']) && ($_GET['verifyhost'] == '1' || $_GET['verifyhost'] == '2')) ? $_GET['verifyhost'] : 0;
72 if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') {
77 $cainfo = isset($_GET['cainfo']) ? $_GET['cainfo'] : '';
78 $proxy = isset($_GET['proxy']) ? $_GET['proxy'] : 0;
79 if (strpos($proxy, 'http://') === 0) {
80 $proxy = substr($proxy, 7);
82 $proxyuser = isset($_GET['proxyuser']) ? $_GET['proxyuser'] : '';
83 $proxypwd = isset($_GET['proxypwd']) ? $_GET['proxypwd'] : '';
84 $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0;
85 if (!is_numeric($timeout)) {
88 $action = $_GET['action'];
90 $method = isset($_GET['method']) ? $_GET['method'] : '';
91 $methodsig = isset($_GET['methodsig']) ? $_GET['methodsig'] : 0;
92 $payload = isset($_GET['methodpayload']) ? $_GET['methodpayload'] : '';
93 $alt_payload = isset($_GET['altmethodpayload']) ? $_GET['altmethodpayload'] : '';
95 if (isset($_GET['run']) && $_GET['run'] == 'now') {
99 $username = isset($_GET['username']) ? $_GET['username'] : '';
100 $password = isset($_GET['password']) ? $_GET['password'] : '';
102 $authtype = (isset($_GET['authtype']) && ($_GET['authtype'] == '2' || $_GET['authtype'] == '8')) ? $_GET['authtype'] : 1;
104 if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) {
105 $requestcompression = $_GET['requestcompression'];
107 $requestcompression = 0;
109 if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) {
110 $responsecompression = $_GET['responsecompression'];
112 $responsecompression = 0;
115 $clientcookies = isset($_GET['clientcookies']) ? $_GET['clientcookies'] : '';
135 $requestcompression = 0;
136 $responsecompression = 0;
140 // check input for known XMLRPC attacks against this or other libs
141 function payload_is_safe($input)