From: arjen Date: Wed, 5 Feb 2003 09:38:42 +0000 (+0000) Subject: A base class for all web interface pages X-Git-Tag: V0_0_4~9 X-Git-Url: http://www.andromeda.nl/gitweb/?p=gnucomo.git;a=commitdiff_plain;h=12e56efac2a1d673bd920393511060dfa33026f1 A base class for all web interface pages --- 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(); + } +}