No longer simple IPs, better is UNL: Universal Node Locator
[core.git] / inc / classes / main / console / class_ConsoleTools.php
index 4d220d710f686434645bf30b4f2c4ef1efddcf2e..b7807d30010a2b5d63c33e27da3c00fa5951832a 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * This class contains static helper functions for console applications
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -123,7 +123,7 @@ class ConsoleTools extends BaseFrameworkSystem {
 
                // Add last new-line
                $proxyTunnel .= self::HTTP_EOL;
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __LINE__ . ']: proxyTunnel=' . $proxyTunnel);
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: proxyTunnel=' . $proxyTunnel);
 
                // Write request
                fwrite($socketResource, $proxyTunnel);
@@ -207,13 +207,13 @@ class ConsoleTools extends BaseFrameworkSystem {
 
                try {
                        // Get a file pointer
-                       $io = FrameworkFileInputPointer::createFrameworkFileInputPointer($helperInstance->getConfigInstance()->getConfigEntry('hostname_file'));
+                       $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($helperInstance->getConfigInstance()->getConfigEntry('hostname_file')));
 
                        // Read the file
-                       $rawData = trim($io->readFromFile());
+                       $rawData = trim($fileInstance->readFromFile());
 
                        // Close the file
-                       $io->closeFile();
+                       $fileInstance->closeFile();
 
                        // Extract hostname from it
                        $hostname = $helperInstance->extractHostnameFromRawData($rawData);
@@ -254,7 +254,7 @@ class ConsoleTools extends BaseFrameworkSystem {
        /**
         * Determines own remote IP address (e.g. can be used to probe if we are
         * reachable from outside by determining external IP and then connect to it.
-        * This is accomblished by connecting to the IP of www.ship-simu.org which
+        * This is accomblished by connecting to the IP of www.shipsimu.org which
         * should default to 188.138.90.169 and requesting /ip.php which does only
         * return the content of $_SERVER['REMOTE_ADDR']. Of course, this method
         * requires a working Internet connection.
@@ -268,7 +268,7 @@ class ConsoleTools extends BaseFrameworkSystem {
         * @todo        This should be moved out to an external class, e.g. HttpClient
         * @todo        Make IP, host name, port and script name configurable
         */
-       public static function determineExternalIp () {
+       public static function determineExternalAddress () {
                // Get helper instance
                $helperInstance = new ConsoleTools();
 
@@ -294,8 +294,8 @@ class ConsoleTools extends BaseFrameworkSystem {
                } // END - if
 
                // Prepare the GET request
-               $request  = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://ship-simu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL;
-               $request .= 'Host: ship-simu.org' . self::HTTP_EOL;
+               $request  = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL;
+               $request .= 'Host: shipsimu.org' . self::HTTP_EOL;
                $request .= 'User-Agent: ' . self::HTTP_USER_AGENT . self::HTTP_EOL;
                $request .= 'Connection: close' . self::HTTP_EOL;
 
@@ -304,12 +304,12 @@ class ConsoleTools extends BaseFrameworkSystem {
                        // CONNECT method?
                        if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') {
                                // Setup proxy tunnel
-                               $response = $helperInstance->setupProxyTunnel('ship-simu.org', 80, $socketResource);
+                               $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource);
 
                                // If the response is invalid, abort
                                if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) {
                                        // Invalid response!
-                                       $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, true));
+                                       $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, TRUE));
                                } // END - if
                        } else {
                                // Add header for proxy
@@ -343,7 +343,7 @@ class ConsoleTools extends BaseFrameworkSystem {
 
 
                // Debug message
-               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __LINE__ . ']: Resolved external address: ' . $externalAddress);
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Resolved external address: ' . $externalAddress);
 
                // Return determined external IP
                return $externalAddress;