+
+ /**
+ * 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 . "://" . $this->detectDomain() . dirname($_SERVER['SCRIPT_NAME']);
+
+ // Return the URL
+ return $baseUrl;
+ }
+
+ /**
+ * Detect safely and return the full domain where this script is installed
+ *
+ * @return $fullDomain The detected full domain
+ */
+ public function detectDomain () {
+ // Detect the full domain
+ $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
+
+ // Return it
+ return $fullDomain;
+ }