From 89bea49f38b1e6bac479ff25eed08246b77edab6 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sun, 27 Apr 2014 08:38:12 +0000 Subject: [PATCH] SIP Status, Get the SIP profile list from the database instead of the file system. --- app/sip_status/sip_status.php | 171 ++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 82 deletions(-) diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php index 5943185b64..5b2972dba1 100644 --- a/app/sip_status/sip_status.php +++ b/app/sip_status/sip_status.php @@ -101,6 +101,14 @@ if ($_GET['a'] == "download") { $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); +//get the sip profiles + $sql = "select sip_profile_name from v_sip_profiles "; + $sql .= "order by sip_profile_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $sip_profiles = $prep_statement->fetchAll(); + unset ($prep_statement, $sql); + //sofia status if ($fp && permission_exists('system_status_sofia_status')) { $cmd = "api sofia xmlstatus"; @@ -177,90 +185,89 @@ if ($_GET['a'] == "download") { //sofia status profile if (permission_exists('system_status_sofia_status_profile')) { - foreach (ListFiles($_SESSION['switch']['conf']['dir'].'/sip_profiles') as $key=>$sip_profile_file){ - if (substr($sip_profile_file, -4) == ".xml") { - $sip_profile_name = str_replace(".xml", "", $sip_profile_file); - if ($fp) { - $cmd = "api sofia xmlstatus profile ".$sip_profile_name.""; - $xml_response = trim(event_socket_request($fp, $cmd)); - if ($xml_response == "Invalid Profile!") { $xml_response = "Invalid Profile!"; } - $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; - } - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " ".$text['title-sofia-status-profile']." ".$sip_profile_name." \n"; - echo "\n"; - if ($sip_profile_name != "external") { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; + foreach ($sip_profiles as $row) { + $sip_profile_name = $row["sip_profile_name"]; - echo ""; - unset($xml); + if ($fp) { + $cmd = "api sofia xmlstatus profile ".$sip_profile_name.""; + $xml_response = trim(event_socket_request($fp, $cmd)); + if ($xml_response == "Invalid Profile!") { $xml_response = "Invalid Profile!"; } + $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; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " ".$text['title-sofia-status-profile']." ".$sip_profile_name." \n"; + echo "\n"; + if ($sip_profile_name != "external") { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo ""; + unset($xml); } } }