From 48661c3aa64945cff7b39a1fe604e2ce6f49bed6 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 22 Mar 2025 15:45:19 -0600 Subject: [PATCH] Update sip_status.php --- app/sip_status/sip_status.php | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php index 369d275272..fcbd4ae396 100644 --- a/app/sip_status/sip_status.php +++ b/app/sip_status/sip_status.php @@ -84,29 +84,31 @@ $cmd = "sofia xmlstatus"; $xml_response = trim(event_socket::api($cmd)); if ($xml_response) { + //read the xml string into an xml object $xml = new SimpleXMLElement($xml_response); - + + //sort the SIP profiles alphabetically //turn into array - $profilesA = array(); - foreach($xml->profile as $profile) { - $profilesA[] = $profile; - } - + $profiles_array = array(); + foreach($xml->profile as $profile) { + $profiles_array[] = $profile; + } + //sort the array - function sortXML($a, $b) { - return strnatcmp($a->name, $b->name); - } - usort($profilesA, 'sortXML'); + function sort_xml($a, $b) { + return strnatcmp($a->name, $b->name); + } + usort($profiles_array, 'sort_xml'); //convert array back to SimpleXMLElement - $xmlString = ""; - foreach ($profilesA as $node) { - $xmlStringRow = $node -> saveXML(); - $xmlString = $xmlString . $xmlStringRow; - } - $xmlString = $xmlString . ""; - - $xml = simplexml_load_string($xmlString); + $xml_string = ""; + foreach ($profiles_array as $node) { + $xml_string .= $node->saveXML(); + } + $xml_string .= ""; + + //read the xml string into a new xml object + $xml = simplexml_load_string($xml_string); } } catch(Exception $e) {