]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/config/class_FrameworkConfiguration.php
Cookie path now detected by generic method
[shipsimu.git] / inc / config / class_FrameworkConfiguration.php
index 8f6fa15f45cd254137a917bb7744bd481a3974f8..e7dfb699c661148635d29fd4ad6e0b76d05c6532 100644 (file)
@@ -231,7 +231,7 @@ class FrameworkConfiguration implements Registerable {
                } // END - if
 
                // Construct the full URL now and secure it against CSRF attacks
-               $baseUrl = $baseUrl . "://" . $this->detectDomain() . dirname($_SERVER['SCRIPT_NAME']);
+               $baseUrl = $baseUrl . "://" . $this->detectDomain() . $this->detectScriptPath();
 
                // Return the URL
                return $baseUrl;
@@ -256,6 +256,24 @@ class FrameworkConfiguration implements Registerable {
                return $fullDomain;
        }
 
+       /**
+        * Detect safely the script path without trailing slash which is the part
+        * between "http://your-domain.invalid/" and "script-name.php"
+        */
+       public function detectScriptPath () {
+               // Default is empty
+               $scriptPath = "";
+
+               // Is the scriptname set?
+               if (isset($_SERVER['SCRIPT_NAME'])) {
+                       // Get dirname of it
+                       $scriptPath = dirname($_SERVER['SCRIPT_NAME']);
+               } // END - if
+
+               // Return it
+               return $scriptPath;
+       }
+
        /**
         * Getter for field name
         *