tests
[plcapi.git] / tests / parse_args.php
index d6632ab..f9c4562 100644 (file)
@@ -7,44 +7,36 @@
  * @param string  LOCALSERVER
  * @param string  URI
  * @param string  HTTPSSERVER
- * @param string  HTTPSSURI
- * @param string  PROXY
- * @param string  NOPROXY
+ * @param string  HTTPSURI
  * @param bool    HTTPSIGNOREPEER
  * @param int     HTTPSVERIFYHOST
  * @param int     SSLVERSION
+ * @param string  PROXYSERVER
  *
- * @copyright (C) 2007-2017 G. Giunta
+ * @copyright (C) 2007-2020 G. Giunta
  * @license code licensed under the BSD License: see file license.txt
  **/
 class argParser
 {
     public static function getArgs()
     {
-        global $argv;
-
         $args = array(
             'DEBUG' => 0,
             'LOCALSERVER' => 'localhost',
-            'HTTPSSERVER' => 'gggeek.ssl.altervista.org',
+            'HTTPSSERVER' => 'gggeek.altervista.org',
             'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
             'HTTPSIGNOREPEER' => false,
             'HTTPSVERIFYHOST' => 2,
             'SSLVERSION' => 0,
             'PROXYSERVER' => null,
-            'NOPROXY' => false,
             'LOCALPATH' => __DIR__,
         );
 
-        // check for command line vs web page input params
+        // check for command line (env vars) vs. web page input params
         if (!isset($_SERVER['REQUEST_METHOD'])) {
-            if (isset($argv)) {
-                foreach ($argv as $param) {
-                    $param = explode('=', $param);
-                    if (count($param) > 1) {
-                        $pname = strtoupper(ltrim($param[0], '-'));
-                        $$pname = $param[1];
-                    }
+            foreach($_SERVER as $key => $val) {
+                if (array_key_exists($key, $args)) {
+                    $$key = $val;
                 }
             }
         } else {
@@ -80,8 +72,8 @@ class argParser
         if (isset($SSLVERSION)) {
             $args['SSLVERSION'] = (int)$SSLVERSION;
         }
-        if (isset($PROXY)) {
-            $arr = explode(':', $PROXY);
+        if (isset($PROXYSERVER)) {
+            $arr = explode(':', $PROXYSERVER);
             $args['PROXYSERVER'] = $arr[0];
             if (count($arr) > 1) {
                 $args['PROXYPORT'] = $arr[1];
@@ -89,10 +81,6 @@ class argParser
                 $args['PROXYPORT'] = 8080;
             }
         }
-        // used to silence testsuite warnings about proxy code not being tested
-        if (isset($NOPROXY)) {
-            $args['NOPROXY'] = true;
-        }
         if (!isset($URI)) {
             // GUESTIMATE the url of local demo server
             // play nice to php 3 and 4-5 in retrieving URL of server.php