From c086264fc2ea239738be0f97e6bc2ec09e645407 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 13 May 2011 12:39:56 +0000 Subject: [PATCH] more db* git-svn-id: http://www.observium.org/svn/observer/trunk@2302 61d68cd4-352d-0410-923a-c4978735b2b8 --- scan-snmp.php => attic/scan-snmp.php | 0 generate-iplist.php | 5 ++--- snmptrap.php | 9 +++------ 3 files changed, 5 insertions(+), 9 deletions(-) rename scan-snmp.php => attic/scan-snmp.php (100%) diff --git a/scan-snmp.php b/attic/scan-snmp.php similarity index 100% rename from scan-snmp.php rename to attic/scan-snmp.php diff --git a/generate-iplist.php b/generate-iplist.php index 25574a4a9b2c..deae608e9b2d 100755 --- a/generate-iplist.php +++ b/generate-iplist.php @@ -7,8 +7,7 @@ $handle = fopen("ips.txt", "w"); -$query = mysql_query("SELECT * FROM `ipv4_networks`"); -while ($data = mysql_fetch_assoc($query)) +foreach (dbFetchRows("SELECT * FROM `ipv4_networks`")) { $cidr = $data['ipv4_network']; list ($network, $bits) = explode("/", $cidr); @@ -21,7 +20,7 @@ while ($ip < $end) { $ipdotted = long2ip($ip); - if (mysql_result(mysql_query("SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted)) + if (dbFetchCell("SELECT COUNT(ipv4_address_id) FROM `ipv4_addresses` WHERE `ipv4_address` = ?", array($ipdotted)) == '0' && match_network($config['nets'], $ipdotted)) { fputs($handle, $ipdotted . "\n"); } diff --git a/snmptrap.php b/snmptrap.php index 8170b7929d62..644b3fc655f5 100755 --- a/snmptrap.php +++ b/snmptrap.php @@ -14,19 +14,16 @@ print_r($entry); -$device = @mysql_fetch_assoc(mysql_query("SELECT * FROM devices WHERE `hostname` = '".$entry['0']."'")); +$device = @dbFetchRow("SELECT * FROM devices WHERE `hostname` = ?", array($entry['0'])); if (!$device['device_id']) { - $device = @mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE - A.ipv4_address = '" . $entry['0']."' AND I.interface_id = A.interface_id")); + $device = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id", array($entry['0'])); } if (!$device['device_id']) { exit; } else { } -print_r($device); - $file = $config['install_dir'] . "/includes/snmptrap/".$entry['1'].".inc.php"; if (is_file($file)) { include("$file"); } else { echo("unknown trap ($file)"); exit; } -?> \ No newline at end of file +?>