From 8326fa85d8b07c85a422f33fb26f585e7aa954d5 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 9 Nov 2003 17:53:47 +0000 Subject: [PATCH] * Moved all of the session-management code from ctdlheader.php to ctdlsession.php, leaving only a single function call. This will hopefully make ctdlheader.php more palatable to non-programmers. --- ctdlphp/ChangeLog | 6 ++++++ ctdlphp/ctdlheader.php | 23 +---------------------- ctdlphp/ctdlsession.php | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/ctdlphp/ChangeLog b/ctdlphp/ChangeLog index f9976427e..4f638b7d2 100644 --- a/ctdlphp/ChangeLog +++ b/ctdlphp/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 1.15 2003/11/09 17:53:47 ajc + * Moved all of the session-management code from ctdlheader.php to + ctdlsession.php, leaving only a single function call. This will + hopefully make ctdlheader.php more palatable to non-programmers. + Revision 1.14 2003/11/07 15:56:13 ajc * ctdlprotocol.php: known room list fetch now sets subscript "hasnewmsgs" * listrooms.php: render rooms with unseen messages in boldface @@ -61,3 +66,4 @@ Revision 1.1 2003/10/31 03:47:13 ajc * Initial CVS import + diff --git a/ctdlphp/ctdlheader.php b/ctdlphp/ctdlheader.php index 512e6c937..1a9ac6583 100644 --- a/ctdlphp/ctdlheader.php +++ b/ctdlphp/ctdlheader.php @@ -3,7 +3,7 @@ // $Id$ // // Header and footer code to be included on every page. Not only does it -// contain some common markup, but it also includes some code glue that holds +// contain some common markup, but it also calls some code glue that holds // the session together. // // Copyright (c) 2003 by Art Cancro @@ -13,29 +13,8 @@ include "ctdlsession.php"; include "ctdlprotocol.php"; function bbs_page_header() { - global $session; - - if (strcmp('4.3.0', phpversion()) > 0) { - die("This program requires PHP 4.3.0 or newer."); - } - establish_citadel_session(); - // 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); - } - } - echo << diff --git a/ctdlphp/ctdlsession.php b/ctdlphp/ctdlsession.php index b8f2dbcd1..f05f9e598 100644 --- a/ctdlphp/ctdlsession.php +++ b/ctdlphp/ctdlsession.php @@ -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"]) { @@ -72,6 +77,22 @@ function establish_citadel_session() { echo "ERROR: no Citadel socket!
\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); + } + } + } -- 2.30.2