]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/config/class_FrameworkConfiguration.php
Cookie-based login initially done
[shipsimu.git] / inc / config / class_FrameworkConfiguration.php
index 6bfc3a26ce0fbfd1fbec6d0396a529c5b3da6bf2..5e9b87ef93ff72aa00d7a03d858522c1f07183b4 100644 (file)
@@ -169,7 +169,7 @@ class FrameworkConfiguration implements Registerable {
        /**
         * Define the local file path
         *
-        * @param               $path   The database type. See path inc/database/.
+        * @param               $path   Local file path for include files.
         * @return      void
         */
        public function definePath ($path) {
@@ -261,6 +261,28 @@ class FrameworkConfiguration implements Registerable {
        public function __toString () {
                return get_class($this);
        }
+
+       /**
+        * Dectect and return the base URL for all URLs and forms
+        *
+        * @return      $baseUrl        Detected base URL
+        */
+       public function detectBaseUrl() {
+               // Initialize the URL
+               $baseUrl = "http";
+
+               // Do we have HTTPS?
+               if (isset($_SERVER['HTTPS'])) {
+                       // Add the >s< for HTTPS
+                       $baseUrl .= "s";
+               } // END - if
+
+               // Construct the full URL now and secure it against CSRF attacks
+               $baseUrl = $baseUrl . "://" . htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES) . dirname($_SERVER['SCRIPT_NAME']);
+
+               // Return the URL
+               return $baseUrl;
+       }
 } // END - class
 
 // [EOF]