diff --git a/html/includes/graphs/device/mempool.inc.php b/html/includes/graphs/device/mempool.inc.php index f0882ef11..d1d882e5f 100644 --- a/html/includes/graphs/device/mempool.inc.php +++ b/html/includes/graphs/device/mempool.inc.php @@ -1,7 +1,6 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/device/processor.inc.php b/html/includes/graphs/device/processor.inc.php index ee998bcab..051319cf1 100644 --- a/html/includes/graphs/device/processor.inc.php +++ b/html/includes/graphs/device/processor.inc.php @@ -1,7 +1,7 @@ "300") { $descr_len = "40"; } else { $descr_len = "22"; } $rrd_options .= " -l 0 -E "; $iter = "1"; -$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='".$class."' AND device_id = '$id' ORDER BY sensor_index"); $rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'"; -while ($sensor = mysql_fetch_assoc($sql)) + +foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`", array($class, $id)) as $sensor) { # FIXME generic colour function switch ($iter) diff --git a/html/includes/graphs/device/storage.inc.php b/html/includes/graphs/device/storage.inc.php index 5dc5c180c..3ddcca5b6 100644 --- a/html/includes/graphs/device/storage.inc.php +++ b/html/includes/graphs/device/storage.inc.php @@ -8,10 +8,9 @@ include("includes/graphs/common.inc.php"); $device = device_by_id_cache($id); $iter = "1"; -$sql = mysql_query("SELECT * FROM storage where device_id = '$id'"); $rrd_options .= " COMMENT:' Size Used %age\\l'"; -while ($storage = mysql_fetch_assoc($sql)) +foreach (dbFetchRows("SELECT * FROM storage where device_id = ?", array($id)) as $storage) { # FIXME generic colour function if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } @@ -32,4 +31,4 @@ while ($storage = mysql_fetch_assoc($sql)) $iter++; } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/device/toner.inc.php b/html/includes/graphs/device/toner.inc.php index 8e372c1e8..bbc61ec22 100644 --- a/html/includes/graphs/device/toner.inc.php +++ b/html/includes/graphs/device/toner.inc.php @@ -6,9 +6,8 @@ $device = device_by_id_cache($id); $rrd_options .= " -l 0 -E "; $iter = "1"; -$sql = mysql_query("SELECT * FROM toner where device_id = '$id'"); $rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'"; -while ($toner = mysql_fetch_assoc($sql)) +foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $toner) { # FIXME generic colour function switch ($iter) diff --git a/html/includes/graphs/diskio/ops.inc.php b/html/includes/graphs/diskio/ops.inc.php index 5fcb49b84..37038cf56 100644 --- a/html/includes/graphs/diskio/ops.inc.php +++ b/html/includes/graphs/diskio/ops.inc.php @@ -1,16 +1,5 @@ \ No newline at end of file +?> diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index 039bddcab..1a22e1b6c 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -10,8 +10,7 @@ foreach (explode(",", $id) as $ifid) $ifid = str_replace("!", "", $ifid); } - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . safename($int[0] . ".rrd"))) { $rrd_filenames[$i] = $config['rrd_dir'] . "/" . $int[1] . "/port-" . safename($int[0] . ".rrd"); @@ -29,4 +28,4 @@ $colour_area_out = "C3D9FF"; include("includes/graphs/generic_multi_bits.inc.php"); -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/multiport/bits_duo.inc.php b/html/includes/graphs/multiport/bits_duo.inc.php index 0c6c7ee29..3a59a13bb 100644 --- a/html/includes/graphs/multiport/bits_duo.inc.php +++ b/html/includes/graphs/multiport/bits_duo.inc.php @@ -9,8 +9,7 @@ $i = 1; foreach (explode(",", $_GET['id']) as $ifid) { - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) { $rrd_options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:INOCTETS:AVERAGE"; @@ -27,8 +26,7 @@ unset($seperator); unset($plus); foreach (explode(",", $_GET['idb']) as $ifid) { - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) { $rrd_options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd:INOCTETS:AVERAGE"; @@ -121,4 +119,4 @@ if ($legend == "no") if ($width <= "300") { $rrd_options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php index 00a481949..05cfe4bfc 100644 --- a/html/includes/graphs/multiport/bits_separate.inc.php +++ b/html/includes/graphs/multiport/bits_separate.inc.php @@ -4,8 +4,7 @@ $i = 0; foreach (explode(",", $id) as $ifid) { - $query = mysql_query("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $port = mysql_fetch_assoc($query); + $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) { $rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"); @@ -26,4 +25,4 @@ $rra_out = "OUTOCTETS"; include("includes/graphs/generic_multi_bits_separated.inc.php"); -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/multiport/bits_trio.inc.php b/html/includes/graphs/multiport/bits_trio.inc.php index fbc30d505..9a9a133d8 100644 --- a/html/includes/graphs/multiport/bits_trio.inc.php +++ b/html/includes/graphs/multiport/bits_trio.inc.php @@ -10,8 +10,7 @@ $i = 1; foreach (explode(",", $_GET['id']) as $ifid) { - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) { if (strstr($inverse, "a")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } @@ -30,8 +29,7 @@ unset($seperator); unset($plus); foreach (explode(",", $_GET['idb']) as $ifid) { - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) { if (strstr($inverse, "b")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } @@ -50,8 +48,7 @@ unset($seperator); unset($plus); foreach (explode(",", $_GET['idc']) as $ifid) { - $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . mres($ifid) . "' AND I.device_id = D.device_id"); - $int = mysql_fetch_row($query); + $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $int[1] . "/port-" . $int[0] . ".rrd")) { if (strstr($inverse, "c")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } @@ -172,4 +169,4 @@ if ($legend == "no") if ($width <= "300") { $rrd_options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } -?> \ No newline at end of file +?> diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php index 3711db676..27d43db06 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -34,40 +34,36 @@ if ($stat == "pkts") } } -$sql = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps, +$accs = dbFetchRows("SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps, (M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps - FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.interface_id = '".$port."' - AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn; + FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.interface_id = ? + AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn, array($port)); -$query = mysql_query($sql); $pluses = ""; $iter = '0'; $rrd_options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'"; -while ($acc = mysql_fetch_assoc($query)) +foreach ($accs as $acc) { $this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"); if (is_file($this_rrd)) { $mac = formatmac($acc['mac']); $name = $mac; - $addy = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'")); + $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ? AND interface_id = ?", array($acc['mac'], $acc['interface_id'])); if ($addy) { $name = $addy['ipv4_address'] . " (".$mac.")"; - $peer = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D - WHERE A.ipv4_address = '".$addy['ipv4_address']."' - AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); + $peer = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D + WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($addy['ipv4_address'])); if ($peer) { $name = $peer['hostname'] . " " . makeshortif($peer['ifDescr']) . " (".$mac.")"; } - if (mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '". - $addy['ipv4_address']."'"),0)) + if (dbFetchCell("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = ?", array($addy['ipv4_address'])),0)) { - $peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"); - $peer_info = mysql_fetch_assoc($peer_query); + $peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ipv4_address'])); $name .= " - AS".$peer_info['bgpPeerRemoteAs']; } @@ -113,4 +109,4 @@ while ($acc = mysql_fetch_assoc($query)) $rrd_options .= $rrd_optionsb; $rrd_options .= " HRULE:0#999999"; -?> \ No newline at end of file +?>