4 * Common parameter parsing for benchmark and tests scripts.
7 * @param string LOCALSERVER
9 * @param string HTTPSSERVER
10 * @param string HTTPSSURI
12 * @param string NOPROXY
13 * @param bool HTTPSIGNOREPEER
14 * @param int HTTPSVERIFYHOST
15 * @param int SSLVERSION
17 * @copyright (C) 2007-2020 G. Giunta
18 * @license code licensed under the BSD License: see file license.txt
22 public static function getArgs()
28 'LOCALSERVER' => 'localhost',
29 'HTTPSSERVER' => 'gggeek.ssl.altervista.org',
30 'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
31 'HTTPSIGNOREPEER' => false,
32 'HTTPSVERIFYHOST' => 2,
34 'PROXYSERVER' => null,
36 'LOCALPATH' => __DIR__,
39 // check for command line (env vars) vs. web page input params
40 if (!isset($_SERVER['REQUEST_METHOD'])) {
41 foreach($_SERVER as $key => $val) {
42 if (array_key_exists($key, $args)) {
47 // NB: we might as well consider using $_GET stuff later on...
53 $args['DEBUG'] = intval($DEBUG);
55 if (isset($LOCALSERVER)) {
56 $args['LOCALSERVER'] = $LOCALSERVER;
58 if (isset($HTTP_HOST)) {
59 $args['LOCALSERVER'] = $HTTP_HOST;
60 } elseif (isset($_SERVER['HTTP_HOST'])) {
61 $args['LOCALSERVER'] = $_SERVER['HTTP_HOST'];
64 if (isset($HTTPSSERVER)) {
65 $args['HTTPSSERVER'] = $HTTPSSERVER;
67 if (isset($HTTPSURI)) {
68 $args['HTTPSURI'] = $HTTPSURI;
70 if (isset($HTTPSIGNOREPEER)) {
71 $args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER;
73 if (isset($HTTPSVERIFYHOST)) {
74 $args['HTTPSVERIFYHOST'] = (int)$HTTPSVERIFYHOST;
76 if (isset($SSLVERSION)) {
77 $args['SSLVERSION'] = (int)$SSLVERSION;
80 $arr = explode(':', $PROXY);
81 $args['PROXYSERVER'] = $arr[0];
82 if (count($arr) > 1) {
83 $args['PROXYPORT'] = $arr[1];
85 $args['PROXYPORT'] = 8080;
88 // used to silence testsuite warnings about proxy code not being tested
89 if (isset($NOPROXY)) {
90 $args['NOPROXY'] = true;
93 // GUESTIMATE the url of local demo server
94 // play nice to php 3 and 4-5 in retrieving URL of server.php
95 /// @todo filter out query string from REQUEST_URI
96 if (isset($REQUEST_URI)) {
97 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $REQUEST_URI);
98 $URI = str_replace('/testsuite.php', '/server.php', $URI);
99 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
100 $URI = str_replace('/benchmark.php', '/server.php', $URI);
101 } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD'])) {
102 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $_SERVER['PHP_SELF']);
103 $URI = str_replace('/testsuite.php', '/server.php', $URI);
104 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
105 $URI = str_replace('/benchmark.php', '/server.php', $URI);
107 $URI = '/demo/server/server.php';
110 if ($URI[0] != '/') {
114 if (isset($LOCALPATH)) {
115 $args['LOCALPATH'] = $LOCALPATH;