From 3a31141e6f23199b1a07302afaf6648185f1d5e7 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 28 Jun 2022 10:59:19 -0600 Subject: [PATCH] Add permisisons to the dashboard. Add new permissions switch_version, switch_uptime, switch_channels, switch_registrations --- .../resources/dashboard/switch_status.php | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/app/switch/resources/dashboard/switch_status.php b/app/switch/resources/dashboard/switch_status.php index 2af47d09ee..956128d70b 100644 --- a/app/switch/resources/dashboard/switch_status.php +++ b/app/switch/resources/dashboard/switch_status.php @@ -6,13 +6,13 @@ //check permisions require_once "resources/check_auth.php"; - if (permission_exists("registration_all") || if_group("superadmin")) { + if (permission_exists("switch_version") + || permission_exists("switch_uptime") + || permission_exists("switch_channels") + || permission_exists("switch_registrations") + || permission_exists("registration_all")) { //access granted } - else { - echo "access denied"; - exit; - } //add multi-lingual support $language = new text; @@ -30,7 +30,7 @@ $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //switch version - if ($fp) { + if (permission_exists('switch_version') && $fp) { $switch_version = event_socket_request($fp, 'api version'); preg_match("/FreeSWITCH Version (\d+\.\d+\.\d+(?:\.\d+)?).*\(.*?(\d+\w+)\s*\)/", $switch_version, $matches); $switch_version = $matches[1]; @@ -38,7 +38,7 @@ } //switch uptime - if ($fp) { + if (permission_exists('switch_uptime') && $fp) { $tmp = event_socket_request($fp, 'api status'); $tmp = explode("\n", $tmp); $tmp = $tmp[0]; @@ -54,7 +54,7 @@ } //channel count - if ($fp) { + if (permission_exists('switch_channels') && $fp) { $tmp = event_socket_request($fp, 'api status'); $matches = Array(); preg_match("/(\d+)\s+session\(s\)\s+\-\speak/", $tmp, $matches); @@ -65,12 +65,13 @@ } //registration count - if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { + if (permission_exists('switch_registrations') && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/registrations/")) { $registration = new registrations; - $registrations = $registration->count(); - if (permission_exists("registration_all") || if_group("superadmin")) { + if (permission_exists("registration_all")) { + $registration->show = 'all'; $tr_link_registrations = "href='".PROJECT_PATH."/app/registrations/registrations.php'"; } + $registrations = $registration->count(); } //add doughnut chart @@ -131,7 +132,7 @@ echo "\n"; //switch version - if ($switch_version != '') { + if (permission_exists('switch_version') && $switch_version != '') { echo "\n"; echo "".$text['label-switch']."\n"; echo "".$switch_version." (".$switch_bits.")\n"; @@ -140,7 +141,7 @@ } //switch uptime - if ($uptime != '') { + if (permission_exists('switch_uptime') && $uptime != '') { echo "\n"; echo "".$text['label-switch_uptime']."\n"; echo "".$uptime."\n"; @@ -149,19 +150,22 @@ } //switch channels - echo "\n"; - echo "".$text['label-channels']."\n"; - echo "".$channels."\n"; - echo "\n"; - $c = ($c) ? 0 : 1; + if (permission_exists('switch_channels')) { + echo "\n"; + echo "".$text['label-channels']."\n"; + echo "".$channels."\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } //switch registrations - echo "\n"; - echo "".$text['label-registrations']."\n"; - echo "".$registrations."\n"; - echo "\n"; - $c = ($c) ? 0 : 1; - + if (permission_exists('switch_registrations')) { + echo "\n"; + echo "".$text['label-registrations']."\n"; + echo "".$registrations."\n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } echo "\n"; echo "";