mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-03-28 03:05:41 +00:00
Change gateway name to gateway uuid.
This commit is contained in:
@@ -48,7 +48,7 @@ else {
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//get the http post values and set theme as php variables
|
||||
if (count($_POST)>0) {
|
||||
if (count($_POST) > 0) {
|
||||
//set the variables
|
||||
$dialplan_name = check_str($_POST["dialplan_name"]);
|
||||
$dialplan_order = check_str($_POST["dialplan_order"]);
|
||||
@@ -139,52 +139,11 @@ else {
|
||||
$gateway_3_id = '';
|
||||
$gateway_3_name = '';
|
||||
}
|
||||
|
||||
if (permission_exists('outbound_route_any_gateway')) {
|
||||
//get the domain_uuid for gateway
|
||||
$sql = "select * from v_gateways ";
|
||||
$sql .= "where gateway_uuid = '$gateway_uuid' ";
|
||||
$sql .= "and gateway = '$gateway_name' ";
|
||||
$sql .= "and enabled = 'true' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$gateway_domain_uuid = $row["domain_uuid"];
|
||||
break;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
//get the domain_uuid for gateway_2
|
||||
$sql = "select * from v_gateways ";
|
||||
$sql .= "where gateway_uuid = '$gateway_2_id' ";
|
||||
$sql .= "and gateway = '$gateway_2_name' ";
|
||||
$sql .= "and enabled = 'true' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$gateway_2_domain_uuid = $row["domain_uuid"];
|
||||
break;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
//get the domain_uuid for gateway_3
|
||||
$sql = "select * from v_gateways ";
|
||||
$sql .= "where gateway_uuid = '$gateway_3_id' ";
|
||||
$sql .= "and gateway = '$gateway_3_name' ";
|
||||
$sql .= "and enabled = 'true' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$gateway_3_domain_uuid = $row["domain_uuid"];
|
||||
break;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
|
||||
$dialplan_description = check_str($_POST["dialplan_description"]);
|
||||
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled
|
||||
//set additional variables
|
||||
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
|
||||
$dialplan_description = check_str($_POST["dialplan_description"]);
|
||||
//set default to enabled
|
||||
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; }
|
||||
}
|
||||
|
||||
//process the http form values
|
||||
@@ -219,40 +178,7 @@ else {
|
||||
|
||||
foreach($tmp_array as $dialplan_expression) {
|
||||
$dialplan_expression = trim($dialplan_expression);
|
||||
if (strlen($dialplan_expression)>0) {
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
if (permission_exists('outbound_route_any_gateway')) {
|
||||
$tmp_gateway_name = $_SESSION['domains'][$gateway_domain_uuid]['domain_name'] .'-'.$gateway_name;
|
||||
}
|
||||
else {
|
||||
$tmp_gateway_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_name;
|
||||
}
|
||||
if (strlen($gateway_2_name) > 0) {
|
||||
if (permission_exists('outbound_route_any_gateway')) {
|
||||
$tmp_gateway_2_name = $_SESSION['domains'][$gateway_2_domain_uuid]['domain_name'] .'-'.$gateway_2_name;
|
||||
}
|
||||
else {
|
||||
$tmp_gateway_2_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_2_name;
|
||||
}
|
||||
}
|
||||
if (strlen($gateway_3_name) > 0) {
|
||||
if (permission_exists('outbound_route_any_gateway')) {
|
||||
$tmp_gateway_3_name = $_SESSION['domains'][$gateway_3_domain_uuid]['domain_name'] .'-'.$gateway_3_name;
|
||||
}
|
||||
else {
|
||||
$tmp_gateway_3_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_3_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tmp_gateway_name = $gateway_name;
|
||||
if (strlen($gateway_2_name) > 0) {
|
||||
$tmp_gateway_2_name = $gateway_2_name;
|
||||
}
|
||||
if (strlen($gateway_3_name) > 0) {
|
||||
$tmp_gateway_3_name = $gateway_3_name;
|
||||
}
|
||||
}
|
||||
if (strlen($dialplan_expression) > 0) {
|
||||
switch ($dialplan_expression) {
|
||||
case "^(\d{7})$":
|
||||
$label = $text['label-7d'];
|
||||
@@ -333,15 +259,15 @@ else {
|
||||
|
||||
if ($gateway_type == "gateway") {
|
||||
$dialplan_name = $gateway_name.".".$abbrv;
|
||||
$action_data = "sofia/gateway/".$tmp_gateway_name."/".$prefix_number."\$1";
|
||||
$action_data = "sofia/gateway/".$gateway_uuid."/".$prefix_number."\$1";
|
||||
}
|
||||
if (strlen($gateway_2_name) > 0 && $gateway_2_type == "gateway") {
|
||||
$extension_2_name = $gateway_2_name.".".$abbrv;
|
||||
$bridge_2_data .= "sofia/gateway/".$tmp_gateway_2_name."/".$prefix_number."\$1";
|
||||
$extension_2_name = $gateway_2_id.".".$abbrv;
|
||||
$bridge_2_data .= "sofia/gateway/".$gateway_2_id."/".$prefix_number."\$1";
|
||||
}
|
||||
if (strlen($gateway_3_name) > 0 && $gateway_3_type == "gateway") {
|
||||
$extension_3_name = $gateway_3_name.".".$abbrv;
|
||||
$bridge_3_data .= "sofia/gateway/".$tmp_gateway_3_name."/".$prefix_number."\$1";
|
||||
$extension_3_name = $gateway_3_id.".".$abbrv;
|
||||
$bridge_3_data .= "sofia/gateway/".$gateway_3_id."/".$prefix_number."\$1";
|
||||
}
|
||||
if ($gateway_type == "freetdm") {
|
||||
$dialplan_name = "freetdm.".$abbrv;
|
||||
@@ -492,14 +418,12 @@ else {
|
||||
$dialplan_detail_group = '';
|
||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||
|
||||
if (strlen($bridge_2_data) > 0) {
|
||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||
$dialplan_detail_type = 'set';
|
||||
$dialplan_detail_data = 'continue_on_fail=true';
|
||||
$dialplan_detail_order = '040';
|
||||
$dialplan_detail_group = '';
|
||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||
}
|
||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||
$dialplan_detail_type = 'set';
|
||||
$dialplan_detail_data = 'continue_on_fail=true';
|
||||
$dialplan_detail_order = '040';
|
||||
$dialplan_detail_group = '';
|
||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||
|
||||
if ($gateway_type == "enum" || $gateway_2_type == "enum") {
|
||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||
@@ -639,7 +563,6 @@ function type_onchange(dialplan_detail_type) {
|
||||
echo "<br />\n";
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
||||
echo " ".$text['label-gateway'].":\n";
|
||||
|
||||
@@ -52,6 +52,7 @@ if (strlen($_GET["id"])>0) {
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$gateway_uuid = $row["gateway_uuid"];
|
||||
$gateway = $row["gateway"];
|
||||
$profile = $row["profile"];
|
||||
}
|
||||
@@ -62,7 +63,7 @@ if (strlen($_GET["id"])>0) {
|
||||
$gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$_SESSION['domain_name'].'-'.$gateway.".xml";
|
||||
}
|
||||
else {
|
||||
$gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway.".xml";
|
||||
$gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway_uuid.".xml";
|
||||
}
|
||||
if (file_exists($gateway_xml_file)) {
|
||||
unlink($gateway_xml_file);
|
||||
@@ -74,12 +75,7 @@ if (strlen($_GET["id"])>0) {
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
$cmd = 'api sofia profile '.$profile.' killgw '.$gateway_uuid;
|
||||
$response = event_socket_request($fp, $cmd);
|
||||
unset($cmd);
|
||||
|
||||
|
||||
@@ -57,18 +57,13 @@ else {
|
||||
$profile = 'external';
|
||||
}
|
||||
if ($_GET["a"] == "stop") {
|
||||
$gateway_name = check_str($_GET["gateway"]);
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway_name;
|
||||
}
|
||||
else {
|
||||
$cmd = 'api sofia profile '.$profile.' killgw '.$gateway_name;
|
||||
}
|
||||
$gateway_uuid = check_str($_GET["gateway"]);
|
||||
$cmd = 'api sofia profile '.$profile.' killgw '.$gateway_uuid;
|
||||
$response = trim(event_socket_request($fp, $cmd));
|
||||
$msg = '<strong>Stop Gateway:</strong><pre>'.$response.'</pre>';
|
||||
}
|
||||
if ($_GET["a"] == "start") {
|
||||
$gateway_name = $_GET["gateway"];
|
||||
$gateway_uuid = $_GET["gateway"];
|
||||
$cmd = 'api sofia profile '.$profile.' rescan';
|
||||
$response = trim(event_socket_request($fp, $cmd));
|
||||
$msg = '<strong>Start Gateway:</strong><pre>'.$response.'</pre>';
|
||||
@@ -76,14 +71,9 @@ else {
|
||||
}
|
||||
|
||||
if (!function_exists('switch_gateway_status')) {
|
||||
function switch_gateway_status($gateway_name, $result_type = 'xml') {
|
||||
function switch_gateway_status($gateway_uuid, $result_type = 'xml') {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$cmd = 'api sofia xmlstatus gateway '.$_SESSION['domain_name'].'-'.$gateway_name;
|
||||
}
|
||||
else {
|
||||
$cmd = 'api sofia xmlstatus gateway '.$gateway_name;
|
||||
}
|
||||
$cmd = 'api sofia xmlstatus gateway '.$gateway_uuid;
|
||||
return trim(event_socket_request($fp, $cmd));
|
||||
}
|
||||
}
|
||||
@@ -179,11 +169,11 @@ else {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$row["context"]."</td>\n";
|
||||
if ($fp) {
|
||||
if ($row["enabled"] == "true") {
|
||||
$response = switch_gateway_status($row["gateway"]);
|
||||
$response = switch_gateway_status($row["gateway_uuid"]);
|
||||
if ($response == "Invalid Gateway!") {
|
||||
//not running
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-status-stopped']."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='gateways.php?a=start&gateway=".$row["gateway"]."&profile=".$row["profile"]."' alt='".$text['label-action-start']."'>".$text['label-action-start']."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='gateways.php?a=start&gateway=".$row["gateway_uuid"]."&profile=".$row["profile"]."' alt='".$text['label-action-start']."'>".$text['label-action-start']."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'> </td>\n";
|
||||
}
|
||||
else {
|
||||
@@ -192,7 +182,7 @@ else {
|
||||
$xml = new SimpleXMLElement($response);
|
||||
$state = $xml->state;
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-status-running']."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='gateways.php?a=stop&gateway=".$row["gateway"]."&profile=".$row["profile"]."' alt='".$text['label-action-stop']."'>".$text['label-action-stop']."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'><a href='gateways.php?a=stop&gateway=".$row["gateway_uuid"]."&profile=".$row["profile"]."' alt='".$text['label-action-stop']."'>".$text['label-action-stop']."</a></td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".$state."</td>\n"; //REGED, NOREG, UNREGED
|
||||
}
|
||||
catch(Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user