diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index 0a5716434..94e02478d 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -30,7 +30,7 @@ if ($_POST['action'] == "update_bill") { if (dbUpdate(array('bill_name' => $_POST['bill_name'], 'bill_day' => $_POST['bill_day'], 'bill_gb' => $_POST['bill_gb'], - 'bill_cdr' => $_POST['bill_cdr'], 'bill_type' => $_POST['bill_type']), 'bills', '`bill_id` = ?' array($bill_id))) + 'bill_cdr' => $_POST['bill_cdr'], 'bill_type' => $_POST['bill_type']), 'bills', '`bill_id` = ?', array($bill_id))) { print_message("Bill Properties Updated"); } diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index e3eec3fea..c0e960f97 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -63,16 +63,16 @@ echo(' echo("
"); -$ports_array = mysql_query("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = '".$bill_data['bill_id']."' AND P.interface_id = B.port_id - AND D.device_id = P.device_id"); +$ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.interface_id = B.port_id + AND D.device_id = P.device_id", array($bill_data['bill_id'])); -if (mysql_affected_rows()) +if (is_array($ports)) { echo("

Billed Ports

"); echo(""); - while ($port = mysql_fetch_assoc($ports_array)) + foreach ($ports as $port) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } echo(""); @@ -98,8 +98,8 @@ echo(""); $row = 1; -while ($interface = mysql_fetch_assoc($query)) +foreach (dbFetchRows($query, $param) as $interface) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/ports/deleted.inc.php b/html/pages/ports/deleted.inc.php index 758a090fb..8d340d46e 100644 --- a/html/pages/ports/deleted.inc.php +++ b/html/pages/ports/deleted.inc.php @@ -2,9 +2,7 @@ if ($_GET['optb'] == "purge" && $_GET['optc'] == "all") { - $sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id"; - $query = mysql_query($sql); - while ($interface = mysql_fetch_assoc($query)) + foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { if (port_permitted($interface['interface_id'], $interface['device_id'])) { @@ -13,7 +11,7 @@ if ($_GET['optb'] == "purge" && $_GET['optc'] == "all") } } } elseif ($_GET['optb'] == "purge" && $_GET['optc']) { - $interface = mysql_fetch_assoc(mysql_query("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = '".mres($_GET['optc'])."' AND D.device_id = P.device_id")); + $interface = dbFetchRow("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = ? AND D.device_id = P.device_id", array($_GET['optc'])); if (port_permitted($interface['interface_id'], $interface['device_id'])) delete_port($interface['interface_id']); echo("
Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."
"); @@ -24,9 +22,7 @@ $i_deleted = 1; echo("
DeviceInterfaceSpeedMediaDescription
"); echo(""); -$sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id"; -$query = mysql_query($sql); -while ($interface = mysql_fetch_assoc($query)) +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { $interface = ifLabel($interface, $interface); if (port_permitted($interface['interface_id'], $interface['device_id'])) @@ -45,4 +41,4 @@ while ($interface = mysql_fetch_assoc($query)) echo("
Purge All
"); -?> \ No newline at end of file +?> diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index a45b853b2..64c0d4d15 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -104,8 +104,8 @@ else $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; } - $peer_query = mysql_query("select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"); - while ($peer = mysql_fetch_assoc($peer_query)) + $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; + foreach(dbFetchRows($peer_query) as $peer) { unset ($alert, $bg_image); @@ -118,7 +118,7 @@ else if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } } - $peerhost = mysql_fetch_assoc(mysql_query("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); + $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } @@ -134,10 +134,8 @@ else echo('"); - $af_query = mysql_query("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = '".$peer['device_id']."' AND bgpPeerIdentifier = '".$peer['bgpPeerIdentifier']."'"); - unset($sep); - while ($afisafi = mysql_fetch_assoc($af_query)) + foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { $afi = $afisafi['afi']; $safi = $afisafi['safi']; @@ -181,7 +179,7 @@ else { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = mysql_fetch_assoc(mysql_query("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND M.mac = I.mac_address AND P.interface_id = M.interface_id AND D.device_id = P.device_id")); + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.interface_id = M.interface_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; if (is_array($acc) && is_file($database)) { diff --git a/html/pages/routing/ospf.inc.php b/html/pages/routing/ospf.inc.php index 0c957931f..be1ae2394 100644 --- a/html/pages/routing/ospf.inc.php +++ b/html/pages/routing/ospf.inc.php @@ -16,15 +16,16 @@ while ($instance = mysql_fetch_assoc($query)) $device = device_by_id_cache($instance['device_id']); - $area_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"),0); - $port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"),0); - $port_count_enabled = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."'"),0); - $neighbour_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'"),0); + $area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"); + $port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"); + $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."'"); + $neighbour_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'"); $ip_query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; - $ip_query .= "(A.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id)"; - $ip_query .= " AND I.device_id = '".$device['device_id']."'"; - $ipv4_host = mysql_fetch_assoc(mysql_query($ip_query)); + $ip_query .= "(A.ipv4_address = ? AND I.interface_id = A.interface_id)"; + $ip_query .= " AND I.device_id = ?"; + + $ipv4_host = dbFetchArray($ip_query, array($peer['bgpPeerIdentifier'], $device['device_id'])); if ($instance['ospfAdminStat'] == "enabled") { $enabled = 'enabled'; } else { $enabled = 'disabled'; } if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = 'yes'; } else { $abr = 'no'; } diff --git a/html/pages/routing/vrf.inc.php b/html/pages/routing/vrf.inc.php index d724462bd..f3d96f0a1 100644 --- a/html/pages/routing/vrf.inc.php +++ b/html/pages/routing/vrf.inc.php @@ -45,8 +45,7 @@ if($_GET['optb'] == "all" ) { echo("
"); $i = "1"; - $vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`"); - while ($vrf = mysql_fetch_assoc($vrf_query)) + foreach (dbFetchRows("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`") as $vrf) { if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } echo(""); @@ -68,10 +67,9 @@ if($_GET['optb'] == "all" ) { if ($device['vrf_name'] != $vrf['vrf_name']) { echo("Configured : ".$device['vrf_name']."', CAPTION, 'VRF Inconsistency' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> "); } echo("
"); - $ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'"); unset($seperator); - while ($port = mysql_fetch_assoc($ports)) + foreach(dbFetchRows("SELECT * FROM `ports` WHERE `ifVrf` = ? AND `device_id` = ?", array($device['vrf_id'], $device['device_id'])) as $port) { $port = array_merge ($device, $port); @@ -114,29 +112,27 @@ if($_GET['optb'] == "all" ) { } else { echo("
"); - $vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$_GET['optb']."'"); - $vrf = mysql_fetch_assoc($vrf_query); + $vrf = dbFetchRow("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = ?", array($_GET['optb'])); echo(""); echo(""); echo(""); echo(""); echo("
" . $vrf['vrf_name'] . "" . $vrf['mplsVpnVrfRouteDistinguisher'] . "" . $vrf['mplsVpnVrfDescription'] . "
"); - $devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id"); $x=0; - while ($device = mysql_fetch_assoc($devices)) + $devices = dbFetchRows("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = ? AND D.device_id = V.device_id", array($vrf['mplsVpnVrfRouteDistinguisher'])); + foreach ($devices as $device) { $hostname = $device['hostname']; if (!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; } echo(""); include("includes/device-header.inc.php"); echo("
"); - $ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'"); unset($seperator); echo('
'); $i=1; - while ($interface = mysql_fetch_assoc($ports)) + foreach (dbFetchRows("SELECT * FROM `ports` WHERE `ifVrf` = ? AND `device_id` = ?", array($device['vrf_id'], $device['device_id'])) as $interface) { if (!is_integer($x/2)) { diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index ee0f47ebb..9827be7f0 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -7,8 +7,7 @@ '); $row = 1; -while ($interface = mysql_fetch_assoc($query)) +foreach (dbFetchRows($query, $param) as $interface) { if ($_POST['address']) { diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 6300ca8cc..ede224ca3 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -7,8 +7,7 @@ '); $row = 1; -while ($interface = mysql_fetch_assoc($query)) +foreach (dbFetchRows($query, $param) as $interface) { if ($_POST['address']) { diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index bdf208b31..336e0a4ee 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -7,8 +7,7 @@ '); $row = 1; -while ($entry = mysql_fetch_assoc($query)) +foreach (dbFetchRows($query, $param) as $entry) { if (!$ignore)
DeviceInterfaceAddressDescription
DeviceInterfaceAddressDescription
DeviceInterfaceMAC AddressDescription