2011-04-29 16:49:37 +00:00
< ? php
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' , array ( $vars [ 'id' ]));
2011-04-29 16:49:37 +00:00
2015-07-10 13:36:21 +02:00
if ( $debug ) {
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' ])) {
2016-07-07 01:33:43 -05:00
$filename = rrd_name ( $acc [ 'hostname' ], array ( 'cip' , $acc [ 'ifIndex' ], $acc [ 'mac' ]));
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 ;
2015-07-10 13:36:21 +02:00
$port = get_port_by_id ( $acc [ 'port_id' ]);
$device = device_by_id_cache ( $port [ 'device_id' ]);
$title = generate_device_link ( $device );
$title .= ' :: Port ' . generate_port_link ( $port );
$title .= ' :: ' . formatMac ( $acc [ 'mac' ]);
$auth = true ;
2016-08-18 20:28:22 -05:00
} else {
2015-07-10 13:36:21 +02:00
graph_error ( 'file not found' );
}
2016-08-18 20:28:22 -05:00
} else {
2015-07-10 13:36:21 +02:00
graph_error ( 'unauthenticated' );
}
2016-08-18 20:28:22 -05:00
} else {
2015-07-10 13:36:21 +02:00
graph_error ( 'entry not found' );
}
2016-08-18 20:28:22 -05:00
} else {
2015-07-10 13:36:21 +02:00
graph_error ( 'invalid id' );
2011-04-29 16:49:37 +00:00
}