Update sip_status.php
This commit is contained in:
parent
efed19ef1c
commit
48661c3aa6
|
|
@ -84,29 +84,31 @@
|
||||||
$cmd = "sofia xmlstatus";
|
$cmd = "sofia xmlstatus";
|
||||||
$xml_response = trim(event_socket::api($cmd));
|
$xml_response = trim(event_socket::api($cmd));
|
||||||
if ($xml_response) {
|
if ($xml_response) {
|
||||||
|
//read the xml string into an xml object
|
||||||
$xml = new SimpleXMLElement($xml_response);
|
$xml = new SimpleXMLElement($xml_response);
|
||||||
|
|
||||||
|
//sort the SIP profiles alphabetically
|
||||||
//turn into array
|
//turn into array
|
||||||
$profilesA = array();
|
$profiles_array = array();
|
||||||
foreach($xml->profile as $profile) {
|
foreach($xml->profile as $profile) {
|
||||||
$profilesA[] = $profile;
|
$profiles_array[] = $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sort the array
|
//sort the array
|
||||||
function sortXML($a, $b) {
|
function sort_xml($a, $b) {
|
||||||
return strnatcmp($a->name, $b->name);
|
return strnatcmp($a->name, $b->name);
|
||||||
}
|
}
|
||||||
usort($profilesA, 'sortXML');
|
usort($profiles_array, 'sort_xml');
|
||||||
|
|
||||||
//convert array back to SimpleXMLElement
|
//convert array back to SimpleXMLElement
|
||||||
$xmlString = "<?xml version='1.0'?><profiles>";
|
$xml_string = "<?xml version='1.0'?><profiles>";
|
||||||
foreach ($profilesA as $node) {
|
foreach ($profiles_array as $node) {
|
||||||
$xmlStringRow = $node -> saveXML();
|
$xml_string .= $node->saveXML();
|
||||||
$xmlString = $xmlString . $xmlStringRow;
|
|
||||||
}
|
}
|
||||||
$xmlString = $xmlString . "</profiles>";
|
$xml_string .= "</profiles>";
|
||||||
|
|
||||||
$xml = simplexml_load_string($xmlString);
|
//read the xml string into a new xml object
|
||||||
|
$xml = simplexml_load_string($xml_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue