<?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 takes care of Editting All objects
*/
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;
}
$what = $_POST['what'];
$db = dbLogin();
$tpl = new HTML_Template_IT(TEMPLATEDIR);
$tpl->loadTemplatefile("basic.tpl");
switch ($what){
case 'firm':{
$tpl->setVariable("title","Firms");
$cname = $_POST['cname'];
$addr = $_POST['addr'];
$btw = $_POST['btw'];
$cid = $_POST['cid'];
$sql = "UPDATE company SET address='$addr', compname='$cname', btw='$btw' WHERE cid='$cid'";
$script="firms.php";
}//case firm
break;
case 'group':{
$tpl->setVariable("title","Groups");
$gname = $_POST['gname'];
$gid = $_POST['gid'];
$sql = "UPDATE groups SET groupname='$gname' WHERE gid='$gid'";
$script="groups.php";
}//case group
break;
case 'device':{
$tpl->setVariable("title","Devices");
$dname = $_POST['dname'];
$host = $_POST['host'];
$pass = $_POST['pass'];
$did = $_POST['did'];
$sql = "UPDATE devices SET devicename='$dname', host='$host', community='$pass' WHERE did='$did'";
$script="switch.php";
}//case device
break;
case 'user':{
$tpl->setVariable("title", "Users");
$uname = $_POST['uname'];
$group = $_POST['group'];
$comp = $_POST['comp'];
$pass = $_POST['pass'];
$fullname = $_POST['fullname'];
$mail = $_POST['mail'];
$tid = $_POST['tid'];
$uid = $_POST['uid'];
$sql = "UPDATE users set username='$uname', cid='$comp', passwd='$pass', fullname='$fullname',email='$mail',tid='$tid' where users.uid='$uid'";
$script="userlist.php";
}//case user
break;
case 'port':{
$tpl->setVariable("title", "Ports");
$gid = $_POST['group'];
$did = $_POST['device'];
$pname = $_POST['pname'];
$pnum = $_POST['pnum'];
$speed = $_POST['speed'];
$pid=$_POST['pid'];
$tp=$_POST['burst'];
if($tp=='on')$burst="true";
else $burst="false";
$sql = "UPDATE ports SET portnr='$pnum', portname='$pname', speed=$speed, did='$did' , burstable='$burst' WHERE pid='$pid'; UPDATE portgroups SET gid=$gid WHERE pid=$pid;";
$script="devices.php";
}//case port
break;
case 'usertype':{
$tpl->setVariable("title", "User Type");
$tid=$_POST['tid'];
$type=$_POST['type'];
$sql = "UPDATE usertype SET type='$type' WHERE tid='$tid'";
$script="userlist.php";
}//case usertype
break;
case 'speed':{
$tpl->setVariable("title", "Speed");
$spid=$_POST['spid'];
$mbit=$_POST['mbit'];
$speed = $mbit * 1048576;
$sql = "UPDATE speed SET mbit='$mbit', speed='$speed' WHERE spid='$spid'";
$script="bandwith.php";
}//case speed
default:{
$tpl->setVariable("data","Default...");
}
}//
//execute query, give error message back if error occurs
$error = $db->query($sql) or die;
if($error != 1){
$tpl->setVariable("data", $error->getMessage());
}//if error
else{
$tpl->setVariable("data", "Edit completed");
header("Location: $script");
exit();
}//else
$tpl->setVariable("add", $sql);
$content = $tpl->get();
fillFrame($db, $content);
dblogout($db);
?>