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.3 $
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 19, 2003
25 **************************************************************************/
27 /*****************************
28 $Log: page.class.php,v $
29 Revision 1.3 2003-02-19 09:12:27 arjen
30 Added the 'form' class on table and td elements. This class is intended
31 for borderless tables that are used to layout HTML forms.
33 Revision 1.2 2003/02/13 08:59:52 arjen
34 Use our own error handler for PHP errors and warnings
36 Revision 1.1 2003/02/05 09:38:42 arjen
37 A base class for all web interface pages
39 ******************************/
41 // RCSID = "$Id: page.class.php,v 1.3 2003-02-19 09:12:27 arjen Exp $";
44 require_once('gnucomo_config.php');
46 $last_error = " ";
48 function error($errno, $errstr, $errfile, $errline)
52 $last_error = $errstr;
61 <h1 align="center">GNU Computer Monitoring</h1>
62 <h4 align="center"><i>Version 0.0.5, February 21, 2003</i></h4>
64 <h2 class='error'><?php echo $last_error?></h2>
66 <center><table class='form'>
68 <td width='50%' class='form'>
69 <a href='http://gnucomo.org/' target='_top'><img src='logo.png' alt='GnoCoMo logo'></a></td>
70 <td class='form'><form name="login" method="POST">
73 <td class='form'>Username</td>
74 <td class='form'><input type="text" name="username"></td>
77 <td class='form'>Password</td>
78 <td class='form'><input type="password" name="password"></td>
81 <td class='form'> </td>
82 <td align="right" class='form'><input type="submit" value="signin"></td>
95 var $the_title; // The title used on the page.
96 var $database; // Connection to the database server.
97 var $path; // Directory path to stylesheets and images.
98 var $config; // The XML configuration object.
102 function page($title, $path = "")
104 $this->the_title = $title;
105 $this->database = false;
108 set_error_handler("error");
114 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
115 "http://www.w3.org/TR/html4/loose.dtd">
118 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
119 <meta name="author" content="Arjen Baart">
120 <meta name="expires" content="0">
122 <link rel='stylesheet' href='<?php echo $this->path ?>gnucomo.css' type='text/css'>
123 <title><?php echo $this->the_title ?></title>
131 echo "The default body.";
138 pg_close($this->database);
146 $this->config = new gnucomo_config;
148 $this->config->read("gnucomo");
151 if (empty($_SESSION['username']))
153 // Nobody logged in yet.
155 if (isset($_POST['username']) && isset($_POST['password']))
157 // Login form submitted. Try to start a new session.
159 $name = $_POST['username']; // PostgreSQL username
160 $passw = $_POST['password']; // PostgreSQL user password
162 // Connect to the database
163 $this->database = pg_connect($this->config->Database($name, $passw));
164 if ($this->database == false)
170 session_register('username');
171 $_SESSION['username'] = $name;
172 session_register('password');
173 $_SESSION['password'] = $passw;
180 // Nobody tried to login yet. Present the login form.
186 $name = $_SESSION['username']; // PostgreSQL username
187 $passw = $_SESSION['password']; // PostgreSQL user password
189 // Connect to the database
190 $this->database = pg_connect($this->config->Database($name, $passw));