]> git.wh0rd.org Git - tt-rss.git/commitdiff
option to redirect to https url for login, option ENABLE_LOGIN_SSL (fixes some non...
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Dec 2005 20:34:29 +0000 (21:34 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Dec 2005 20:34:29 +0000 (21:34 +0100)
config.php-dist
functions.php
login.php
logout.php

index 309af2da9d939f2d8ce6ff9f0dc9d1d71dbaf1bd..446038110e6fcc0b49557628f47fc67877c4e763 100644 (file)
@@ -54,4 +54,7 @@
        define('GLOBAL_ENABLE_LABELS', false);
        // Labels are a security risk, so this option can globally disable them for all users.
 
+       define('ENABLE_LOGIN_SSL', false);
+       // Redirect to SSL url for login
+
 ?>
index ba80bab94da6914ac089a9eb2a865bcdb78722a5..8b990740e1247f17faf00a1b12009e00a38cd04b 100644 (file)
                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 {
index b162fa9cdbd294342514f34a6221f91cc7f1ec5e..eda2ac826a53324f32d9e5c84e70e83c9896f226 100644 (file)
--- a/login.php
+++ b/login.php
@@ -6,8 +6,11 @@
        require_once "config.php";
        require_once "functions.php";
 
+       $url_path = get_script_urlpath();
+       $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;
+
        if (SINGLE_USER_MODE) {
-               header("Location: tt-rss.php");
+               header("Location: $redirect_base/tt-rss.php");
                exit;
        }
 
@@ -25,7 +28,7 @@
                        } else {
                                $redirect_to = "tt-rss.php";
                        }
-                       header("Location: $redirect_to");
+                       header("Location: $redirect_base/$redirect_to");
                }
        }
 
index 9af2bab61beb0b3a9e664191450a7040badbbf3f..b258067a6a83010122ba4d448e4382835adaec13 100644 (file)
@@ -7,7 +7,17 @@
        logout_user();
 
        if (!USE_HTTP_AUTH) {
-               header("Location: login.php");
+               $url_path = get_script_urlpath();
+
+               if (ENABLE_LOGIN_SSL) {
+                       $protocol = "https";
+               } else {
+                       $protocol = "http";
+               }               
+
+               $redirect_base = "$protocol://" . $_SERVER["SERVER_NAME"] . $url_path;
+
+               header("Location: $redirect_base/login.php");
        } else { ?>
        
        <html>