$url = (($_SERVER["HTTPS"] == "off" || empty($_SERVER["HTTPS"])) ? "http://" : "https://") . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
http://lucb1e.com/randomprojects/geturl.php