Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists("registration_domain") || permission_exists("registration_all") || if_group("superadmin")) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the HTTP values and set as variables $sip_profile_name = trim($_REQUEST["profile"]); $show = trim($_REQUEST["show"]); if ($show != "all") { $show = ''; } //define variables $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //create the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if (!$fp) { $msg = "
".$text['error-event-socket']."
"; } //define js function call var $onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'"; //show the error message or show the content if (strlen($msg) > 0) { echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-message']."
$msg
\n"; echo "
\n"; } else { //get sofia status profile information including registrations $cmd = "api sofia xmlstatus profile ".$sip_profile_name." reg"; $xml_response = trim(event_socket_request($fp, $cmd)); if ($xml_response == "Invalid Profile!") { $xml_response = "".$text['label-message'].""; } $xml_response = str_replace("", "", $xml_response); $xml_response = str_replace("", "", $xml_response); try { $xml = new SimpleXMLElement($xml_response); } catch(Exception $e) { echo $e->getMessage(); exit; } //build the registration array if (count($xml->registrations->registration) > 0) { $registrations = ''; $x = 0; foreach ($xml->registrations->registration as $row) { //get the values from xml and set them to the channel array $registrations[$x]['user'] = $row->{'user'} ?: " "; $user_array = explode('@', $row->{'user'}); $registrations[$x]['call-id'] = $row->{'call-id'} ?: " "; $registrations[$x]['contact'] = $row->{'contact'} ?: " "; $registrations[$x]['sip-auth-user'] = $row->{'sip-auth-user'} ?: " "; $registrations[$x]['agent'] = $row->{'agent'} ?: " "; $registrations[$x]['host'] = $row->{'host'} ?: " "; $registrations[$x]['network-port'] = $row->{'network-port'} ?: " "; $registrations[$x]['sip-auth-realm'] = $row->{'sip-auth-realm'} ?: " "; $registrations[$x]['mwi-account'] = $row->{'mwi-account'} ?: " "; $registrations[$x]['status'] = $row->{'status'} ?: " "; $registrations[$x]['ping-time'] = $row->{'ping-time'} ?: " "; //get network-ip to url or blank if(isset($row->{'network-ip'})) { $registrations[$x]['network-ip'] = "".$row->{'network-ip'}.""; }else{ $registrations[$x]['network-ip'] = " "; } //get the LAN IP address if it exists replace the external ip $call_id_array = explode('@', $row->{'call-id'}); if (isset($call_id_array[1])) { $registrations[$x]['lan-ip'] = "".$call_id_array[1].""; }else{ $registrations[$x]['lan-ip'] = " "; } //remove unrelated domains if (count($_SESSION["domains"]) > 1) { if (!(permission_exists('registration_all') && $show == "all")) { if ($registrations[$x]['sip-auth-realm'] == $_SESSION['domain_name']) {} elseif ($user_array[1] == $_SESSION['domain_name']){} else { unset($registrations[$x]); } } } //increment the array id $x++; } } //show the registrations echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['header-registrations']." (".count($registrations).")\n"; echo ""; echo " \"".$text['label-refresh_pause']."\""; echo ""; if (permission_exists('registration_all')) { if ($show == "all") { echo " \n"; } else { echo " \n"; } } echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; //order the array require_once "resources/classes/array_order.php"; $order = new array_order(); $registrations = $order->sort($registrations, 'sip-auth-realm', 'user'); //display the array if (count($registrations) > 0) { foreach ($registrations as $row) { //set the user agent $agent = $row['agent']; //show the registrations echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } } echo "
".$text['label-user']."".$text['label-agent']."".$text['label-lan_ip']."".$text['label-ip']."".$text['label-port']."".$text['label-hostname']."".$text['label-status']."".$text['label-ping']."".$text['label-tools']." 
".$row['user']." ".htmlentities($row['agent'])." ".$row['lan-ip']."".$row['network-ip']."".$row['network-port']."".$row['host']."".$row['status']."".$row['ping-time']."\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; //close the connection and unset the variable fclose($fp); unset($xml); } ?>