<?php
-session_start();
-require_once('classes/gnucomo_config.php');
-include "functions.php";
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel='stylesheet' href='gnucomo.css' type='text/css'>
-<title>GNUCoMo login</title>
-</head>
-<body>
-<?php
-if (empty($_SESSION["username"]))
-{
+/**************************************************************************
+** (c) Copyright 2003, Andromeda Technology & Automation
+** This is free software; you can redistribute it and/or modify it under the
+** terms of the GNU General Public License, see the file COPYING.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+** FILE NAME : login.php
+** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
+** VERSION NUMBER : $Revision: 1.3 $
+**
+** DESCRIPTION : The entry page for the Gnucomo web interface
+**
+** EXPORTED OBJECTS :
+** LOCAL OBJECTS :
+** MODULES USED :
+***************************************************************************
+** ADMINISTRATIVE INFORMATION *
+********************************
+** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+** CREATION DATE : Dec 03, 2002
+** LAST UPDATE : Feb 08, 2003
+** MODIFICATIONS :
+**************************************************************************/
+
+/*****************************
+ $Log: login.php,v $
+ Revision 1.3 2003-02-13 09:01:29 arjen
+ All web interface pages use the page class.
-if( isset($_POST["username"]) and isset($_POST["password"]) and isset($_SESSION['login']) )
-{
- $name = $_POST["username"]; // PostgreSQL username
- $passw = $_POST["password"]; // PostgreSQL user password
+******************************/
- $config = new gnucomo_config;
+// RCSID = "$Id: login.php,v 1.3 2003-02-13 09:01:29 arjen Exp $";
- $config->read("gnucomo");
+ini_set('include_path', '.:./classes:../phpclasses');
+require_once('page.class.php');
- // connect to the database
- //echo "Database connection = " . $config->Database($name, $passw) . "<br>";
- $conn = pg_connect($config->Database($name, $passw));
+$login_page = new page("Gnucomo Login");
- if ( !$conn )
- {
- echo "Error connecting, try again.";
- echo login_form();
- }
- else
- {
- $sql = "SELECT * FROM usr WHERE username='$name'";
- $res = pg_exec( $conn, $sql );
- if ($res && pg_numrows($res) == 1)
- {
- echo "<br> Database login OK.<br>";
- session_register('username');
- $_SESSION["username"] = $name;
- session_register('password');
- $_SESSION["password"] = $passw;
- }
- else
- {
- // User not found in database. Check if we have any users at all.
+$login_page->Showpage();
- $res = pg_exec($conn, "SELECT count(username) FROM usr");
- $nusers = pg_fetch_object($res, 0);
- $nusers = $nusers->count;
- if ($nusers == 0)
- {
- echo "<br>No users in database. Authentication granted.<br>";
- session_register('username');
- $_SESSION["username"] = $name;
- session_register('password');
- $_SESSION["password"] = $passw;
- }
- else
- {
- echo "<br>User $name not found in database.<br>";
- }
- }
- }
-}
-else
-{
- echo login_form();
- $_SESSION["login"] = true;
-}
-}
-else
-{
- echo "Logged in as " . $_SESSION['username'] . "<br>";
-}
?>
-</body>
-</html>