Location: PHPKode > projects > Limph > limph-1.9.7/agent.php
<?php
 /*
   Limph Is Monitoring Pingable Hosts
   Copyright (C) 2005 Jonathan Ciesla
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
require_once("config.php");
require_once("functionlib.php");
echo "<html><head><title>$sitetitle</title></head>";
echo "<body><h1>$sitetitle: User Manager</h1>";
session_start();
favicon();

$link = dbms_connect($dbhost, $dbuser, $dbpass, $dbname);

$user_id = dbms_escape_string($_SESSION['limphid']);

$admin_level =$_SESSION['limphadmin'];
authentication($admin_level,1);

echo "<link rel=stylesheet href=css.php>";

$updatedel = $_POST['updatedel'];
if($updatedel=="yes"){
  $num = $_POST['num'];
  $query = "DELETE FROM users WHERE number = '$num';";
  $result = dbms_query($query);
  $query = "DELETE FROM host_notif WHERE user = '$num';";
  $result = dbms_query($query);

 };

$updateadd = $_POST['updateadd'];
if($updateadd=="yes"){
  $query = "SELECT number FROM users ORDER BY number DESC LIMIT 1;";
  $result = dbms_query($query);
  $line = dbms_fetch_array($result, "NUM");
  dbms_free_result($result);
  $num = $line[0];
  $num++;

  $id = $_POST['id'];
  $new1 = $_POST['new1'];
  $new2 = $_POST['new2'];
  $admin = $_POST['admin'];
  $email = $_POST['email'];

  $salt = substr($id, 0, 2);

  $id = dbms_escape_string($id);
  $new1 = dbms_escape_string($new1);
  $new2 = dbms_escape_string($new2);
  $email = dbms_escape_string($email);
  if (($new1 == $new2)&&($id)) {
    $insert = crypt($new1, $salt);
    $insert = dbms_escape_string($insert);
    $query = "INSERT INTO users (number,id,pass,admin,email) VALUES ('$num','$id','$insert','$admin','$email')";
    $result = dbms_query($query);
  };
};

echo "<form action=index.php method=post>";
echo "<input type=submit value=Back />";
echo "</form>";
echo "<table border=1 align=center>";
echo "<tr>";
echo "<td align=center>";

echo "<h4>Create new user</h4>";
echo "<form action=agent.php method=post>";
echo "<table border=1 align=center><tr><td align=right>";
echo "Enter ID:<input type=text name=id /><br />";
echo "Enter new password:<input type=password name=new1 /><br />";
echo "Confirm new password:<input type=password name=new2 /><br />";
echo "</td><td align=right>";
echo "Admin level:0<input type=radio name=admin value=0 checked>";
echo "1<input type=radio name=admin value=1>";
echo "</td><td>";
echo "Email:<input type=text name=email /><br />";
echo "<input type=hidden name=updateadd value=yes>";
echo "</td></tr></table>";
echo "<input type=submit value=Submit /><br /></form><br />";

echo "</td>";
echo "</tr>";

echo "<tr><td colspan=2 align=center>";

echo "<h4>Current user list</h4>";

$query = "SELECT number,id,admin,email,notify,digest FROM users ORDER BY id ASC;";
$result = dbms_query($query);


echo "<table border=1 cellpadding=5>";
echo "<tr><th>#</th><th>ID</th><th>Admin</th><th>Notify</th><th>Digest</th><th>Email</th><th>Edit</th><th>Delete</th></tr>";
                
while ($line = dbms_fetch_array($result, "ASSOC")) {
        echo "<tr>";
	echo "<td>{$line['number']}</td>";
	echo "<td>{$line['id']}</td>";
	echo "<td>{$line['admin']}</td>";
	echo "<td>{$line['notify']}</td>";
	echo "<td>{$line['digest']}</td>";
	echo "<td>{$line['email']}</td>";
	echo "<td>";
	echo "<form action=edit_agent.php method=post>";
	echo "<input type=hidden name=num value=\"{$line['number']}\">";
	echo "<input type=submit value=Edit>";
	echo "</form>";
	echo "</td>";
	echo "<td>";
	echo "<form action=agent.php method=post>";
	echo "<input type=hidden name=updatedel value=yes>";
	echo "<input type=hidden name=num value=\"{$line['number']}\">";
	echo "<input type=submit value=Delete>";
	echo "</form>";
	echo "</td>";
        echo "</tr>";
}
echo "</table>";

dbms_free_result($result);
dbms_close($link);

echo "</td></tr>";
echo "</table>";

echo "<form action=index.php method=post>";
echo "<input type=submit value=Back />";
echo "</form>";
?>
Return current item: Limph