Passed
Push — master ( 0baeb0...d4017c )
by Tony
19:18 queued 08:55
created

includes/discovery/cisco-mac-accounting.inc.php (1 issue)

1
<?php
2
3
if ($device['os_group'] == 'cisco') {
4
    $datas = snmp_walk($device, 'cipMacSwitchedBytes', '-Oqn', 'CISCO-IP-STAT-MIB');
5
6
    foreach (explode("\n", $datas) as $data) {
7
        list($oid) = explode(' ', $data);
8
        $oid       = str_replace('.1.3.6.1.4.1.9.9.84.1.2.1.1.4.', '', $oid);
9
        list($if, $direction, $a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode('.', $oid);
10
        unset($interface);
11
        $interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $if));
12
        $ah_a      = zeropad(dechex($a_a));
0 ignored issues
show
$a_a of type string is incompatible with the type integer expected by parameter $number of dechex(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

12
        $ah_a      = zeropad(dechex(/** @scrutinizer ignore-type */ $a_a));
Loading history...
13
        $ah_b      = zeropad(dechex($a_b));
14
        $ah_c      = zeropad(dechex($a_c));
15
        $ah_d      = zeropad(dechex($a_d));
16
        $ah_e      = zeropad(dechex($a_e));
17
        $ah_f      = zeropad(dechex($a_f));
18
        $mac = "$ah_a$ah_b$ah_c$ah_d$ah_e$ah_f";
19
20
        if ($interface) {
21
            if (dbFetchCell('SELECT COUNT(*) from mac_accounting WHERE port_id = ? AND mac = ?', array($interface['port_id'], $mac))) {
22
                echo '.';
23
            } else {
24
                dbInsert(array('port_id' => $interface['port_id'], 'mac' => $mac), 'mac_accounting');
25
                echo '+';
26
            }
27
        }
28
    }//end foreach
29
30
    echo "\n";
31
} //end if
32
33
// FIXME - NEEDS TO REMOVE STALE ENTRIES?? :O
34