Move the 'show application' completely out of the content. Then save the result in a session variable $_SESSION['switch']['applications'].

This commit is contained in:
markjcrane 2015-07-21 09:47:23 -06:00
parent f35d5bc891
commit c4517b15c2
1 changed files with 100 additions and 98 deletions

View File

@ -77,6 +77,21 @@ else {
$dialplan_description = check_str($_POST["dialplan_description"]);
}
//get the list of applications
if (count($_SESSION['switch']['applications']) == 0) {
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$result = event_socket_request($fp, 'api show application');
$_SESSION['switch']['applications'] = explode("\n\n", $result);
$_SESSION['switch']['applications'] = explode("\n", $_SESSION['switch']['applications'][0]);
unset($result);
unset($fp);
} else {
$_SESSION['switch']['applications'] = Array();
}
}
//process and save the data
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
@ -508,18 +523,6 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//display the results
if ($result_count > 0) {
//get the list of applications
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$result = event_socket_request($fp, 'api show application');
$installed_app = explode("\n\n", $result);
$installed_app = explode("\n", $installed_app[0]);
unset($result);
unset($fp);
} else {
$installed_app = Array();
}
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2' style='margin: -2px;'>\n";
$x = 0;
@ -641,7 +644,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo " <optgroup label='".$text['optgroup-applications']."'>\n";
foreach ($installed_app as $row) {
foreach ($_SESSION['switch']['applications'] as $row) {
if (strlen($row) > 0) {
$application = explode(",", $row);
if ($application[0] != "name" && stristr($application[0], "[") != true) {
@ -773,7 +776,6 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
} //end if results
} //end if update
echo "<br>\n";