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 .= "<center><table>";
24 $login .= "<td width='50%'><img src='../doc/logo.png' alt='GnuCoMo logo'></td>";
25 $login .= "<td><form name=\"login\" method=\"POST\" action=\"login.php\">";
28 $login .= " <td>Username</td>";
29 $login .= " <td><input type=\"text\" name=\"username\"></td>";
32 $login .= " <td>Password</td>";
33 $login .= " <td><input type=\"password\" name=\"password\"></td>";
36 $login .= " <td> </td>";
37 $login .= " <td align=\"right\"><input type=\"submit\" value=\"signin\"></td>";
39 $login .= " </table>";
43 $login .= "</table></center>";
49 /******************************************************************************************/
50 /* array function query( resource connection, string sqlquery ) */
52 /* gives an array return. */
53 /* arr[0] = boolean if action completed whitout error, return true otherwise false */
54 /* arr[1] = result sql query result */
55 /* arr[2] = int number of rows */
56 /* arr[3] = string error information */
57 /******************************************************************************************/
58 function query( $conn, $sql ) {
60 $query_result = pg_exec( $conn, $sql );
62 if( $query_result != FALSE ) {
63 $query_nRows = pg_NumRows($query_result);
64 $query_error = pg_errormessage( $conn );
65 return array( TRUE, $query_result, $query_nRows, "" );
67 $query_error = @pg_errormessage( $conn );
68 return array( FALSE, $query_result, 0, $query_error );
72 /******************************************************************************************/
73 /* void function pgsql_error( string error ) */
75 /* prints an error message */
76 /******************************************************************************************/
77 function pgsql_error( $err ) {
78 echo "An error occured. Please contact your systemadministrator.<br>";