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.1 $
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.1 2003-02-05 09:38:42 arjen
30 A base class for all web interface pages
32 ******************************/
34 // RCSID = "$Id: page.class.php,v 1.1 2003-02-05 09:38:42 arjen Exp $";
37 require_once('gnucomo_config.php');
43 <h1 align="center">GNU Computer Monitoring</h1>
44 <h4 align="center"><i>Version 0.0.4, Februari 05, 2003</i></h4>
47 <td width='50%'><img src='logo.png' alt='GnoCoMo logo'></td>
48 <td><form name="login" method="POST">
52 <td><input type="text" name="username"></td>
56 <td><input type="password" name="password"></td>
60 <td align="right"><input type="submit" value="signin"></td>
73 var $the_title; // The title used on the page.
74 var $database; // Connection to the database server.
75 var $path; // Directory path to stylesheets and images.
76 var $config; // The XML configuration object.
80 function page($title, $path = "")
82 $this->the_title = $title;
83 $this->database = false;
91 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
92 "http://www.w3.org/TR/html4/loose.dtd">
95 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
96 <meta name="author" content="Arjen Baart">
97 <meta name="expires" content="0">
99 <link rel='stylesheet' href='<?php echo $this->path ?>gnucomo.css' type='text/css'>
100 <title><?php echo $this->the_title ?></title>
108 echo "The default body.";
115 pg_close($this->database);
123 $this->config = new gnucomo_config;
125 $this->config->read("gnucomo");
128 if (empty($_SESSION['username']))
130 // Nobody logged in yet.
132 if (isset($_POST['username']) && isset($_POST['password']))
134 // Login form submitted. Try to start a new session.
136 $name = $_POST['username']; // PostgreSQL username
137 $passw = $_POST['password']; // PostgreSQL user password
139 // Connect to the database
140 $this->database = pg_connect($this->config->Database($name, $passw));
141 if ($this->database == false)
147 session_register('username');
148 $_SESSION['username'] = $name;
149 session_register('password');
150 $_SESSION['password'] = $passw;
157 // Nobody tried to login yet. Present the login form.
163 $name = $_SESSION['username']; // PostgreSQL username
164 $passw = $_SESSION['password']; // PostgreSQL user password
166 // Connect to the database
167 $this->database = pg_connect($this->config->Database($name, $passw));