From 75836f33860f26ca55ec8e8661cff4b0edc2fe5e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 9 Dec 2005 21:34:29 +0100 Subject: option to redirect to https url for login, option ENABLE_LOGIN_SSL (fixes some non-absolute redirects) --- functions.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index ba80bab94..8b990740e 100644 --- a/functions.php +++ b/functions.php @@ -723,12 +723,34 @@ session_destroy(); } + function get_script_urlpath() { + $request_uri = $_SERVER["REQUEST_URI"]; + return preg_replace('/\/[^\/]+$/', "", $request_uri); + } + + function get_login_redirect() { + $server = $_SERVER["SERVER_NAME"]; + + if (ENABLE_LOGIN_SSL) { + $protocol = "https"; + } else { + $protocol = "http"; + } + + $url_path = get_script_urlpath(); + + $redirect_uri = "$protocol://$server$url_path/login.php"; + + return $redirect_uri; + } + function login_sequence($link) { if (!SINGLE_USER_MODE) { - + if (!USE_HTTP_AUTH) { if (!$_SESSION["uid"]) { - header("Location: login.php?rt=tt-rss.php"); + $redirect_uri = get_login_redirect(); + header("Location: $redirect_uri?rt=tt-rss.php"); exit; } } else { -- cgit v1.2.3