make addhost from the webinterface work correctly

git-svn-id: http://www.observium.org/svn/observer/trunk@2646 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-10-05 09:32:34 +00:00
parent 86c65da8aa
commit 83f335785b
3 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -13,11 +13,20 @@ if ($_POST['hostname'])
if ($_SESSION['userlevel'] > '5')
{
$hostname = mres($_POST['hostname']);
if ($_POST['community']) { $community = mres($_POST['community']); } else { $community = $config['snmp']['community']; }
if ($_POST['community'])
{
$config['snmp']['community'] = array($_POST['community']);
}
$snmpver = mres($_POST['snmpver']);
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
print_message("Adding host $hostname community $community port $port");
$result = addHost($hostname, $community, $snmpver, $port);
print_message("Adding host $hostname communit" . (count($config['snmp']['community']) == 1 ? "y" : "ies") . " " . implode(', ',$config['snmp']['community']) . " port $port");
$result = addHost($hostname, $snmpver, $port);
if ($result)
{
print_message("Device added ($result)");
}
} else {
print_error("You don't have the necessary privileges to add hosts.");
}