".$text['label-message'].""; } $xml_response = str_replace("", "", $xml_response); $xml_response = str_replace("", "", $xml_response); if (strlen($xml_response) > 101) { try { $xml = new SimpleXMLElement($xml_response); } catch(Exception $e) { echo $e->getMessage(); exit; } $array = json_decode(json_encode($xml) , true); } //normalize the array if (is_array($array) && !is_array($array['registrations']['registration'][0])) { $row = $array['registrations']['registration']; unset($array['registrations']['registration']); $array['registrations']['registration'][0] = $row; } //set the registrations array if (is_array($array)) { $x=0; foreach ($array['registrations']['registration'] as $row) { //build the registrations array //$registrations[0] = $row; $user_array = explode('@', $row['user']); $registrations[$x]['user'] = $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])) { $agent = $row['agent']; $lan_ip = $call_id_array[1]; if (false !== stripos($agent, 'grandstream')) { $lan_ip = str_ireplace( array('A','B','C','D','E','F','G','H','I','J'), array('0','1','2','3','4','5','6','7','8','9'), $lan_ip); } $registrations[$x]['lan-ip'] = "".$lan_ip.""; } 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 the registrations array return $registrations; } ?>