]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - plugins/sql_auth/sql_auth.php
Redirect back on login
[irc/unrealircd/unrealircd-webpanel.git] / plugins / sql_auth / sql_auth.php
index 856dc094eb7fab5e5015568caa232c7d4dff1e99..0f8486597fbfdf6eaf243a74fa0a663b4621886f 100644 (file)
@@ -55,6 +55,7 @@ class sql_auth
                }
        }
 
+       /* pre-Header hook */
        public static function session_start($n)
        {
                if (!isset($_SESSION))
@@ -65,13 +66,14 @@ class sql_auth
                do_log($_SESSION);
                if (!isset($_SESSION['id']) || empty($_SESSION))
                {
+                       $secure = ($_SERVER['HTTPS'] == 'on') ? "https://" : "http://";
+                       $current_url = "$secure$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
                        $tok = split($_SERVER['SCRIPT_FILENAME'], "/");
                        if ($check = security_check() && $tok[count($tok) - 1] !== "error.php") {
                                header("Location: " . BASE_URL . "plugins/sql_auth/error.php");
                                die();
                        }
-                       session_destroy();
-                       header("Location: ".BASE_URL."plugins/sql_auth/login.php");
+                       header("Location: ".BASE_URL."plugins/sql_auth/login.php?redirect=".urlencode($current_url));
                        die();
                }
                else