Sfoglia il codice sorgente

- clean nagios status if disable nagios check
- cosmetic changes

Dmitriev Roman 4 anni fa
parent
commit
36a700f5df

+ 12 - 5
html/admin/devices/editdevice.php

@@ -38,12 +38,14 @@ if (isset($_POST["editdevice"]) and isset($id)) {
         }
     }
     unset($new);
+    if (isset($_POST["f_ip"])) { $new['ip'] = $_POST["f_ip"]; }
+    $cur_device = get_record_sql($db_link,"SELECT * FROM devices WHERE id=".$id);
+    if (!empty($new['ip'])) { $cur_auth = get_record_sql($db_link,"SELECT * FROM User_auth WHERE deleted=0 AND ip='".$new['ip']."'"); }
     if (isset($_POST["f_device_model_id"])) { $new['device_model_id'] = $_POST["f_device_model_id"]*1; }
     if (isset($_POST["f_devtype_id"])) { $new['device_type'] = $_POST["f_devtype_id"]*1; }
     if (isset($_POST["f_comment"])) { $new['comment'] = $_POST["f_comment"]; }
     if (isset($_POST["f_SN"])) { $new['SN'] = $_POST["f_SN"]; }
     if (isset($_POST["f_firmware"])) { $new['firmware'] = $_POST["f_firmware"]; }
-    if (isset($_POST["f_ip"])) { $new['ip'] = substr($_POST["f_ip"], 0, 15); }
     if (isset($_POST["f_snmp_version"])) { $new['snmp_version'] = $_POST["f_snmp_version"] * 1; }
     if (isset($_POST["f_community"])) { $new['community'] = substr($_POST["f_community"], 0, 50); }
     if (isset($_POST["f_rw_community"])) { $new['rw_community'] = substr($_POST["f_rw_community"], 0, 50); }
@@ -60,10 +62,15 @@ if (isset($_POST["editdevice"]) and isset($id)) {
     if (isset($_POST["f_wan"])) { $new['wan_int'] = $_POST["f_wan"]; }
     if (isset($_POST["f_lan"])) { $new['lan_int'] = $_POST["f_lan"]; }
     if (isset($_POST["f_building_id"])) { $new['building_id'] = $_POST["f_building_id"] * 1; }
-    $new['user_id'] = get_user_by_ip($db_link,$new['ip']);
-    if (!isset($new['user_id']) or empty($new['user_id'])) { $new['user_id']=0; }
-    if (isset($_POST["f_nagios"])) { $new['nagios'] = $_POST["f_nagios"] * 1; }
-    if (empty($new['nagios'])) { $new['nagios_status'] = 'UP'; }
+    if (isset($_POST["f_nagios"])) {
+	$new['nagios'] = $_POST["f_nagios"] * 1;
+        if ($new['nagios'] ==0) { $new['nagios_status']='UP'; }
+	} else {
+	if (!empty($cur_auth)) {
+	    $new['nagios']=0;
+	    $new['nagios_status']=$cur_auth['nagios_status'];
+	    }
+	}
     $new['vendor_id'] = get_device_model_vendor($db_link,$new['device_model_id']);
     if (isset($_POST["f_port_count"])) { $new['port_count'] = $sw_ports; }
     update_record($db_link, "devices", "id='$id'", $new);

+ 1 - 0
html/admin/users/editauth.php

@@ -80,6 +80,7 @@ if (isset($_POST["editauth"]) and !$old_auth_info['deleted']) {
                 $new['queue_id'] = $_POST["f_queue_id"] * 1;
                 $new['filter_group_id'] = $_POST["f_group_id"] * 1;
             }
+        if ($new['nagios'] ==0) { $new['nagios_status']='UP'; }
         $changes = get_diff_rec($db_link,"User_auth","id='$id'", $new, 0);
         if (!empty($changes)) { LOG_WARNING($db_link,"Изменен адрес доступа! Список изменений: $changes",$id); }
         if (is_auth_bind_changed($db_link,$id,$ip,$mac)) {

+ 6 - 4
html/admin/users/edituser.php

@@ -186,23 +186,25 @@ if (!empty($_SESSION[$page_url]['msg'])) {
 <tr>
 <td colspan=2><?php print $cell_perday; ?></td>
 <td colspan=2><?php print $cell_permonth; ?></td>
-<td colspan=2><?php print $cell_blocked; ?></td>
+<td><?php print $cell_blocked; ?></td>
+<td><?php print $cell_enabled; ?></td>
 </tr>
 <tr>
 <td colspan=2><input type="text" name="f_perday" value="<?php echo $user_info["day_quota"]; ?>" size=5></td>
 <td colspan=2><input type="text" name="f_permonth" value="<?php echo $user_info["month_quota"]; ?>" size=5></td>
-<td colspan=2><?php print_qa_select('f_blocked', $user_info["blocked"]); ?></td>
+<td ><?php print_qa_select('f_blocked', $user_info["blocked"]); ?></td>
+<td ><?php print_qa_select('f_enabled', $user_info["enabled"]); ?></td>
 </tr>
 <tr><td class=data colspan=6>Параметры для автоназначенных адресов:</td></tr>
 <tr>
 <td colspan=2><?php print $cell_filter; ?></td>
 <td colspan=2><?php print $cell_shaper; ?></td>
-<td colspan=2><?php print $cell_enabled; ?></td>
+<td colspan=2></td>
 </tr>
 <tr>
 <td colspan=2><?php print_group_select($db_link, 'f_filter', $user_info["filter_group_id"]); ?></td>
 <td colspan=2><?php print_queue_select($db_link, 'f_queue', $user_info["queue_id"]); ?></td>
-<td colspan=2><?php print_qa_select('f_enabled', $user_info["enabled"]); ?></td>
+<td colspan=2></td>
 </tr>
 <tr>
 <?php