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.4 $
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.4 2003-07-15 11:05:32 arjen
30 Chnaged version number to 0.0.6 in login form.
32 Revision 1.3 2003/02/19 09:12:27 arjen
33 Added the 'form' class on table and td elements. This class is intended
34 for borderless tables that are used to layout HTML forms.
36 Revision 1.2 2003/02/13 08:59:52 arjen
37 Use our own error handler for PHP errors and warnings
39 Revision 1.1 2003/02/05 09:38:42 arjen
40 A base class for all web interface pages
42 ******************************/
44 // RCSID = "$Id: page.class.php,v 1.4 2003-07-15 11:05:32 arjen Exp $";
47 require_once('gnucomo_config.php');
49 $last_error = " ";
51 function error($errno, $errstr, $errfile, $errline)
55 $last_error = $errstr;
64 <h1 align="center">GNU Computer Monitoring</h1>
65 <h4 align="center"><i>Version 0.0.6, July 15, 2003</i></h4>
67 <h2 class='error'><?php echo $last_error?></h2>
69 <center><table class='form'>
71 <td width='50%' class='form'>
72 <a href='http://gnucomo.org/' target='_top'><img src='logo.png' alt='GnoCoMo logo'></a></td>
73 <td class='form'><form name="login" method="POST">
76 <td class='form'>Username</td>
77 <td class='form'><input type="text" name="username"></td>
80 <td class='form'>Password</td>
81 <td class='form'><input type="password" name="password"></td>
84 <td class='form'> </td>
85 <td align="right" class='form'><input type="submit" value="signin"></td>
98 var $the_title; // The title used on the page.
99 var $database; // Connection to the database server.
100 var $path; // Directory path to stylesheets and images.
101 var $config; // The XML configuration object.
105 function page($title, $path = "")
107 $this->the_title = $title;
108 $this->database = false;
111 set_error_handler("error");
117 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
118 "http://www.w3.org/TR/html4/loose.dtd">
121 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
122 <meta name="author" content="Arjen Baart">
123 <meta name="expires" content="0">
125 <link rel='stylesheet' href='<?php echo $this->path ?>gnucomo.css' type='text/css'>
126 <title><?php echo $this->the_title ?></title>
134 echo "The default body.";
141 pg_close($this->database);
149 $this->config = new gnucomo_config;
151 $this->config->read("gnucomo");
154 if (empty($_SESSION['username']))
156 // Nobody logged in yet.
158 if (isset($_POST['username']) && isset($_POST['password']))
160 // Login form submitted. Try to start a new session.
162 $name = $_POST['username']; // PostgreSQL username
163 $passw = $_POST['password']; // PostgreSQL user password
165 // Connect to the database
166 $this->database = pg_connect($this->config->Database($name, $passw));
167 if ($this->database == false)
173 session_register('username');
174 $_SESSION['username'] = $name;
175 session_register('password');
176 $_SESSION['password'] = $passw;
183 // Nobody tried to login yet. Present the login form.
189 $name = $_SESSION['username']; // PostgreSQL username
190 $passw = $_SESSION['password']; // PostgreSQL user password
192 // Connect to the database
193 $this->database = pg_connect($this->config->Database($name, $passw));