]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/ctdlsession.php
* cleanup
[citadel.git] / ctdlphp / ctdlsession.php
index a890e842149692bebc7d170fa755cdd9bdb9ee88..f05f9e598159efc5ebbdc8607e57da832e6c5721 100644 (file)
@@ -10,6 +10,11 @@ function establish_citadel_session() {
 
        global $session, $clientsocket;
 
+       if (strcmp('4.3.0', phpversion()) > 0) {
+               die("This program requires PHP 4.3.0 or newer.");
+       }
+
+
        session_start();
 
        if ($_SESSION["ctdlsession"]) {
@@ -42,7 +47,7 @@ function establish_citadel_session() {
                // Ok, now try again.
                $clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5);
 
-               // Try to log the user back in.
+               // Try to log the user back in and go back to the correct room.
                if ($clientsocket) {
 
                        ctdl_iden();    // Identify client
@@ -53,6 +58,13 @@ function establish_citadel_session() {
                                        $_SESSION["password"]
                                );
                        }
+
+                       if ($_SESSION["room"]) {
+                               ctdl_goto($_SESSION["room"]);
+                       }
+                       else {
+                               ctdl_goto("_BASEROOM_");
+                       }
                }
        }
 
@@ -65,6 +77,22 @@ function establish_citadel_session() {
                echo "ERROR: no Citadel socket!<BR>\n";
                flush();
        }
+
+       // If the user is trying to call up any page other than
+       // login.php logout.php do_login.php,
+       // and the session is not logged in, redirect to login.php
+       //
+       if ($_SESSION["logged_in"] != 1) {
+               $filename = basename(getenv('SCRIPT_NAME'));
+               if (    (strcmp($filename, "login.php"))
+                  &&   (strcmp($filename, "logout.php"))
+                  &&   (strcmp($filename, "do_login.php"))
+               ) {
+                       header("Location: login.php");
+                       exit(0);
+               }
+       }
+
        
 }