diff --git a/app/gateways/gateway_delete.php b/app/gateways/gateway_delete.php index 5fe24593c8..262fd7fdfd 100644 --- a/app/gateways/gateway_delete.php +++ b/app/gateways/gateway_delete.php @@ -54,7 +54,6 @@ if (strlen($_GET["id"])>0) { foreach ($result as &$row) { $gateway = $row["gateway"]; $profile = $row["profile"]; - break; //limit to 1 row } unset ($prep_statement); @@ -65,25 +64,26 @@ if (strlen($_GET["id"])>0) { else { $gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway.".xml"; } - unlink($gateway_xml_file); + if (file_exists($gateway_xml_file)) { + unlink($gateway_xml_file); + } //create the event socket connection and stop the gateway if (!$fp) { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); } - if ($fp) { - //send the api gateway stop command over event socket - if (count($_SESSION["domains"]) > 1) { - $tmp_cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway; - } - else { - $tmp_cmd = 'api sofia profile '.$profile.' killgw '.$gateway; - } - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); - } - //delete gateway + //send the api gateway stop command over event socket + if (count($_SESSION["domains"]) > 1) { + $cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway; + } + else { + $cmd = 'api sofia profile '.$profile.' killgw '.$gateway; + } + $response = event_socket_request($fp, $cmd); + unset($cmd); + + //delete the gateway $sql = "delete from v_gateways "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and gateway_uuid = '$id' "; @@ -94,12 +94,13 @@ if (strlen($_GET["id"])>0) { save_gateway_xml(); //synchronize the xml config - save_dialplan_xml(); + //save_dialplan_xml(); //delete the gateways from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { - $switch_cmd = "memcache delete configuration:sofia.conf"; + $hostname = trim(event_socket_request($fp, 'api switchname')); + $switch_cmd = "memcache delete configuration:sofia.conf:".$hostname; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } @@ -110,9 +111,9 @@ if (strlen($_GET["id"])>0) { } if ($fp) { //send the api commandover event socket - $tmp_cmd = 'api sofia profile '.$profile.' rescan'; - $response = event_socket_request($fp, $tmp_cmd); - unset($tmp_cmd); + $cmd = 'api sofia profile '.$profile.' rescan'; + $response = event_socket_request($fp, $cmd); + unset($cmd); //close the connection fclose($fp); } diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index c0b671c076..6fd2d4868c 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -251,12 +251,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { save_gateway_xml(); //synchronize the xml config - save_dialplan_xml(); + //save_dialplan_xml(); //delete the sip profiles from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { - $switch_cmd = "memcache delete configuration:sofia.conf"; + $hostname = trim(event_socket_request($fp, 'api switchname')); + $switch_cmd = "memcache delete configuration:sofia.conf:".$hostname; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index cf46b64996..dad0dec907 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -52,12 +52,12 @@ else { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { if (strlen($_GET["a"]) > 0) { - $profile = $_GET["profile"]; + $profile = check_str($_GET["profile"]); if (strlen($profile) == 0) { $profile = 'external'; } if ($_GET["a"] == "stop") { - $gateway_name = $_GET["gateway"]; + $gateway_name = check_str($_GET["gateway"]); if (count($_SESSION["domains"]) > 1) { $cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway_name; }