From 12e56efac2a1d673bd920393511060dfa33026f1 Mon Sep 17 00:00:00 2001 From: arjen Date: Wed, 5 Feb 2003 09:38:42 +0000 Subject: [PATCH] A base class for all web interface pages --- src/web/page.class.php | 172 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 src/web/page.class.php diff --git a/src/web/page.class.php b/src/web/page.class.php new file mode 100644 index 0000000..81598be --- /dev/null +++ b/src/web/page.class.php @@ -0,0 +1,172 @@ + +
+

GNU Computer Monitoring

+

Version 0.0.4, Februari 05, 2003

+
+ + + + +
GnoCoMo logo
+ + + + + + + + + + + + + +
Username
Password
 
+
+
+
+the_title = $title; + $this->database = false; + $this->path = $path; + session_start(); + } + + function Head() + { +?> + + + + + + + + + <?php echo $this->the_title ?> + + +database) + { + pg_close($this->database); + } + echo ""; + echo ""; + } + + function Showpage() + { + $this->config = new gnucomo_config; + + $this->config->read("gnucomo"); + + $this->Head(); + if (empty($_SESSION['username'])) + { + // Nobody logged in yet. + + if (isset($_POST['username']) && isset($_POST['password'])) + { + // Login form submitted. Try to start a new session. + + $name = $_POST['username']; // PostgreSQL username + $passw = $_POST['password']; // PostgreSQL user password + + // Connect to the database + $this->database = pg_connect($this->config->Database($name, $passw)); + if ($this->database == false) + { + login_form(); + } + else + { + session_register('username'); + $_SESSION['username'] = $name; + session_register('password'); + $_SESSION['password'] = $passw; + $this->Body(); + } + + } + else + { + // Nobody tried to login yet. Present the login form. + login_form(); + } + } + else + { + $name = $_SESSION['username']; // PostgreSQL username + $passw = $_SESSION['password']; // PostgreSQL user password + + // Connect to the database + $this->database = pg_connect($this->config->Database($name, $passw)); + $this->Body(); + } + $this->Tail(); + } +} -- 2.11.0