diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 8e1b227f8..f2c4b58fc 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -372,7 +372,7 @@ function humanspeed($speed) function print_error($text) { - echo('
'.$text.'
'); + echo('
'.$text.'
'); } function print_message($text) diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index 56f9839b1..2b0a6ab2f 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -8,12 +8,12 @@ if ($_SESSION['userlevel'] < 10) echo("

Add Device

"); -if ($_POST['hostname'] && $_POST['community']) +if ($_POST['hostname']) { if ($_SESSION['userlevel'] > '5') { $hostname = mres($_POST['hostname']); - $community = mres($_POST['community']); + if ($_POST['community']) { $community = mres($_POST['community']); } else { $community = $config['snmp']['community']; } $snmpver = mres($_POST['snmpver']); if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; } print_message("Adding host $hostname community $community port $port"); @@ -21,10 +21,6 @@ if ($_POST['hostname'] && $_POST['community']) } else { print_error("You don't have the necessary privileges to add hosts."); } -} elseif ($_POST['hostname'] && !$_POST['community']) { - print_error("A community string is required."); -} elseif (!$_POST['hostname'] && $_POST['community']) { - print_error("A hostname is required."); } ?> diff --git a/includes/functions.php b/includes/functions.php index 0d9138e16..e6ceb8eeb 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -190,10 +190,10 @@ function addHost($host, $community, $snmpver, $port = 161, $transport = 'udp') if ($snmphost == $host || $hostshort = $host) { createHost($host, $community, $snmpver, $port, $transport); - } else { echo("Given hostname does not match SNMP-read hostname!\n"); } - } else { echo("Already got host $host\n"); } - } else { echo("Could not ping $host\n"); } - } else { echo("Could not resolve $host\n"); } + } else { print_error("Given hostname does not match SNMP-read hostname!\n"); } + } else { print_error("Already got host $host\n"); } + } else { print_error("Could not ping $host\n"); } + } else { print_error("Could not resolve $host\n"); } } function scanUDP($host, $port, $timeout)