2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2018-01-23 06:41:55 +01:00
|
|
|
Copyright (C) 2008-2018 All Rights Reserved.
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
*/
|
2016-07-27 05:00:05 +02:00
|
|
|
|
|
|
|
|
//includes
|
|
|
|
|
require_once "root.php";
|
|
|
|
|
require_once "resources/require.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//check permissions
|
2013-07-06 07:50:55 +02:00
|
|
|
require_once "resources/check_auth.php";
|
2013-03-20 17:53:37 +01:00
|
|
|
if (permission_exists('device_add') || permission_exists('device_edit')) {
|
2012-06-04 16:58:40 +02:00
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 10:18:12 +02:00
|
|
|
//add multi-lingual support
|
2015-01-18 08:42:57 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-23 10:18:12 +02:00
|
|
|
|
2015-05-04 22:07:51 +02:00
|
|
|
//check for duplicates
|
|
|
|
|
if ($_GET["check"] == 'duplicate') {
|
|
|
|
|
//mac address
|
|
|
|
|
if ($_GET["mac"] != '' && $_GET["mac"] != "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_mac_address = '".check_str($_GET["mac"])."' ";
|
|
|
|
|
if ($_GET["device_uuid"] != '') {
|
|
|
|
|
$sql .= " and d1.device_uuid <> '".check_str($_GET["device_uuid"])."' ";
|
|
|
|
|
}
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if ($row['domain_name'] != '') {
|
|
|
|
|
echo $text['message-duplicate'].((if_group("superadmin") && $_SESSION["domain_name"] != $row["domain_name"]) ? ": ".$row["domain_name"] : null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement);
|
2014-08-02 04:16:46 +02:00
|
|
|
}
|
2015-05-04 22:07:51 +02:00
|
|
|
|
|
|
|
|
//username
|
|
|
|
|
if ($_GET['username'] != '') {
|
|
|
|
|
$sql = "select ";
|
|
|
|
|
$sql .= "d2.domain_name, ";
|
|
|
|
|
$sql .= "d1.device_mac_address ";
|
|
|
|
|
$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_username = '".check_str($_GET["username"])."' ";
|
|
|
|
|
if ($_GET['domain_uuid'] != '') {
|
|
|
|
|
$sql .= "and d2.domain_uuid = '".check_str($_GET['domain_uuid'])."' ";
|
|
|
|
|
}
|
|
|
|
|
if ($_GET['device_uuid'] != '') {
|
|
|
|
|
$sql .= "and d1.device_uuid <> '".check_str($_GET["device_uuid"])."' ";
|
|
|
|
|
}
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
if ($row['domain_name'] != '') {
|
|
|
|
|
echo $text['message-duplicate_username'].((if_group("superadmin")) ? ": ".format_mac($row['device_mac_address']).(($_SESSION["domain_name"] != $row["domain_name"]) ? " (".$row["domain_name"].")" : null) : null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-02 04:16:46 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 00:11:42 +01:00
|
|
|
//include the device class
|
|
|
|
|
require_once "app/devices/resources/classes/device.php";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//action add or update
|
|
|
|
|
if (isset($_REQUEST["id"])) {
|
|
|
|
|
$action = "update";
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_uuid = check_str($_REQUEST["id"]);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$action = "add";
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 09:17:04 +01:00
|
|
|
//get total device count from the database, check limit, if defined
|
|
|
|
|
if ($action == 'add') {
|
|
|
|
|
if ($_SESSION['limit']['devices']['numeric'] != '') {
|
|
|
|
|
$sql = "select count(*) as num_rows from v_devices where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
$total_devices = $row['num_rows'];
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement, $row);
|
|
|
|
|
if ($total_devices >= $_SESSION['limit']['devices']['numeric']) {
|
2017-06-08 17:39:04 +02:00
|
|
|
messages::add($text['message-maximum_devices'].' '.$_SESSION['limit']['devices']['numeric'], 'negative');
|
2015-03-22 09:17:04 +01:00
|
|
|
header('Location: devices.php');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 10:18:12 +02:00
|
|
|
//get http post variables and set them to php variables
|
2013-04-10 01:26:20 +02:00
|
|
|
if (count($_POST) > 0) {
|
2015-11-05 20:25:30 +01:00
|
|
|
//device mac address
|
|
|
|
|
if (permission_exists('device_mac_address')) {
|
|
|
|
|
$device_mac_address = check_str($_POST["device_mac_address"]);
|
|
|
|
|
$device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address));
|
|
|
|
|
$_POST["device_mac_address"] = $device_mac_address;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2016-10-23 07:30:11 +02:00
|
|
|
$sql = "select * from v_devices ";
|
|
|
|
|
$sql .= "where device_uuid = '$device_uuid' ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2015-11-05 20:25:30 +01:00
|
|
|
foreach ($result as &$row) {
|
|
|
|
|
$device_mac_address = $row["device_mac_address"];
|
|
|
|
|
$_POST["device_mac_address"] = $device_mac_address;
|
|
|
|
|
}
|
|
|
|
|
unset ($prep_statement);
|
|
|
|
|
}
|
2016-05-20 18:39:16 +02:00
|
|
|
//get assigned user
|
2016-06-18 01:45:42 +02:00
|
|
|
$device_user_uuid = check_str($_POST["device_user_uuid"]);
|
2013-06-09 22:46:14 +02:00
|
|
|
//devices
|
|
|
|
|
$device_label = check_str($_POST["device_label"]);
|
|
|
|
|
$device_vendor = check_str($_POST["device_vendor"]);
|
2015-05-22 06:34:31 +02:00
|
|
|
$device_uuid_alternate = check_str($_POST["device_uuid_alternate"]);
|
2013-06-09 22:46:14 +02:00
|
|
|
$device_model = check_str($_POST["device_model"]);
|
|
|
|
|
$device_firmware_version = check_str($_POST["device_firmware_version"]);
|
2016-03-11 19:46:02 +01:00
|
|
|
$device_enabled = check_str($_POST["device_enabled"]);
|
2013-06-09 22:46:14 +02:00
|
|
|
$device_template = check_str($_POST["device_template"]);
|
|
|
|
|
$device_description = check_str($_POST["device_description"]);
|
|
|
|
|
//lines
|
|
|
|
|
$line_number = check_str($_POST["line_number"]);
|
|
|
|
|
$server_address = check_str($_POST["server_address"]);
|
2016-07-27 05:00:05 +02:00
|
|
|
$outbound_proxy_primary = check_str($_POST["outbound_proxy_primary"]);
|
|
|
|
|
$outbound_proxy_secondary = check_str($_POST["outbound_proxy_secondary"]);
|
2013-06-09 22:46:14 +02:00
|
|
|
$display_name = check_str($_POST["display_name"]);
|
|
|
|
|
$user_id = check_str($_POST["user_id"]);
|
|
|
|
|
$auth_id = check_str($_POST["auth_id"]);
|
|
|
|
|
$password = check_str($_POST["password"]);
|
2015-02-15 01:33:56 +01:00
|
|
|
//profile
|
|
|
|
|
$device_profile_uuid = check_str($_POST["device_profile_uuid"]);
|
2013-12-17 17:19:54 +01:00
|
|
|
//keys
|
2014-01-03 09:05:46 +01:00
|
|
|
$device_key_category = check_str($_POST["device_key_category"]);
|
2013-12-17 17:19:54 +01:00
|
|
|
$device_key_id = check_str($_POST["device_key_id"]);
|
|
|
|
|
$device_key_type = check_str($_POST["device_key_type"]);
|
2014-01-03 09:05:46 +01:00
|
|
|
$device_key_line = check_str($_POST["device_key_line"]);
|
2013-12-17 17:19:54 +01:00
|
|
|
$device_key_value = check_str($_POST["device_key_value"]);
|
2014-01-04 00:11:42 +01:00
|
|
|
$device_key_extension = check_str($_POST["device_key_extension"]);
|
2013-12-17 17:19:54 +01:00
|
|
|
$device_key_label = check_str($_POST["device_key_label"]);
|
2013-12-10 16:05:16 +01:00
|
|
|
//settings
|
|
|
|
|
//$device_setting_category = check_str($_POST["device_setting_category"]);
|
|
|
|
|
$device_setting_subcategory = check_str($_POST["device_setting_subcategory"]);
|
|
|
|
|
//$device_setting_name = check_str($_POST["device_setting_name"]);
|
|
|
|
|
$device_setting_value = check_str($_POST["device_setting_value"]);
|
|
|
|
|
$device_setting_enabled = check_str($_POST["device_setting_enabled"]);
|
|
|
|
|
$device_setting_description = check_str($_POST["device_setting_description"]);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-04 00:11:42 +01:00
|
|
|
//use the mac address to get the vendor
|
2013-03-20 17:53:37 +01:00
|
|
|
if (strlen($device_vendor) == 0) {
|
2014-01-04 00:11:42 +01:00
|
|
|
$device_vendor = device::get_vendor($device_mac_address);
|
2012-07-05 20:22:02 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//add or update the database
|
2013-04-10 01:26:20 +02:00
|
|
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//check for all required data
|
2014-02-15 00:25:46 +01:00
|
|
|
$msg = '';
|
2014-03-30 09:46:50 +02:00
|
|
|
//if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
|
2013-03-20 17:53:37 +01:00
|
|
|
//if (strlen($device_label) == 0) { $msg .= "Please provide: Label<br>\n"; }
|
|
|
|
|
//if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor<br>\n"; }
|
|
|
|
|
//if (strlen($device_model) == 0) { $msg .= "Please provide: Model<br>\n"; }
|
|
|
|
|
//if (strlen($device_firmware_version) == 0) { $msg .= "Please provide: Firmware Version<br>\n"; }
|
2016-03-11 19:46:02 +01:00
|
|
|
//if (strlen($device_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
|
2013-03-20 17:53:37 +01:00
|
|
|
//if (strlen($device_template) == 0) { $msg .= "Please provide: Template<br>\n"; }
|
|
|
|
|
//if (strlen($device_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
|
|
|
|
|
//if (strlen($device_password) == 0) { $msg .= "Please provide: Password<br>\n"; }
|
|
|
|
|
//if (strlen($device_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
|
2013-06-09 22:46:14 +02:00
|
|
|
if (strlen($msg) > 0) {
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2013-07-06 08:21:12 +02:00
|
|
|
require_once "resources/persist_form_var.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<div align='center'>\n";
|
|
|
|
|
echo "<table><tr><td>\n";
|
|
|
|
|
echo $msg."<br />";
|
|
|
|
|
echo "</td></tr></table>\n";
|
|
|
|
|
persistformvar($_POST);
|
|
|
|
|
echo "</div>\n";
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add or update the database
|
|
|
|
|
if ($_POST["persistformvar"] != "true") {
|
2014-01-20 10:34:04 +01:00
|
|
|
//add domain_uuid to the array
|
|
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
|
|
if (is_array($value)) {
|
|
|
|
|
$y = 0;
|
|
|
|
|
foreach ($value as $k => $v) {
|
|
|
|
|
if (!isset($v["domain_uuid"])) {
|
2015-01-10 02:02:39 +01:00
|
|
|
$_POST[$key][$y]["domain_uuid"] = $_POST["domain_uuid"];
|
2014-01-20 10:34:04 +01:00
|
|
|
}
|
|
|
|
|
$y++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-10 02:02:39 +01:00
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
//array cleanup
|
|
|
|
|
$x = 0;
|
2015-09-23 02:35:20 +02:00
|
|
|
//unset($_POST["autocomplete"]);
|
2015-11-25 08:10:49 +01:00
|
|
|
unset($_POST["target_file"]);
|
|
|
|
|
unset($_POST["file_action"]);
|
|
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
foreach ($_POST["device_lines"] as $row) {
|
|
|
|
|
//unset the empty row
|
|
|
|
|
if (strlen($row["line_number"]) == 0) {
|
|
|
|
|
unset($_POST["device_lines"][$x]);
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
//unset device_detail_uuid if the field has no value
|
2014-01-20 10:34:04 +01:00
|
|
|
if (strlen($row["device_line_uuid"]) == 0) {
|
|
|
|
|
unset($_POST["device_lines"][$x]["device_line_uuid"]);
|
|
|
|
|
}
|
|
|
|
|
//increment the row
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach ($_POST["device_keys"] as $row) {
|
|
|
|
|
//unset the empty row
|
2014-02-08 04:47:42 +01:00
|
|
|
if (strlen($row["device_key_category"]) == 0) {
|
2014-01-20 10:34:04 +01:00
|
|
|
unset($_POST["device_keys"][$x]);
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
//unset device_detail_uuid if the field has no value
|
2014-01-20 10:34:04 +01:00
|
|
|
if (strlen($row["device_key_uuid"]) == 0) {
|
|
|
|
|
unset($_POST["device_keys"][$x]["device_key_uuid"]);
|
|
|
|
|
}
|
|
|
|
|
//increment the row
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach ($_POST["device_settings"] as $row) {
|
|
|
|
|
//unset the empty row
|
|
|
|
|
if (strlen($row["device_setting_subcategory"]) == 0) {
|
|
|
|
|
unset($_POST["device_settings"][$x]);
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
//unset device_detail_uuid if the field has no value
|
2014-01-20 10:34:04 +01:00
|
|
|
if (strlen($row["device_setting_uuid"]) == 0) {
|
|
|
|
|
unset($_POST["device_settings"][$x]["device_setting_uuid"]);
|
|
|
|
|
}
|
|
|
|
|
//increment the row
|
|
|
|
|
$x++;
|
2013-12-17 17:19:54 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-15 00:25:46 +01:00
|
|
|
//set the default
|
|
|
|
|
$save = true;
|
|
|
|
|
|
|
|
|
|
//check to see if the mac address exists
|
|
|
|
|
if ($action == "add") {
|
2014-03-30 09:46:50 +02:00
|
|
|
if ($device_mac_address == "" || $device_mac_address == "000000000000") {
|
|
|
|
|
//allow duplicates to be used as templaes
|
|
|
|
|
}
|
|
|
|
|
else {
|
2014-08-02 04:16:46 +02:00
|
|
|
$save = true;
|
2014-02-15 00:25:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$save = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 09:13:25 +02:00
|
|
|
//prepare the array
|
|
|
|
|
$array['devices'][] = $_POST;
|
|
|
|
|
|
2014-02-15 00:25:46 +01:00
|
|
|
//save the device
|
|
|
|
|
if ($save) {
|
2016-10-18 17:19:20 +02:00
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'devices';
|
|
|
|
|
$database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
|
2014-01-20 10:34:04 +01:00
|
|
|
if (strlen($device_uuid) > 0) {
|
2016-10-18 17:19:20 +02:00
|
|
|
$database->uuid($device_uuid);
|
2014-01-20 10:34:04 +01:00
|
|
|
}
|
2016-10-18 17:19:20 +02:00
|
|
|
$database->save($array);
|
|
|
|
|
$response = $database->message;
|
2014-02-15 00:25:46 +01:00
|
|
|
if (strlen($response['uuid']) > 0) {
|
|
|
|
|
$device_uuid = $response['uuid'];
|
|
|
|
|
}
|
2013-12-10 16:05:16 +01:00
|
|
|
}
|
|
|
|
|
|
2013-06-09 22:46:14 +02:00
|
|
|
//write the provision files
|
2015-11-05 03:59:27 +01:00
|
|
|
if (strlen($_SESSION['provision']['path']['text']) > 0) {
|
2016-12-06 19:25:08 +01:00
|
|
|
$prov = new provision;
|
|
|
|
|
$prov->domain_uuid = $domain_uuid;
|
|
|
|
|
$response = $prov->write();
|
2015-01-10 02:02:39 +01:00
|
|
|
}
|
2014-01-20 10:34:04 +01:00
|
|
|
|
|
|
|
|
//set the message
|
2014-02-15 00:25:46 +01:00
|
|
|
if (!isset($_SESSION['message'])) {
|
|
|
|
|
if ($save) {
|
|
|
|
|
if ($action == "add") {
|
|
|
|
|
//save the message to a session variable
|
2017-06-08 17:39:04 +02:00
|
|
|
messages::add($text['message-add']);
|
2014-02-15 00:25:46 +01:00
|
|
|
}
|
|
|
|
|
if ($action == "update") {
|
|
|
|
|
//save the message to a session variable
|
2017-06-08 17:39:04 +02:00
|
|
|
messages::add($text['message-update']);
|
2014-02-15 00:25:46 +01:00
|
|
|
}
|
2015-05-04 22:07:51 +02:00
|
|
|
//redirect the browser
|
|
|
|
|
header("Location: device_edit.php?id=$device_uuid");
|
|
|
|
|
exit;
|
2014-02-15 00:25:46 +01:00
|
|
|
}
|
2014-01-20 10:34:04 +01:00
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
} //if ($_POST["persistformvar"] != "true")
|
2014-01-20 19:00:45 +01:00
|
|
|
} //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//pre-populate the form
|
2014-01-04 00:11:42 +01:00
|
|
|
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
2016-10-23 07:30:11 +02:00
|
|
|
$sql = "select * from v_devices ";
|
|
|
|
|
$sql .= "where device_uuid = '$device_uuid' ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2012-06-04 16:58:40 +02:00
|
|
|
foreach ($result as &$row) {
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_mac_address = $row["device_mac_address"];
|
2017-06-09 00:21:47 +02:00
|
|
|
$device_provisioned_ip = $row["device_provisioned_ip"];
|
2014-05-08 11:22:35 +02:00
|
|
|
$domain_uuid = $row["domain_uuid"];
|
|
|
|
|
$device_label = $row["device_label"];
|
2014-02-23 08:15:03 +01:00
|
|
|
//$device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2);
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_label = $row["device_label"];
|
2016-06-18 01:45:42 +02:00
|
|
|
$device_user_uuid = $row["device_user_uuid"];
|
2015-04-30 06:36:57 +02:00
|
|
|
$device_username = $row["device_username"];
|
|
|
|
|
$device_password = $row["device_password"];
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_vendor = $row["device_vendor"];
|
2015-05-22 06:34:31 +02:00
|
|
|
$device_uuid_alternate = $row["device_uuid_alternate"];
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_model = $row["device_model"];
|
|
|
|
|
$device_firmware_version = $row["device_firmware_version"];
|
2016-03-11 19:46:02 +01:00
|
|
|
$device_enabled = $row["device_enabled"];
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_template = $row["device_template"];
|
2015-02-15 01:33:56 +01:00
|
|
|
$device_profile_uuid = $row["device_profile_uuid"];
|
2013-03-20 17:53:37 +01:00
|
|
|
$device_description = $row["device_description"];
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
unset ($prep_statement);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 12:03:05 +01:00
|
|
|
//use the mac address to get the vendor
|
|
|
|
|
if (strlen($device_vendor) == 0) {
|
|
|
|
|
$template_array = explode("/", $device_template);
|
|
|
|
|
$device_vendor = $template_array[0];
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-20 19:00:45 +01:00
|
|
|
//set the sub array index
|
|
|
|
|
$x = "999";
|
|
|
|
|
|
2015-05-24 07:00:40 +02:00
|
|
|
//alternate device settings
|
|
|
|
|
if (strlen($device_uuid_alternate) > 0) {
|
|
|
|
|
$sql = "select * from v_devices ";
|
|
|
|
|
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
|
|
|
|
|
$sql .= "and device_uuid = '$device_uuid_alternate' ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$device_alternate = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
unset ($prep_statement, $sql);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
//get device lines
|
|
|
|
|
$sql = "SELECT * FROM v_device_lines ";
|
2014-05-08 11:22:35 +02:00
|
|
|
$sql .= "where device_uuid = '".$device_uuid."' ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "order by line_number asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2014-01-20 19:00:45 +01:00
|
|
|
$device_lines[$x]['line_number'] = '';
|
|
|
|
|
$device_lines[$x]['server_address'] = '';
|
2016-07-27 05:00:05 +02:00
|
|
|
$device_lines[$x]['outbound_proxy_primary'] = $_SESSION['provision']['outbound_proxy_primary']['text'];
|
|
|
|
|
$device_lines[$x]['outbound_proxy_secondary'] = $_SESSION['provision']['outbound_proxy_secondary']['text'];
|
2014-01-20 19:00:45 +01:00
|
|
|
$device_lines[$x]['display_name'] = '';
|
|
|
|
|
$device_lines[$x]['user_id'] = '';
|
|
|
|
|
$device_lines[$x]['auth_id'] = '';
|
|
|
|
|
$device_lines[$x]['password'] = '';
|
2018-01-23 06:41:55 +01:00
|
|
|
$device_lines[$x]['shared_line'] = '';
|
2015-05-19 18:09:04 +02:00
|
|
|
$device_lines[$x]['enabled'] = '';
|
2015-05-20 07:14:14 +02:00
|
|
|
$device_lines[$x]['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric'];
|
|
|
|
|
$device_lines[$x]['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text'];
|
|
|
|
|
$device_lines[$x]['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric'];
|
2014-01-20 10:34:04 +01:00
|
|
|
|
|
|
|
|
//get device keys
|
|
|
|
|
$sql = "SELECT * FROM v_device_keys ";
|
2014-05-08 11:22:35 +02:00
|
|
|
$sql .= "WHERE device_uuid = '".$device_uuid."' ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "ORDER by ";
|
2015-07-08 06:41:24 +02:00
|
|
|
$sql .= "device_key_vendor asc, ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "CASE device_key_category ";
|
|
|
|
|
$sql .= "WHEN 'line' THEN 1 ";
|
2015-02-15 01:33:56 +01:00
|
|
|
$sql .= "WHEN 'memory' THEN 2 ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "WHEN 'programmable' THEN 3 ";
|
|
|
|
|
$sql .= "WHEN 'expansion' THEN 4 ";
|
2017-10-15 00:35:16 +02:00
|
|
|
$sql .= "WHEN 'expansion-1' THEN 5 ";
|
|
|
|
|
$sql .= "WHEN 'expansion-2' THEN 6 ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "ELSE 100 END, ";
|
2014-09-04 06:06:19 +02:00
|
|
|
if ($db_type == "mysql") {
|
|
|
|
|
$sql .= "device_key_id asc ";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sql .= "cast(device_key_id as numeric) asc ";
|
|
|
|
|
}
|
2014-01-20 10:34:04 +01:00
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2014-01-20 19:00:45 +01:00
|
|
|
$device_keys[$x]['device_key_category'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_id'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_type'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_line'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_value'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_extension'] = '';
|
|
|
|
|
$device_keys[$x]['device_key_label'] = '';
|
2014-01-20 10:34:04 +01:00
|
|
|
|
2016-08-02 21:35:38 +02:00
|
|
|
//get the vendor functions
|
|
|
|
|
$sql = "SELECT v.name as vendor_name, f.name, 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.name asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
//get device settings
|
|
|
|
|
$sql = "SELECT * FROM v_device_settings ";
|
2014-05-08 11:22:35 +02:00
|
|
|
$sql .= "WHERE device_uuid = '".$device_uuid."' ";
|
2014-01-20 10:34:04 +01:00
|
|
|
$sql .= "ORDER by device_setting_subcategory asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2014-01-20 19:00:45 +01:00
|
|
|
$device_settings[$x]['device_setting_name'] = '';
|
|
|
|
|
$device_settings[$x]['device_setting_value'] = '';
|
|
|
|
|
$device_settings[$x]['enabled'] = '';
|
|
|
|
|
$device_settings[$x]['device_setting_description'] = '';
|
2014-01-20 10:34:04 +01:00
|
|
|
|
2016-05-20 18:39:16 +02:00
|
|
|
//get the users
|
|
|
|
|
$sql = "SELECT * FROM v_users ";
|
|
|
|
|
$sql .= "WHERE domain_uuid = '".$domain_uuid."' ";
|
|
|
|
|
$sql .= "ORDER by username asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
|
2014-01-04 00:11:42 +01:00
|
|
|
//use the mac address to get the vendor
|
|
|
|
|
if (strlen($device_vendor) == 0) {
|
|
|
|
|
$device_vendor = device::get_vendor($device_mac_address);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 06:12:49 +01:00
|
|
|
//get the device line info for provision button
|
|
|
|
|
foreach($device_lines as $row) {
|
|
|
|
|
if (strlen($row['user_id']) > 0) {
|
|
|
|
|
$user_id = $row['user_id'];
|
|
|
|
|
}
|
|
|
|
|
if (strlen($row['server_address']) > 0) {
|
|
|
|
|
$server_address = $row['server_address'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-21 05:09:52 +02:00
|
|
|
|
|
|
|
|
//get the sip profile name
|
|
|
|
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
|
|
|
|
if ($fp) {
|
2017-09-23 08:12:47 +02:00
|
|
|
$command = "sofia_contact */".$user_id."@".$server_address;
|
2017-09-21 05:09:52 +02:00
|
|
|
$contact_string = event_socket_request($fp, "api ".$command);
|
|
|
|
|
if (substr($contact_string, 0, 5) == "sofia") {
|
|
|
|
|
$contact_array = explode("/", $contact_string);
|
|
|
|
|
$sip_profile_name = $contact_array[1];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sip_profile_name = 'internal';
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-21 06:12:49 +01:00
|
|
|
|
2013-05-23 10:18:12 +02:00
|
|
|
//show the header
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
//javascript to change select to input and back again
|
2016-07-27 05:00:05 +02:00
|
|
|
?>
|
|
|
|
|
<script language="javascript">
|
2014-01-20 10:34:04 +01:00
|
|
|
var objs;
|
|
|
|
|
|
|
|
|
|
function change_to_input(obj){
|
|
|
|
|
tb=document.createElement('INPUT');
|
|
|
|
|
tb.type='text';
|
|
|
|
|
tb.name=obj.name;
|
|
|
|
|
tb.className='formfld';
|
|
|
|
|
//tb.setAttribute('id', 'ivr_menu_option_param');
|
|
|
|
|
tb.setAttribute('style', 'width:175px;');
|
|
|
|
|
tb.value=obj.options[obj.selectedIndex].value;
|
|
|
|
|
tbb=document.createElement('INPUT');
|
|
|
|
|
tbb.setAttribute('class', 'btn');
|
2014-08-03 08:12:10 +02:00
|
|
|
tbb.setAttribute('style', 'margin-left: 4px;');
|
2014-01-20 10:34:04 +01:00
|
|
|
tbb.type='button';
|
2014-08-03 09:02:12 +02:00
|
|
|
tbb.value=$("<div />").html('◁').text();
|
2014-01-20 10:34:04 +01:00
|
|
|
tbb.objs=[obj,tb,tbb];
|
|
|
|
|
tbb.onclick=function(){ replace_param(this.objs); }
|
|
|
|
|
obj.parentNode.insertBefore(tb,obj);
|
|
|
|
|
obj.parentNode.insertBefore(tbb,obj);
|
|
|
|
|
obj.parentNode.removeChild(obj);
|
|
|
|
|
replace_param(this.objs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function replace_param(obj){
|
|
|
|
|
obj[2].parentNode.insertBefore(obj[0],obj[2]);
|
|
|
|
|
obj[0].parentNode.removeChild(obj[1]);
|
|
|
|
|
obj[0].parentNode.removeChild(obj[2]);
|
|
|
|
|
}
|
2014-08-02 04:16:46 +02:00
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
</script>
|
2015-11-25 08:10:49 +01:00
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
<?php
|
2015-11-25 08:10:49 +01:00
|
|
|
|
|
|
|
|
//select file download javascript
|
|
|
|
|
if (permission_exists("device_files")) {
|
|
|
|
|
echo "<script language='javascript' type='text/javascript'>\n";
|
|
|
|
|
echo " var fade_speed = 400;\n";
|
|
|
|
|
echo " function show_files() {\n";
|
|
|
|
|
echo " document.getElementById('file_action').value = 'files';\n";
|
2016-03-14 17:14:27 +01:00
|
|
|
echo " $('#button_back_location').fadeOut(fade_speed);\n";
|
2015-11-25 08:10:49 +01:00
|
|
|
echo " $('#button_files').fadeOut(fade_speed, function() {\n";
|
|
|
|
|
echo " $('#button_back').fadeIn(fade_speed);\n";
|
|
|
|
|
echo " $('#target_file').fadeIn(fade_speed);\n";
|
|
|
|
|
echo " $('#button_download').fadeIn(fade_speed);\n";
|
|
|
|
|
echo " });";
|
|
|
|
|
echo " }";
|
|
|
|
|
echo " function hide_files() {\n";
|
|
|
|
|
echo " document.getElementById('file_action').value = '';\n";
|
2016-03-14 17:14:27 +01:00
|
|
|
echo " $('#button_download').fadeOut(fade_speed);\n";
|
2015-11-25 08:10:49 +01:00
|
|
|
echo " $('#target_file').fadeOut(fade_speed);\n";
|
2016-03-14 17:14:27 +01:00
|
|
|
echo " $('#button_back').fadeOut(fade_speed, function() {\n";
|
|
|
|
|
echo " $('#button_files').fadeIn(fade_speed)\n";
|
|
|
|
|
echo " $('#button_back_location').fadeIn(fade_speed);\n";
|
|
|
|
|
echo " });";
|
|
|
|
|
echo " document.getElementById('target_file').selectedIndex = 0;\n";
|
2015-11-25 08:10:49 +01:00
|
|
|
echo " }\n";
|
|
|
|
|
|
|
|
|
|
echo " function download(d) {\n";
|
|
|
|
|
echo " if (d == '".$text['label-download']."') return;\n";
|
2015-12-03 18:29:33 +01:00
|
|
|
if ($_SESSION['provision']['http_domain_filter']['text'] == "false") {
|
|
|
|
|
$domain_name = $_SERVER["HTTP_HOST"];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$domain_name = $_SESSION['domain_name'];
|
|
|
|
|
}
|
2016-01-16 17:44:15 +01:00
|
|
|
|
|
|
|
|
if (!isset($_SERVER['HTTP_PROTOCOL'])) {
|
|
|
|
|
$_SERVER['HTTP_PROTOCOL'] = 'http';
|
|
|
|
|
if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; }
|
2016-01-20 14:44:36 +01:00
|
|
|
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
|
|
|
|
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
|
2016-01-16 17:44:15 +01:00
|
|
|
}
|
2017-06-09 00:21:47 +02:00
|
|
|
echo " window.location = '".$_SERVER['HTTP_PROTOCOL']."://".$domain_name.PROJECT_PATH."/app/provision/index.php?mac=".$device_mac_address."&file=' + d + '&content_type=application/octet-stream';\n";
|
2015-11-25 08:10:49 +01:00
|
|
|
echo " }\n";
|
|
|
|
|
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo " $( document ).ready(function() {\n";
|
|
|
|
|
echo " $('#default_setting_search').focus();\n";
|
|
|
|
|
if ($search == '') {
|
|
|
|
|
echo " // scroll to previous category\n";
|
|
|
|
|
echo " var category_span_id;\n";
|
|
|
|
|
echo " var url = document.location.href;\n";
|
|
|
|
|
echo " var hashindex = url.indexOf('#');\n";
|
|
|
|
|
echo " if (hashindex == -1) { }\n";
|
|
|
|
|
echo " else {\n";
|
|
|
|
|
echo " category_span_id = url.substr(hashindex + 1);\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo " if (category_span_id) {\n";
|
|
|
|
|
echo " $('#page').animate({scrollTop: $('#anchor_'+category_span_id).offset().top - 200}, 'slow');\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
}
|
|
|
|
|
echo " });\n";
|
|
|
|
|
echo "</script>";
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 10:18:12 +02:00
|
|
|
//show the content
|
2016-02-26 02:19:51 +01:00
|
|
|
echo "<form name='frm' id='frm' method='post' action=''>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo "<input type='hidden' name='file_action' id='file_action' value='' />\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "<td align='left' nowrap='nowrap' valign='top'>";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <b>".$text['header-device']."</b>";
|
|
|
|
|
echo "</td>\n";
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "<td align='right' valign='top'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='button' class='btn' id='button_back_location' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'/>\n";
|
2017-12-08 22:32:03 +01:00
|
|
|
echo " <input type='button' class='btn' value='".$text['button-provision']."' onclick=\"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_vendor."';\"> \n";
|
2015-11-25 08:10:49 +01:00
|
|
|
if (permission_exists("device_files")) {
|
|
|
|
|
//get the template directory
|
|
|
|
|
$prov = new provision;
|
|
|
|
|
$prov->domain_uuid = $domain_uuid;
|
|
|
|
|
$template_dir = $prov->template_dir;
|
|
|
|
|
$files = glob($template_dir.'/'.$device_template.'/*');
|
|
|
|
|
//add file buttons and the file list
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='button' class='btn' id='button_files' name='' alt='".$text['button-files']."' onclick='show_files();' value='".$text['button-files']."'/>";
|
|
|
|
|
echo " <input type='button' class='btn' style='display: none;' id='button_back' name='' alt='".$text['button-back']."' onclick='hide_files();' value='".$text['button-back']."'/> ";
|
2015-11-25 08:10:49 +01:00
|
|
|
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";
|
|
|
|
|
foreach ($files as $file) {
|
2016-02-26 02:19:51 +01:00
|
|
|
//format the mac address and
|
2016-01-09 19:22:10 +01:00
|
|
|
$format = new provision();
|
|
|
|
|
$mac = $format->format_mac($device_mac_address, $device_vendor);
|
2015-11-25 08:10:49 +01:00
|
|
|
//render the file name
|
2016-01-09 19:22:10 +01:00
|
|
|
$file_name = str_replace("{\$mac}", $mac, basename($file));
|
2015-11-25 08:10:49 +01:00
|
|
|
//add the select option
|
|
|
|
|
echo " <option value='".basename($file)."'>".$file_name."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
//echo " <input type='button' class='btn' id='button_download' style='display: none;' alt='".$text['button-download']."' value='".$text['button-download']."' onclick='document.forms.frm.submit();'>";
|
|
|
|
|
}
|
2016-06-18 01:34:31 +02:00
|
|
|
|
2015-11-05 20:11:53 +01:00
|
|
|
if (permission_exists('device_add') && $action != "add") {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"var new_mac = prompt('".$text['message_device']."'); if (new_mac != null) { window.location='device_copy.php?id=".$device_uuid."&mac=' + new_mac; }\" value='".$text['button-copy']."'/>\n";
|
2014-02-23 10:33:27 +01:00
|
|
|
}
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'/>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td colspan='2'>\n";
|
|
|
|
|
echo " ".$text['description-device'];
|
|
|
|
|
echo " <br><br>";
|
2014-01-12 07:38:28 +01:00
|
|
|
echo "</td>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</tr>\n";
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "</table>\n";
|
2013-05-23 10:18:12 +02:00
|
|
|
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "<tr>\n";
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "<td class='vncell' width='30%' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " ".$text['label-device_mac_address']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
2016-03-25 23:29:20 +01:00
|
|
|
echo "<td class='vtable' width='70%' align='left'>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_mac_address')) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"$device_mac_address\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_mac_address']."\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo $device_mac_address;
|
|
|
|
|
}
|
2014-08-02 04:16:46 +02:00
|
|
|
echo " <div style='display: none;' id='duplicate_mac_response'></div>\n";
|
2017-06-09 00:21:47 +02:00
|
|
|
echo " ".$device_provisioned_ip."(<a href='http://".$device_provisioned_ip."' target='_blank'>http</a>|<a href='https://".$device_provisioned_ip."' target='_blank'>https</a>)\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
2013-05-23 10:18:12 +02:00
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " ".$text['label-device_label']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_label')) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_label' maxlength='255' value=\"$device_label\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_label']."\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo $device_label;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_template')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device_template']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
|
|
$device = new device;
|
|
|
|
|
$template_dir = $device->get_template_dir();
|
|
|
|
|
|
|
|
|
|
echo "<select id='device_template' name='device_template' class='formfld'>\n";
|
2017-09-01 17:36:06 +02:00
|
|
|
echo "<option value=''></option>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
|
|
|
|
|
if (is_dir($template_dir)) {
|
|
|
|
|
$templates = scandir($template_dir);
|
|
|
|
|
foreach($templates as $dir) {
|
|
|
|
|
if($file != "." && $dir != ".." && $dir[0] != '.') {
|
|
|
|
|
if(is_dir($template_dir . "/" . $dir)) {
|
|
|
|
|
echo "<optgroup label='$dir'>";
|
|
|
|
|
$dh_sub=$template_dir . "/" . $dir;
|
|
|
|
|
if(is_dir($dh_sub)) {
|
|
|
|
|
$templates_sub = scandir($dh_sub);
|
|
|
|
|
foreach($templates_sub as $dir_sub) {
|
2018-02-25 09:58:17 +01:00
|
|
|
if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.' && $dir_sub[0] != 'include') {
|
2015-11-05 19:56:50 +01:00
|
|
|
if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) {
|
|
|
|
|
if ($device_template == $dir."/".$dir_sub) {
|
2017-09-01 17:36:06 +02:00
|
|
|
echo "<option value='".$dir."/".$dir_sub."' selected='selected'>".$dir."/".$dir_sub."</option>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2017-09-01 17:36:06 +02:00
|
|
|
echo "<option value='".$dir."/".$dir_sub."'>".$dir."/".$dir_sub."</option>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
}
|
2015-10-16 15:04:31 +02:00
|
|
|
}
|
2013-06-09 22:46:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-05 19:56:50 +01:00
|
|
|
echo "</optgroup>";
|
2013-06-09 22:46:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-05 19:56:50 +01:00
|
|
|
echo "</select>\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_template']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
2013-06-09 22:46:14 +02:00
|
|
|
|
2015-11-05 19:24:28 +01:00
|
|
|
if (permission_exists('device_line_view')) {
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <tr>";
|
|
|
|
|
echo " <td class='vncell' valign='top'>".$text['label-lines']."</td>";
|
|
|
|
|
echo " <td class='vtable' align='left'>";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <table width='80%' border='0'>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <tr>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <td class='vtable'>".$text['label-line']."</td>\n";
|
|
|
|
|
if (permission_exists('device_line_server_address')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-server_address']."</td>\n";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('device_outbound_proxy_primary')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-outbound_proxy_primary']."</td>\n";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('device_outbound_proxy_secondary')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-outbound_proxy_secondary']."</td>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " <td class='vtable'>".$text['label-display_name']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-user_id']."</td>\n";
|
|
|
|
|
if (permission_exists('device_line_auth_id')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-auth_id']."</td>\n";
|
|
|
|
|
}
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_line_password')) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <td class='vtable'>".$text['label-password']."</td>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " <td class='vtable'>".$text['label-sip_port']."</td>\n";
|
|
|
|
|
if (permission_exists('device_line_transport')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-sip_transport']."</td>\n";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('device_line_register_expires')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-register_expires']."</td>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
}
|
2018-02-04 03:01:48 +01:00
|
|
|
if (permission_exists('device_line_shared')) {
|
2018-01-23 06:41:55 +01:00
|
|
|
echo " <td class='vtable'>".$text['label-shared_line']."</td>\n";
|
|
|
|
|
}
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <td class='vtable'>".$text['label-enabled']."</td>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <td> </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
$x = 0;
|
|
|
|
|
foreach($device_lines as $row) {
|
2016-07-27 05:00:05 +02:00
|
|
|
|
|
|
|
|
//set the defaults
|
|
|
|
|
if (!permission_exists('device_line_server_address')) {
|
|
|
|
|
if (strlen($row['server_address']) == 0) { $row['server_address'] = $_SESSION['domain_name']; }
|
|
|
|
|
}
|
|
|
|
|
if (strlen($row['sip_transport']) == 0) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; }
|
|
|
|
|
if (strlen($row['sip_port']) == 0) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; }
|
|
|
|
|
if (strlen($row['register_expires']) == 0) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; }
|
|
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
//determine whether to hide the element
|
|
|
|
|
if (strlen($device_line_uuid) == 0) {
|
|
|
|
|
$element['hidden'] = false;
|
|
|
|
|
$element['visibility'] = "visibility:visible;";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$element['hidden'] = true;
|
|
|
|
|
$element['visibility'] = "visibility:hidden;";
|
|
|
|
|
}
|
|
|
|
|
//add the primary key uuid
|
|
|
|
|
if (strlen($row['device_line_uuid']) > 0) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input name='device_lines[".$x."][device_line_uuid]' type='hidden' value=\"".$row['device_line_uuid']."\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
}
|
|
|
|
|
//show each row in the array
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
$selected = "selected=\"selected\" ";
|
|
|
|
|
echo " <select class='formfld' style='width: 45px;' name='device_lines[".$x."][line_number]'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
echo " <option value='1' ".($row['line_number'] == "1" ? $selected:"").">1</option>\n";
|
|
|
|
|
echo " <option value='2' ".($row['line_number'] == "2" ? $selected:"").">2</option>\n";
|
|
|
|
|
echo " <option value='3' ".($row['line_number'] == "3" ? $selected:"").">3</option>\n";
|
|
|
|
|
echo " <option value='4' ".($row['line_number'] == "4" ? $selected:"").">4</option>\n";
|
|
|
|
|
echo " <option value='5' ".($row['line_number'] == "5" ? $selected:"").">5</option>\n";
|
|
|
|
|
echo " <option value='6' ".($row['line_number'] == "6" ? $selected:"").">6</option>\n";
|
|
|
|
|
echo " <option value='7' ".($row['line_number'] == "7" ? $selected:"").">7</option>\n";
|
|
|
|
|
echo " <option value='8' ".($row['line_number'] == "8" ? $selected:"").">8</option>\n";
|
|
|
|
|
echo " <option value='9' ".($row['line_number'] == "9" ? $selected:"").">9</option>\n";
|
|
|
|
|
echo " <option value='10' ".($row['line_number'] == "10" ? $selected:"").">10</option>\n";
|
|
|
|
|
echo " <option value='11' ".($row['line_number'] == "11" ? $selected:"").">11</option>\n";
|
|
|
|
|
echo " <option value='12' ".($row['line_number'] == "12" ? $selected:"").">12</option>\n";
|
2017-12-14 06:57:41 +01:00
|
|
|
echo " <option value='13' ".($row['line_number'] == "13" ? $selected:"").">13</option>\n";
|
|
|
|
|
echo " <option value='14' ".($row['line_number'] == "14" ? $selected:"").">14</option>\n";
|
|
|
|
|
echo " <option value='15' ".($row['line_number'] == "15" ? $selected:"").">15</option>\n";
|
|
|
|
|
echo " <option value='16' ".($row['line_number'] == "16" ? $selected:"").">16</option>\n";
|
|
|
|
|
echo " <option value='17' ".($row['line_number'] == "17" ? $selected:"").">17</option>\n";
|
|
|
|
|
echo " <option value='18' ".($row['line_number'] == "18" ? $selected:"").">18</option>\n";
|
|
|
|
|
echo " <option value='19' ".($row['line_number'] == "19" ? $selected:"").">19</option>\n";
|
|
|
|
|
echo " <option value='20' ".($row['line_number'] == "20" ? $selected:"").">20</option>\n";
|
|
|
|
|
echo " <option value='21' ".($row['line_number'] == "21" ? $selected:"").">21</option>\n";
|
|
|
|
|
echo " <option value='22' ".($row['line_number'] == "22" ? $selected:"").">22</option>\n";
|
|
|
|
|
echo " <option value='23' ".($row['line_number'] == "23" ? $selected:"").">23</option>\n";
|
|
|
|
|
echo " <option value='24' ".($row['line_number'] == "24" ? $selected:"").">24</option>\n";
|
|
|
|
|
echo " <option value='25' ".($row['line_number'] == "25" ? $selected:"").">25</option>\n";
|
|
|
|
|
echo " <option value='26' ".($row['line_number'] == "26" ? $selected:"").">26</option>\n";
|
|
|
|
|
echo " <option value='27' ".($row['line_number'] == "27" ? $selected:"").">27</option>\n";
|
|
|
|
|
echo " <option value='28' ".($row['line_number'] == "28" ? $selected:"").">28</option>\n";
|
|
|
|
|
echo " <option value='29' ".($row['line_number'] == "29" ? $selected:"").">29</option>\n";
|
|
|
|
|
echo " <option value='30' ".($row['line_number'] == "30" ? $selected:"").">30</option>\n";
|
|
|
|
|
echo " <option value='31' ".($row['line_number'] == "31" ? $selected:"").">31</option>\n";
|
|
|
|
|
echo " <option value='32' ".($row['line_number'] == "32" ? $selected:"").">32</option>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </select>\n";
|
|
|
|
|
echo " </td>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_line_server_address')) {
|
|
|
|
|
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][server_address]' maxlength='255' value=\"".$row['server_address']."\"/>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input type='hidden' name='device_lines[".$x."][server_address]' value=\"".$row['server_address']."\"/>\n";
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_outbound_proxy_primary')) {
|
|
|
|
|
if (permission_exists('device_outbound_proxy_secondary')) {
|
|
|
|
|
$placeholder_label = $text['label-primary'];
|
|
|
|
|
}
|
|
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' style='width: 65px;' type='text' name='device_lines[".$x."][outbound_proxy_primary]' placeholder=\"".$placeholder_label."\" maxlength='255' value=\"".$row['outbound_proxy_primary']."\"/>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
unset($placeholder_label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (permission_exists('device_outbound_proxy_secondary')) {
|
|
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' style='width: 65px;' type='text' name='device_lines[".$x."][outbound_proxy_secondary]' placeholder=\"".$text['label-secondary']."\" maxlength='255' value=\"".$row['outbound_proxy_secondary']."\"/>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][display_name]' maxlength='255' value=\"".$row['display_name']."\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </td>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <td align='left'>\n";
|
2018-02-10 20:03:33 +01:00
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][user_id]' maxlength='255' autocomplete=\"off\" value=\"".$row['user_id']."\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </td>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_line_auth_id')) {
|
|
|
|
|
echo " <td align='left'>\n";
|
2018-02-10 20:03:33 +01:00
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][auth_id]' maxlength='255' autocomplete=\"off\" value=\"".$row['auth_id']."\"/>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_line_password')) {
|
|
|
|
|
echo " <td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' style='width:75px;' type='password' name='device_lines[".$x."][password]' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete=\"off\" maxlength='255' value=\"".$row['password']."\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
2014-04-27 11:53:45 +02:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][sip_port]' maxlength='255' value=\"".$row['sip_port']."\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </td>\n";
|
2014-04-27 11:53:45 +02:00
|
|
|
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_line_transport')) {
|
|
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <select class='formfld' style='width: 50px;' name='device_lines[".$x."][sip_transport]'>\n";
|
|
|
|
|
echo " <option value='tcp' ".(($row['sip_transport'] == 'tcp') ? "selected" : null).">TCP</option>\n";
|
|
|
|
|
echo " <option value='udp' ".(($row['sip_transport'] == 'udp') ? "selected" : null).">UDP</option>\n";
|
|
|
|
|
echo " <option value='tls' ".(($row['sip_transport'] == 'tls') ? "selected" : null).">TLS</option>\n";
|
|
|
|
|
echo " <option value='dns srv' ".(($row['sip_transport'] == 'dns srv') ? "selected" : null).">DNS SRV</option>\n";
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input type='hidden' name='device_lines[".$x."][sip_transport]' value=\"".$row['sip_transport']."\" />\n";
|
|
|
|
|
}
|
2014-04-27 11:53:45 +02:00
|
|
|
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_line_register_expires')) {
|
|
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][register_expires]' maxlength='255' value=\"".$row['register_expires']."\"/>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input type='hidden' name='device_lines[".$x."][register_expires]' value=\"".$row['register_expires']."\"/>\n";
|
|
|
|
|
}
|
2015-05-19 18:09:04 +02:00
|
|
|
|
2018-02-04 03:01:48 +01:00
|
|
|
if (permission_exists('device_line_shared')) {
|
2018-01-23 06:41:55 +01:00
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[".$x."][shared_line]' maxlength='255' value=\"".$row['shared_line']."\"/>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input type='hidden' name='device_lines[".$x."][shared_line]' value=\"".$row['shared_line']."\"/>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <td align='left'>\n";
|
|
|
|
|
echo " <select class='formfld' name='device_lines[".$x."][enabled]'>\n";
|
|
|
|
|
echo " <option value='true' ".(($row['enabled'] == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n";
|
|
|
|
|
echo " <option value='false' ".(($row['enabled'] == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
|
|
|
|
|
echo " <td>\n";
|
|
|
|
|
if (strlen($row['device_line_uuid']) > 0) {
|
|
|
|
|
if (permission_exists('device_delete')) {
|
|
|
|
|
echo " <a href='device_line_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_line_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
|
|
|
|
}
|
2014-01-20 19:00:45 +01:00
|
|
|
}
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
$x++;
|
2013-06-09 23:06:12 +02:00
|
|
|
}
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </table>\n";
|
|
|
|
|
if (strlen($text['description-lines']) > 0) {
|
|
|
|
|
echo " <br>".$text['description-lines']."\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </td>";
|
|
|
|
|
echo " </tr>";
|
2013-11-26 11:14:38 +01:00
|
|
|
}
|
2013-12-17 17:19:54 +01:00
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_profile_edit')) {
|
2015-02-15 01:33:56 +01:00
|
|
|
//device profile
|
|
|
|
|
$sql = "select * from v_device_profiles ";
|
|
|
|
|
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
|
|
|
|
|
$sql .= "order by device_profile_name asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
$result_count = count($result);
|
|
|
|
|
unset ($prep_statement, $sql);
|
|
|
|
|
if ($result_count > 0) {
|
|
|
|
|
echo " <tr>";
|
|
|
|
|
echo " <td class='vncell' valign='top'>".$text['label-profile']."</td>";
|
|
|
|
|
echo " <td class='vtable' align='left'>";
|
2016-08-15 17:32:01 +02:00
|
|
|
echo " <select class='formfld' id='device_profile_uuid' name='device_profile_uuid'>\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
foreach($result as $row) {
|
|
|
|
|
echo " <option value='".$row['device_profile_uuid']."' ".(($row['device_profile_uuid'] == $device_profile_uuid) ? "selected='selected'" : null).">".$row['device_profile_name']." ".(($row['domain_uuid'] == '') ? " (".$text['select-global'].")" : null)."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
2016-08-15 19:27:35 +02:00
|
|
|
echo " <button type='button' class='btn btn-default list_control_icon' id='device_profile_edit' onclick=\"if($('#device_profile_uuid').val() != '') window.location='device_profile_edit.php?id='+$('#device_profile_uuid').val();\"><span class='glyphicon glyphicon-pencil'></span></button>";
|
2016-08-15 17:32:01 +02:00
|
|
|
echo " <button type='button' class='btn btn-default list_control_icon' onclick=\"window.location='device_profile_edit.php'\"><span class='glyphicon glyphicon-plus'></span></button>";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <br>".$text['description-profile2']."\n";
|
|
|
|
|
echo " </td>";
|
|
|
|
|
echo " </tr>";
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
2015-02-15 01:33:56 +01:00
|
|
|
|
2015-11-05 20:05:49 +01:00
|
|
|
if (permission_exists('device_key_edit')) {
|
2015-07-08 06:41:24 +02:00
|
|
|
$vendor_count = 0;
|
|
|
|
|
foreach($device_keys as $row) {
|
|
|
|
|
if ($previous_vendor != $row['device_key_vendor']) {
|
|
|
|
|
$previous_vendor = $row['device_key_vendor'];
|
|
|
|
|
$vendor_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 21:52:38 +01:00
|
|
|
echo " <tr>";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <td class='vncell' valign='top'>".$text['label-keys']."</td>";
|
2013-12-27 21:52:38 +01:00
|
|
|
echo " <td class='vtable' align='left'>";
|
2015-05-19 18:09:04 +02:00
|
|
|
echo " <table border='0' cellpadding='0' cellspacing='3'>\n";
|
2015-07-08 06:41:24 +02:00
|
|
|
if ($vendor_count == 0) {
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_category']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_id']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_type']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_line']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_value']."</td>\n";
|
2016-09-11 00:27:57 +02:00
|
|
|
if (permission_exists('device_key_extension')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_extension']."</td>\n";
|
|
|
|
|
}
|
2015-07-08 06:41:24 +02:00
|
|
|
echo " <td class='vtable'>".$text['label-device_key_label']."</td>\n";
|
|
|
|
|
echo " <td> </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
}
|
2014-01-20 10:34:04 +01:00
|
|
|
|
2015-11-05 20:05:49 +01:00
|
|
|
$x = 0;
|
|
|
|
|
foreach($device_keys as $row) {
|
|
|
|
|
//set the column names
|
|
|
|
|
if ($previous_device_key_vendor != $row['device_key_vendor']) {
|
2015-07-08 06:41:24 +02:00
|
|
|
echo " <tr>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo " <td class='vtable'>".$text['label-device_key_category']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_id']."</td>\n";
|
|
|
|
|
if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) {
|
|
|
|
|
echo " <td class='vtable'>".ucwords($row['device_key_vendor'])."</td>\n";
|
|
|
|
|
} else {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_type']."</td>\n";
|
2015-07-08 06:41:24 +02:00
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
echo " <td class='vtable'>".$text['label-device_key_line']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_value']."</td>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_key_extension')) {
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_key_extension']."</td>\n";
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
echo " <td class='vtable'>".$text['label-device_key_label']."</td>\n";
|
|
|
|
|
echo " <td> </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
}
|
|
|
|
|
//determine whether to hide the element
|
|
|
|
|
if (strlen($device_key_uuid) == 0) {
|
|
|
|
|
$element['hidden'] = false;
|
|
|
|
|
$element['visibility'] = "visibility:visible;";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$element['hidden'] = true;
|
|
|
|
|
$element['visibility'] = "visibility:hidden;";
|
|
|
|
|
}
|
|
|
|
|
//add the primary key uuid
|
|
|
|
|
if (strlen($row['device_key_uuid']) > 0) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input name='device_keys[".$x."][device_key_uuid]' type='hidden' value=\"".$row['device_key_uuid']."\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
//show all the rows in the array
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo "<td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " <select class='formfld' name='device_keys[".$x."][device_key_category]'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
if ($row['device_key_category'] == "line") {
|
|
|
|
|
echo " <option value='line' selected='selected'>".$text['label-line']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='line'>".$text['label-line']."</option>\n";
|
|
|
|
|
}
|
2017-10-15 00:35:16 +02:00
|
|
|
if ($row['device_key_vendor'] !== "polycom") {
|
|
|
|
|
if ($row['device_key_category'] == "memory") {
|
|
|
|
|
echo " <option value='memory' selected='selected'>".$text['label-memory']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='memory'>".$text['label-memory']."</option>\n";
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
if ($row['device_key_category'] == "programmable") {
|
|
|
|
|
echo " <option value='programmable' selected='selected'>".$text['label-programmable']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='programmable'>".$text['label-programmable']."</option>\n";
|
|
|
|
|
}
|
2017-10-15 00:35:16 +02:00
|
|
|
if ($row['device_key_vendor'] !== "polycom") {
|
|
|
|
|
if (strlen($device_vendor) == 0) {
|
|
|
|
|
if ($row['device_key_category'] == "expansion") {
|
|
|
|
|
echo " <option value='expansion' selected='selected'>".$text['label-expansion']."</option>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2017-10-15 00:35:16 +02:00
|
|
|
echo " <option value='expansion'>".$text['label-expansion']."</option>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
if ($row['device_key_category'] == "expansion-2") {
|
|
|
|
|
echo " <option value='expansion-2' selected='selected'>".$text['label-expansion']." 2</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='expansion-2'>".$text['label-expansion']." 2</option>\n";
|
|
|
|
|
}
|
2014-07-20 02:49:27 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2017-10-15 00:35:16 +02:00
|
|
|
if (strtolower($device_vendor) == "cisco" or strtolower($row['device_key_vendor']) == "yealink") {
|
|
|
|
|
if ($row['device_key_category'] == "expansion-1" || $row['device_key_category'] == "expansion") {
|
|
|
|
|
echo " <option value='expansion-1' selected='selected'>".$text['label-expansion']." 1</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='expansion-1'>".$text['label-expansion']." 1</option>\n";
|
|
|
|
|
}
|
|
|
|
|
if ($row['device_key_category'] == "expansion-2") {
|
|
|
|
|
echo " <option value='expansion-2' selected='selected'>".$text['label-expansion']." 2</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='expansion-2'>".$text['label-expansion']." 2</option>\n";
|
|
|
|
|
}
|
2014-07-20 02:49:27 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2017-10-15 00:35:16 +02:00
|
|
|
if ($row['device_key_category'] == "expansion") {
|
|
|
|
|
echo " <option value='expansion' selected='selected'>".$text['label-expansion']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='expansion'>".$text['label-expansion']."</option>\n";
|
|
|
|
|
}
|
2014-07-20 02:49:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "</td>\n";
|
2015-08-17 16:27:37 +02:00
|
|
|
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "<td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
$selected = "selected='selected'";
|
|
|
|
|
echo " <select class='formfld' name='device_keys[".$x."][device_key_id]'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
2016-08-13 16:55:54 +02:00
|
|
|
for ($i = 1; $i <= 255; $i++) {
|
|
|
|
|
echo " <option value='$i' ".($row['device_key_id'] == $i ? "selected":null).">$i</option>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
|
|
|
|
|
echo "<td align='left' nowrap='nowrap'>\n";
|
|
|
|
|
//echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_type]' style='width: 120px;' maxlength='255' value=\"$row['device_key_type']\">\n";
|
|
|
|
|
if (strlen($row['device_key_vendor']) > 0) {
|
|
|
|
|
$device_key_vendor = $row['device_key_vendor'];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$device_key_vendor = $device_vendor;
|
|
|
|
|
}
|
|
|
|
|
?>
|
2016-07-27 05:00:05 +02:00
|
|
|
<input class='formfld' type='hidden' id='key_vendor_<?php echo $x; ?>' name='device_keys[<?php echo $x; ?>][device_key_vendor]' value="<?php echo $device_key_vendor; ?>"/>
|
2015-11-05 20:05:49 +01:00
|
|
|
<?php
|
2016-08-03 03:44:07 +02:00
|
|
|
echo "<select class='formfld' name='device_keys[".$x."][device_key_type]' id='key_type_".$x."'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
$previous_vendor = '';
|
|
|
|
|
$i=0;
|
|
|
|
|
foreach ($vendor_functions as $function) {
|
|
|
|
|
if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) {
|
|
|
|
|
if ($i > 0) { echo " </optgroup>\n"; }
|
|
|
|
|
echo " <optgroup label='".ucwords($function['vendor_name'])."'>\n";
|
|
|
|
|
}
|
|
|
|
|
$selected = '';
|
2017-02-24 08:19:28 +01:00
|
|
|
if (strtolower($row['device_key_vendor']) == $function['vendor_name'] && $row['device_key_type'] == $function['value']) {
|
2016-08-03 03:44:07 +02:00
|
|
|
$selected = "selected='selected'";
|
|
|
|
|
}
|
|
|
|
|
if (strlen($row['device_key_vendor']) == 0) {
|
|
|
|
|
echo " <option value='".$function['value']."' vendor='".$function['vendor_name']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
|
|
|
|
}
|
2017-02-24 08:19:28 +01:00
|
|
|
if (strlen($row['device_key_vendor']) > 0 && strtolower($row['device_key_vendor']) == $function['vendor_name']) {
|
2016-08-03 03:44:07 +02:00
|
|
|
echo " <option value='".$function['value']."' vendor='".$function['vendor_name']."' $selected >".$text['label-'.$function['name']]."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
$previous_vendor = $function['vendor_name'];
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
if (strlen($row['device_key_vendor']) == 0) {
|
|
|
|
|
echo " </optgroup>\n";
|
|
|
|
|
}
|
|
|
|
|
echo "</select>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " <select class='formfld' name='device_keys[".$x."][device_key_line]'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
for ($l = 0; $l <= 12; $l++) {
|
|
|
|
|
echo " <option value='".$l."' ".(($row['device_key_line'] == $l) ? "selected='selected'" : null).">".$l."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
|
|
|
|
|
echo "<td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_value]' style='width: 120px;' maxlength='255' value=\"".$row['device_key_value']."\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2016-07-27 05:00:05 +02:00
|
|
|
if (permission_exists('device_key_extension')) {
|
|
|
|
|
echo "<td align='left'>\n";
|
|
|
|
|
echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_extension]' style='width: 75px;' maxlength='255' value=\"".$row['device_key_extension']."\"/>\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
|
|
|
|
|
echo "<td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_keys[".$x."][device_key_label]' style='width: 75px;' maxlength='255' value=\"".$row['device_key_label']."\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
|
|
|
|
|
//echo " <td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
//echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
//echo " </td>\n";
|
|
|
|
|
echo " <td nowrap='nowrap'>\n";
|
|
|
|
|
if (strlen($row['device_key_uuid']) > 0) {
|
|
|
|
|
if (permission_exists('device_key_delete')) {
|
|
|
|
|
echo " <a href='device_key_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_key_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
//set the previous vendor
|
|
|
|
|
$previous_device_key_vendor = $row['device_key_vendor'];
|
|
|
|
|
//increment the array key
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
if (strlen($text['description-keys']) > 0) {
|
|
|
|
|
echo " <br>".$text['description-keys']."\n";
|
2013-12-27 21:52:38 +01:00
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
echo " </td>";
|
|
|
|
|
echo " </tr>";
|
2013-12-17 17:19:54 +01:00
|
|
|
}
|
2013-06-09 22:46:14 +02:00
|
|
|
|
2014-01-20 10:34:04 +01:00
|
|
|
//device settings
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_setting_edit')) {
|
2013-12-27 21:52:38 +01:00
|
|
|
echo " <tr>";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <td class='vncell' valign='top'>".$text['label-settings']."</td>";
|
2013-12-27 21:52:38 +01:00
|
|
|
echo " <td class='vtable' align='left'>";
|
2015-05-19 18:09:04 +02:00
|
|
|
echo " <table border='0' cellpadding='0' cellspacing='3'>\n";
|
2013-12-10 16:05:16 +01:00
|
|
|
echo " <tr>\n";
|
2013-12-27 21:52:38 +01:00
|
|
|
echo " <td class='vtable'>".$text['label-device_setting_name']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_setting_value']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-enabled']."</td>\n";
|
|
|
|
|
echo " <td class='vtable'>".$text['label-device_setting_description']."</td>\n";
|
|
|
|
|
echo " <td> </td>\n";
|
2013-12-10 16:05:16 +01:00
|
|
|
echo " </tr>\n";
|
2014-01-20 10:34:04 +01:00
|
|
|
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach($device_settings as $row) {
|
2014-01-20 19:00:45 +01:00
|
|
|
//determine whether to hide the element
|
|
|
|
|
if (strlen($device_setting_uuid) == 0) {
|
|
|
|
|
$element['hidden'] = false;
|
|
|
|
|
$element['visibility'] = "visibility:visible;";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$element['hidden'] = true;
|
|
|
|
|
$element['visibility'] = "visibility:hidden;";
|
|
|
|
|
}
|
|
|
|
|
//add the primary key uuid
|
|
|
|
|
if (strlen($row['device_setting_uuid']) > 0) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input name='device_settings[".$x."][device_setting_uuid]' type='hidden' value=\"".$row['device_setting_uuid']."\"/>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
}
|
2013-12-10 16:05:16 +01:00
|
|
|
|
2014-01-20 19:00:45 +01:00
|
|
|
//show alls rows in the array
|
|
|
|
|
echo "<tr>\n";
|
2015-05-19 18:09:04 +02:00
|
|
|
echo "<td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_subcategory]' style='width: 120px;' maxlength='255' value=\"".$row['device_setting_subcategory']."\"/>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2015-05-19 18:09:04 +02:00
|
|
|
echo "<td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_value]' style='width: 120px;' maxlength='255' value=\"".$row['device_setting_value']."\"/>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
|
2015-05-19 18:09:04 +02:00
|
|
|
echo "<td align='left'>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
echo " <select class='formfld' name='device_settings[".$x."][device_setting_enabled]' style='width: 90px;'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
if ($row['device_setting_enabled'] == "true") {
|
|
|
|
|
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='true'>".$text['label-true']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
if ($row['device_setting_enabled'] == "false") {
|
|
|
|
|
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='false'>".$text['label-false']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "</td>\n";
|
2013-12-10 16:05:16 +01:00
|
|
|
|
2015-05-19 18:09:04 +02:00
|
|
|
echo "<td align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_description]' style='width: 150px;' maxlength='255' value=\"".$row['device_setting_description']."\"/>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
echo "</td>\n";
|
2013-12-10 16:05:16 +01:00
|
|
|
|
2014-01-20 19:00:45 +01:00
|
|
|
if (strlen($text['description-settings']) > 0) {
|
|
|
|
|
echo " <br>".$text['description-settings']."\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </td>";
|
|
|
|
|
|
|
|
|
|
echo " <td>\n";
|
|
|
|
|
if (strlen($row['device_setting_uuid']) > 0) {
|
|
|
|
|
if (permission_exists('device_edit')) {
|
|
|
|
|
echo " <a href='device_setting_edit.php?device_uuid=".$row['device_uuid']."&id=".$row['device_setting_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('device_delete')) {
|
|
|
|
|
echo " <a href='device_setting_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_setting_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
/*
|
2015-05-19 18:09:04 +02:00
|
|
|
echo " <td align='left'>\n";
|
2016-02-26 02:19:51 +01:00
|
|
|
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
|
2014-01-20 19:00:45 +01:00
|
|
|
*/
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
2013-12-10 16:05:16 +01:00
|
|
|
}
|
|
|
|
|
|
2016-06-10 19:02:17 +02:00
|
|
|
if (permission_exists('device_user')) {
|
2016-05-20 18:39:16 +02:00
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2016-05-27 06:00:33 +02:00
|
|
|
echo " ".$text['label-user']."\n";
|
2016-05-20 18:39:16 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-06-18 01:45:42 +02:00
|
|
|
echo " <select name=\"device_user_uuid\" class='formfld' style='width: auto;'>\n";
|
2016-05-20 18:39:16 +02:00
|
|
|
echo " <option value=\"\"></option>\n";
|
|
|
|
|
foreach($users as $field) {
|
2016-06-21 16:05:44 +02:00
|
|
|
if ($field['user_uuid'] == $device_user_uuid) { $selected = "selected='selected'"; } else { $selected = ''; }
|
|
|
|
|
echo " <option value='".$field['user_uuid']."' $selected>".$field['username']."</option>\n";
|
2016-05-20 18:39:16 +02:00
|
|
|
}
|
|
|
|
|
echo " </select>";
|
|
|
|
|
unset($users);
|
|
|
|
|
echo " <br>\n";
|
2016-05-27 06:00:33 +02:00
|
|
|
echo " ".$text['description-user']."\n";
|
2016-05-20 18:39:16 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_username_password')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_username' id='device_username' autocomplete=\"off\" maxlength='255' placeholder=\"".$text['label-device_username']."\" value=\"$device_username\"/>\n";
|
|
|
|
|
echo " <input class='formfld' type='password' name='device_password' id='device_password' autocomplete=\"off\" onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='255' placeholder=\"".$text['label-device_password']."\" value=\"$device_password\"/>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <div style='display: none;' id='duplicate_username_response'></div>\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2015-05-24 07:00:40 +02:00
|
|
|
}
|
2015-11-05 19:19:22 +01:00
|
|
|
|
|
|
|
|
if (permission_exists('device_alternate')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device_uuid_alternate']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
if (strlen($device_uuid_alternate) == 0) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\"/>";
|
2015-11-05 19:19:22 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$label = $device_alternate[0]['device_label'];
|
|
|
|
|
if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; }
|
|
|
|
|
if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; }
|
|
|
|
|
echo " <table>\n";
|
|
|
|
|
echo " <tr>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <td><a href='?id=$device_uuid_alternate' id='device_uuid_alternate_link'>$label</a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\" /> </td>";
|
2016-02-26 02:19:51 +01:00
|
|
|
echo " <td><a href='#' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.getElementById('device_uuid_alternate').value = ''; document.getElementById('device_uuid_alternate_link').hidden = 'true'; submit_form(); }\" alt='".$text['button-delete']."'>$v_link_label_delete</a></td>\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo " </table>\n";
|
|
|
|
|
unset($label);
|
|
|
|
|
}
|
|
|
|
|
echo $text['description-device_uuid_alternate']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2015-05-24 07:00:40 +02:00
|
|
|
}
|
2015-05-22 06:34:31 +02:00
|
|
|
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_vendor')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device_vendor']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value=\"$device_vendor\"/>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_vendor']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
2015-06-03 00:25:43 +02:00
|
|
|
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_model')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device_model']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_model' maxlength='255' value=\"$device_model\"/>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_model']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_firmware')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
|
|
echo " ".$text['label-device_firmware_version']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value=\"$device_firmware_version\"/>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_firmware_version']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-05-08 11:22:35 +02:00
|
|
|
if (permission_exists('device_domain')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " ".$text['label-domain']."\n";
|
2014-05-08 11:22:35 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2015-05-04 22:07:51 +02:00
|
|
|
echo " <select class='formfld' name='domain_uuid' id='domain_uuid'>\n";
|
2014-05-08 11:22:35 +02:00
|
|
|
if (strlen($domain_uuid) == 0) {
|
|
|
|
|
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value=''>".$text['select-global']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
foreach ($_SESSION['domains'] as $row) {
|
|
|
|
|
if ($row['domain_uuid'] == $domain_uuid) {
|
|
|
|
|
echo " <option value='".$row['domain_uuid']."' selected='selected'>".$row['domain_name']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-domain_name']."\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2017-09-21 05:09:52 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$_SESSION['domain_uuid']."\"/>\n";
|
2014-05-08 11:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-05 19:19:22 +01:00
|
|
|
if (permission_exists('device_enable')) {
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2016-03-11 19:46:02 +01:00
|
|
|
echo " ".$text['label-device_enabled']."\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2016-03-11 19:46:02 +01:00
|
|
|
echo " <select class='formfld' name='device_enabled'>\n";
|
|
|
|
|
if ($device_enabled == "true" || strlen($device_enabled) == 0) {
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='true'>".$text['label-true']."</option>\n";
|
|
|
|
|
}
|
2016-03-11 19:46:02 +01:00
|
|
|
if ($device_enabled == "false") {
|
2015-11-05 19:19:22 +01:00
|
|
|
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='false'>".$text['label-false']."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
echo "<br />\n";
|
2016-03-11 19:46:02 +01:00
|
|
|
echo $text['description-device_enabled']."\n";
|
2015-11-05 19:19:22 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
2013-05-23 10:18:12 +02:00
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " ".$text['label-device_description']."\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
if (permission_exists('device_description')) {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input class='formfld' type='text' name='device_description' maxlength='255' value=\"$device_description\"/>\n";
|
2015-11-05 20:05:49 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo $text['description-device_description']."\n";
|
2015-11-05 19:56:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo $device_description."\n";
|
|
|
|
|
}
|
2015-11-05 20:05:49 +01:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td colspan='2' align='right'>\n";
|
|
|
|
|
if ($action == "update") {
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='hidden' name='device_uuid' value='$device_uuid'/>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2015-02-15 01:33:56 +01:00
|
|
|
echo " <br>";
|
2016-07-27 05:00:05 +02:00
|
|
|
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'/>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>";
|
|
|
|
|
echo "</table>";
|
2015-02-15 10:39:23 +01:00
|
|
|
echo "<br><br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</form>";
|
|
|
|
|
|
2016-02-26 02:19:51 +01:00
|
|
|
echo "<script>\n";
|
2016-08-15 19:27:35 +02:00
|
|
|
echo " $(window).load(function(event){\n";
|
|
|
|
|
// triger initial onchage to set button state
|
|
|
|
|
echo " $('#device_profile_uuid').trigger('change')";
|
|
|
|
|
echo " });\n";
|
2016-07-27 05:00:05 +02:00
|
|
|
//capture enter key to submit form
|
2016-02-26 02:19:51 +01:00
|
|
|
echo " $(window).keypress(function(event){\n";
|
|
|
|
|
echo " if (event.which == 13) { submit_form(); }\n";
|
|
|
|
|
echo " });\n";
|
2016-08-15 19:27:35 +02:00
|
|
|
// capture device selection events
|
|
|
|
|
echo " $('#device_profile_uuid').change(function(event){ \n";
|
|
|
|
|
echo " if (this.value == '') {\$('#device_profile_edit').hide()} else {\$('#device_profile_edit').show()} \n";
|
|
|
|
|
echo " }); \n";
|
2016-07-27 05:00:05 +02:00
|
|
|
// convert password fields to
|
2016-02-26 02:19:51 +01:00
|
|
|
echo " function submit_form() {\n";
|
2017-02-21 06:12:49 +01:00
|
|
|
echo " $('form#frm').submit();\n";
|
2016-02-26 02:19:51 +01:00
|
|
|
echo " }\n";
|
|
|
|
|
echo " function submit_form_2() {\n";
|
|
|
|
|
echo " $('input:password').css('visibility','hidden');\n";
|
|
|
|
|
echo " $('input:password').attr({type:'text'});\n";
|
|
|
|
|
echo " $('form#frm').submit();\n";
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "</script>\n";
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2016-07-27 05:00:05 +02:00
|
|
|
|
2016-05-27 05:54:20 +02:00
|
|
|
?>
|