From 62fe879ee932a93fea8c565330fc4da02ec86f25 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 2 Sep 2017 23:26:04 -0600 Subject: [PATCH] Update registrations.php --- app/registrations/registrations.php | 115 ++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 8 deletions(-) diff --git a/app/registrations/registrations.php b/app/registrations/registrations.php index d92a51789a..2bbed51178 100644 --- a/app/registrations/registrations.php +++ b/app/registrations/registrations.php @@ -69,6 +69,68 @@ $show = trim($_REQUEST["show"]); if ($show == "all") { $profile = 'all'; } +//set the registrations variable + $registrations = $_REQUEST["registrations"]; + +//get the action and remove items from the array that are not checked + if (is_array($registrations)) { + $x = 0; + foreach ($registrations as $row) { + //get the action + switch ($row['action']) { + case "unregister": + $action = 'unregister'; + break; + case "provision": + $action = 'provision'; + break; + break; + case "reboot": + $action = 'reboot'; + break; + } + //unset rows that were not selected + if (!isset($row['checked'])) { + unset($registrations[$x]); + } + //increment the id + $x++; + } + } + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//user registrations + if (isset($action)) { + if (is_array($registrations)) { + foreach ($registrations as $row) { + if ($fp) { + //get the vendor + $vendor = device::get_vendor_by_agent($row['agent']); + //prepare the command + if ($action == "unregister") { + $command = "sofia profile ".$row['profile']." flush_inbound_reg ".$row['user']." reboot"; + } + if ($action == "provision") { + $command = "lua app.lua event_notify ".$row['profile']." check_sync ".$row['user']." ".$vendor; + } + if ($action == "reboot") { + $command = "lua app.lua event_notify ".$row['profile']." reboot ".$row['user']." ".$vendor; + } + //send the command + $response = event_socket_request($fp, "api ".$command); + $response = event_socket_request($fp, "api log notice ".$command); + } + } + } + } + +//show the response + if (isset($response)) { + messages::add($text['label-event']." ".ucwords($cmd)."     ".$text['label-response'].htmlentities($response)); + } + //define variables $c = 0; $row_style["0"] = "row_style0"; @@ -95,28 +157,46 @@ //count the registrations $registration_count = 0; - if (count($registrations) > 0) { + if (is_array($registrations)) { foreach ($registrations as $row) { - //search $matches = preg_grep ("/$search/i",$row); if ($matches != FALSE) { $registration_count++; } } } + + //define the checkbox_toggle function + echo "\n"; + //show the registrations + echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "
\n"; echo " ".$text['header-registrations']." (".$registration_count.")\n"; echo ""; - echo " \n"; + //echo " \n"; echo " "; echo " "; echo " "; echo " "; - echo " \n"; + //echo " \n"; echo ""; if (permission_exists('registration_all')) { @@ -135,6 +215,9 @@ echo "\n"; echo "\n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -144,6 +227,7 @@ echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo "\n"; @@ -153,16 +237,27 @@ $registrations = $order->sort($registrations, 'sip-auth-realm', 'user'); //display the array - if (count($registrations) > 0) { + if (is_array($registrations)) { + $x = 0; foreach ($registrations as $row) { //search $matches = preg_grep ("/$search/i",$row); if ($matches != FALSE) { //set the user agent $agent = $row['agent']; + + //set the user id + $user_id = str_replace('@', '_', $row['user']); //show the registrations echo "\n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -172,17 +267,21 @@ echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } + $x++; } } } echo "
\n"; + echo " \n"; + echo " ".$text['label-user']."".$text['label-agent']."".$text['label-contact']."".$text['label-hostname']."".$text['label-status']."".$text['label-ping']."".$text['label-sip_profile_name']."".$text['label-tools']." 
".$row['user']." ".htmlentities($row['agent'])." ".explode('"',$row['contact'])[1]."".$row['host']."".$row['status']."".$row['ping-time']."".$row['sip_profile_name']."\n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo "
\n"; + echo "\n"; + echo "\n"; //close the connection and unset the variable fclose($fp);