Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('device_add') || permission_exists('device_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set the defaults $device_model = ''; $device_firmware_version = ''; $device_template =''; //get the domain values $domain_uuid = $_SESSION['domain_uuid'] ?? ''; $domain_name = $_SESSION['domain_name'] ?? ''; //initialize the database object $database = database::new(); //initialize the settigns object $settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]); //action add or update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; $device_uuid = $_REQUEST["id"]; } else { $action = "add"; } //get the total device count from the database, check the limit, if defined if ($action == 'add') { if (!empty($settings->get('limit', 'devices', ''))) { $sql = "select count(*) from v_devices where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; $total_devices = $database->select($sql, $parameters, 'column'); if ($total_devices >= $settings->get('limit', 'devices', '')) { message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative'); header('Location: devices.php'); exit; } unset($sql, $parameters, $total_devices); } } //get http post variables and set them to php variables if (count($_POST) > 0) { //process the http post data by submitted action if (!empty($_POST['action']) && is_uuid($_POST['device_uuid'])) { $array[0]['checked'] = 'true'; $array[0]['uuid'] = $_POST['device_uuid']; switch ($_POST['action']) { case 'delete': if (permission_exists('device_delete')) { $obj = new device; $obj->delete($array); } break; } header('Location: devices.php'); exit; } //device device address if (permission_exists('device_address')) { $device_address = $_POST["device_address"]; } else { $sql = "select device_address from v_devices "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $device_address = $row["device_address"]; } unset($sql, $parameters, $row); } //devices $domain_uuid = $_POST["domain_uuid"]; $device_uuid = $_POST["device_uuid"] ?? null; //$device_provisioned_ip = $_POST["device_provisioned_ip"]; $domain_uuid = $_POST["domain_uuid"]; $device_label = $_POST["device_label"]; $device_user_uuid = $_POST["device_user_uuid"]; $device_username = $_POST["device_username"]; $device_password = $_POST["device_password"]; $device_vendor = $_POST["device_vendor"]; $device_location = $_POST["device_location"]; $device_serial_number = $_POST["device_serial_number"]; $device_uuid_alternate = $_POST["device_uuid_alternate"] ?? null; $device_model = $_POST["device_model"] ?? null; $device_firmware_version = $_POST["device_firmware_version"] ?? null; $device_enabled = $_POST["device_enabled"] ?? 'false'; $device_template = $_POST["device_template"]; $device_description = $_POST["device_description"]; //lines $device_lines = $_POST["device_lines"]; $device_lines_delete = $_POST["device_lines_delete"] ?? null; //$line_number = $_POST["line_number"]; //$server_address = $_POST["server_address"]; //$outbound_proxy_primary = $_POST["outbound_proxy_primary"]; //$outbound_proxy_secondary = $_POST["outbound_proxy_secondary"]; //$label = $_POST["label"]; //$display_name = $_POST["display_name"]; //$user_id = $_POST["user_id"]; //$auth_id = $_POST["auth_id"]; //$password = $_POST["password"]; //profile $device_profile_uuid = $_POST["device_profile_uuid"] ?? null; //keys $device_keys = $_POST["device_keys"]; $device_keys_delete = $_POST["device_keys_delete"] ?? null; //$device_key_category = $_POST["device_key_category"]; //$device_key_id = $_POST["device_key_id"]; //$device_key_type = $_POST["device_key_type"]; //$device_key_subtype = $_POST["device_key_subtype"]; //$device_key_line = $_POST["device_key_line"]; //$device_key_value = $_POST["device_key_value"]; //$device_key_extension = $_POST["device_key_extension"]; //$device_key_label = $_POST["device_key_label"]; //$device_key_icon = $_POST["device_key_icon"]; //settings $device_settings = $_POST["device_settings"]; $device_settings_delete = $_POST["device_settings_delete"] ?? null; //$device_setting_category = $_POST["device_setting_category"]); //$device_setting_subcategory = $_POST["device_setting_subcategory"]; //$device_setting_name = $_POST["device_setting_name"]; //$device_setting_value = $_POST["device_setting_value"]; //$device_setting_enabled = $_POST["device_setting_enabled"]; //$device_setting_description = $_POST["device_setting_description"]; //normalize the address if (!empty($device_address)) { $device_address = strtolower($device_address); $device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address); } } //use the device address to get the vendor if (empty($device_vendor)) { $device_vendor = device::get_vendor($device_address ?? null); } //add or update the database if (!empty($_POST) && empty($_POST["persistformvar"])) { //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: devices.php'); exit; } //check for all required data $msg = ''; if (empty($device_address)) { $msg .= $text['message-required'].$text['label-device_address']."
\n"; } //if (empty($device_label)) { $msg .= "Please provide: Label
\n"; } //if (empty($device_vendor)) { $msg .= "Please provide: Vendor
\n"; } //if (empty($device_model)) { $msg .= "Please provide: Model
\n"; } //if (empty($device_firmware_version)) { $msg .= "Please provide: Firmware Version
\n"; } //if (empty($device_enabled)) { $msg .= "Please provide: Enabled
\n"; } //if (empty($device_template)) { $msg .= "Please provide: Template
\n"; } //if (empty($device_username)) { $msg .= "Please provide: Username
\n"; } //if (empty($device_password)) { $msg .= "Please provide: Password
\n"; } //if (empty($device_description)) { $msg .= "Please provide: Description
\n"; } if (!empty($msg)) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //check for duplicates if ($action == 'add' && $device_address != "000000000000") { $sql = "select "; $sql .= "d2.domain_name "; $sql .= "from "; $sql .= "v_devices as d1, "; $sql .= "v_domains as d2 "; $sql .= "where "; $sql .= "d1.domain_uuid = d2.domain_uuid and "; $sql .= "d1.device_address = :device_address "; if (!empty($_GET["device_uuid"]) && is_uuid($_GET["device_uuid"])) { $sql .= " and d1.device_uuid <> :device_uuid "; } $parameters['device_address'] = $device_address; $device_domain_name = $database->select($sql, $parameters, 'column'); if ($device_domain_name != '') { $message = $text['message-duplicate'].($device_domain_name != $domain_name ? ": ".$device_domain_name : null); message::add($message,'negative'); header('Location: devices.php'); exit; } unset($sql, $parameters, $device_domain_name); } //add or update the database if (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true") { //set the device uuid if (!is_uuid($device_uuid)) { $device_uuid = uuid(); } //prepare the array $array['devices'][0]['domain_uuid'] = $domain_uuid; $array['devices'][0]['device_uuid'] = $device_uuid; if (permission_exists('device_address')) { $array['devices'][0]['device_address'] = $device_address; } //$array['devices'][0]['device_provisioned_ip'] = $device_provisioned_ip; if (permission_exists('device_label')) { $array['devices'][0]['device_label'] = $device_label; } if (permission_exists('device_user') && (is_uuid($device_user_uuid) || empty($device_user_uuid))) { $array['devices'][0]['device_user_uuid'] = $device_user_uuid; } if (permission_exists('device_username_password')) { $array['devices'][0]['device_username'] = $device_username; $array['devices'][0]['device_password'] = $device_password; } if (permission_exists('device_vendor')) { $array['devices'][0]['device_vendor'] = $device_vendor; } if (permission_exists('device_location')) { $array['devices'][0]['device_location'] = $device_location; } if (permission_exists('device_serial_number')) { $array['devices'][0]['device_serial_number'] = $device_serial_number; } if (permission_exists('device_alternate')) { $array['devices'][0]['device_uuid_alternate'] = is_uuid($device_uuid_alternate) ? $device_uuid_alternate : null; } if (permission_exists('device_model')) { $array['devices'][0]['device_model'] = $device_model; } if (permission_exists('device_firmware')) { $array['devices'][0]['device_firmware_version'] = $device_firmware_version; } if (permission_exists('device_enable')) { $array['devices'][0]['device_enabled'] = $device_enabled; $array['devices'][0]['device_enabled_date'] = 'now()'; } if (permission_exists('device_template')) { $array['devices'][0]['device_template'] = $device_template; } if (permission_exists('device_profile_view')) { $array['devices'][0]['device_profile_uuid'] = is_uuid($device_profile_uuid) ? $device_profile_uuid : null; } if (permission_exists('device_description')) { $array['devices'][0]['device_description'] = $device_description; } if (permission_exists('device_line_edit')) { $y = 0; foreach ($device_lines as $row) { if (!empty($row['line_number'])) { $new_line = false; if (!empty($row["device_line_uuid"]) && is_uuid($row["device_line_uuid"])) { $device_line_uuid = $row["device_line_uuid"]; } else { $device_line_uuid = uuid(); $new_line = true; } $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_line_uuid'] = $device_line_uuid; $array['devices'][0]['device_lines'][$y]['line_number'] = $row["line_number"]; $array['devices'][0]['device_lines'][$y]['server_address'] = $row["server_address"]; if (permission_exists('device_line_outbound_proxy_primary')) { $array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $row["outbound_proxy_primary"]; } else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_primary'))) { $array['devices'][0]['device_lines'][$y]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', ''); } if (permission_exists('device_line_outbound_proxy_secondary')) { $array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"]; } else if ($new_line && !empty($settings->get('provision', 'outbound_proxy_secondary'))) { $array['devices'][0]['device_lines'][$y]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', ''); } if (permission_exists('device_line_server_address_primary')) { $array['devices'][0]['device_lines'][$y]['server_address_primary'] = $row["server_address_primary"]; } else if ($new_line && !empty($settings->get('provision', 'server_address_primary'))) { $array['devices'][0]['device_lines'][$y]['server_address_primary'] = $settings->get('provision', 'server_address_primary', ''); } if (permission_exists('device_line_server_address_secondary')) { $array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $row["server_address_secondary"]; } else if ($new_line && !empty($settings->get('provision', 'server_address_secondary'))) { $array['devices'][0]['device_lines'][$y]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', ''); } if (permission_exists('device_line_label')) { $array['devices'][0]['device_lines'][$y]['label'] = $row["label"]; } if (permission_exists('device_line_display_name')) { $array['devices'][0]['device_lines'][$y]['display_name'] = $row["display_name"]; } $array['devices'][0]['device_lines'][$y]['user_id'] = $row["user_id"]; if (permission_exists('device_line_auth_id')) { $array['devices'][0]['device_lines'][$y]['auth_id'] = $row["auth_id"]; } if (permission_exists('device_line_password')) { $array['devices'][0]['device_lines'][$y]['password'] = $row["password"]; } if (permission_exists('device_line_shared')) { $array['devices'][0]['device_lines'][$y]['shared_line'] = $row["shared_line"]; } $array['devices'][0]['device_lines'][$y]['enabled'] = $row["enabled"]; if (permission_exists('device_line_port')) { $array['devices'][0]['device_lines'][$y]['sip_port'] = $row["sip_port"]; } else { if ($action == "add") { $array['devices'][0]['device_lines'][$y]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060'); } } if (permission_exists('device_line_transport')) { $array['devices'][0]['device_lines'][$y]['sip_transport'] = $row["sip_transport"]; } else { if ($action == "add") { $array['devices'][0]['device_lines'][$y]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); } } if (permission_exists('device_line_register_expires')) { $array['devices'][0]['device_lines'][$y]['register_expires'] = $row["register_expires"]; } else { if ($action == "add") { $array['devices'][0]['device_lines'][$y]['register_expires'] = $settings->get('provision', 'line_register_expires', '120'); } } $y++; } } } if (permission_exists('device_key_edit')) { $y = 0; foreach ($device_keys as $row) { if (!empty($row['device_key_category'])) { if (!empty($row["device_key_uuid"]) && is_uuid($row["device_key_uuid"])) { $device_key_uuid = $row["device_key_uuid"]; } else { $device_key_uuid = uuid(); } $array['devices'][0]['device_keys'][$y]['domain_uuid'] = $domain_uuid; $array['devices'][0]['device_keys'][$y]['device_uuid'] = $device_uuid; $array['devices'][0]['device_keys'][$y]['device_key_uuid'] = $device_key_uuid; $array['devices'][0]['device_keys'][$y]['device_key_category'] = $row["device_key_category"]; $array['devices'][0]['device_keys'][$y]['device_key_vendor'] = $row["device_key_vendor"]; if (permission_exists('device_key_id')) { $array['devices'][0]['device_keys'][$y]['device_key_id'] = $row["device_key_id"]; } $array['devices'][0]['device_keys'][$y]['device_key_type'] = $row["device_key_type"]; if (isset($row["device_key_subtype"])) { $array['devices'][0]['device_keys'][$y]['device_key_subtype'] = $row["device_key_subtype"]; } if (permission_exists('device_key_line')) { $array['devices'][0]['device_keys'][$y]['device_key_line'] = $row["device_key_line"]; } $array['devices'][0]['device_keys'][$y]['device_key_value'] = $row["device_key_value"]; if (permission_exists('device_key_extension')) { $array['devices'][0]['device_keys'][$y]['device_key_extension'] = $row["device_key_extension"]; } //$array['devices'][0]['device_keys'][$y]['device_key_protected'] = $row["device_key_protected"]; $array['devices'][0]['device_keys'][$y]['device_key_label'] = $row["device_key_label"]; if (permission_exists('device_key_icon')) { $array['devices'][0]['device_keys'][$y]['device_key_icon'] = $row["device_key_icon"]; } $y++; } } } if (permission_exists('device_setting_edit')) { $y = 0; foreach ($device_settings as $row) { if (!empty($row['device_setting_subcategory'])) { if (!empty($row["device_setting_uuid"]) && is_uuid($row["device_setting_uuid"])) { $device_setting_uuid = $row["device_setting_uuid"]; } else { $device_setting_uuid = uuid(); } $array['devices'][0]['device_settings'][$y]['domain_uuid'] = $domain_uuid; $array['devices'][0]['device_settings'][$y]['device_uuid'] = $device_uuid; $array['devices'][0]['device_settings'][$y]['device_setting_uuid'] = $device_setting_uuid; $array['devices'][0]['device_settings'][$y]['device_setting_category'] = $row["device_setting_category"] ?? null; $array['devices'][0]['device_settings'][$y]['device_setting_subcategory'] = $row["device_setting_subcategory"] ?? null; $array['devices'][0]['device_settings'][$y]['device_setting_name'] = $row["device_setting_name"] ?? null; $array['devices'][0]['device_settings'][$y]['device_setting_value'] = $row["device_setting_value"] ?? null; $array['devices'][0]['device_settings'][$y]['device_setting_enabled'] = $row["device_setting_enabled"]; $array['devices'][0]['device_settings'][$y]['device_setting_description'] = $row["device_setting_description"]; $y++; } } } //save the device $database->app_name = 'devices'; $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; $database->save($array); //remove checked lines if ( $action == 'update' && permission_exists('device_line_delete') && is_array($device_lines_delete) && @sizeof($device_lines_delete) != 0 ) { $obj = new device; $obj->device_uuid = $device_uuid; $obj->delete_lines($device_lines_delete); } //remove checked keys if ( $action == 'update' && permission_exists('device_key_delete') && is_array($device_keys_delete) && @sizeof($device_keys_delete) != 0 ) { $obj = new device; $obj->device_uuid = $device_uuid; $obj->delete_keys($device_keys_delete); } //remove checked settings if ( $action == 'update' && permission_exists('device_setting_delete') && is_array($device_settings_delete) && @sizeof($device_settings_delete) != 0 ) { $obj = new device; $obj->device_uuid = $device_uuid; $obj->delete_settings($device_settings_delete); } //write the provision files if (!empty($settings->get('provision', 'path'))) { $prov = new provision(['settings' => $settings]); $prov->domain_uuid = $domain_uuid; $response = $prov->write(); } //set the message if (isset($action)) { if ($action == "add") { //save the message to a session variable message::add($text['message-add']); } if ($action == "update") { //save the message to a session variable message::add($text['message-update']); } //redirect the browser header("Location: device_edit.php?id=".urlencode($device_uuid)); exit; } } } //pre-populate the form if (!empty($_GET) && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) { $sql = "select * from v_devices "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $device_address = $row["device_address"]; $device_provisioned_ip = $row["device_provisioned_ip"]; $domain_uuid = $row["domain_uuid"]; $device_label = $row["device_label"]; $device_user_uuid = $row["device_user_uuid"]; $device_username = $row["device_username"]; $device_password = $row["device_password"]; $device_vendor = $row["device_vendor"]; $device_location = $row["device_location"]; $device_serial_number = $row["device_serial_number"]; $device_uuid_alternate = $row["device_uuid_alternate"]; $device_model = $row["device_model"]; $device_firmware_version = $row["device_firmware_version"]; $device_enabled = $row["device_enabled"]; $device_template = $row["device_template"]; $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } unset($sql, $parameters, $row); } //get device lines $sql = "select * "; $sql .= "from v_domains "; $sql .= "order by domain_name asc "; $domains = $database->select($sql, null, 'all'); unset($sql, $parameters); //set the defaults if (empty($device_enabled)) { $device_enabled = 'true'; } //use the device address to get the vendor if (empty($device_vendor)) { //get the device vendor using the device address $device_vendor = device::get_vendor($device_address ?? null); //if the vendor was not found using the device address use an alternative method if (empty($device_vendor)) { $template_array = explode("/", $device_template ?? ''); $device_vendor = $template_array[0] ?? ''; } } //set the sub array index $x = "999"; //alternate device settings if (!empty($device_uuid_alternate) && is_uuid($device_uuid_alternate)) { $sql = "select * from v_devices "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and device_uuid = :device_uuid "; $parameters['domain_uuid'] = $domain_uuid; $parameters['device_uuid'] = $device_uuid_alternate; $device_alternate = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); } //get 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 .= "and l.domain_uuid = d.domain_uuid "; $sql .= "order by cast(line_number as int) asc "; $parameters['device_uuid'] = $device_uuid ?? null; $device_lines = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //set the new line defaults $device_lines[$x]['line_number'] = ''; $device_lines[$x]['server_address'] = ''; $device_lines[$x]['outbound_proxy_primary'] = $settings->get('provision', 'outbound_proxy_primary', null); $device_lines[$x]['outbound_proxy_secondary'] = $settings->get('provision', 'outbound_proxy_secondary', null); $device_lines[$x]['server_address_primary'] = $settings->get('provision', 'server_address_primary', null); $device_lines[$x]['server_address_secondary'] = $settings->get('provision', 'server_address_secondary', null); $device_lines[$x]['label'] = ''; $device_lines[$x]['display_name'] = ''; $device_lines[$x]['user_id'] = ''; $device_lines[$x]['auth_id'] = ''; $device_lines[$x]['password'] = ''; $device_lines[$x]['shared_line'] = ''; $device_lines[$x]['enabled'] = ''; $device_lines[$x]['sip_port'] = $settings->get('provision', 'line_sip_port', '5060'); $device_lines[$x]['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); $device_lines[$x]['register_expires'] = $settings->get('provision', 'line_register_expires', '120'); //get device keys $sql = "select * from v_device_keys "; $sql .= "where device_uuid = :device_uuid "; $sql .= "order by "; $sql .= "device_key_vendor asc, "; $sql .= "case device_key_category "; $sql .= "when 'line' then 1 "; $sql .= "when 'memory' then 2 "; $sql .= "when 'programmable' then 3 "; $sql .= "when 'expansion' then 4 "; $sql .= "when 'expansion-1' then 5 "; $sql .= "when 'expansion-2' then 6 "; $sql .= "when 'expansion-3' then 7 "; $sql .= "when 'expansion-4' then 8 "; $sql .= "when 'expansion-5' then 9 "; $sql .= "when 'expansion-6' then 10 "; $sql .= "else 100 end, "; $sql .= $db_type == "mysql" ? "device_key_id asc " : "cast(device_key_id as numeric) asc "; $parameters['device_uuid'] = $device_uuid ?? null; $device_keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //add empty device key row(s) if (!is_uuid($device_uuid)) { $rows = $settings->get('devices', 'key_add_rows', '10'); $id = 0; } else { $rows = $settings->get('devices', 'key_edit_rows', '3'); $id = count($device_keys) + 1; } for ($x = 0; $x < $rows; $x++) { $device_keys[$id]['device_key_category'] = ''; $device_keys[$id]['device_key_id'] = ''; $device_keys[$id]['device_key_type'] = ''; $device_keys[$id]['device_key_subtype'] = ''; $device_keys[$id]['device_key_line'] = ''; $device_keys[$id]['device_key_value'] = ''; $device_keys[$id]['device_key_extension'] = ''; $device_keys[$id]['device_key_label'] = ''; $device_keys[$id]['device_key_icon'] = ''; $id++; } unset($id); //get the device vendors $sql = "select name "; $sql .= "from v_device_vendors "; $sql .= "where enabled = 'true' "; $sql .= "order by name asc "; $device_vendors = $database->select($sql, null, 'all'); unset($sql); //get the vendor functions $sql = "select v.name as vendor_name, f.type, f.subtype, f.value "; $sql .= "from v_device_vendors as v, v_device_vendor_functions as f "; $sql .= "where v.device_vendor_uuid = f.device_vendor_uuid "; $sql .= "and v.enabled = 'true' "; $sql .= "and f.enabled = 'true' "; $sql .= "order by v.name asc, f.type asc "; $vendor_functions = $database->select($sql, null, 'all'); unset($sql); //get device settings $sql = "select * from v_device_settings "; $sql .= "where device_uuid = :device_uuid "; $sql .= "order by device_setting_subcategory asc "; $parameters['device_uuid'] = $device_uuid ?? null; $device_settings = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //add empty device setting row(s) if (!is_uuid($device_uuid)) { $rows = $settings->get('devices', 'key_add_rows', '10'); $id = 0; } else { $rows = $settings->get('devices', 'key_edit_rows', '3'); $id = count($device_settings) + 1; } for ($x = 0; $x < $rows; $x++) { $device_settings[$id]['device_setting_name'] = ''; $device_settings[$id]['device_setting_value'] = ''; $device_settings[$id]['device_setting_enabled'] = ''; $device_settings[$id]['device_setting_description'] = ''; $id++; } unset($id); //get the users $sql = "select * from v_users "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and user_enabled = 'true' "; $sql .= "order by username asc "; $parameters['domain_uuid'] = $domain_uuid; $users = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //use the device address to get the vendor if (empty($device_vendor)) { $device_vendor = device::get_vendor($device_address ?? null); } //get the first device line info (found on the local server) for the provision button foreach ($device_lines as $row) { if ($row['server_address'] == $row['domain_name'] && !empty($row['user_id']) && !empty($row['server_address'])) { $user_id = $row['user_id']; $server_address = $row['server_address']; break; } } //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header $document['title'] = $text['title-device']; require_once "resources/header.php"; //select file download javascript if (permission_exists("device_files")) { echo ""; } //determine whether to build the qrcode if ($device_template == "grandstream/wave") { $qr_code_enabled = true; } else if ($device_template == "linphone/default") { $qr_code_enabled = true; } else if ($device_template == "sipnetic/default") { $qr_code_enabled = true; } else if ($device_template == "acrobits/default") { $qr_code_enabled = true; } else if ($device_template == "groundwire/default") { $qr_code_enabled = true; } else { $qr_code_enabled = false; } //add the QR code if (permission_exists("device_line_password") && !empty($device_template) && $qr_code_enabled) { //set the mode if (!empty($settings->get('theme', 'qr_image', ''))) { $mode = '4'; } else { $mode = '0'; } //get the device line settings $row = $device_lines[0] ?? null; if (!empty($row)) { //set the outbound proxy settings if (empty($row['outbound_proxy_primary'])) { $outbound_proxy_primary = $row['server_address']; } else { $outbound_proxy_primary = $row['outbound_proxy_primary']; } $outbound_proxy_secondary = $row['outbound_proxy_secondary']; //build content for grandstream wave if ($device_template == "grandstream/wave") { $content = ""; $content .= ""; $content .= ""; $content .= "".$row['server_address'].""; $content .= "".$outbound_proxy_primary.":".$row['sip_port'].""; $content .= "".$outbound_proxy_secondary.":".$row['sip_port'].""; $content .= "".$row['user_id'].""; $content .= "".$row['auth_id'].""; $content .= "".$row['password'].""; $content .= "".$row['user_id'].""; $content .= "".$row['display_name'].""; $content .= "{x+|*x+|*++}"; $content .= "0"; $content .= "*97"; $content .= ""; $content .= ""; } //build content for sipnetic else if ($device_template == 'sipnetic/default') { switch ($row['sip_transport']) { case 'udp': $sip_transport = 0; break; case 'tls': $sip_transport = 2; break; default: $sip_transport = 1; //tcp } //check custom template provision location if (is_file('/usr/share/fusionpbx/templates/provision/'.$device_template.'/template.csv')) { $template = file_get_contents('/usr/share/fusionpbx/templates/provision/'.$device_template.'/template.csv'); } else if (is_file('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/template.csv')) { $template = file_get_contents('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/template.csv'); } else if (is_file('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/template.csv')) { $template = file_get_contents('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/template.csv'); } if (!empty($template)) { $template = str_replace('{$server_address}', $row['server_address'], $template); $template = str_replace('{$user_id}', $row['user_id'], $template); $template = str_replace('{$password}', str_replace(';',';;',$row['password']), $template); $template = str_replace('{$display_name}', ($row['display_name'] ?? $row['user_id']), $template); $template = str_replace('{$auth_id}', ($row['auth_id'] ?? $row['user_id']), $template); $template = str_replace('{$sip_transport}', $sip_transport, $template); $template = str_replace('{$outbound_proxy}', $outbound_proxy_primary, $template); $template = str_replace('{$sip_port}', $row['sip_port'], $template); $content = $template; unset($template); } } //build content for acrobits else if ($device_template == 'acrobits/default') { //check custom template provision location if (is_file('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt'); } else if (is_file('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt'); } else if (is_file('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt'); } //get the provision settings $provision = new settings(["category" => "provision"]); $acrobits_code = $provision->get('provision', 'acrobits_code'); if (!empty($template) && isset($acrobits_code)) { $template = str_replace('{$server_address}', $row['server_address'], $template); $template = str_replace('{$user_id}', urlencode($row['user_id']), $template); $template = str_replace('{$password}', urlencode(str_replace(';',';;',$row['password'])), $template); $template = str_replace('{$code}', $acrobits_code, $template); $content = trim($template, "\r\n"); unset($template); unset($acrobits_code); } } //build content for groundwire else if ($device_template == 'groundwire/default') { //check custom template provision location if (is_file('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/usr/share/fusionpbx/templates/provision/'.$device_template.'/qr_template.txt'); } else if (is_file('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/var/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt'); } else if (is_file('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt')) { $template = file_get_contents('/usr/local/www/fusionpbx/resources/templates/provision/'.$device_template.'/qr_template.txt'); } if (!empty($template)) { $template = str_replace('{$server_address}', $row['server_address'], $template); $template = str_replace('{$mac}', $device_address, $template); $content = trim($template, "\r\n"); unset($template); } } } //build content for linphone if ($device_template == "linphone/default") { $auth_string = ''; if ($settings->get('provision', 'http_auth_enabled', true) && !empty($settings->get('provision', 'http_auth_username', '')) && !empty($settings->get('provision', 'http_auth_password', ''))) { $auth_string = $settings->get('provision', 'http_auth_username', '').':'.$settings->get('provision', 'http_auth_password', '').'@'; } $content = "https://".$auth_string.$provision_domain_name.'/app/provision/index.php?address='.$device_address; } //stream the file if (!empty($content)) { $content = html_entity_decode($content, ENT_QUOTES, 'UTF-8'); require_once 'resources/qr_code/QRErrorCorrectLevel.php'; require_once 'resources/qr_code/QRCode.php'; require_once 'resources/qr_code/QRCodeImage.php'; try { $code = new QRCode (- 1, QRErrorCorrectLevel::H); $code->addData($content); $code->make(); $img = new QRCodeImage ($code, $width=420, $height=420, $quality=50); $img->draw(); $image = $img->getImage(); $img->finish(); } catch (Exception $error) { echo $error; } } //html image if (!empty($content) && !empty($image)) { echo "\n"; echo "\n"; echo ""; echo "
\n"; echo " \n"; echo "
\n"; } /* if (!empty($settings->get('theme', 'qr_image', ''))) { echo ""; } else { echo ""; } */ } //show the content echo "
\n"; echo "\n"; echo "
\n"; echo "
".$text['header-device']."
\n"; echo "
\n"; 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') { $button_margin = 'margin-left: 15px;'; if (permission_exists("device_line_password") && $qr_code_enabled) { echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','style'=>($button_margin ?? ''),'onclick'=>"fade_in('image-container');"]); unset($button_margin); } else if (!empty($user_id) && !empty($server_address)) { echo button::create(['type'=>'button','label'=>$text['button-provision'],'icon'=>'fax','style'=>($button_margin ?? ''),'link'=>PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&user=".urlencode($user_id ?? '')."&domain=".urlencode($server_address ?? '')."&agent=".urlencode($device_vendor)]); unset($button_margin); } if (permission_exists("device_files")) { //get the template directory $prov = new provision(['settings' => $settings]); $prov->domain_uuid = $domain_uuid; $template_dir = $prov->template_dir; $files = glob($template_dir.'/'.$device_template.'/*'); //add file buttons and the file list 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 ""; unset($button_margin); } if (permission_exists('device_add')) { 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); } if ( permission_exists('device_delete') || permission_exists('device_line_delete') || permission_exists('device_key_delete') || permission_exists('device_setting_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); } } 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 "
\n"; echo "
\n"; echo "
\n"; if (permission_exists('device_add')) { echo modal::create([ 'id'=>'modal-copy', 'type'=>'general', 'message'=>$text['message_device']."...

", 'actions'=>button::create([ 'type'=>'button', 'label'=>$text['button-continue'], 'icon'=>'check', 'id'=>'btn_copy', 'style'=>'float: right; margin-left: 15px;', 'collapse'=>'never', 'onclick'=>"modal_close(); if (document.getElementById('new_address').value != '') { window.location='device_copy.php?id=".urlencode($device_uuid ?? '')."&mac=' + document.getElementById('new_address').value; }" ]), 'onclose'=>"document.getElementById('new_address').value = '';", ]); } if ( permission_exists('device_delete') || permission_exists('device_line_delete') || permission_exists('device_key_delete') || permission_exists('device_setting_delete') ) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); } echo $text['description-device']."\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('device_template')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_line_edit')) { echo " "; echo " "; echo " "; echo " "; } if (permission_exists('device_profile_view')) { //device profiles $sql = "select * from v_device_profiles "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "order by device_profile_name asc "; $parameters['domain_uuid'] = $domain_uuid; $device_profiles = $database->select($sql, $parameters, 'all'); if (is_array($device_profiles) && @sizeof($device_profiles) != 0) { echo " "; echo " "; echo " "; echo " "; } unset($sql, $parameters, $device_profiles); } if (permission_exists('device_key_edit')) { //determine whether to show the key_subtype $show_key_subtype = false; if ($device_vendor == 'fanvil') { $show_key_subtype = true; } //set the previous_vendor and vendor_count $vendor_count = 0; foreach($device_keys as $row) { if (empty($row['device_key_vendor']) || empty($previous_vendor) || $previous_vendor != $row['device_key_vendor']) { $previous_vendor = $row['device_key_vendor'] ?? null; $vendor_count++; } } //show the device keys html form echo " "; echo " "; echo " "; echo " "; } //device settings if (permission_exists('device_setting_edit')) { $device_setting_exists = false; foreach ($device_settings as $row) { if (!empty($row['device_setting_uuid']) && is_uuid($row['device_setting_uuid'])) { $device_setting_exists = true; break; } } echo " "; echo " "; echo " \n"; echo "\n"; } if (permission_exists('device_user')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_alternate') && !empty($device_uuid_alternate) && is_uuid($device_uuid_alternate)) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_vendor')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_location')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_serial_number')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_model')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_firmware')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (permission_exists('device_domain')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } else { echo " \n"; } if (permission_exists('device_enable')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
\n"; echo " ".$text['label-device_address']."\n"; echo "\n"; if (permission_exists('device_address')) { echo " \n"; echo "
\n"; echo $text['description-device_address']."\n"; } else { echo escape(format_device_address($device_address ?? '')); } echo " \n"; if (!empty($device_provisioned_ip)) { echo " ".escape($device_provisioned_ip ?? '')." (http|https)\n"; } echo "
\n"; echo " ".$text['label-device_label']."\n"; echo "\n"; if (permission_exists('device_label')) { echo " \n"; echo "
\n"; echo $text['description-device_label']."\n"; } else { echo escape($device_label); } echo "
\n"; echo " ".$text['label-device_template']."\n"; echo "\n"; echo "
"; $device = new device; $template_dir = $device->get_template_dir(); echo " \n"; echo " \n"; echo " ".$text['description-device_template']."\n"; echo " "; echo "
"; echo " "; $device_image_path = ($current_device_path ?? '').'/'; $device_image_name = ($current_device ?? '').'.jpg'; $device_image_full = ($device_image_path ?? '').'/'.($current_device ?? '').'/'.($device_image_name ?? ''); if (file_exists($device_image_full)) { $device_image = base64_encode(file_get_contents($device_image_full)); echo "
\n"; echo ""; echo "
"; } echo "
".$text['label-lines'].""; echo " \n"; echo " \n"; echo " \n"; if (permission_exists('device_line_server_address')) { echo " \n"; } if (permission_exists('device_line_server_address_primary')) { echo " \n"; } if (permission_exists('device_line_server_address_secondary')) { echo " \n"; } if (permission_exists('device_line_outbound_proxy_primary')) { echo " \n"; } if (permission_exists('device_line_outbound_proxy_secondary')) { echo " \n"; } if (permission_exists('device_line_label')) { echo " \n"; } if (permission_exists('device_line_display_name')) { echo " \n"; } echo " \n"; if (permission_exists('device_line_auth_id')) { echo " \n"; } if (permission_exists('device_line_password')) { echo " \n"; } if (permission_exists('device_line_port')) { echo " \n"; } if (permission_exists('device_line_transport')) { echo " \n"; } if (permission_exists('device_line_register_expires')) { echo " \n"; } if (permission_exists('device_line_shared')) { echo " \n"; } echo " \n"; if (is_array($device_lines) && @sizeof($device_lines) > 1 && permission_exists('device_line_delete')) { echo " \n"; } echo " \n"; $x = 0; foreach ($device_lines as $row) { //set the defaults if (!permission_exists('device_line_server_address')) { if (empty($row['server_address'])) { $row['server_address'] = $domain_name; } } if (empty($row['sip_transport'])) { $row['sip_transport'] = $settings->get('provision', 'line_sip_transport', 'tcp'); } 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'] = $settings->get('provision', 'line_register_expires', '120'); } //add the primary key uuid if (!empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) { echo " \n"; } //show each row in the array echo " \n"; echo " \n"; if (permission_exists('device_line_server_address')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_line_server_address_primary')) { echo " \n"; } if (permission_exists('device_line_server_address_secondary')) { echo " \n"; } if (permission_exists('device_line_outbound_proxy_primary')) { echo " \n"; } if (permission_exists('device_line_outbound_proxy_secondary')) { echo " \n"; } if (permission_exists('device_line_label')) { echo " \n"; } if (permission_exists('device_line_display_name')) { echo " \n"; } echo " \n"; if (permission_exists('device_line_auth_id')) { echo " \n"; } if (permission_exists('device_line_password')) { echo " \n"; } if (permission_exists('device_line_port')) { echo " \n"; } if (permission_exists('device_line_transport')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_line_register_expires')) { echo " \n"; } else { echo " \n"; } if (permission_exists('device_line_shared')) { echo " \n"; } else { echo " \n"; } echo " \n"; if (!empty($device_lines) && is_array($device_lines) && @sizeof($device_lines) > 1 && permission_exists('device_line_delete') && !empty($row['device_line_uuid']) && is_uuid($row['device_line_uuid'])) { echo " \n"; //increment counter $x++; } echo "
".$text['label-line']."".$text['label-server_address']."".$text['label-server_address_primary']."".$text['label-server_address_secondary']."".$text['label-outbound_proxy_primary']."".$text['label-outbound_proxy_secondary']."".$text['label-label']."".$text['label-display_name']."".$text['label-user_id']."".$text['label-auth_id']."".$text['label-password']."".$text['label-sip_port']."".$text['label-sip_transport']."".$text['label-register_expires']."".$text['label-shared_line']."".$text['label-enabled']."\n"; echo " ".$text['label-delete']."\n"; echo " \n"; echo "
\n"; $selected = "selected=\"selected\" "; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $provision_server_address_primary = $settings->get('provision', 'server_address_primary'); if (!empty($provision_server_address_primary) && is_array($provision_server_address_primary)) { echo " \n"; } else { echo " \n"; } echo " \n"; $provision_server_address_secondary = $settings->get('provision', 'server_address_secondary'); if (!empty($provision_server_address_secondary) && is_array($provision_server_address_secondary)) { echo " \n"; } else { echo " \n"; } echo " \n"; $provision_outbound_proxy_primary = $settings->get('provision', 'outbound_proxy_primary'); if (!empty($provision_outbound_proxy_primary) && is_array($provision_outbound_proxy_primary)) { echo " \n"; } else { echo " \n"; } echo " \n"; $provision_outbound_proxy_secondary = $settings->get('provision', 'outbound_proxy_secondary'); if (!empty($provision_outbound_proxy_secondary) && is_array($provision_outbound_proxy_secondary)) { echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //help defeat browser auto-fill echo " \n"; echo " "; //help defeat browser auto-fill echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo "
\n"; if (!empty($text['description-lines'])) { echo "
".$text['description-lines']."\n"; } echo "
".$text['label-profile'].""; if (permission_exists('device_profile_select')) { echo " \n"; } else { foreach($device_profiles as $row) { if ($row['device_profile_uuid'] == $device_profile_uuid) { echo escape($row['device_profile_name']); } } } if (permission_exists('device_profile_edit')) { echo " "; echo " "; } echo "
".$text['description-profile2']."\n"; echo "
".$text['label-keys'].""; echo " \n"; if ($vendor_count == 0) { echo " \n"; echo " \n"; if (permission_exists('device_key_id')) { echo " \n"; } echo " \n"; if ($show_key_subtype) { echo " \n"; } if (permission_exists('device_key_line')) { echo " \n"; } echo " \n"; if (permission_exists('device_key_extension')) { echo " \n"; } echo " \n"; if (permission_exists('device_key_icon')) { echo " \n"; } if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { echo " \n"; } echo " \n"; } $x = 0; $device_keys_generic_header_displayed = false; foreach ($device_keys as $row) { //set the column names if ((empty($row['device_key_vendor']) || empty($previous_device_key_vendor) || $previous_device_key_vendor != $row['device_key_vendor']) && !$device_keys_generic_header_displayed) { echo " \n"; echo " \n"; if (permission_exists('device_key_id')) { echo " \n"; } if ($vendor_count > 1 && !empty($row['device_key_vendor'])) { echo " \n"; if ($show_key_subtype) { echo " \n"; } } else { $device_keys_generic_header_displayed = true; echo " \n"; if ($show_key_subtype) { echo " \n"; } } if (permission_exists('device_key_line')) { echo " \n"; } echo " \n"; if (permission_exists('device_key_extension')) { echo " \n"; } echo " \n"; if (permission_exists('device_key_icon')) { echo " \n"; } if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete') && !$device_keys_generic_header_displayed) { echo " \n"; } echo " \n"; } //add the primary key uuid if (!empty($row['device_key_uuid']) && is_uuid($row['device_key_uuid'])) { echo " \n"; } //show all the rows in the array echo " \n"; echo "\n"; if (permission_exists('device_key_id')) { echo "\n"; } echo "\n"; if($show_key_subtype) { echo "\n"; } if (permission_exists('device_key_line')) { echo "\n"; } echo "\n"; if (permission_exists('device_key_extension')) { echo "\n"; } echo "\n"; if (permission_exists('device_key_icon')) { echo "\n"; } if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { if (!empty($row['device_key_uuid']) && is_uuid($row['device_key_uuid'])) { echo " \n"; echo " \n"; //set the previous vendor $previous_device_key_vendor = $row['device_key_vendor'] ?? ''; //increment the array key $x++; } echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_key_type']."".$text['label-device_key_subtype']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']."".$text['label-device_key_icon']."\n"; echo " ".$text['label-delete']."\n"; echo " \n"; echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_subtype']."".$text['label-device_key_type']."".$text['label-device_key_subtype']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']."".$text['label-device_key_icon']."\n"; echo " ".$text['label-delete']."\n"; echo " \n"; echo "
\n"; echo " \n"; echo "\n"; $selected = "selected='selected'"; echo " \n"; echo "\n"; //echo " \n"; if (!empty($row['device_key_vendor'])) { $device_key_vendor = $row['device_key_vendor']; } else { $device_key_vendor = $device_vendor; } echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; } else { echo " \n"; } } echo "
\n"; if (!empty($text['description-keys'])) { echo "
".$text['description-keys']."\n"; } echo "
".$text['label-settings'].""; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete') && $device_setting_exists) { echo " \n"; } echo " \n"; $x = 0; foreach ($device_settings as $row) { //add the primary key uuid if (!empty($row['device_setting_uuid']) && is_uuid($row['device_setting_uuid'])) { echo " \n"; } //show alls rows in the array echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete')) { if (!empty($row['device_setting_uuid']) && is_uuid($row['device_setting_uuid'])) { echo "\n"; } echo "\n"; $x++; } echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']."\n"; echo " ".$text['label-delete']."\n"; echo " \n"; echo "
\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo "\n"; echo " \n"; echo " \n"; } else { echo "\n"; } echo "
\n"; if (!empty($text['description-settings'])) { echo "
".$text['description-settings']."\n"; } echo "
\n"; echo " ".$text['label-user']."\n"; echo "\n"; echo " "; unset($users); echo "
\n"; echo " ".$text['description-user']."\n"; } if (permission_exists('device_username_password')) { echo "
\n"; echo " ".$text['label-device']."\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo $text['description-device']."\n"; echo "
\n"; echo " ".$text['label-device_uuid_alternate']."\n"; echo "\n"; $label = $device_alternate[0]['device_label']; if (empty($label)) { $label = $device_alternate[0]['device_description']; } if (empty($label)) { $label = $device_alternate[0]['device_address']; } echo " \n"; echo " \n"; echo " "; echo " \n"; echo " \n"; echo "
".escape($label)." $v_link_label_delete
\n"; unset($label); echo $text['description-device_uuid_alternate']."\n"; echo "
\n"; echo " ".$text['label-device_vendor']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_vendor']."\n"; echo "
\n"; echo " ".$text['label-device_location']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_location']."\n"; echo "
\n"; echo " ".$text['label-device_serial_number']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_serial_number']."\n"; echo "
\n"; echo " ".$text['label-device_model']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_model']."\n"; echo "
\n"; echo " ".$text['label-device_firmware_version']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_firmware_version']."\n"; echo "
\n"; echo " ".$text['label-domain']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-domain_name']."\n"; echo "
\n"; echo " ".$text['label-device_enabled']."\n"; echo "\n"; if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') { echo " \n"; } else { echo " \n"; } echo "
\n"; echo $text['description-device_enabled']."\n"; echo "
\n"; echo " ".$text['label-device_description']."\n"; echo "\n"; if (permission_exists('device_description')) { echo " \n"; echo "
\n"; echo $text['description-device_description']."\n"; } else { echo escape($device_description)."\n"; } echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo "
\n"; echo "

"; echo "
"; echo "\n"; //show the footer require_once "resources/footer.php"; ?>