");
-$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("
");
-$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("
");
-?>
\ 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("
");
- $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("