Update switch.php
This commit is contained in:
+46
-44
@@ -379,58 +379,60 @@ function save_gateway_xml() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save_var_xml() {
|
function save_var_xml() {
|
||||||
global $config, $domain_uuid;
|
if (is_array($_SESSION['switch']['conf'])) {
|
||||||
|
global $config, $domain_uuid;
|
||||||
|
|
||||||
//get the database connection
|
//get the database connection
|
||||||
require_once "resources/classes/database.php";
|
require_once "resources/classes/database.php";
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$database->connect();
|
$database->connect();
|
||||||
$db = $database->db;
|
$db = $database->db;
|
||||||
|
|
||||||
//open the vars.xml file
|
//open the vars.xml file
|
||||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/vars.xml","w");
|
$fout = fopen($_SESSION['switch']['conf']['dir']."/vars.xml","w");
|
||||||
|
|
||||||
//get the hostname
|
//get the hostname
|
||||||
$hostname = trim(event_socket_request_cmd('api switchname'));
|
$hostname = trim(event_socket_request_cmd('api switchname'));
|
||||||
|
|
||||||
//build the xml
|
//build the xml
|
||||||
$sql = "select * from v_vars ";
|
$sql = "select * from v_vars ";
|
||||||
$sql .= "where var_enabled = 'true' ";
|
$sql .= "where var_enabled = 'true' ";
|
||||||
$sql .= "order by var_cat, var_order asc ";
|
$sql .= "order by var_cat, var_order asc ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$prev_var_cat = '';
|
$prev_var_cat = '';
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$xml = '';
|
$xml = '';
|
||||||
foreach ($result as &$row) {
|
foreach ($result as &$row) {
|
||||||
if ($row['var_cat'] != 'Provision') {
|
if ($row['var_cat'] != 'Provision') {
|
||||||
if ($prev_var_cat != $row['var_cat']) {
|
if ($prev_var_cat != $row['var_cat']) {
|
||||||
$xml .= "\n<!-- ".$row['var_cat']." -->\n";
|
$xml .= "\n<!-- ".$row['var_cat']." -->\n";
|
||||||
if (strlen($row["var_description"]) > 0) {
|
if (strlen($row["var_description"]) > 0) {
|
||||||
$xml .= "<!-- ".base64_decode($row['var_description'])." -->\n";
|
$xml .= "<!-- ".base64_decode($row['var_description'])." -->\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['var_cat'] == 'Exec-Set') { $var_cmd = 'exec-set'; } else { $var_cmd = 'set'; }
|
||||||
|
if (strlen($row['var_hostname']) == 0) {
|
||||||
|
$xml .= "<X-PRE-PROCESS cmd=\"".$var_cmd."\" data=\"".$row['var_name']."=".$row['var_value']."\" />\n";
|
||||||
|
} elseif ($row['var_hostname'] == $hostname) {
|
||||||
|
$xml .= "<X-PRE-PROCESS cmd=\"".$var_cmd."\" data=\"".$row['var_name']."=".$row['var_value']."\" />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$prev_var_cat = $row['var_cat'];
|
||||||
if ($row['var_cat'] == 'Exec-Set') { $var_cmd = 'exec-set'; } else { $var_cmd = 'set'; }
|
|
||||||
if (strlen($row['var_hostname']) == 0) {
|
|
||||||
$xml .= "<X-PRE-PROCESS cmd=\"".$var_cmd."\" data=\"".$row['var_name']."=".$row['var_value']."\" />\n";
|
|
||||||
} elseif ($row['var_hostname'] == $hostname) {
|
|
||||||
$xml .= "<X-PRE-PROCESS cmd=\"".$var_cmd."\" data=\"".$row['var_name']."=".$row['var_value']."\" />\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$prev_var_cat = $row['var_cat'];
|
$xml .= "\n";
|
||||||
|
fwrite($fout, $xml);
|
||||||
|
unset($xml);
|
||||||
|
fclose($fout);
|
||||||
|
|
||||||
|
//apply settings
|
||||||
|
$_SESSION["reload_xml"] = true;
|
||||||
|
|
||||||
|
//$cmd = "api reloadxml";
|
||||||
|
//event_socket_request_cmd($cmd);
|
||||||
|
//unset($cmd);
|
||||||
}
|
}
|
||||||
$xml .= "\n";
|
|
||||||
fwrite($fout, $xml);
|
|
||||||
unset($xml);
|
|
||||||
fclose($fout);
|
|
||||||
|
|
||||||
//apply settings
|
|
||||||
$_SESSION["reload_xml"] = true;
|
|
||||||
|
|
||||||
//$cmd = "api reloadxml";
|
|
||||||
//event_socket_request_cmd($cmd);
|
|
||||||
//unset($cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function outbound_route_to_bridge ($domain_uuid, $destination_number) {
|
function outbound_route_to_bridge ($domain_uuid, $destination_number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user