فهرست منبع

some bugfixes and mistakes

Dmitriev Roman 5 سال پیش
والد
کامیت
53d4540f20

+ 1 - 1
html/admin/customers/control-options.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];
     if (!empty($fid)) {
-        while (list ($key, $val) = @each($fid)) {
+        foreach ($fid as $key => $val) {
             if (isset($val) and $val != 1) {
                 LOG_INFO($db_link, "Remove config option id: $val");
                 delete_record($db_link, "config", "id=" . $val);

+ 1 - 1
html/admin/customers/control-subnets.php

@@ -6,7 +6,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
     if (!empty($s_id)) {
-        while (list ($key, $val) = @each($s_id)) {
+        foreach ($s_id as $key => $val) {
             if (isset($val)) {
                 LOG_INFO($db_link, "Remove subnet id: $val");
                 delete_record($db_link, "subnets", "id=" . $val);

+ 1 - 1
html/admin/customers/control.php

@@ -59,7 +59,7 @@ if (isset($_POST["not_save_traf_all"]) and get_option($db_link, 23)) {
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
-    while (list ($key, $val) = @each($s_id)) {
+    foreach ($s_id as $key => $val) {
         if (isset($val)) {
             LOG_INFO($db_link, "Remove subnet id: $val");
             delete_record($db_link, "subnets", "id=" . $val);

+ 1 - 1
html/admin/customers/index.php

@@ -25,7 +25,7 @@ if (isset($_POST["create"])) {
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["fid"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if ($val) {
             LOG_INFO($db_link, "Удаляем менеджера с id: $val");
             delete_record($db_link, "Customers", "id=" . $val);

+ 2 - 2
html/admin/devices/building.php

@@ -4,7 +4,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if (isset($val) and $val > 1) {
             LOG_INFO($db_link,'Удаляем расположение с id: '.$val);
             delete_record($db_link, "building", "id=" . $val);
@@ -82,7 +82,7 @@ foreach ($t_building as $row) {
 <td align="right"></td>
 </tr>
 </table>
-</form>
+</form>
 <?
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
 ?>

+ 1 - 1
html/admin/devices/edit_l3int.php

@@ -9,7 +9,7 @@ $device_info = get_record_sql($db_link, $sSQL);
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
-    while (list ($key, $val) = @each($s_id)) {
+    foreach ($s_id as $key => $val) {
         if (isset($val)) {
             LOG_INFO($db_link, "Remove l3_interface id: $val");
             delete_record($db_link, "device_l3_interfaces", "id=" . $val);

+ 2 - 2
html/admin/devices/index.php

@@ -23,7 +23,7 @@ if (isset($_POST["create"])) {
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["fid"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if ($val) {
             LOG_INFO($db_link, "Delete device id: $val");
             unbind_ports($db_link, $val);
@@ -95,7 +95,7 @@ foreach ($switches as $row) {
     print "<td class=\"$cl\">" . get_qa($row['nagios']) . "</td>\n";
     print "<td class=\"$cl\">" . get_qa($row['discovery']) . "</td>\n";
 }
-?>
+?>
 </table>
 <table class="data">
 <tr align=left>

+ 1 - 1
html/admin/devices/switchport-conn.php

@@ -7,7 +7,7 @@ $switch=get_record($db_link,'devices',"id=".$id);
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if (isset($val) and $val != 1) {
                 LOG_INFO($db_link, "Remove connection id: $val");
                 delete_record($db_link, "connections", "id=" . $val);

+ 3 - 3
html/admin/devices/switchstatus.php

@@ -65,8 +65,8 @@ if ($switch['snmp_version']>0) {
             if ($switch['snmp_version'] == 2) {
 	        $modules_oids = snmp2_real_walk($switch['ip'], $switch['community'], $cisco_modules);
 	    }
-            if ($switch[snmp_version] == 1) {
-	        $modules_oids = snmpreal_walk($switch['ip'], $switch['community'], $cisco_modules);
+            if ($switch['snmp_version'] == 1) {
+	        $modules_oids = snmprealwalk($switch['ip'], $switch['community'], $cisco_modules);
 	    }
 	}
     } else { $snmp_ok = 0; }
@@ -127,7 +127,7 @@ if ($switch['snmp_version']>0) {
         print "</td>\n";
         print "<td class=\"$cl\">" . $d_comment . "</td>\n";
         if ($snmp_ok) {
-            if ($switch[fdb_snmp_index]) {
+            if ($switch['fdb_snmp_index']) {
                 $vlan = get_port_vlan($d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);
             } else {
                 $vlan = get_port_vlan($d_port, $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);

+ 2 - 2
html/admin/filters/editgroup.php

@@ -22,7 +22,7 @@ if (isset($_POST["addfilter"])) {
 
 if (isset($_POST["removefilter"])) {
     $fgid = $_POST["fgid"];
-    while (list ($key, $val) = @each($fgid)) {
+    foreach ($fgid as $key => $val) {
         if ($val) {
             delete_record($db_link, "Group_filters", "id=" . $val * 1);
         }
@@ -34,7 +34,7 @@ if (isset($_POST["saveorder"])) {
         $fgid = $_POST["fgid"];
         $ford = $_POST["ford"];
         LOG_DEBUG($db_link, "Resort filter rules for group id: $id");
-        while (list ($key, $val) = @each($ford)) {
+        foreach ($ford as $key => $val) {
             $gid = $fgid[$key];
             $new['order'] = $val;
             update_record($db_link, "Group_filters", "id=" . $gid, $new);

+ 1 - 1
html/admin/filters/index.php

@@ -18,7 +18,7 @@ if (isset($_POST["create"])) {
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["fid"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if ($val) {
             delete_record($db_link, "Group_filters", "filter_id=$val");
             delete_record($db_link, "Filter_list", "id=$val");

+ 1 - 1
html/admin/groups/index.php

@@ -4,7 +4,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . $language . ".php");
 
 if (isset($_POST["remove"])) {
     $fid = $_POST["f_id"];
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if (isset($val) and $val > 0) {
             $new['ou_id'] = 0;
             update_record($db_link, "User_list", "ou_id=" . $val, $new);

+ 1 - 1
html/admin/iplist/doubles.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 
 if (isset($_POST["removeauth"])) {
     $auth_id = $_POST["f_auth_id"];
-    while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
         if ($val) {
                 delete_record($db_link, 'connections', "auth_id=" . $val);
                 delete_record($db_link, 'User_auth_alias', "auth_id=" . $val);

+ 1 - 1
html/admin/users/edit_alias.php

@@ -13,7 +13,7 @@ $auth_info = get_record_sql($db_link, $sSQL);
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
-    while (list ($key, $val) = @each($s_id)) {
+    foreach ($s_id as $key => $val) {
         if (isset($val)) {
             LOG_INFO($db_link, "Remove alias id: $val");
             delete_record($db_link, "User_auth_alias", "id=" . $val);

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

@@ -64,7 +64,7 @@ if (isset($_POST["addauth"])) {
 
 if (isset($_POST["removeauth"])) {
     $auth_id = $_POST["f_auth_id"];
-    while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
         if ($val) {
             delete_record($db_link, 'connections', "auth_id=" . $val);
             delete_record($db_link, 'User_auth_alias', "auth_id=" . $val);
@@ -85,7 +85,7 @@ if (isset($_POST["ApplyForAll"])) {
     $a_month = $_POST["a_month_q"] * 1;
     $a_queue = $_POST["a_queue_id"] * 1;
     $a_group = $_POST["a_group_id"] * 1;
-    while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
         if ($val) {
             unset($new);
             if ($default_user_id == $id or $hotspot_user_id == $id) {
@@ -114,7 +114,7 @@ if (isset($_POST["moveauth"]) and isset($_POST["new_parent"])) {
     $auth_id = $_POST["f_auth_id"];
     if ($new_user_id <> $id) {
 	$user_rec = get_record($db_link, 'User_list', "id=".$new_user_id);
-        while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
 	    if ($val) {
         	$new["filter_group_id"]=$user_rec["filter_group_id"];
 	        $new["queue_id"] = $user_rec["queue_id"];
@@ -132,7 +132,7 @@ if (isset($_POST["moveauth"]) and isset($_POST["new_parent"])) {
 if (isset($_POST["new_user"])) {
     $auth_id = $_POST["f_auth_id"];
     $save_traf = get_option($db_link, 23) * 1;
-    while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
         if ($val) {
             $flist = mysqli_query($db_link, "SELECT ip, comments, dns_name, dhcp_hostname from User_auth WHERE id=$val");
             list ($f_auth_ip, $f_auth_comments, $f_dns_name, $f_dhcp_name) = mysqli_fetch_array($flist);

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

@@ -36,7 +36,7 @@ if (isset($_POST["ApplyForAll"])) {
     $a_queue = $_POST["a_queue_id"] * 1;
     $a_group = $_POST["a_group_id"] * 1;
     $msg="Массовое изменение пользователей!";
-    while (list ($key, $val) = @each($auth_id)) {
+    foreach ($auth_id as $key => $val) {
         if ($val) {
             unset($auth);
             unset($user);
@@ -63,11 +63,9 @@ if (isset($_POST["remove"])) {
     if (! isset($default_user_id)) {
         $default_user_id = 1;
     }
-    while (list ($key, $val) = @each($fid)) {
+    foreach ($fid as $key => $val) {
         if ($val) {
-            if ($val == 1) {
-                continue;
-            }
+            if ($val == 1) { continue; }
             $auth['user_id'] = $default_user_id;
             $changes = get_diff_rec($db_link,"User_list","id='$val'", '', 1);
             $login = get_record($db_link,"User_list","id='$val'");
@@ -150,7 +148,7 @@ $sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month
 <td><b><?php print $cell_perday; ?></b></td>
 <td><b><?php print $cell_permonth; ?></b></td>
 <td><b><?php print $cell_report; ?></b></td>
-</tr>
+</tr>
 <?
 
 $users = get_records_sql($db_link, $sSQL);

+ 8 - 20
html/inc/common.php

@@ -545,7 +545,7 @@ function get_ou($db, $ou_value)
     if (!isset($ou_value)) { return; }
     $ou_name = get_record_sql($db, "SELECT ou_name FROM OU WHERE id=$ou_value");
     if (empty($ou_name)) { return; }
-    return $ou_name[ou_name];
+    return $ou_name['ou_name'];
 }
 
 function get_building($db, $building_value)
@@ -759,7 +759,7 @@ function print_filter_select($db, $filter_name, $group_id)
 
 function get_filter($db, $filter_value)
 {
-    list ($filter) = mysqli_fetch_array(mysqli_query($db, "SELECT name FROM Filter_list WHERE id=$user_id"));
+    list ($filter) = mysqli_fetch_array(mysqli_query($db, "SELECT name FROM Filter_list WHERE id=".$filter_value));
     return $filter;
 }
 
@@ -1582,24 +1582,18 @@ function get_fdb_port_table($ip, $port_index, $community, $version)
             return;
         }
         foreach ($vlan_table as $vlan_oid => $value) {
-            if (! $vlan_oid) {
-                next;
-            }
+            if (! $vlan_oid) { continue; }
             $pattern = '/\.(\d{1,4})$/';
             $result = preg_match($pattern, $vlan_oid, $matches);
             if ($result) {
                 $vlan_id = preg_replace('/^\./', '', $matches[0]);
-                if ($vlan_id > 1000 and $vlan_id < 1009) {
-                    next;
-                }
+                if ($vlan_id > 1000 and $vlan_id < 1009) { continue; }
                 $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community . '@' . $vlan_id, $version, $mac_table_oid2);
                 if (! isset($fdb_vlan_table) or ! $fdb_vlan_table or count($fdb_vlan_table) == 0) {
                     $fdb_vlan_table = get_mac_port_table($ip, $port_index, $community, $version, $mac_table_oid);
                 }
                 foreach ($fdb_vlan_table as $mac => $port) {
-                    if (! isset($mac)) {
-                        next;
-                    }
+                    if (! isset($mac)) { continue; }
                     $fdb_port_table[$mac] = $port;
                 }
             }
@@ -1667,24 +1661,18 @@ function get_fdb_table($ip, $community, $version)
             return;
         }
         foreach ($vlan_table as $vlan_oid => $value) {
-            if (! $vlan_oid) {
-                next;
-            }
+            if (! $vlan_oid) { continue; }
             $pattern = '/\.(\d{1,4})$/';
             $result = preg_match($pattern, $vlan_oid, $matches);
             if ($result) {
                 $vlan_id = preg_replace('/^\./', '', $matches[0]);
-                if ($vlan_id > 1000 and $vlan_id < 1009) {
-                    next;
-                }
+                if ($vlan_id > 1000 and $vlan_id < 1009) { continue; }
                 $fdb_vlan_table = get_mac_table($ip, $community . '@' . $vlan_id, $version, $mac_table_oid2);
                 if (! isset($fdb_vlan_table) or ! $fdb_vlan_table or count($fdb_vlan_table) == 0) {
                     $fdb_vlan_table = get_mac_table($ip, $community, $version, $mac_table_oid);
                 }
                 foreach ($fdb_vlan_table as $mac => $port) {
-                    if (! isset($mac)) {
-                        next;
-                    }
+                    if (! isset($mac)) { continue; }
                     $fdb_port_table[$mac] = $port;
                 }
             }