Fix the device line default values and use the settings class
This commit is contained in:
parent
5e8271ecc6
commit
2aae8635db
|
|
@ -44,8 +44,9 @@
|
||||||
$device_firmware_version = '';
|
$device_firmware_version = '';
|
||||||
$device_template ='';
|
$device_template ='';
|
||||||
|
|
||||||
//get the domain uuid
|
//get the domain values
|
||||||
$domain_uuid = $_SESSION['domain_uuid'] ?? '';
|
$domain_uuid = $_SESSION['domain_uuid'] ?? '';
|
||||||
|
$domain_name = $_SESSION['domain_name'] ?? '';
|
||||||
|
|
||||||
//initialize the database object
|
//initialize the database object
|
||||||
$database = database::new();
|
$database = database::new();
|
||||||
|
|
@ -64,12 +65,12 @@
|
||||||
|
|
||||||
//get the total device count from the database, check the limit, if defined
|
//get the total device count from the database, check the limit, if defined
|
||||||
if ($action == 'add') {
|
if ($action == 'add') {
|
||||||
if (!empty($_SESSION['limit']['devices']['numeric']) && $_SESSION['limit']['devices']['numeric']) {
|
if (!empty($settings->get('limit', 'devices', ''))) {
|
||||||
$sql = "select count(*) from v_devices where domain_uuid = :domain_uuid ";
|
$sql = "select count(*) from v_devices where domain_uuid = :domain_uuid ";
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
$total_devices = $database->select($sql, $parameters, 'column');
|
$total_devices = $database->select($sql, $parameters, 'column');
|
||||||
if ($total_devices >= $_SESSION['limit']['devices']['numeric']) {
|
if ($total_devices >= $settings->get('limit', 'devices', '')) {
|
||||||
message::add($text['message-maximum_devices'].' '.$_SESSION['limit']['devices']['numeric'], 'negative');
|
message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative');
|
||||||
header('Location: devices.php');
|
header('Location: devices.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
@ -228,14 +229,14 @@
|
||||||
$sql .= " and d1.device_uuid <> :device_uuid ";
|
$sql .= " and d1.device_uuid <> :device_uuid ";
|
||||||
}
|
}
|
||||||
$parameters['device_address'] = $device_address;
|
$parameters['device_address'] = $device_address;
|
||||||
$domain_name = $database->select($sql, $parameters, 'column');
|
$device_domain_name = $database->select($sql, $parameters, 'column');
|
||||||
if ($domain_name != '') {
|
if ($device_domain_name != '') {
|
||||||
$message = $text['message-duplicate'].(if_group("superadmin") && $_SESSION["domain_name"] != $domain_name ? ": ".$domain_name : null);
|
$message = $text['message-duplicate'].($device_domain_name != $domain_name ? ": ".$device_domain_name : null);
|
||||||
message::add($message,'negative');
|
message::add($message,'negative');
|
||||||
header('Location: devices.php');
|
header('Location: devices.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
unset($sql, $parameters, $domain_name);
|
unset($sql, $parameters, $device_domain_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add or update the database
|
//add or update the database
|
||||||
|
|
@ -304,6 +305,7 @@
|
||||||
$device_line_uuid = uuid();
|
$device_line_uuid = uuid();
|
||||||
$new_line = true;
|
$new_line = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$array['devices'][0]['device_lines'][$y]['domain_uuid'] = $domain_uuid;
|
$array['devices'][0]['device_lines'][$y]['domain_uuid'] = $domain_uuid;
|
||||||
$array['devices'][0]['device_lines'][$y]['device_uuid'] = $device_uuid;
|
$array['devices'][0]['device_lines'][$y]['device_uuid'] = $device_uuid;
|
||||||
$array['devices'][0]['device_lines'][$y]['device_line_uuid'] = $device_line_uuid;
|
$array['devices'][0]['device_lines'][$y]['device_line_uuid'] = $device_line_uuid;
|
||||||
|
|
@ -311,23 +313,23 @@
|
||||||
$array['devices'][0]['device_lines'][$y]['server_address'] = $row["server_address"];
|
$array['devices'][0]['device_lines'][$y]['server_address'] = $row["server_address"];
|
||||||
if (permission_exists('device_line_outbound_proxy_primary')) {
|
if (permission_exists('device_line_outbound_proxy_primary')) {
|
||||||
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $row["outbound_proxy_primary"];
|
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $row["outbound_proxy_primary"];
|
||||||
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_primary'])) {
|
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_primary'))) {
|
||||||
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'];
|
$array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', '');
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_outbound_proxy_secondary')) {
|
if (permission_exists('device_line_outbound_proxy_secondary')) {
|
||||||
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"];
|
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"];
|
||||||
} else if ($new_line && isset($_SESSION['provision']['outbound_proxy_secondary'])) {
|
} else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_secondary'))) {
|
||||||
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'];
|
$array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', '');
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_server_address_primary')) {
|
if (permission_exists('device_line_server_address_primary')) {
|
||||||
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $row["server_address_primary"];
|
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $row["server_address_primary"];
|
||||||
} else if ($new_line && isset($_SESSION['provision']['server_address_primary'])) {
|
} else if ($new_line && !empty($settings->get('provision', 'server_address_primary'))) {
|
||||||
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'];
|
$array['devices'][0]['device_lines'][$y]['server_address_primary'] = $settings->get('provision', 'server_address_primary', '');
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_server_address_secondary')) {
|
if (permission_exists('device_line_server_address_secondary')) {
|
||||||
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $row["server_address_secondary"];
|
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $row["server_address_secondary"];
|
||||||
} else if ($new_line && isset($_SESSION['provision']['server_address_secondary'])) {
|
} else if ($new_line && !empty($settings->get('provision', 'server_address_secondary'))) {
|
||||||
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'];
|
$array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', '');
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_label')) {
|
if (permission_exists('device_line_label')) {
|
||||||
$array['devices'][0]['device_lines'][$y]['label'] = $row["label"];
|
$array['devices'][0]['device_lines'][$y]['label'] = $row["label"];
|
||||||
|
|
@ -351,7 +353,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($action == "add") {
|
if ($action == "add") {
|
||||||
$array['devices'][0]['device_lines'][$y]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
|
$array['devices'][0]['device_lines'][$y]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_transport')) {
|
if (permission_exists('device_line_transport')) {
|
||||||
|
|
@ -359,7 +361,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($action == "add") {
|
if ($action == "add") {
|
||||||
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
|
$array['devices'][0]['device_lines'][$y]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permission_exists('device_line_register_expires')) {
|
if (permission_exists('device_line_register_expires')) {
|
||||||
|
|
@ -367,7 +369,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($action == "add") {
|
if ($action == "add") {
|
||||||
$array['devices'][0]['device_lines'][$y]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
|
$array['devices'][0]['device_lines'][$y]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$y++;
|
$y++;
|
||||||
|
|
@ -480,7 +482,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//write the provision files
|
//write the provision files
|
||||||
if (!empty($_SESSION['provision']['path']['text'])) {
|
if (!empty($settings->get('provision', 'path'))) {
|
||||||
$prov = new provision(['settings' => $settings]);
|
$prov = new provision(['settings' => $settings]);
|
||||||
$prov->domain_uuid = $domain_uuid;
|
$prov->domain_uuid = $domain_uuid;
|
||||||
$response = $prov->write();
|
$response = $prov->write();
|
||||||
|
|
@ -509,7 +511,6 @@
|
||||||
$sql = "select * from v_devices ";
|
$sql = "select * from v_devices ";
|
||||||
$sql .= "where device_uuid = :device_uuid ";
|
$sql .= "where device_uuid = :device_uuid ";
|
||||||
$parameters['device_uuid'] = $device_uuid;
|
$parameters['device_uuid'] = $device_uuid;
|
||||||
|
|
||||||
$row = $database->select($sql, $parameters, 'row');
|
$row = $database->select($sql, $parameters, 'row');
|
||||||
if (is_array($row) && @sizeof($row) != 0) {
|
if (is_array($row) && @sizeof($row) != 0) {
|
||||||
$device_address = $row["device_address"];
|
$device_address = $row["device_address"];
|
||||||
|
|
@ -533,6 +534,14 @@
|
||||||
unset($sql, $parameters, $row);
|
unset($sql, $parameters, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get device lines
|
||||||
|
$sql = "select * ";
|
||||||
|
$sql .= "from v_domains ";
|
||||||
|
$sql .= "where domain_enabled = true ";
|
||||||
|
$sql .= "order by domain_name asc ";
|
||||||
|
$domains = $database->select($sql, null, 'all');
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
//set the defaults
|
//set the defaults
|
||||||
if (empty($device_enabled)) { $device_enabled = 'true'; }
|
if (empty($device_enabled)) { $device_enabled = 'true'; }
|
||||||
|
|
||||||
|
|
@ -563,20 +572,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
//get device lines
|
//get device lines
|
||||||
$sql = "select * from v_device_lines ";
|
$sql = "select l.*, d.domain_name ";
|
||||||
|
$sql .= "from v_device_lines as l, v_domains as d ";
|
||||||
$sql .= "where device_uuid = :device_uuid ";
|
$sql .= "where device_uuid = :device_uuid ";
|
||||||
|
$sql .= "and l.domain_uuid = d.domain_uuid ";
|
||||||
$sql .= "order by cast(line_number as int) asc ";
|
$sql .= "order by cast(line_number as int) asc ";
|
||||||
$parameters['device_uuid'] = $device_uuid ?? null;
|
$parameters['device_uuid'] = $device_uuid ?? null;
|
||||||
|
|
||||||
$device_lines = $database->select($sql, $parameters, 'all');
|
$device_lines = $database->select($sql, $parameters, 'all');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
//set the new line defaults
|
||||||
$device_lines[$x]['line_number'] = '';
|
$device_lines[$x]['line_number'] = '';
|
||||||
$device_lines[$x]['server_address'] = '';
|
$device_lines[$x]['server_address'] = '';
|
||||||
$device_lines[$x]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'] ?? null;
|
$device_lines[$x]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', null);
|
||||||
$device_lines[$x]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'] ?? null;
|
$device_lines[$x]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', null);
|
||||||
$device_lines[$x]['server_address_primary'] = $_SESSION['provision']['server_address_primary']['text'] ?? null;
|
$device_lines[$x]['server_address_primary'] = $settings->get('provision', 'server_address_primary', null);
|
||||||
$device_lines[$x]['server_address_secondary'] = $_SESSION['provision']['server_address_secondary']['text'] ?? null;
|
$device_lines[$x]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', null);
|
||||||
$device_lines[$x]['label'] = '';
|
$device_lines[$x]['label'] = '';
|
||||||
$device_lines[$x]['display_name'] = '';
|
$device_lines[$x]['display_name'] = '';
|
||||||
$device_lines[$x]['user_id'] = '';
|
$device_lines[$x]['user_id'] = '';
|
||||||
|
|
@ -584,9 +595,9 @@
|
||||||
$device_lines[$x]['password'] = '';
|
$device_lines[$x]['password'] = '';
|
||||||
$device_lines[$x]['shared_line'] = '';
|
$device_lines[$x]['shared_line'] = '';
|
||||||
$device_lines[$x]['enabled'] = '';
|
$device_lines[$x]['enabled'] = '';
|
||||||
$device_lines[$x]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
|
$device_lines[$x]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060');
|
||||||
$device_lines[$x]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
|
$device_lines[$x]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp');
|
||||||
$device_lines[$x]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
|
$device_lines[$x]['register_expires'] = $settings->get('provision', 'line_register_expires', '120');
|
||||||
|
|
||||||
//get device keys
|
//get device keys
|
||||||
$sql = "select * from v_device_keys ";
|
$sql = "select * from v_device_keys ";
|
||||||
|
|
@ -612,11 +623,11 @@
|
||||||
|
|
||||||
//add empty device key row(s)
|
//add empty device key row(s)
|
||||||
if (!is_uuid($device_uuid)) {
|
if (!is_uuid($device_uuid)) {
|
||||||
$rows = $_SESSION['devices']['key_add_rows']['numeric'] ?? 1;
|
$rows = $settings->get('devices', 'key_add_rows', '10');
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rows = $_SESSION['devices']['key_edit_rows']['numeric'] ?? 1;
|
$rows = $settings->get('devices', 'key_edit_rows', '3');
|
||||||
$id = count($device_keys) + 1;
|
$id = count($device_keys) + 1;
|
||||||
}
|
}
|
||||||
for ($x = 0; $x < $rows; $x++) {
|
for ($x = 0; $x < $rows; $x++) {
|
||||||
|
|
@ -638,7 +649,6 @@
|
||||||
$sql .= "from v_device_vendors ";
|
$sql .= "from v_device_vendors ";
|
||||||
$sql .= "where enabled = 'true' ";
|
$sql .= "where enabled = 'true' ";
|
||||||
$sql .= "order by name asc ";
|
$sql .= "order by name asc ";
|
||||||
|
|
||||||
$device_vendors = $database->select($sql, null, 'all');
|
$device_vendors = $database->select($sql, null, 'all');
|
||||||
unset($sql);
|
unset($sql);
|
||||||
|
|
||||||
|
|
@ -662,11 +672,11 @@
|
||||||
|
|
||||||
//add empty device setting row(s)
|
//add empty device setting row(s)
|
||||||
if (!is_uuid($device_uuid)) {
|
if (!is_uuid($device_uuid)) {
|
||||||
$rows = $_SESSION['devices']['setting_add_rows']['numeric'] ?? 1;
|
$rows = $settings->get('devices', 'key_add_rows', '10');
|
||||||
$id = 0;
|
$id = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rows = $_SESSION['devices']['setting_edit_rows']['numeric'] ?? 1;
|
$rows = $settings->get('devices', 'key_edit_rows', '3');
|
||||||
$id = count($device_settings) + 1;
|
$id = count($device_settings) + 1;
|
||||||
}
|
}
|
||||||
for ($x = 0; $x < $rows; $x++) {
|
for ($x = 0; $x < $rows; $x++) {
|
||||||
|
|
@ -694,12 +704,7 @@
|
||||||
|
|
||||||
//get the first device line info (found on the local server) for the provision button
|
//get the first device line info (found on the local server) for the provision button
|
||||||
foreach ($device_lines as $row) {
|
foreach ($device_lines as $row) {
|
||||||
if (
|
if ($row['server_address'] == $row['domain_name'] && !empty($row['user_id']) && !empty($row['server_address'])) {
|
||||||
array_key_exists($row['domain_uuid'], $_SESSION['domains']) &&
|
|
||||||
$row['server_address'] == $_SESSION['domains'][$row['domain_uuid']]['domain_name'] &&
|
|
||||||
!empty($row['user_id']) &&
|
|
||||||
!empty($row['server_address'])
|
|
||||||
) {
|
|
||||||
$user_id = $row['user_id'];
|
$user_id = $row['user_id'];
|
||||||
$server_address = $row['server_address'];
|
$server_address = $row['server_address'];
|
||||||
break;
|
break;
|
||||||
|
|
@ -731,14 +736,13 @@
|
||||||
echo " $('#target_file').fadeOut(fade_speed);\n";
|
echo " $('#target_file').fadeOut(fade_speed);\n";
|
||||||
echo " document.getElementById('target_file').selectedIndex = 0;\n";
|
echo " document.getElementById('target_file').selectedIndex = 0;\n";
|
||||||
echo " }\n";
|
echo " }\n";
|
||||||
|
|
||||||
echo " function download(d) {\n";
|
echo " function download(d) {\n";
|
||||||
echo " if (d == '".$text['label-download']."') return;\n";
|
echo " if (d == '".$text['label-download']."') return;\n";
|
||||||
if ($_SESSION['provision']['http_domain_filter']['boolean'] == "false") {
|
if ($settings->get('provision', 'http_domain_filter', true)) {
|
||||||
$domain_name = $_SERVER["HTTP_HOST"];
|
$provision_domain_name = $domain_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$domain_name = $_SESSION['domain_name'];
|
$provision_domain_name = $_SERVER["HTTP_HOST"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_SERVER['HTTP_PROTOCOL'])) {
|
if (!isset($_SERVER['HTTP_PROTOCOL'])) {
|
||||||
|
|
@ -747,7 +751,7 @@
|
||||||
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
||||||
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
||||||
}
|
}
|
||||||
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
|
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$provision_domain_name.PROJECT_PATH."/app/provision/index.php?address=".escape($device_address ?? '')."&file=' + d + '&content_type=application/octet-stream';\n";
|
||||||
echo " }\n";
|
echo " }\n";
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
@ -793,17 +797,12 @@
|
||||||
//add the QR code
|
//add the QR code
|
||||||
if (permission_exists("device_line_password") && !empty($device_template) && $qr_code_enabled) {
|
if (permission_exists("device_line_password") && !empty($device_template) && $qr_code_enabled) {
|
||||||
//set the mode
|
//set the mode
|
||||||
if (isset($_SESSION['theme']['qr_image'])) {
|
if (!empty($settings->get('theme', 'qr_image', ''))) {
|
||||||
if (!empty($_SESSION['theme']['qr_image'])) {
|
|
||||||
$mode = '4';
|
$mode = '4';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$mode = '0';
|
$mode = '0';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
$mode = '4';
|
|
||||||
}
|
|
||||||
|
|
||||||
//get the device line settings
|
//get the device line settings
|
||||||
$row = $device_lines[0] ?? null;
|
$row = $device_lines[0] ?? null;
|
||||||
|
|
@ -922,15 +921,10 @@
|
||||||
//build content for linphone
|
//build content for linphone
|
||||||
if ($device_template == "linphone/default") {
|
if ($device_template == "linphone/default") {
|
||||||
$auth_string = '';
|
$auth_string = '';
|
||||||
if (
|
if ($settings->get('provision', 'http_auth_enabled', true) && !empty($settings->get('provision', 'http_auth_username', '')) && !empty($settings->get('provision', 'http_auth_password', ''))) {
|
||||||
!empty($_SESSION['provision']['http_auth_enabled']['boolean']) &&
|
$auth_string = $settings->get('provision', 'http_auth_username', '').':'.$settings->get('provision', 'http_auth_password', '').'@';
|
||||||
$_SESSION['provision']['http_auth_enabled']['boolean'] == 'true' &&
|
|
||||||
!empty($_SESSION['provision']['http_auth_username']['text']) &&
|
|
||||||
!empty($_SESSION['provision']['http_auth_password'][0])
|
|
||||||
) {
|
|
||||||
$auth_string = $_SESSION['provision']['http_auth_username']['text'].':'.$_SESSION['provision']['http_auth_password'][0].'@';
|
|
||||||
}
|
}
|
||||||
$content = "https://".$auth_string.$_SESSION['domain_name'].'/app/provision/index.php?address='.$device_address;
|
$content = "https://".$auth_string.$provision_domain_name.'/app/provision/index.php?address='.$device_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
//stream the file
|
//stream the file
|
||||||
|
|
@ -1001,16 +995,16 @@
|
||||||
echo " <img id='qr_code' src='data:image/jpeg;base64,".base64_encode($image)."'>\n";
|
echo " <img id='qr_code' src='data:image/jpeg;base64,".base64_encode($image)."'>\n";
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (isset($_SESSION['theme']['qr_image'])) {
|
if (!empty($settings->get('theme', 'qr_image', ''))) {
|
||||||
echo "<img id='img-buffer' src='".$_SESSION["theme"]["qr_image"]["text"]."' style='display: none;'>";
|
echo "<img id='img-buffer' src='".$settings->get('theme', 'qr_image', '')."' style='display: none;'>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png' style='display: none;'>";
|
echo "<img id='img-buffer' src='".PROJECT_PATH."/themes/".$settings->get('domain', 'template', '')."/images/qr_code.png' style='display: none;'>";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//show the content
|
//show the content
|
||||||
|
|
@ -1020,7 +1014,7 @@
|
||||||
echo "<div class='action_bar' id='action_bar'>\n";
|
echo "<div class='action_bar' id='action_bar'>\n";
|
||||||
echo " <div class='heading'><b>".$text['header-device']."</b></div>\n";
|
echo " <div class='heading'><b>".$text['header-device']."</b></div>\n";
|
||||||
echo " <div class='actions'>\n";
|
echo " <div class='actions'>\n";
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'devices.php']);
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back', ''),'id'=>'btn_back','link'=>'devices.php']);
|
||||||
if ($action == 'update') {
|
if ($action == 'update') {
|
||||||
$button_margin = 'margin-left: 15px;';
|
$button_margin = 'margin-left: 15px;';
|
||||||
if (permission_exists("device_line_password") && $qr_code_enabled) {
|
if (permission_exists("device_line_password") && $qr_code_enabled) {
|
||||||
|
|
@ -1038,7 +1032,7 @@
|
||||||
$template_dir = $prov->template_dir;
|
$template_dir = $prov->template_dir;
|
||||||
$files = glob($template_dir.'/'.$device_template.'/*');
|
$files = glob($template_dir.'/'.$device_template.'/*');
|
||||||
//add file buttons and the file list
|
//add file buttons and the file list
|
||||||
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$_SESSION['theme']['button_icon_download'],'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
|
echo button::create(['type'=>'button','id'=>'button_files','label'=>$text['button-files'],'icon'=>$settings->get('theme', 'button_icon_download', ''),'style'=>($button_margin ?? ''),'onclick'=>'show_files()']);
|
||||||
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
|
echo "<select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
|
||||||
echo " <option value=''>".$text['label-download']."</option>\n";
|
echo " <option value=''>".$text['label-download']."</option>\n";
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
@ -1054,7 +1048,7 @@
|
||||||
unset($button_margin);
|
unset($button_margin);
|
||||||
}
|
}
|
||||||
if (permission_exists('device_add')) {
|
if (permission_exists('device_add')) {
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
|
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy', ''),'style'=>($button_margin ?? ''),'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','new_address');"]);
|
||||||
unset($button_margin);
|
unset($button_margin);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|
@ -1063,11 +1057,11 @@
|
||||||
permission_exists('device_key_delete') ||
|
permission_exists('device_key_delete') ||
|
||||||
permission_exists('device_setting_delete')
|
permission_exists('device_setting_delete')
|
||||||
) {
|
) {
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete', ''),'style'=>($button_margin ?? ''),'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||||
unset($button_margin);
|
unset($button_margin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
|
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save', ''),'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
|
||||||
echo " </div>\n";
|
echo " </div>\n";
|
||||||
echo " <div style='clear: both;'></div>\n";
|
echo " <div style='clear: both;'></div>\n";
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
|
|
@ -1289,11 +1283,11 @@
|
||||||
|
|
||||||
//set the defaults
|
//set the defaults
|
||||||
if (!permission_exists('device_line_server_address')) {
|
if (!permission_exists('device_line_server_address')) {
|
||||||
if (empty($row['server_address'])) { $row['server_address'] = $_SESSION['domain_name']; }
|
if (empty($row['server_address'])) { $row['server_address'] = $domain_name; }
|
||||||
}
|
}
|
||||||
if (empty($row['sip_transport'])) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
|
if (empty($row['sip_transport'])) { $row['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); }
|
||||||
if (!isset($row['sip_port'])) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
|
if (!isset($row['sip_port'])) { $row['sip_port'] = $settings->get('provision', 'line_sip_port', '5060'); } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
|
||||||
if (empty($row['register_expires'])) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
|
if (empty($row['register_expires'])) { $row['register_expires'] = $settings->get('provision', 'line_register_expires', '120'); }
|
||||||
|
|
||||||
//add the primary key uuid
|
//add the primary key uuid
|
||||||
if (!empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) {
|
if (!empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) {
|
||||||
|
|
@ -1323,10 +1317,10 @@
|
||||||
|
|
||||||
if (permission_exists('device_line_server_address_primary')) {
|
if (permission_exists('device_line_server_address_primary')) {
|
||||||
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
||||||
if (isset($_SESSION['provision']['server_address_primary']) && !isset($_SESSION['provision']['server_address_primary']['text'])) {
|
if (!empty($settings->get('provision', 'server_address_primary', ''))) {
|
||||||
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_primary]'>\n";
|
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_primary]'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
foreach($_SESSION['provision']['server_address_primary'] as $field) {
|
foreach($settings->get('provision', 'server_address_primary', '') as $field) {
|
||||||
echo " <option value='".$field."' ".(($row['server_address_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
echo " <option value='".$field."' ".(($row['server_address_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
||||||
}
|
}
|
||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
|
|
@ -1339,10 +1333,10 @@
|
||||||
|
|
||||||
if (permission_exists('device_line_server_address_secondary')) {
|
if (permission_exists('device_line_server_address_secondary')) {
|
||||||
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
||||||
if (isset($_SESSION['provision']['server_address_secondary']) && !isset($_SESSION['provision']['server_address_secondary']['text'])) {
|
if (!empty($settings->get('provision', 'server_address_secondary', ''))) {
|
||||||
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_secondary]'>\n";
|
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][server_address_secondary]'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
foreach($_SESSION['provision']['server_address_secondary'] as $field) {
|
foreach($settings->get('provision', 'server_address_secondary', '') as $field) {
|
||||||
echo " <option value='".$field."' ".(($row['server_address_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
echo " <option value='".$field."' ".(($row['server_address_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
||||||
}
|
}
|
||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
|
|
@ -1355,10 +1349,10 @@
|
||||||
|
|
||||||
if (permission_exists('device_line_outbound_proxy_primary')) {
|
if (permission_exists('device_line_outbound_proxy_primary')) {
|
||||||
echo " <td align='left'>\n";
|
echo " <td align='left'>\n";
|
||||||
if (isset($_SESSION['provision']['outbound_proxy_primary']) && !isset($_SESSION['provision']['outbound_proxy_primary']['text'])) {
|
if (!empty($settings->get('provision', 'outbound_proxy_primary', ''))) {
|
||||||
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_primary]'>\n";
|
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_primary]'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
foreach($_SESSION['provision']['outbound_proxy_primary'] as $field) {
|
foreach($settings->get('provision', 'outbound_proxy_primary', '') as $field) {
|
||||||
echo " <option value='".$field."' ".(($row['outbound_proxy_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
echo " <option value='".$field."' ".(($row['outbound_proxy_primary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
||||||
}
|
}
|
||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
|
|
@ -1371,10 +1365,10 @@
|
||||||
|
|
||||||
if (permission_exists('device_line_outbound_proxy_secondary')) {
|
if (permission_exists('device_line_outbound_proxy_secondary')) {
|
||||||
echo " <td align='left'>\n";
|
echo " <td align='left'>\n";
|
||||||
if (isset($_SESSION['provision']['outbound_proxy_secondary']) && !isset($_SESSION['provision']['outbound_proxy_secondary']['text'])) {
|
if (!empty($settings->get('provision', 'outbound_proxy_secondary', ''))) {
|
||||||
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_secondary]'>\n";
|
echo " <select class='formfld' style='width: 75px;' name='device_lines[".$x."][outbound_proxy_secondary]'>\n";
|
||||||
echo " <option value=''></option>\n";
|
echo " <option value=''></option>\n";
|
||||||
foreach($_SESSION['provision']['outbound_proxy_secondary'] as $field) {
|
foreach($settings->get('provision', 'outbound_proxy_secondary', '') as $field) {
|
||||||
echo " <option value='".$field."' ".(($row['outbound_proxy_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
echo " <option value='".$field."' ".(($row['outbound_proxy_secondary'] == $field) ? "selected" : null).">".$field."</option>\n";
|
||||||
}
|
}
|
||||||
echo " </select>\n";
|
echo " </select>\n";
|
||||||
|
|
@ -1963,7 +1957,7 @@
|
||||||
else {
|
else {
|
||||||
echo " <option value=''>".$text['select-global']."</option>\n";
|
echo " <option value=''>".$text['select-global']."</option>\n";
|
||||||
}
|
}
|
||||||
foreach ($_SESSION['domains'] as $row) {
|
foreach ($domains as $row) {
|
||||||
if ($row['domain_uuid'] == $domain_uuid) {
|
if ($row['domain_uuid'] == $domain_uuid) {
|
||||||
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
|
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
|
||||||
}
|
}
|
||||||
|
|
@ -1978,7 +1972,7 @@
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$_SESSION['domain_uuid']."\"/>\n";
|
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$domain_uuid."\"/>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission_exists('device_enable')) {
|
if (permission_exists('device_enable')) {
|
||||||
|
|
@ -1987,7 +1981,7 @@
|
||||||
echo " ".$text['label-device_enabled']."\n";
|
echo " ".$text['label-device_enabled']."\n";
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
echo "<td class='vtable' align='left'>\n";
|
echo "<td class='vtable' align='left'>\n";
|
||||||
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
|
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
|
||||||
echo " <label class='switch'>\n";
|
echo " <label class='switch'>\n";
|
||||||
echo " <input type='checkbox' id='device_enabled' name='device_enabled' value='true' ".($device_enabled == 'true' ? "checked='checked'" : null).">\n";
|
echo " <input type='checkbox' id='device_enabled' name='device_enabled' value='true' ".($device_enabled == 'true' ? "checked='checked'" : null).">\n";
|
||||||
echo " <span class='slider'></span>\n";
|
echo " <span class='slider'></span>\n";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue