Update provision.php
Fix the variables in the device_keys array.
This commit is contained in:
parent
2636bfacc7
commit
75b36f0cf0
|
|
@ -550,7 +550,22 @@ include "root.php";
|
|||
$lines[$line_number]['user_id'] = $row["user_id"];
|
||||
$lines[$line_number]['password'] = $row["password"];
|
||||
|
||||
//assign the variables
|
||||
//assign the variables for line one - short name
|
||||
if ($line_number == "1") {
|
||||
$view->assign("server_address", $row["server_address"]);
|
||||
$view->assign("outbound_proxy", $row["outbound_proxy_primary"]);
|
||||
$view->assign("outbound_proxy_primary", $row["outbound_proxy_primary"]);
|
||||
$view->assign("outbound_proxy_secondary", $row["outbound_proxy_secondary"]);
|
||||
$view->assign("display_name", $row["display_name"]);
|
||||
$view->assign("auth_id", $row["auth_id"]);
|
||||
$view->assign("user_id", $row["user_id"]);
|
||||
$view->assign("user_password", $row["password"]);
|
||||
$view->assign("sip_transport", $sip_transport);
|
||||
$view->assign("sip_port", $sip_port);
|
||||
$view->assign("register_expires", $register_expires);
|
||||
}
|
||||
|
||||
//assign the variables with the line number as part of the name
|
||||
$view->assign("server_address_".$line_number, $row["server_address"]);
|
||||
$view->assign("outbound_proxy_".$line_number, $row["outbound_proxy_primary"]);
|
||||
$view->assign("outbound_proxy_primary_".$line_number, $row["outbound_proxy_primary"]);
|
||||
|
|
@ -701,11 +716,45 @@ include "root.php";
|
|||
exit;
|
||||
}
|
||||
|
||||
//set the variables key and values
|
||||
$x = 1;
|
||||
$variables['domain_name'] = $domain_name;
|
||||
$variables['user_id'] = $lines[$x]['user_id'];
|
||||
$variables['auth_id'] = $lines[$x]['auth_id'];
|
||||
$variables['extension'] = $lines[$x]['extension'];
|
||||
//$variables['password'] = $lines[$x]['password'];
|
||||
$variables['register_expires'] = $lines[$x]['register_expires'];
|
||||
$variables['sip_transport'] = $lines[$x]['sip_transport'];
|
||||
$variables['sip_port'] = $lines[$x]['sip_port'];
|
||||
$variables['server_address'] = $lines[$x]['server_address'];
|
||||
$variables['outbound_proxy'] = $lines[$x]['outbound_proxy_primary'];
|
||||
$variables['outbound_proxy_primary'] = $lines[$x]['outbound_proxy_primary'];
|
||||
$variables['outbound_proxy_secondary'] = $lines[$x]['outbound_proxy_secondary'];
|
||||
$variables['display_name'] = $lines[$x]['display_name'];
|
||||
|
||||
//update the device keys by replacing variables with their values
|
||||
foreach($variables as $name => $value) {
|
||||
foreach($device_keys as $k => $field) {
|
||||
if (strlen($field['device_key_uuid']) > 0) {
|
||||
$device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']);
|
||||
$device_keys[$k]['device_key_extension'] = str_replace("\${".$name."}", $value, $field['device_key_extension']);
|
||||
$device_keys[$k]['device_key_label'] = str_replace("\${".$name."}", $value, $field['device_key_label']);
|
||||
}
|
||||
else {
|
||||
foreach($field as $key => $row) {
|
||||
$device_keys[$k][$key]['device_key_value'] = str_replace("\${".$name."}", $value, $row['device_key_value']);
|
||||
$device_keys[$k][$key]['device_key_extension'] = str_replace("\${".$name."}", $value, $row['device_key_extension']);
|
||||
$device_keys[$k][$key]['device_key_label'] = str_replace("\${".$name."}", $value, $row['device_key_label']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//assign the keys array
|
||||
$view->assign("keys", $device_keys);
|
||||
|
||||
//set the variables
|
||||
foreach($device_keys as $row) {
|
||||
foreach($device_keys['line'] as $row) {
|
||||
//set the variables
|
||||
$device_key_category = $row['device_key_category'];
|
||||
$device_key_id = $row['device_key_id']; //1
|
||||
|
|
@ -715,91 +764,6 @@ include "root.php";
|
|||
$device_key_extension = $row['device_key_extension'];
|
||||
$device_key_label = $row['device_key_label']; //label
|
||||
|
||||
//set the line key
|
||||
$x = $device_key_line;
|
||||
|
||||
//add a simple variable with the index
|
||||
if ($x === 0 || $x === 1) {
|
||||
$device_key_value = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${password}", $lines[$x]['password'], $device_key_value);
|
||||
$device_key_value = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_value);
|
||||
$device_key_value = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_value);
|
||||
$device_key_value = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_value);
|
||||
$device_key_value = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy_primary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy_primary}", $lines[$x]['outbound_proxy_primary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy_secondary}", $lines[$x]['outbound_proxy_secondary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_value);
|
||||
|
||||
$device_key_extension = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${password}", $lines[$x]['password'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy_primary'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${outbound_proxy_primary}", $lines[$x]['outbound_proxy_primary'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${outbound_proxy_secondary}", $lines[$x]['outbound_proxy_secondary'], $device_key_extension);
|
||||
$device_key_extension = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_extension);
|
||||
|
||||
$device_key_label = str_replace("\${user_id}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${auth_id}", $lines[$x]['auth_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${extension}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${password}", $lines[$x]['password'], $device_key_label);
|
||||
$device_key_label = str_replace("\${register_expires}", $lines[$x]['register_expires'], $device_key_label);
|
||||
$device_key_label = str_replace("\${sip_transport}", $lines[$x]['sip_transport'], $device_key_label);
|
||||
$device_key_label = str_replace("\${sip_port}", $lines[$x]['sip_port'], $device_key_label);
|
||||
$device_key_label = str_replace("\${server_address}", $lines[$x]['server_address'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy_primary}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy_secondary}", $lines[$x]['outbound_proxy_secondary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${display_name}", $lines[$x]['display_name'], $device_key_label);
|
||||
}
|
||||
|
||||
//add variables with the index
|
||||
$device_key_value = str_replace("\${user_id_$x}", $lines[$x]['user_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${auth_id_$x}", $lines[$x]['auth_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${extension_$x}", $lines[$x]['user_id'], $device_key_value);
|
||||
$device_key_value = str_replace("\${password_$x}", $lines[$x]['password'], $device_key_value);
|
||||
$device_key_value = str_replace("\${register_expires_$x}", $lines[$x]['register_expires'], $device_key_value);
|
||||
$device_key_value = str_replace("\${sip_transport_$x}", $lines[$x]['sip_transport'], $device_key_value);
|
||||
$device_key_value = str_replace("\${sip_port_$x}", $lines[$x]['sip_port'], $device_key_value);
|
||||
$device_key_value = str_replace("\${server_address_$x}", $lines[$x]['server_address'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy_primary_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${outbound_proxy_secondary_$x}", $lines[$x]['outbound_proxy_secondary'], $device_key_value);
|
||||
$device_key_value = str_replace("\${display_name_$x}", $lines[$x]['display_name'], $device_key_value);
|
||||
|
||||
$device_key_extension = str_replace("\${user_id_$x}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${auth_id_$x}", $lines[$x]['auth_id'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${extension_$x}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${password_$x}", $lines[$x]['password'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${register_expires_$x}", $lines[$x]['register_expires'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${sip_transport_$x}", $lines[$x]['sip_transport'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${sip_port_$x}", $lines[$x]['sip_port'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${server_address_$x}", $lines[$x]['server_address'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${outbound_proxy_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${outbound_proxy_primary_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${outbound_proxy_secondary_$x}", $lines[$x]['outbound_proxy_secondary'], $device_key_label);
|
||||
$device_key_extension = str_replace("\${display_name_$x}", $lines[$x]['display_name'], $device_key_label);
|
||||
|
||||
$device_key_label = str_replace("\${user_id_$x}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${auth_id_$x}", $lines[$x]['auth_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${extension_$x}", $lines[$x]['user_id'], $device_key_label);
|
||||
$device_key_label = str_replace("\${password_$x}", $lines[$x]['password'], $device_key_label);
|
||||
$device_key_label = str_replace("\${register_expires_$x}", $lines[$x]['register_expires'], $device_key_label);
|
||||
$device_key_label = str_replace("\${sip_transport_$x}", $lines[$x]['sip_transport'], $device_key_label);
|
||||
$device_key_label = str_replace("\${sip_port_$x}", $lines[$x]['sip_port'], $device_key_label);
|
||||
$device_key_label = str_replace("\${server_address_$x}", $lines[$x]['server_address'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy_primary_$x}", $lines[$x]['outbound_proxy_primary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${outbound_proxy_secondary_$x}", $lines[$x]['outbound_proxy_secondary'], $device_key_label);
|
||||
$device_key_label = str_replace("\${display_name_$x}", $lines[$x]['display_name'], $device_key_label);
|
||||
|
||||
//add general variables
|
||||
$device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value);
|
||||
$device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension);
|
||||
|
|
|
|||
Loading…
Reference in New Issue