function getCurrentUrl() {
if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' ) {
$url = 'https://' . $_SERVER["SERVER_NAME"];
} else {
$url = 'http://' . $_SERVER["SERVER_NAME"];
}
if ( $_SERVER["SERVER_PORT"] != 80 ) {
$url .= ':' . $_SERVER["SERVER_PORT"];
}
$url .= $_SERVER["REQUEST_URI"];
return $url;
}