3 * @author Gaetano Giunta
4 * @copyright (C) 2005-2015 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 (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 /// @bug this is not a perfect detection method - it will fail if eg. a latin1 character is in the method name
32 $inputcharset = mb_detect_encoding(urldecode(isset($_GET['methodpayload'])) ? $_GET['methodpayload'] : '', $preferredEncodings);
35 // recover input parameters
41 if (isset($_GET['action'])) {
42 if (isset($_GET['wstype']) && $_GET['wstype'] == '1') {
44 if (isset($_GET['id'])) {
48 $host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error...
49 if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) {
50 $protocol = $_GET['protocol'];
52 if (strpos($host, 'http://') === 0) {
53 $host = substr($host, 7);
54 } elseif (strpos($host, 'https://') === 0) {
55 $host = substr($host, 8);
58 $port = isset($_GET['port']) ? $_GET['port'] : '';
59 $path = isset($_GET['path']) ? $_GET['path'] : '';
60 // in case user forgot initial '/' in xmlrpc server path, add it back
61 if ($path && ($path[0]) != '/') {
65 if (isset($_GET['debug']) && ($_GET['debug'] == '1' || $_GET['debug'] == '2')) {
66 $debug = $_GET['debug'];
69 $verifyhost = (isset($_GET['verifyhost']) && ($_GET['verifyhost'] == '1' || $_GET['verifyhost'] == '2')) ? $_GET['verifyhost'] : 0;
70 if (isset($_GET['verifypeer']) && $_GET['verifypeer'] == '1') {
75 $cainfo = isset($_GET['cainfo']) ? $_GET['cainfo'] : '';
76 $proxy = isset($_GET['proxy']) ? $_GET['proxy'] : 0;
77 if (strpos($proxy, 'http://') === 0) {
78 $proxy = substr($proxy, 7);
80 $proxyuser = isset($_GET['proxyuser']) ? $_GET['proxyuser'] : '';
81 $proxypwd = isset($_GET['proxypwd']) ? $_GET['proxypwd'] : '';
82 $timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0;
83 if (!is_numeric($timeout)) {
86 $action = $_GET['action'];
88 $method = isset($_GET['method']) ? $_GET['method'] : '';
89 $methodsig = isset($_GET['methodsig']) ? $_GET['methodsig'] : 0;
90 $payload = isset($_GET['methodpayload']) ? $_GET['methodpayload'] : '';
91 $alt_payload = isset($_GET['altmethodpayload']) ? $_GET['altmethodpayload'] : '';
93 if (isset($_GET['run']) && $_GET['run'] == 'now') {
97 $username = isset($_GET['username']) ? $_GET['username'] : '';
98 $password = isset($_GET['password']) ? $_GET['password'] : '';
100 $authtype = (isset($_GET['authtype']) && ($_GET['authtype'] == '2' || $_GET['authtype'] == '8')) ? $_GET['authtype'] : 1;
102 if (isset($_GET['requestcompression']) && ($_GET['requestcompression'] == '1' || $_GET['requestcompression'] == '2')) {
103 $requestcompression = $_GET['requestcompression'];
105 $requestcompression = 0;
107 if (isset($_GET['responsecompression']) && ($_GET['responsecompression'] == '1' || $_GET['responsecompression'] == '2' || $_GET['responsecompression'] == '3')) {
108 $responsecompression = $_GET['responsecompression'];
110 $responsecompression = 0;
113 $clientcookies = isset($_GET['clientcookies']) ? $_GET['clientcookies'] : '';
133 $requestcompression = 0;
134 $responsecompression = 0;
138 // check input for known XMLRPC attacks against this or other libs
139 function payload_is_safe($input)