Skip to content

Commit

Permalink
more db*
Browse files Browse the repository at this point in the history
git-svn-id: http://www.observium.org/svn/observer/trunk@2302 61d68cd4-352d-0410-923a-c4978735b2b8
  • Loading branch information
Adam Amstrong committed May 13, 2011
1 parent 164ada6 commit c086264
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
File renamed without changes.
5 changes: 2 additions & 3 deletions generate-iplist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
}
Expand Down
9 changes: 3 additions & 6 deletions snmptrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

?>
?>

0 comments on commit c086264

Please sign in to comment.