Files

37 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2015-04-12 11:22:43 +00:00
<?php
2018-09-11 07:51:35 -05:00
use LibreNMS\Authentication\LegacyAuth;
2018-09-11 07:51:35 -05:00
if (LegacyAuth::user()->hasGlobalRead()) {
2015-07-13 20:10:26 +02:00
$data['count'] = array( 'query' => 'SELECT COUNT(*) FROM services');
2016-04-26 22:05:34 +10:00
$data['up'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'");
$data['down'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '2'");
2015-07-13 20:10:26 +02:00
$data['ignored'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '1' AND `service_disabled` = '0'");
$data['disabled'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_disabled` = '1'");
} else {
2015-07-13 20:10:26 +02:00
$data['count'] = array(
'query' => 'SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id`',
2018-09-11 07:51:35 -05:00
'params' => array(LegacyAuth::id()),
2015-07-13 20:10:26 +02:00
);
$data['up'] = array(
2016-04-26 22:05:34 +10:00
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0'",
2018-09-11 07:51:35 -05:00
'params' => array(LegacyAuth::id()),
2015-07-13 20:10:26 +02:00
);
$data['down'] = array(
2016-04-26 22:05:34 +10:00
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '2'",
2018-09-11 07:51:35 -05:00
'params' => array(LegacyAuth::id()),
2015-07-13 20:10:26 +02:00
);
$data['ignored'] = array(
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '1' AND S.`service_disabled` = '0'",
2018-09-11 07:51:35 -05:00
'params' => array(LegacyAuth::id()),
2015-07-13 20:10:26 +02:00
);
$data['disabled'] = array(
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_disabled` = '1'",
2018-09-11 07:51:35 -05:00
'params' => array(LegacyAuth::id()),
2015-07-13 20:10:26 +02:00
);
}//end if