]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/console/class_ConsoleTools.php
Code cleanups, deprecated classes renamed
[core.git] / inc / classes / main / console / class_ConsoleTools.php
index 1599cdc8fbfff3a7584c46eb047f23890aa26341..c9fec474ff417a282f494f68e0c93c65eeeb1d79 100644 (file)
@@ -101,7 +101,7 @@ class ConsoleTools extends BaseFrameworkSystem {
 
                        // Resolve the IP number
                        $ip = $helper->resolveIpAddress($hostname);
-               } catch (FileNotFoundException $e) {
+               } catch (FileIoException $e) {
                        // Fall-back to 'SESSION_SVR' which found on my Sun Station
                        if (isset($_SERVER['SESSION_SVR'])) {
                                // Resolve it
@@ -172,6 +172,54 @@ class ConsoleTools extends BaseFrameworkSystem {
                // Return determined external IP
                return $externalAddress;
        }
+
+       /**
+        * Analyzes the 'environment', mostly $_SERVER, for presence of elements
+        * which indicates clearly that e.g. this script has been executed from
+        * console or web.
+        *
+        * @return      $type   The analyzed type, can be 'http' or 'console'
+        */
+       public static function analyzeEnvironmentForType () {
+               // Default is the console
+               $type = 'console';
+
+               // Now, do we have a request method, or query string set?
+               if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) {
+                       // Possibly HTTP request
+                       $type = 'http';
+               } // END - if
+
+               // Return it
+               return $type;
+       }
+
+       /**
+        * Analyzes the 'environment', mostly $_SERVER, for presence of elements
+        * which indicates clearly that e.g. this script has been executed from
+        * console or web. This method should be used for class names, they
+        * currently are named differently. Here is a list to clarify this:
+        *
+        *   Request type | Class type
+        * -----------------------------
+        *      http      |    web
+        *     console    |  console
+        *
+        * @return      $type   The analyzed type, can be 'http' or 'console'
+        */
+       public static function analyzeEnvironmentForClassType () {
+               // Default is the console
+               $type = 'console';
+
+               // Now, do we have a request method, or query string set?
+               if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) {
+                       // Possibly HTTP request
+                       $type = 'web';
+               } // END - if
+
+               // Return it
+               return $type;
+       }
 }
 
 // [EOF]