2011-04-29 16:49:37 +00:00
< ? php
2022-11-03 15:07:17 -05:00
use LibreNMS\Exceptions\RrdGraphException ;
2015-07-10 13:36:21 +02:00
if ( is_numeric ( $vars [ 'id' ])) {
$acc = dbFetchRow ( 'SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id' , [ $vars [ 'id' ]]);
2011-04-29 16:49:37 +00:00
2021-04-29 22:42:18 -05:00
if ( \LibreNMS\Util\Debug :: isEnabled ()) {
2015-07-10 13:36:21 +02:00
echo '<pre>' ;
print_r ( $acc );
echo '</pre>' ;
}
2011-06-01 09:52:03 +00:00
2015-07-10 13:36:21 +02:00
if ( is_array ( $acc )) {
if ( $auth || port_permitted ( $acc [ 'port_id' ])) {
2021-03-28 17:25:30 -05:00
$filename = Rrd :: name ( $acc [ 'hostname' ], [ 'cip' , $acc [ 'ifIndex' ], $acc [ 'mac' ]]);
2016-07-07 01:33:43 -05:00
d_echo ( $filename );
2011-06-01 09:54:05 +00:00
2016-07-07 01:33:43 -05:00
if ( is_file ( $filename )) {
2015-08-20 15:07:28 +02:00
d_echo ( 'exists' );
2011-06-01 09:54:05 +00:00
2016-07-07 01:33:43 -05:00
$rrd_filename = $filename ;
2017-04-04 08:08:23 +01:00
$port = cleanPort ( get_port_by_id ( $acc [ 'port_id' ]));
2015-07-10 13:36:21 +02:00
$device = device_by_id_cache ( $port [ 'device_id' ]);
$title = generate_device_link ( $device );
$title .= ' :: Port ' . generate_port_link ( $port );
2021-03-28 17:25:30 -05:00
$title .= ' :: ' . \LibreNMS\Util\Rewrite :: readableMac ( $acc [ 'mac' ]);
2015-07-10 13:36:21 +02:00
$auth = true ;
2016-08-18 20:28:22 -05:00
} else {
2022-11-03 15:07:17 -05:00
throw new RrdGraphException ( 'file not found' );
2015-07-10 13:36:21 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2022-11-03 15:07:17 -05:00
throw new RrdGraphException ( 'unauthenticated' );
2015-07-10 13:36:21 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2022-11-03 15:07:17 -05:00
throw new RrdGraphException ( 'entry not found' );
2015-07-10 13:36:21 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2022-11-03 15:07:17 -05:00
throw new RrdGraphException ( 'invalid id' );
2011-04-29 16:49:37 +00:00
}