2 /**************************************************************************
3 ** This is free software; you can redistribute it and/or modify it under the
4 ** terms of the GNU General Public License, see the file COPYING.
5 ***************************************************************************/
6 /******************************************************************************************/
7 /* global parameters */
8 /******************************************************************************************/
9 //$pgsqlhost = "10.10.10.145"; // PostgreSQL server
10 //$pgsqlport = "5432"; // PostgreSQL port
11 //$dbname = "gnucomo"; // PostgreSQL database name
13 /******************************************************************************************/
14 /* string function login_form( void ) */
16 /* returns the login form */
17 /******************************************************************************************/
18 function login_form() {
20 $login = "<div class='login'>";
21 $login .= "<h1 align=\"center\">GNU Computer Monitoring</h1>";
22 $login .= "<h4 align=\"center\"><i>Version 0.0.4, Februari 05, 2003</i></h4>";
23 $login .= "<center><table>";
25 $login .= "<td width='50%'><img src='logo.png' alt='GnuCoMo logo'></td>";
26 $login .= "<td><form name=\"login\" method=\"POST\" action=\"login.php\">";
29 $login .= " <td>Username</td>";
30 $login .= " <td><input type=\"text\" name=\"username\"></td>";
33 $login .= " <td>Password</td>";
34 $login .= " <td><input type=\"password\" name=\"password\"></td>";
37 $login .= " <td> </td>";
38 $login .= " <td align=\"right\"><input type=\"submit\" value=\"signin\"></td>";
40 $login .= " </table>";
44 $login .= "</table></center>";
50 /******************************************************************************************/
51 /* array function query( resource connection, string sqlquery ) */
53 /* gives an array return. */
54 /* arr[0] = boolean if action completed whitout error, return true otherwise false */
55 /* arr[1] = result sql query result */
56 /* arr[2] = int number of rows */
57 /* arr[3] = string error information */
58 /******************************************************************************************/
59 function query( $conn, $sql ) {
61 $query_result = pg_exec( $conn, $sql );
63 if( $query_result != FALSE ) {
64 $query_nRows = pg_NumRows($query_result);
65 $query_error = pg_errormessage( $conn );
66 return array( TRUE, $query_result, $query_nRows, "" );
68 $query_error = @pg_errormessage( $conn );
69 return array( FALSE, $query_result, 0, $query_error );
73 /******************************************************************************************/
74 /* void function pgsql_error( string error ) */
76 /* prints an error message */
77 /******************************************************************************************/
78 function pgsql_error( $err ) {
79 echo "An error occured. Please contact your systemadministrator.<br>";