2 /**************************************************************************
3 ** (c) Copyright 2003, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 ** FILE NAME : page.class.php
10 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
11 ** VERSION NUMBER : $Revision: 1.2 $
13 ** DESCRIPTION : Base class for Gnucomo web interface pages.
18 ***************************************************************************
19 ** ADMINISTRATIVE INFORMATION *
20 ********************************
21 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 ** CREATION DATE : Jan 22, 2003
23 ** LAST UPDATE : Feb 03, 2003
25 **************************************************************************/
27 /*****************************
28 $Log: page.class.php,v $
29 Revision 1.2 2003-02-13 08:59:52 arjen
30 Use our own error handler for PHP errors and warnings
32 Revision 1.1 2003/02/05 09:38:42 arjen
33 A base class for all web interface pages
35 ******************************/
37 // RCSID = "$Id: page.class.php,v 1.2 2003-02-13 08:59:52 arjen Exp $";
40 require_once('gnucomo_config.php');
42 $last_error = " ";
44 function error($errno, $errstr, $errfile, $errline)
48 $last_error = $errstr;
57 <h1 align="center">GNU Computer Monitoring</h1>
58 <h4 align="center"><i>Version 0.0.5, Februari 08, 2003</i></h4>
60 <h2 class='error'><?php echo $last_error?></h2>
64 <td width='50%'><img src='logo.png' alt='GnoCoMo logo'></td>
65 <td><form name="login" method="POST">
69 <td><input type="text" name="username"></td>
73 <td><input type="password" name="password"></td>
77 <td align="right"><input type="submit" value="signin"></td>
90 var $the_title; // The title used on the page.
91 var $database; // Connection to the database server.
92 var $path; // Directory path to stylesheets and images.
93 var $config; // The XML configuration object.
97 function page($title, $path = "")
99 $this->the_title = $title;
100 $this->database = false;
103 set_error_handler("error");
109 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
110 "http://www.w3.org/TR/html4/loose.dtd">
113 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
114 <meta name="author" content="Arjen Baart">
115 <meta name="expires" content="0">
117 <link rel='stylesheet' href='<?php echo $this->path ?>gnucomo.css' type='text/css'>
118 <title><?php echo $this->the_title ?></title>
126 echo "The default body.";
133 pg_close($this->database);
141 $this->config = new gnucomo_config;
143 $this->config->read("gnucomo");
146 if (empty($_SESSION['username']))
148 // Nobody logged in yet.
150 if (isset($_POST['username']) && isset($_POST['password']))
152 // Login form submitted. Try to start a new session.
154 $name = $_POST['username']; // PostgreSQL username
155 $passw = $_POST['password']; // PostgreSQL user password
157 // Connect to the database
158 $this->database = pg_connect($this->config->Database($name, $passw));
159 if ($this->database == false)
165 session_register('username');
166 $_SESSION['username'] = $name;
167 session_register('password');
168 $_SESSION['password'] = $passw;
175 // Nobody tried to login yet. Present the login form.
181 $name = $_SESSION['username']; // PostgreSQL username
182 $passw = $_SESSION['password']; // PostgreSQL user password
184 // Connect to the database
185 $this->database = pg_connect($this->config->Database($name, $passw));