diff --git a/app/registrations/resources/classes/status_registrations.php b/app/registrations/resources/classes/status_registrations.php index 7a0e5472b0..3de6bc6dc2 100644 --- a/app/registrations/resources/classes/status_registrations.php +++ b/app/registrations/resources/classes/status_registrations.php @@ -2,71 +2,74 @@ function get_registrations($sip_profile_name) { - global $_SESSION, $fp, $show; -//get sofia status profile information including registrations - $cmd = "api sofia xmlstatus profile ".$sip_profile_name." reg"; - $xml_response = trim(event_socket_request($fp, $cmd)); + //get the global variables + global $_SESSION, $fp, $show; + + //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; + } - 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]); + //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++; - } - } - return $registrations; + //increment the array id + $x++; + } + } + + //return the registrations array + return $registrations; } -?> \ No newline at end of file +?>