code standard/cleanups

git-svn-id: http://www.observium.org/svn/observer/trunk@1978 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-26 19:12:24 +00:00
parent ec7535c25a
commit 7454791074
19 changed files with 239 additions and 229 deletions
+21 -13
View File
@@ -13,17 +13,21 @@ $ports = str_replace("ifDescr.", "", $ports);
$interface_ignored = 0;
$interface_added = 0;
foreach (explode("\n", $ports) as $entry){
foreach (explode("\n", $ports) as $entry)
{
$entry = trim($entry);
list($ifIndex, $ifDescr) = explode(" ", $entry, 2);
if (!strstr($entry, "irtual")) {
if (!strstr($entry, "irtual"))
{
$if = trim(strtolower($ifDescr));
$nullintf = 0;
foreach ($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
if (is_array($config['bad_if_regexp'])) {
foreach ($config['bad_if_regexp'] as $bi) {
if (preg_match($bi ."i", $if)) {
if (is_array($config['bad_if_regexp']))
{
foreach ($config['bad_if_regexp'] as $bi)
{
if (preg_match($bi ."i", $if))
{
$nullintf = 1;
}
}
@@ -34,11 +38,13 @@ foreach (explode("\n", $ports) as $entry){
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $ifDescr, $matches)) { $ifDescr = $matches[1]; }
$ifDescr = fixifName($ifDescr);
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
if (isset($config['allow_ng']) && !$config['allow_ng']) {
if (isset($config['allow_ng']) && !$config['allow_ng'])
{
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; }
}
if ($debug) echo("\n $if ");
if ($nullintf == 0) {
if ($nullintf == 0)
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
# Add Interface
@@ -61,19 +67,21 @@ foreach (explode("\n", $ports) as $entry){
}
}
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
while ($test_if = mysql_fetch_array($query)) {
while ($test_if = mysql_fetch_array($query))
{
unset($exists);
$i = 0;
while ($i < count($int_exists) && !isset($exists)) {
while ($i < count($int_exists) && !isset($exists))
{
$this_if = $test_if['ifIndex'];
if ($int_exists[$i] == $this_if) { $exists = 1; }
$i++;
}
if (!$exists) {
if (!$exists)
{
echo("-");
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
}
@@ -82,4 +90,4 @@ while ($test_if = mysql_fetch_array($query)) {
unset($temp_exists);
echo("\n");
?>
?>