Portions created by the Initial Developer are Copyright (C) 2008-2014 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 if (!is_array($text)) { require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } } //request profile $sip_profile_name = trim($_REQUEST["profile"]); $show = trim($_REQUEST["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']."
"; } //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-ip'] = $row->{'network-ip'}; $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'}; //remove unrelated domains if (count($_SESSION["domains"]) > 1) { if (permission_exists('registration_all') && $show == "all") { //show all registrations } else { if ($registrations[$x]['sip-auth-realm'] != $_SESSION['domain_name']) { unset($registrations[$x]); } } } //increment the array id $x++; } } //show the registrations echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['header-registrations'].": ".count($registrations)."\n"; echo "\n"; 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"; //order the array require_once "resources/classes/array_order.php"; $order = new array_order(); $registrations = $order->sort($registrations, 'domain', '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"; if ($c==0) { $c=1; } else { $c=0; } } } echo "
".$text['label-user']."".$text['label-agent']."".$text['label-ip']."".$text['label-port']."".$text['label-status']."".$text['label-tools']." 
".$row['user']." ".htmlentities($row['agent'])." ".$row['network-ip']." ".$row['network-port']." ".$row['status']." \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; //close the connection and unset the variable fclose($fp); unset($xml); } ?>