4 * Common parameter parsing for benchmarks and tests scripts.
7 * @param string LOCALSERVER
9 * @param string HTTPSSERVER
10 * @param string HTTPSSURI
12 * @param string NOPROXY
14 * @copyright (C) 2007-20014 G. Giunta
15 * @license code licensed under the BSD License: see file license.txt
19 public static function getArgs()
25 'LOCALSERVER' => 'localhost',
26 'HTTPSSERVER' => 'gggeek.ssl.altervista.org',
27 'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
28 'HTTPSIGNOREPEER' => false,
29 'PROXYSERVER' => null,
31 'LOCALPATH' => __DIR__,
34 // check for command line vs web page input params
35 if (!isset($_SERVER['REQUEST_METHOD'])) {
37 foreach ($argv as $param) {
38 $param = explode('=', $param);
39 if (count($param) > 1) {
40 $pname = strtoupper(ltrim($param[0], '-'));
46 // NB: we might as well consider using $_GET stuff later on...
52 $args['DEBUG'] = intval($DEBUG);
54 if (isset($LOCALSERVER)) {
55 $args['LOCALSERVER'] = $LOCALSERVER;
57 if (isset($HTTP_HOST)) {
58 $args['LOCALSERVER'] = $HTTP_HOST;
59 } elseif (isset($_SERVER['HTTP_HOST'])) {
60 $args['LOCALSERVER'] = $_SERVER['HTTP_HOST'];
63 if (isset($HTTPSSERVER)) {
64 $args['HTTPSSERVER'] = $HTTPSSERVER;
66 if (isset($HTTPSURI)) {
67 $args['HTTPSURI'] = $HTTPSURI;
69 if (isset($HTTPSIGNOREPEER)) {
70 $args['HTTPSIGNOREPEER'] = bool($HTTPSIGNOREPEER);
73 $arr = explode(':', $PROXY);
74 $args['PROXYSERVER'] = $arr[0];
75 if (count($arr) > 1) {
76 $args['PROXYPORT'] = $arr[1];
78 $args['PROXYPORT'] = 8080;
81 // used to silence testsuite warnings about proxy code not being tested
82 if (isset($NOPROXY)) {
83 $args['NOPROXY'] = true;
86 // GUESTIMATE the url of local demo server
87 // play nice to php 3 and 4-5 in retrieving URL of server.php
88 /// @todo filter out query string from REQUEST_URI
89 if (isset($REQUEST_URI)) {
90 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $REQUEST_URI);
91 $URI = str_replace('/testsuite.php', '/server.php', $URI);
92 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
93 $URI = str_replace('/benchmark.php', '/server.php', $URI);
94 } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD'])) {
95 $URI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $_SERVER['PHP_SELF']);
96 $URI = str_replace('/testsuite.php', '/server.php', $URI);
97 $URI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $URI);
98 $URI = str_replace('/benchmark.php', '/server.php', $URI);
100 $URI = '/demo/server/server.php';
103 if ($URI[0] != '/') {
107 if (isset($LOCALPATH)) {
108 $args['LOCALPATH'] = $LOCALPATH;