';
+
+// first load enabled, after that check snmp variable
+$snmp_enabled = !isset($_POST['hostname']) || isset($_POST['snmp']);
+
+if (!empty($_POST['hostname'])) {
$hostname = clean($_POST['hostname']);
if (!is_valid_hostname($hostname) && !IP::isValid($hostname)) {
- print_error('Invalid hostname or IP.');
- $hostname = false;
+ print_error("Invalid hostname or IP: $hostname");
}
-} else {
- $hostname = false;
-}
-$snmp_enabled = isset($_POST['snmp']);
-
-if ($hostname !== false) {
- echo '
-
-
-
';
if ($_SESSION['userlevel'] > '5') {
// Settings common to SNMPv2 & v3
if ($_POST['port']) {
@@ -93,12 +90,12 @@
}
} else {
print_error("You don't have the necessary privileges to add hosts.");
- }//end if
- echo '
-
-
-
';
-}//end if
+ }
+}
+echo '