Location: PHPKode > projects > Network Traffic Monitor > online/edituser.php
<?php

#Network Traffic Monitor is an application to monitor the network traffic on all SNMP managable devices.
#
#Copyright (c) 2004, Daimler Trust nv <hide@address.com> - Jan Van Hees <hide@address.com>
# 
#This file is part of Network Traffic Monitor.
#
#    Network Traffic Monitor 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.
#
#    Network Traffic Monitor 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 Network Traffic Monitor; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
/*
* This script provides a user interface to Edit users 
*/
require_once("../auth.php");
require_once ("../config.php");
require_once ("HTML/Template/IT.php");
require_once "HTML/Table.php";
if($_POST['port']){
	header("Location: error.php");
	exit;
}
$db = dbLogin();


$tpl = new HTML_Template_IT(TEMPLATEDIR);
$tpl->loadTemplatefile("adduser.tpl");
$tpl->setVariable("title","Edit User");
$tpl->setVariable("action","edit.php");

$ui=$_GET['u'];


$sql = "SELECT users.username, users.fullname, users.email, groups.groupname, company.compname, users.tid, users.uid, groups.gid, company.cid, users.passwd, users.uid FROM company
	INNER JOIN users ON users.cid = company.cid
	INNER JOIN groupmember ON groupmember.uid = users.uid
	INNER JOIN groups ON groups.gid = groupmember.gid 
	WHERE users.uid=$ui ORDER BY users.username"; 

	$temp = $db->query($sql);
	$i = 0;
	while ($row = $temp->fetchrow()){
		$uname = $row[0];
		$fullname = $row[1];
		$mail = $row[2];
		$group = $row[3];
		$gid = $row[7];
		$cid = $row[8];
		$tid = $row[5];
		$passwd = $row[9];
		$ui=$row[10];
	}//while fetchrow

	$sql = "SELECT groups.gid, groups.groupname FROM groups ORDER BY groups.groupname";

	$result = $db->query($sql);
	
	// Get each row of data on each iteration until
	// there are no more rows
	while ($row = $result->fetchRow()){
		if ($row[0]==$gid) $selected="selected";
		else $selected="";
    		$combobox .= "<option value=\"$row[0]\" $selected>$row[1]</option>";
	}

	$sqlC = "SELECT company.cid, company.compname FROM company ORDER BY company.compname";

	$res = $db->query($sqlC);

	// Get each row of data on each iteration until
	// there are no more rows
	while ($row = $res->fetchRow()){
		if ($row[0]==$cid) $selected="selected";
		else $selected="";
    		$combo .= "<option value=\"$row[0]\" $selected>$row[1]</option>";
	}

	$sqlU = "SELECT tid, type FROM usertype";

	$res = $db->query($sqlU);
	
	// Get each row of data on each iteration until
	// there are no more rows
	while ($row = $res->fetchRow()){
    		if($tid==$row[0])$selected="selected";
		else $selected="";
		$comb .= "<option value=\"$row[0]\" $selected >$row[1]</option>";
	}



	
	$tpl->setVariable("groupoptions", $combobox);
	$tpl->setVariable("compoptions", $combo);
	$tpl->setVariable("usertype", $comb);
	$tpl->setVariable("uid", $ui);
	$tpl->setVariable("mail", $mail);
	$tpl->setVariable("fullname", $fullname);
	$tpl->setVariable("name",$uname);
	$tpl->setVariable("pass",$passwd);

$content = $tpl->get();

fillFrame($db, $content);

dblogout($db);

?>  
Return current item: Network Traffic Monitor