mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-05 15:39:24 +00:00
move the dynamic provision variables that are defined in the variables page and move them to default settings and domain settings. Example use in default and domain settings.
category=provision, subcategory=sip_transport, name=var, value=tls - used in the template as {v_sip_transport}
This commit is contained in:
@@ -48,4 +48,43 @@
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
|
||||
//move the dynamic provision variables that from v_vars table to v_default_settings
|
||||
if (count($_SESSION['provision']) == 0 && $domains_processed == 1) {
|
||||
$sql = "select * from v_vars ";
|
||||
$sql .= "where var_cat = 'Provision' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$sql = "insert into v_default_settings ";
|
||||
$sql .= "(";
|
||||
$sql .= "default_setting_uuid, ";
|
||||
$sql .= "default_setting_category, ";
|
||||
$sql .= "default_setting_subcategory, ";
|
||||
$sql .= "default_setting_name, ";
|
||||
$sql .= "default_setting_value, ";
|
||||
$sql .= "default_setting_enabled, ";
|
||||
$sql .= "default_setting_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'provision', ";
|
||||
$sql .= "'".check_str($row['var_name'])."', ";
|
||||
$sql .= "'var', ";
|
||||
$sql .= "'".check_str($row['var_value'])."', ";
|
||||
$sql .= "'".check_str($row['var_enabled'])."', ";
|
||||
$sql .= "'".check_str($row['var_description'])."' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
//delete the provision variables from system -> variables
|
||||
//$sql = "delete from v_vars ";
|
||||
//$sql .= "where var_cat = 'Provision' ";
|
||||
//echo $sql ."\n";
|
||||
//$db->exec(check_sql($sql));
|
||||
//echo "$var_name $var_value \n";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -32,27 +32,10 @@ require_once "includes/require.php";
|
||||
$tmp_array = '';
|
||||
$phone_template = '';
|
||||
|
||||
//get any system -> variables defined in the 'provision;
|
||||
$sql = "select * from v_vars ";
|
||||
$sql .= "where var_enabled = 'true' ";
|
||||
$sql .= "and var_cat = 'Provision' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$provision_variables_array = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($provision_variables_array as &$row) {
|
||||
if ($row['var_name'] == "password") {
|
||||
$var_name = $row['var_name'];
|
||||
$var_value = $row['var_value'];
|
||||
$$var_name = $var_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if password was defined in the system -> variables page then require the password.
|
||||
if (strlen($password) > 0) {
|
||||
if (strlen($_SESSION['provision']['password']['var']) > 0) {
|
||||
//deny access if the password doesn't match
|
||||
if ($password != $_REQUEST['password']) {
|
||||
if ($_SESSION['provision']['password']['var'] != $_REQUEST['password']) {
|
||||
//log the failed auth attempt to the system, to be available for fail2ban.
|
||||
openlog('FusionPBX', LOG_NDELAY, LOG_AUTH);
|
||||
syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt bad password for ".$_REQUEST['mac']);
|
||||
@@ -376,15 +359,13 @@ require_once "includes/require.php";
|
||||
$file_contents = str_replace("{v_line".$i."_user_password}", "", $file_contents);
|
||||
}
|
||||
|
||||
//replace the dynamic provision variables that are defined in the system -> variables page
|
||||
foreach ($provision_variables_array as &$row) {
|
||||
if (substr($var_name, 0, 2) == "v_") {
|
||||
$file_contents = str_replace('{'.$row[var_name].'}', $row[var_value], $file_contents);
|
||||
}
|
||||
//replace the dynamic provision variables that are defined in 'default settings' and 'domain settings'
|
||||
//example: category=provision, subcategory=sip_transport, name=var, value=tls - used in the template as {v_sip_transport}
|
||||
foreach($_SESSION['provision'] as $key=>$value) {
|
||||
$file_contents = str_replace('{v_'.$key.'}', $value['var'], $file_contents);
|
||||
}
|
||||
|
||||
//deliver the customized config over HTTP/HTTPS
|
||||
|
||||
//need to make sure content-type is correct
|
||||
$cfg_ext = ".cfg";
|
||||
if ($phone_vendor === "aastra" && strrpos($file, $cfg_ext, 0) === strlen($file) - strlen($cfg_ext)) {
|
||||
|
||||
@@ -39,21 +39,6 @@ else {
|
||||
$row_count = 0;
|
||||
$tmp_array = '';
|
||||
|
||||
//get any system -> variables defined in the 'provision;
|
||||
$sql = "select * from v_vars ";
|
||||
$sql .= "where var_enabled = 'true' ";
|
||||
$sql .= "and var_cat = 'Provision' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$provision_variables_array = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($provision_variables_array as &$row) {
|
||||
if ($row[var_name] == "password") {
|
||||
$var_name = $row[var_name];
|
||||
$var_value = $row[var_value];
|
||||
$$var_name = $var_value;
|
||||
}
|
||||
}
|
||||
|
||||
//get the hardware phone list
|
||||
$sql = "select * from v_hardware_phones ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
@@ -186,11 +171,10 @@ else {
|
||||
$file_contents = str_replace("{v_server1_address}", $server1_address, $file_contents);
|
||||
$file_contents = str_replace("{v_proxy1_address}", $proxy1_address, $file_contents);
|
||||
|
||||
//replace the dynamic provision variables that are defined in the system -> variables page
|
||||
foreach ($provision_variables_array as &$row) {
|
||||
if (substr($var_name, 0, 2) == "v_") {
|
||||
$file_contents = str_replace('{'.$row[var_name].'}', $row[var_value], $file_contents);
|
||||
}
|
||||
//replace the dynamic provision variables that are defined in 'default settings' and 'domain settings';
|
||||
//example: category=provision, subcategory=sip_transport, name=var, value=tls - used in the template as {v_sip_transport}
|
||||
foreach($_SESSION['provision'] as $key=>$value) {
|
||||
$file_contents = str_replace('{v_'.$key.'}', $value['var'], $file_contents);
|
||||
}
|
||||
|
||||
//create a mac address with back slashes for backwards compatability
|
||||
|
||||
Reference in New Issue
Block a user