]> 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 9f919fa900bec40f2025dda1696365ee5dcef1bf..5e9b87ef93ff72aa00d7a03d858522c1f07183b4 100644 (file)
@@ -6,11 +6,11 @@
  * in the class loader. See inc/loader/class_ClassLoader.php for instance
  *
  * @see                        ClassLoader
- * @author             Roland Haeder <webmaster@mxchange.org>
- * @version            0.3.0
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
  * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.mxchange.org
+ * @link               http://www.ship-simu.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
@@ -25,7 +25,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class FrameworkConfiguration {
+class FrameworkConfiguration implements Registerable {
        /**
         * The framework's main configuration array which will be initialized with
         * hard-coded configuration data and might be overwritten/extended by
@@ -169,7 +169,7 @@ class FrameworkConfiguration {
        /**
         * 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 {
        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]