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 >
2024-09-06 19:20:03 +02:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2024
2020-02-27 18:24:32 +01:00
the Initial Developer . All Rights Reserved .
2019-12-12 17:15:55 +01:00
2012-06-04 16:58:40 +02:00
*/
2016-07-27 05:00:05 +02:00
2022-10-11 00:35:14 +02:00
//includes files
2023-06-15 19:28:23 +02:00
require_once dirname ( __DIR__ , 2 ) . " /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
2023-06-03 01:08:11 +02:00
//set the defaults
$device_model = '' ;
$device_firmware_version = '' ;
2023-07-06 22:51:02 +02:00
$device_template = '' ;
2023-06-03 01:08:11 +02:00
2024-06-23 03:28:04 +02:00
//get the domain uuid
$domain_uuid = $_SESSION [ 'domain_uuid' ] ? ? '' ;
//initialize the database object
$database = database :: new ();
//initialize the settigns object
$settings = new settings ([ 'database' => $database , 'domain_uuid' => $domain_uuid ]);
2014-01-04 00:11:42 +01:00
2012-06-04 16:58:40 +02:00
//action add or update
2023-05-24 22:52:50 +02:00
if ( ! empty ( $_REQUEST [ " id " ]) && is_uuid ( $_REQUEST [ " id " ])) {
2012-06-04 16:58:40 +02:00
$action = " update " ;
2019-08-04 04:21:56 +02:00
$device_uuid = $_REQUEST [ " id " ];
2012-06-04 16:58:40 +02:00
}
else {
$action = " add " ;
}
2024-06-23 03:28:04 +02:00
//get the total device count from the database, check the limit, if defined
2015-03-22 09:17:04 +01:00
if ( $action == 'add' ) {
2023-06-03 01:08:11 +02:00
if ( ! empty ( $_SESSION [ 'limit' ][ 'devices' ][ 'numeric' ]) && $_SESSION [ 'limit' ][ 'devices' ][ 'numeric' ]) {
2019-08-04 04:21:56 +02:00
$sql = " select count(*) from v_devices where domain_uuid = :domain_uuid " ;
$parameters [ 'domain_uuid' ] = $_SESSION [ 'domain_uuid' ];
$total_devices = $database -> select ( $sql , $parameters , 'column' );
2015-03-22 09:17:04 +01:00
if ( $total_devices >= $_SESSION [ 'limit' ][ 'devices' ][ 'numeric' ]) {
2018-08-31 05:09:01 +02:00
message :: add ( $text [ 'message-maximum_devices' ] . ' ' . $_SESSION [ 'limit' ][ 'devices' ][ 'numeric' ], 'negative' );
2015-03-22 09:17:04 +01:00
header ( 'Location: devices.php' );
2019-08-04 04:21:56 +02:00
exit ;
2015-03-22 09:17:04 +01:00
}
2019-08-04 04:21:56 +02:00
unset ( $sql , $parameters , $total_devices );
2015-03-22 09:17:04 +01:00
}
}
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 ) {
2020-02-27 18:24:32 +01:00
//process the http post data by submitted action
2023-05-24 22:52:50 +02:00
if ( ! empty ( $_POST [ 'action' ]) && is_uuid ( $_POST [ 'device_uuid' ])) {
2020-02-27 18:24:32 +01:00
$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 ;
}
2023-06-30 07:40:11 +02:00
//device device address
if ( permission_exists ( 'device_address' )) {
$device_address = $_POST [ " device_address " ];
2015-11-05 20:25:30 +01:00
}
else {
2023-07-03 16:26:19 +02:00
$sql = " select device_address from v_devices " ;
2019-08-04 04:21:56 +02:00
$sql .= " where device_uuid = :device_uuid " ;
$parameters [ 'device_uuid' ] = $device_uuid ;
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2023-06-30 07:40:11 +02:00
$device_address = $row [ " device_address " ];
2015-11-05 20:25:30 +01:00
}
2019-08-04 04:21:56 +02:00
unset ( $sql , $parameters , $row );
2015-11-05 20:25:30 +01:00
}
2013-06-09 22:46:14 +02:00
//devices
2019-09-23 17:29:06 +02:00
$domain_uuid = $_POST [ " domain_uuid " ];
2023-05-24 22:52:50 +02:00
$device_uuid = $_POST [ " device_uuid " ] ? ? null ;
2019-09-29 05:32:18 +02:00
//$device_provisioned_ip = $_POST["device_provisioned_ip"];
2019-09-23 17:29:06 +02:00
$domain_uuid = $_POST [ " domain_uuid " ];
2019-08-04 04:21:56 +02:00
$device_label = $_POST [ " device_label " ];
2019-09-23 17:29:06 +02:00
$device_label = $_POST [ " device_label " ];
$device_user_uuid = $_POST [ " device_user_uuid " ];
$device_username = $_POST [ " device_username " ];
2019-11-14 00:20:58 +01:00
$device_password = $_POST [ " device_password " ];
2019-08-04 04:21:56 +02:00
$device_vendor = $_POST [ " device_vendor " ];
2022-01-18 07:53:55 +01:00
$device_location = $_POST [ " device_location " ];
2023-05-24 22:52:50 +02:00
$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' ;
2019-08-04 04:21:56 +02:00
$device_template = $_POST [ " device_template " ];
$device_description = $_POST [ " device_description " ];
2013-06-09 22:46:14 +02:00
//lines
2019-09-23 17:29:06 +02:00
$device_lines = $_POST [ " device_lines " ];
2023-05-24 22:52:50 +02:00
$device_lines_delete = $_POST [ " device_lines_delete " ] ? ? null ;
2019-09-23 17:29:06 +02:00
//$line_number = $_POST["line_number"];
//$server_address = $_POST["server_address"];
//$outbound_proxy_primary = $_POST["outbound_proxy_primary"];
//$outbound_proxy_secondary = $_POST["outbound_proxy_secondary"];
2021-12-15 17:40:14 +01:00
//$label = $_POST["label"];
2019-09-23 17:29:06 +02:00
//$display_name = $_POST["display_name"];
//$user_id = $_POST["user_id"];
//$auth_id = $_POST["auth_id"];
//$password = $_POST["password"];
2015-02-15 01:33:56 +01:00
//profile
2023-05-24 22:52:50 +02:00
$device_profile_uuid = $_POST [ " device_profile_uuid " ] ? ? null ;
2013-12-17 17:19:54 +01:00
//keys
2019-09-23 17:29:06 +02:00
$device_keys = $_POST [ " device_keys " ];
2023-05-24 22:52:50 +02:00
$device_keys_delete = $_POST [ " device_keys_delete " ] ? ? null ;
2019-09-23 17:29:06 +02:00
//$device_key_category = $_POST["device_key_category"];
//$device_key_id = $_POST["device_key_id"];
//$device_key_type = $_POST["device_key_type"];
2023-04-04 16:57:41 +02:00
//$device_key_subtype = $_POST["device_key_subtype"];
2019-09-23 17:29:06 +02:00
//$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"];
2013-12-10 16:05:16 +01:00
//settings
2019-09-23 17:29:06 +02:00
$device_settings = $_POST [ " device_settings " ];
2023-05-24 22:52:50 +02:00
$device_settings_delete = $_POST [ " device_settings_delete " ] ? ? null ;
2019-08-04 04:21:56 +02:00
//$device_setting_category = $_POST["device_setting_category"]);
2019-09-23 17:29:06 +02:00
//$device_setting_subcategory = $_POST["device_setting_subcategory"];
2019-08-04 04:21:56 +02:00
//$device_setting_name = $_POST["device_setting_name"];
2019-09-23 17:29:06 +02:00
//$device_setting_value = $_POST["device_setting_value"];
//$device_setting_enabled = $_POST["device_setting_enabled"];
//$device_setting_description = $_POST["device_setting_description"];
2019-09-27 07:58:56 +02:00
2023-06-30 07:40:11 +02:00
//normalize the address
if ( ! empty ( $device_address )) {
$device_address = strtolower ( $device_address );
$device_address = preg_replace ( '#[^a-fA-F0-9./]#' , '' , $device_address );
2019-09-27 07:58:56 +02:00
}
2012-06-04 16:58:40 +02:00
}
2023-06-30 07:40:11 +02:00
//use the device address to get the vendor
2023-05-05 18:46:37 +02:00
if ( empty ( $device_vendor )) {
2023-06-30 07:40:11 +02:00
$device_vendor = device :: get_vendor ( $device_address ? ? null );
2012-07-05 20:22:02 +02:00
}
2012-06-04 16:58:40 +02:00
//add or update the database
2023-05-05 18:46:37 +02:00
if ( ! empty ( $_POST ) && empty ( $_POST [ " persistformvar " ])) {
2012-06-04 16:58:40 +02:00
2019-09-18 06:35:49 +02:00
//validate the token
2019-09-23 18:07:00 +02:00
$token = new token ;
if ( ! $token -> validate ( $_SERVER [ 'PHP_SELF' ])) {
message :: add ( $text [ 'message-invalid_token' ], 'negative' );
header ( 'Location: devices.php' );
exit ;
}
2019-09-18 06:35:49 +02:00
2012-06-04 16:58:40 +02:00
//check for all required data
2014-02-15 00:25:46 +01:00
$msg = '' ;
2023-06-30 07:40:11 +02:00
if ( empty ( $device_address )) { $msg .= $text [ 'message-required' ] . $text [ 'label-device_address' ] . " <br> \n " ; }
2023-05-05 18:46:37 +02:00
//if (empty($device_label)) { $msg .= "Please provide: Label<br>\n"; }
//if (empty($device_vendor)) { $msg .= "Please provide: Vendor<br>\n"; }
//if (empty($device_model)) { $msg .= "Please provide: Model<br>\n"; }
//if (empty($device_firmware_version)) { $msg .= "Please provide: Firmware Version<br>\n"; }
//if (empty($device_enabled)) { $msg .= "Please provide: Enabled<br>\n"; }
//if (empty($device_template)) { $msg .= "Please provide: Template<br>\n"; }
//if (empty($device_username)) { $msg .= "Please provide: Username<br>\n"; }
//if (empty($device_password)) { $msg .= "Please provide: Password<br>\n"; }
//if (empty($device_description)) { $msg .= "Please provide: Description<br>\n"; }
if ( ! empty ( $msg )) {
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 ;
}
2019-09-24 21:24:13 +02:00
//check for duplicates
2023-06-30 07:40:11 +02:00
if ( $action == 'add' && $device_address != " 000000000000 " ) {
2019-09-24 21:24:13 +02:00
$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 " ;
2023-06-30 07:40:11 +02:00
$sql .= " d1.device_address = :device_address " ;
2023-05-24 22:52:50 +02:00
if ( ! empty ( $_GET [ " device_uuid " ]) && is_uuid ( $_GET [ " device_uuid " ])) {
2019-09-24 21:24:13 +02:00
$sql .= " and d1.device_uuid <> :device_uuid " ;
}
2023-06-30 07:40:11 +02:00
$parameters [ 'device_address' ] = $device_address ;
2019-09-24 21:24:13 +02:00
$domain_name = $database -> select ( $sql , $parameters , 'column' );
if ( $domain_name != '' ) {
$message = $text [ 'message-duplicate' ] . ( if_group ( " superadmin " ) && $_SESSION [ " domain_name " ] != $domain_name ? " : " . $domain_name : null );
message :: add ( $message , 'negative' );
header ( 'Location: devices.php' );
exit ;
}
unset ( $sql , $parameters , $domain_name );
}
2012-06-04 16:58:40 +02:00
//add or update the database
2023-05-24 22:52:50 +02:00
if ( empty ( $_POST [ " persistformvar " ]) || $_POST [ " persistformvar " ] != " true " ) {
2013-12-17 17:19:54 +01:00
2019-09-24 21:24:13 +02:00
//set the device uuid
if ( ! is_uuid ( $device_uuid )) {
$device_uuid = uuid ();
2014-02-15 00:25:46 +01:00
}
2019-09-23 17:29:06 +02:00
//prepare the array
$array [ 'devices' ][ 0 ][ 'domain_uuid' ] = $domain_uuid ;
$array [ 'devices' ][ 0 ][ 'device_uuid' ] = $device_uuid ;
2023-06-30 07:40:11 +02:00
if ( permission_exists ( 'device_address' )) {
$array [ 'devices' ][ 0 ][ 'device_address' ] = $device_address ;
2020-04-16 01:33:22 +02:00
}
2019-09-29 05:32:18 +02:00
//$array['devices'][0]['device_provisioned_ip'] = $device_provisioned_ip;
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_label' )) {
$array [ 'devices' ][ 0 ][ 'device_label' ] = $device_label ;
}
2024-07-23 23:15:50 +02:00
if ( permission_exists ( 'device_user' ) && ( is_uuid ( $device_user_uuid ) || empty ( $device_user_uuid ))) {
2020-04-16 01:33:22 +02:00
$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 ;
}
2022-01-18 07:53:55 +01:00
if ( permission_exists ( 'device_location' )) {
$array [ 'devices' ][ 0 ][ 'device_location' ] = $device_location ;
}
2022-05-25 20:21:02 +02:00
if ( permission_exists ( 'device_alternate' )) {
$array [ 'devices' ][ 0 ][ 'device_uuid_alternate' ] = is_uuid ( $device_uuid_alternate ) ? $device_uuid_alternate : null ;
2020-04-16 01:33:22 +02:00
}
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 ;
}
2023-11-03 06:37:42 +01:00
if ( permission_exists ( 'device_profile_view' )) {
2020-09-29 22:38:15 +02:00
$array [ 'devices' ][ 0 ][ 'device_profile_uuid' ] = is_uuid ( $device_profile_uuid ) ? $device_profile_uuid : null ;
2020-04-16 01:33:22 +02:00
}
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 ) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'line_number' ])) {
2020-11-17 07:21:53 +01:00
$new_line = false ;
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ " device_line_uuid " ]) && is_uuid ( $row [ " device_line_uuid " ])) {
2020-04-16 01:33:22 +02:00
$device_line_uuid = $row [ " device_line_uuid " ];
}
else {
$device_line_uuid = uuid ();
2020-11-17 07:21:53 +01:00
$new_line = true ;
2020-04-16 01:33:22 +02:00
}
$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 " ];
2020-11-17 07:21:53 +01:00
} else if ( $new_line && isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ])) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'outbound_proxy_primary' ] = $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ][ 'text' ];
2020-04-16 01:33:22 +02:00
}
if ( permission_exists ( 'device_line_outbound_proxy_secondary' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'outbound_proxy_secondary' ] = $row [ " outbound_proxy_secondary " ];
2020-11-17 07:21:53 +01:00
} else if ( $new_line && isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ])) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'outbound_proxy_secondary' ] = $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ][ 'text' ];
2020-04-16 01:33:22 +02:00
}
if ( permission_exists ( 'device_line_server_address_primary' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'server_address_primary' ] = $row [ " server_address_primary " ];
2020-11-17 07:21:53 +01:00
} else if ( $new_line && isset ( $_SESSION [ 'provision' ][ 'server_address_primary' ])) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'server_address_primary' ] = $_SESSION [ 'provision' ][ 'server_address_primary' ][ 'text' ];
2020-04-16 01:33:22 +02:00
}
if ( permission_exists ( 'device_line_server_address_secondary' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'server_address_secondary' ] = $row [ " server_address_secondary " ];
2020-11-17 07:21:53 +01:00
} else if ( $new_line && isset ( $_SESSION [ 'provision' ][ 'server_address_secondary' ])) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'server_address_secondary' ] = $_SESSION [ 'provision' ][ 'server_address_secondary' ][ 'text' ];
2020-04-16 01:33:22 +02:00
}
2022-05-27 05:34:39 +02:00
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 " ];
}
2020-04-16 01:33:22 +02:00
$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 " ];
}
2021-07-26 18:37:21 +02:00
if ( permission_exists ( 'device_line_shared' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'shared_line' ] = $row [ " shared_line " ];
}
2020-04-16 01:33:22 +02:00
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'enabled' ] = $row [ " enabled " ];
2021-07-26 18:37:21 +02:00
if ( permission_exists ( 'device_line_port' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'sip_port' ] = $row [ " sip_port " ];
}
else {
2021-10-14 08:26:54 +02:00
if ( $action == " add " ) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'sip_port' ] = $_SESSION [ 'provision' ][ 'line_sip_port' ][ 'numeric' ];
}
2021-07-26 18:37:21 +02:00
}
if ( permission_exists ( 'device_line_transport' )) {
2021-10-14 08:26:54 +02:00
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'sip_transport' ] = $row [ " sip_transport " ];
2021-07-26 18:37:21 +02:00
}
else {
2021-10-14 08:26:54 +02:00
if ( $action == " add " ) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'sip_transport' ] = $_SESSION [ 'provision' ][ 'line_sip_transport' ][ 'text' ];
}
2021-07-26 18:37:21 +02:00
}
if ( permission_exists ( 'device_line_register_expires' )) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'register_expires' ] = $row [ " register_expires " ];
}
else {
2021-10-14 08:26:54 +02:00
if ( $action == " add " ) {
$array [ 'devices' ][ 0 ][ 'device_lines' ][ $y ][ 'register_expires' ] = $_SESSION [ 'provision' ][ 'line_register_expires' ][ 'numeric' ];
}
2021-07-26 18:37:21 +02:00
}
2020-04-16 01:33:22 +02:00
$y ++ ;
2019-09-23 17:29:06 +02:00
}
}
2019-04-13 09:34:00 +02:00
}
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_edit' )) {
$y = 0 ;
foreach ( $device_keys as $row ) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'device_key_category' ])) {
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ " device_key_uuid " ]) && is_uuid ( $row [ " device_key_uuid " ])) {
2020-04-16 01:33:22 +02:00
$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 " ];
2023-04-04 16:57:41 +02:00
if ( isset ( $row [ " device_key_subtype " ])) {
$array [ 'devices' ][ 0 ][ 'device_keys' ][ $y ][ 'device_key_subtype' ] = $row [ " device_key_subtype " ];
}
2020-04-16 01:33:22 +02:00
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 " ];
2022-01-25 17:53:03 +01:00
if ( permission_exists ( 'device_key_icon' )) {
$array [ 'devices' ][ 0 ][ 'device_keys' ][ $y ][ 'device_key_icon' ] = $row [ " device_key_icon " ];
}
2020-04-16 01:33:22 +02:00
$y ++ ;
2019-09-23 17:29:06 +02:00
}
}
}
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_setting_edit' )) {
$y = 0 ;
foreach ( $device_settings as $row ) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'device_setting_subcategory' ])) {
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ " device_setting_uuid " ]) && is_uuid ( $row [ " device_setting_uuid " ])) {
2020-04-16 01:33:22 +02:00
$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 ;
2023-05-24 22:52:50 +02:00
$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 ;
2020-04-16 01:33:22 +02:00
$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 ++ ;
2019-09-23 17:29:06 +02:00
}
}
}
2016-10-02 09:13:25 +02:00
2014-02-15 00:25:46 +01:00
//save the device
2019-09-24 21:24:13 +02:00
$database -> app_name = 'devices' ;
$database -> app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e' ;
$database -> save ( $array );
2013-12-10 16:05:16 +01:00
2020-02-27 18:24:32 +01:00
//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 );
}
2013-06-09 22:46:14 +02:00
//write the provision files
2023-05-05 18:46:37 +02:00
if ( ! empty ( $_SESSION [ 'provision' ][ 'path' ][ 'text' ])) {
2024-06-23 03:28:04 +02:00
$prov = new provision ([ 'settings' => $settings ]);
2016-12-06 19:25:08 +01:00
$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
2019-09-24 21:24:13 +02:00
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' ]);
2014-02-15 00:25:46 +01:00
}
2019-09-24 21:24:13 +02:00
//redirect the browser
header ( " Location: device_edit.php?id= " . urlencode ( $device_uuid ));
exit ;
2014-01-20 10:34:04 +01:00
}
2020-02-27 18:24:32 +01:00
}
}
2012-06-04 16:58:40 +02:00
//pre-populate the form
2023-05-24 22:52:50 +02:00
if ( ! empty ( $_GET ) && ( empty ( $_POST [ " persistformvar " ]) || $_POST [ " persistformvar " ] != " true " )) {
2016-10-23 07:30:11 +02:00
$sql = " select * from v_devices " ;
2019-08-04 04:21:56 +02:00
$sql .= " where device_uuid = :device_uuid " ;
$parameters [ 'device_uuid' ] = $device_uuid ;
2024-09-06 19:20:03 +02:00
2019-08-04 04:21:56 +02:00
$row = $database -> select ( $sql , $parameters , 'row' );
if ( is_array ( $row ) && @ sizeof ( $row ) != 0 ) {
2023-06-30 07:40:11 +02:00
$device_address = $row [ " device_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 " ];
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 " ];
2022-01-18 07:53:55 +01:00
$device_location = $row [ " device_location " ];
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
}
2019-08-04 04:21:56 +02:00
unset ( $sql , $parameters , $row );
2012-06-04 16:58:40 +02:00
}
2023-02-17 22:21:41 +01:00
//set the defaults
2023-05-05 18:46:37 +02:00
if ( empty ( $device_enabled )) { $device_enabled = 'true' ; }
2023-02-17 22:21:41 +01:00
2023-06-30 07:40:11 +02:00
//use the device address to get the vendor
2023-05-05 18:46:37 +02:00
if ( empty ( $device_vendor )) {
2023-06-30 07:40:11 +02:00
//get the device vendor using the device address
$device_vendor = device :: get_vendor ( $device_address ? ? null );
2024-09-06 19:20:03 +02:00
2023-06-30 07:40:11 +02:00
//if the vendor was not found using the device address use an alternative method
2023-05-05 18:46:37 +02:00
if ( empty ( $device_vendor )) {
$template_array = explode ( " / " , $device_template ? ? '' );
$device_vendor = $template_array [ 0 ] ? ? '' ;
2022-07-19 17:52:34 +02:00
}
2014-01-28 12:03:05 +01:00
}
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
2023-05-24 22:52:50 +02:00
if ( ! empty ( $device_uuid_alternate ) && is_uuid ( $device_uuid_alternate )) {
2015-05-24 07:00:40 +02:00
$sql = " select * from v_devices " ;
2019-08-04 04:21:56 +02:00
$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 );
2015-05-24 07:00:40 +02:00
}
2014-01-20 10:34:04 +01:00
//get device lines
2019-08-04 04:21:56 +02:00
$sql = " select * from v_device_lines " ;
$sql .= " where device_uuid = :device_uuid " ;
2018-09-14 21:10:17 +02:00
$sql .= " order by cast(line_number as int) asc " ;
2023-05-24 22:52:50 +02:00
$parameters [ 'device_uuid' ] = $device_uuid ? ? null ;
2024-09-06 19:20:03 +02:00
2019-08-04 04:21:56 +02:00
$device_lines = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
2014-01-20 19:00:45 +01:00
$device_lines [ $x ][ 'line_number' ] = '' ;
$device_lines [ $x ][ 'server_address' ] = '' ;
2023-05-24 22:52:50 +02:00
$device_lines [ $x ][ 'outbound_proxy_primary' ] = $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ][ 'text' ] ? ? null ;
$device_lines [ $x ][ 'outbound_proxy_secondary' ] = $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ][ 'text' ] ? ? null ;
$device_lines [ $x ][ 'server_address_primary' ] = $_SESSION [ 'provision' ][ 'server_address_primary' ][ 'text' ] ? ? null ;
$device_lines [ $x ][ 'server_address_secondary' ] = $_SESSION [ 'provision' ][ 'server_address_secondary' ][ 'text' ] ? ? null ;
2021-12-15 17:40:14 +01:00
$device_lines [ $x ][ 'label' ] = '' ;
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
2019-08-04 04:21:56 +02:00
$sql = " select * from v_device_keys " ;
$sql .= " where device_uuid = :device_uuid " ;
$sql .= " order by " ;
2015-07-08 06:41:24 +02:00
$sql .= " device_key_vendor asc, " ;
2019-08-04 04:21:56 +02:00
$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 " ;
2023-05-24 22:52:50 +02:00
$parameters [ 'device_uuid' ] = $device_uuid ? ? null ;
2019-08-04 04:21:56 +02:00
$device_keys = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
2023-11-25 00:29:46 +01:00
//add empty device key row(s)
if ( ! is_uuid ( $device_uuid )) {
$rows = $_SESSION [ 'devices' ][ 'key_add_rows' ][ 'numeric' ] ? ? 1 ;
$id = 0 ;
}
else {
$rows = $_SESSION [ 'devices' ][ 'key_edit_rows' ][ 'numeric' ] ? ? 1 ;
$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 );
2014-01-20 10:34:04 +01:00
2018-07-03 05:41:48 +02:00
//get the device vendors
2019-08-04 04:21:56 +02:00
$sql = " select name " ;
$sql .= " from v_device_vendors " ;
$sql .= " where enabled = 'true' " ;
$sql .= " order by name asc " ;
2024-09-06 19:20:03 +02:00
2019-08-04 04:21:56 +02:00
$device_vendors = $database -> select ( $sql , null , 'all' );
unset ( $sql );
2018-07-03 05:41:48 +02:00
2016-08-02 21:35:38 +02:00
//get the vendor functions
2023-04-04 16:57:41 +02:00
$sql = " select v.name as vendor_name, f.type, f.subtype, f.value " ;
2019-08-04 04:21:56 +02:00
$sql .= " from v_device_vendors as v, v_device_vendor_functions as f " ;
$sql .= " where v.device_vendor_uuid = f.device_vendor_uuid " ;
2016-08-02 21:35:38 +02:00
$sql .= " and v.enabled = 'true' " ;
$sql .= " and f.enabled = 'true' " ;
2023-04-04 16:57:41 +02:00
$sql .= " order by v.name asc, f.type asc " ;
2019-08-04 04:21:56 +02:00
$vendor_functions = $database -> select ( $sql , null , 'all' );
unset ( $sql );
2016-08-02 21:35:38 +02:00
2014-01-20 10:34:04 +01:00
//get device settings
2019-08-04 04:21:56 +02:00
$sql = " select * from v_device_settings " ;
$sql .= " where device_uuid = :device_uuid " ;
$sql .= " order by device_setting_subcategory asc " ;
2023-05-24 22:52:50 +02:00
$parameters [ 'device_uuid' ] = $device_uuid ? ? null ;
2019-08-04 04:21:56 +02:00
$device_settings = $database -> select ( $sql , $parameters , 'all' );
unset ( $sql , $parameters );
2023-11-25 00:29:46 +01:00
//add empty device setting row(s)
if ( ! is_uuid ( $device_uuid )) {
$rows = $_SESSION [ 'devices' ][ 'setting_add_rows' ][ 'numeric' ] ? ? 1 ;
$id = 0 ;
}
else {
$rows = $_SESSION [ 'devices' ][ 'setting_edit_rows' ][ 'numeric' ] ? ? 1 ;
$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 );
2014-01-20 10:34:04 +01:00
2016-05-20 18:39:16 +02:00
//get the users
2019-08-04 04:21:56 +02:00
$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 );
2016-05-20 18:39:16 +02:00
2023-06-30 07:40:11 +02:00
//use the device address to get the vendor
2023-05-05 18:46:37 +02:00
if ( empty ( $device_vendor )) {
2023-06-30 07:40:11 +02:00
$device_vendor = device :: get_vendor ( $device_address ? ? null );
2014-01-04 00:11:42 +01:00
}
2023-10-30 20:19:56 +01:00
//get the first device line info (found on the local server) for the provision button
foreach ( $device_lines as $row ) {
if (
array_key_exists ( $row [ 'domain_uuid' ], $_SESSION [ 'domains' ]) &&
$row [ 'server_address' ] == $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ] &&
! empty ( $row [ 'user_id' ]) &&
! empty ( $row [ 'server_address' ])
) {
2017-02-21 06:12:49 +01:00
$user_id = $row [ 'user_id' ];
$server_address = $row [ 'server_address' ];
2023-10-30 20:19:56 +01:00
break ;
2017-02-21 06:12:49 +01:00
}
}
2017-09-21 05:09:52 +02:00
2019-09-18 06:35:49 +02:00
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
2013-05-23 10:18:12 +02:00
//show the header
2020-02-27 18:24:32 +01:00
$document [ 'title' ] = $text [ 'title-device' ];
2013-07-06 08:29:50 +02:00
require_once " resources/header.php " ;
2012-06-04 16:58:40 +02:00
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 " ;
echo " $ ('#button_files').fadeOut(fade_speed, function() { \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 " 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 " ;
2019-07-04 18:05:30 +02:00
if ( $_SESSION [ 'provision' ][ 'http_domain_filter' ][ 'boolean' ] == " false " ) {
2015-12-03 18:29:33 +01:00
$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
}
2023-06-30 17:59:57 +02:00
echo " window.location = ' " . $_SERVER [ 'HTTP_PROTOCOL' ] . " :// " . $domain_name . PROJECT_PATH . " /app/provision/index.php?address= " . escape ( $device_address ? ? '' ) . " &file=' + d + '&content_type=application/octet-stream'; \n " ;
2015-11-25 08:10:49 +01:00
echo " } \n " ;
echo " \n " ;
echo " $ ( document ).ready(function() { \n " ;
2019-08-21 02:15:50 +02:00
echo " $ ('#default_setting_search').trigger('focus'); \n " ;
2023-05-24 22:52:50 +02:00
if ( empty ( $search )) {
2015-11-25 08:10:49 +01:00
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> " ;
}
2023-07-03 16:26:19 +02:00
//determine whether to build the qrcode
if ( $device_template == " grandstream/wave " ) {
$qr_code_enabled = true ;
}
2023-09-08 01:26:27 +02:00
else if ( $device_template == " linphone/default " ) {
$qr_code_enabled = true ;
}
else if ( $device_template == " sipnetic/default " ) {
2023-07-03 16:26:19 +02:00
$qr_code_enabled = true ;
}
2024-06-13 22:53:30 +02:00
else if ( $device_template == " acrobits/default " ) {
$qr_code_enabled = true ;
}
2024-07-24 15:21:12 +02:00
else if ( $device_template == " groundwire/default " ) {
$qr_code_enabled = true ;
}
2023-07-03 16:26:19 +02:00
else {
$qr_code_enabled = false ;
}
2018-03-22 07:45:43 +01:00
//add the QR code
2023-07-03 16:26:19 +02:00
if ( permission_exists ( " device_line_password " ) && ! empty ( $device_template ) && $qr_code_enabled ) {
2018-03-22 07:45:43 +01:00
//set the mode
if ( isset ( $_SESSION [ 'theme' ][ 'qr_image' ])) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $_SESSION [ 'theme' ][ 'qr_image' ])) {
2018-03-22 07:45:43 +01:00
$mode = '4' ;
}
else {
$mode = '0' ;
}
}
else {
$mode = '4' ;
}
2018-08-02 10:28:01 +02:00
//get the device line settings
2023-07-03 20:02:17 +02:00
$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 = " <?xml version='1.0' encoding='utf-8'?> " ;
$content .= " <AccountConfig version='1'> " ;
$content .= " <Account> " ;
$content .= " <RegisterServer> " . $row [ 'server_address' ] . " </RegisterServer> " ;
$content .= " <OutboundServer> " . $outbound_proxy_primary . " : " . $row [ 'sip_port' ] . " </OutboundServer> " ;
$content .= " <SecOutboundServer> " . $outbound_proxy_secondary . " : " . $row [ 'sip_port' ] . " </SecOutboundServer> " ;
$content .= " <UserID> " . $row [ 'user_id' ] . " </UserID> " ;
$content .= " <AuthID> " . $row [ 'auth_id' ] . " </AuthID> " ;
$content .= " <AuthPass> " . $row [ 'password' ] . " </AuthPass> " ;
$content .= " <AccountName> " . $row [ 'user_id' ] . " </AccountName> " ;
$content .= " <DisplayName> " . $row [ 'display_name' ] . " </DisplayName> " ;
$content .= " <Dialplan> { x+|*x+|*++}</Dialplan> " ;
$content .= " <RandomPort>0</RandomPort> " ;
$content .= " <Voicemail>*97</Voicemail> " ;
$content .= " </Account> " ;
$content .= " </AccountConfig> " ;
}
2018-08-02 10:28:01 +02:00
2023-09-08 01:26:27 +02:00
//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' );
}
2024-07-14 17:51:44 +02:00
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' );
}
2023-09-08 01:26:27 +02:00
if ( ! empty ( $template )) {
2024-02-19 22:56:46 +01:00
$template = str_replace ( '{$server_address}' , $row [ 'server_address' ], $template );
2023-09-08 01:26:27 +02:00
$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 );
}
}
2024-06-13 22:53:30 +02:00
//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' );
}
2024-07-14 17:51:44 +02:00
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' );
}
2024-06-13 22:53:30 +02:00
//get the provision settings
$provision = new settings ([ " category " => " provision " ]);
$acrobits_code = $provision -> get ( 'provision' , 'acrobits_code' );
2024-09-06 19:20:03 +02:00
2024-06-13 22:53:30 +02:00
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 );
}
}
2023-09-08 01:26:27 +02:00
2024-07-24 15:21:12 +02:00
//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 );
}
}
2023-07-03 16:26:19 +02:00
}
//build content for linphone
if ( $device_template == " linphone/default " ) {
2023-07-05 22:22:44 +02:00
$auth_string = '' ;
2023-07-03 21:52:56 +02:00
if (
! empty ( $_SESSION [ 'provision' ][ 'http_auth_enabled' ][ 'boolean' ]) &&
$_SESSION [ 'provision' ][ 'http_auth_enabled' ][ 'boolean' ] == 'true' &&
! empty ( $_SESSION [ 'provision' ][ 'http_auth_username' ][ 'text' ]) &&
! empty ( $_SESSION [ 'provision' ][ 'http_auth_password' ][ 0 ])
) {
$auth_string = $_SESSION [ 'provision' ][ 'http_auth_username' ][ 'text' ] . ':' . $_SESSION [ 'provision' ][ 'http_auth_password' ][ 0 ] . '@' ;
}
$content = " https:// " . $auth_string . $_SESSION [ 'domain_name' ] . '/app/provision/index.php?address=' . $device_address ;
2023-07-03 16:26:19 +02:00
}
//stream the file
if ( ! empty ( $content )) {
2023-07-03 20:02:17 +02:00
$content = html_entity_decode ( $content , ENT_QUOTES , 'UTF-8' );
2023-07-03 16:26:19 +02:00
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
2023-07-03 20:02:17 +02:00
if ( ! empty ( $content ) && ! empty ( $image )) {
2023-07-03 16:26:19 +02:00
echo " <script> \n " ;
echo " function fade_in(id) { \n " ;
echo " var image_container = document.getElementById(id); \n " ;
2023-07-03 20:55:07 +02:00
echo " image_container.style.opacity = 1; \n " ;
echo " image_container.style.zIndex = 999999; \n " ;
2023-07-03 16:26:19 +02:00
echo " } \n " ;
2023-07-03 21:52:56 +02:00
echo " function fade_out(image_container) { \n " ;
2023-07-03 20:55:07 +02:00
echo " image_container.style.opacity = 0; \n " ;
2023-07-03 21:52:56 +02:00
echo " setTimeout(function() { image_container.style.zIndex = -1; }, 1000); \n " ;
2023-07-03 16:26:19 +02:00
echo " } \n " ;
echo " </script> \n " ;
echo " \n " ;
echo " <style> \n " ;
2023-07-03 21:52:56 +02:00
echo " div#image-container { \n " ;
2023-07-03 20:55:07 +02:00
echo " z-index: -1; \n " ;
2023-07-03 16:26:19 +02:00
echo " position: absolute; \n " ;
2023-07-03 21:52:56 +02:00
echo " top: 0; \n " ;
echo " left: 0; \n " ;
echo " width: 100%; \n " ;
echo " height: 100%; \n " ;
2023-07-03 16:26:19 +02:00
echo " opacity: 0; \n " ;
echo " transition: opacity 1s; \n " ;
2023-07-03 21:52:56 +02:00
echo " padding: 20px; \n " ;
2023-07-03 16:26:19 +02:00
echo " } \n " ;
2023-07-03 20:55:07 +02:00
echo " img#qr_code { \n " ;
2023-07-03 21:52:56 +02:00
echo " display: block; \n " ;
echo " margin: max(5%, 50px) auto; \n " ;
2023-07-03 20:55:07 +02:00
echo " width: 100%; \n " ;
2023-07-03 21:52:56 +02:00
echo " max-width: 600px; \n " ;
2023-07-03 20:55:07 +02:00
echo " min-width: 300px; \n " ;
echo " height: auto; \n " ;
2023-07-03 21:52:56 +02:00
echo " max-height: 650px; \n " ;
2023-07-03 16:26:19 +02:00
echo " -webkit-box-shadow: 0px 1px 20px #888; \n " ;
echo " -moz-box-shadow: 0px 1px 20px #888; \n " ;
echo " box-shadow: 0px 1px 20px #888; \n " ;
2023-07-03 21:52:56 +02:00
echo " border: 50px solid #fff; \n " ;
2023-07-03 16:26:19 +02:00
echo " } \n " ;
echo " </style> " ;
2023-07-03 21:52:56 +02:00
echo " <div id='image-container' onclick='fade_out(this);'> \n " ;
echo " <img id='qr_code' src='data:image/jpeg;base64, " . base64_encode ( $image ) . " '> \n " ;
2023-07-03 16:26:19 +02:00
echo " </div> \n " ;
}
/*
2018-03-22 07:45:43 +01:00
if ( isset ( $_SESSION [ 'theme' ][ 'qr_image' ])) {
echo " <img id='img-buffer' src=' " . $_SESSION [ " theme " ][ " qr_image " ][ " text " ] . " ' style='display: none;'> " ;
}
else {
echo " <img id='img-buffer' src=' " . PROJECT_PATH . " /themes/ " . $_SESSION [ " domain " ][ " template " ][ " name " ] . " /images/qr_code.png' style='display: none;'> " ;
}
2023-07-03 16:26:19 +02:00
*/
2018-03-22 07:45:43 +01:00
}
2013-05-23 10:18:12 +02:00
//show the content
2020-02-27 18:24:32 +01:00
echo " <form name='frm' id='frm' method='post'> \n " ;
2016-07-27 05:00:05 +02:00
echo " <input type='hidden' name='file_action' id='file_action' value='' /> \n " ;
2020-01-08 21:28:01 +01:00
echo " <div class='action_bar' id='action_bar'> \n " ;
echo " <div class='heading'><b> " . $text [ 'header-device' ] . " </b></div> \n " ;
echo " <div class='actions'> \n " ;
2020-03-05 08:05:45 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-back' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_back' ], 'id' => 'btn_back' , 'link' => 'devices.php' ]);
2020-02-28 15:31:35 +01:00
if ( $action == 'update' ) {
$button_margin = 'margin-left: 15px;' ;
2023-07-03 16:26:19 +02:00
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'); " ]);
2020-02-28 15:31:35 +01:00
unset ( $button_margin );
}
2023-10-30 20:19:56 +01:00
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 )]);
2023-07-03 22:14:22 +02:00
unset ( $button_margin );
}
2020-02-28 15:31:35 +01:00
if ( permission_exists ( " device_files " )) {
//get the template directory
2024-06-23 03:28:04 +02:00
$prov = new provision ([ 'settings' => $settings ]);
2020-02-28 15:31:35 +01:00
$prov -> domain_uuid = $domain_uuid ;
$template_dir = $prov -> template_dir ;
$files = glob ( $template_dir . '/' . $device_template . '/*' );
//add file buttons and the file list
2023-10-30 20:19:56 +01:00
echo button :: create ([ 'type' => 'button' , 'id' => 'button_files' , 'label' => $text [ 'button-files' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_download' ], 'style' => ( $button_margin ? ? '' ), 'onclick' => 'show_files()' ]);
2020-02-28 15:31:35 +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 ) {
2023-06-30 07:40:11 +02:00
//format the device address
2024-06-23 03:28:04 +02:00
$address = $prov -> format_address ( $device_address , $device_vendor );
2020-02-28 15:31:35 +01:00
//render the file name
2023-07-01 04:08:30 +02:00
$file_name = str_replace ( " { \$ address} " , $address , basename ( $file ));
$file_name = str_replace ( " { \$ mac} " , $address , basename ( $file_name ));
2020-02-28 15:31:35 +01:00
//add the select option
echo " <option value=' " . basename ( $file ) . " '> " . $file_name . " </option> \n " ;
}
echo " </select> " ;
2023-10-30 20:19:56 +01:00
unset ( $button_margin );
2020-02-28 15:31:35 +01:00
}
if ( permission_exists ( 'device_add' )) {
2023-10-30 20:19:56 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-copy' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_copy' ], 'style' => ( $button_margin ? ? '' ), 'name' => 'btn_copy' , 'onclick' => " modal_open('modal-copy','new_address'); " ]);
unset ( $button_margin );
2020-02-28 15:31:35 +01:00
}
if (
permission_exists ( 'device_delete' ) ||
permission_exists ( 'device_line_delete' ) ||
permission_exists ( 'device_key_delete' ) ||
permission_exists ( 'device_setting_delete' )
) {
2023-10-30 20:19:56 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-delete' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_delete' ], 'style' => ( $button_margin ? ? '' ), 'name' => 'btn_delete' , 'onclick' => " modal_open('modal-delete','btn_delete'); " ]);
unset ( $button_margin );
2020-02-28 15:31:35 +01:00
}
2020-02-27 18:24:32 +01:00
}
2023-01-04 17:19:48 +01:00
echo button :: create ([ 'type' => 'submit' , 'label' => $text [ 'button-save' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_save' ], 'id' => 'btn_save' , 'style' => 'margin-left: 15px;' , 'onclick' => 'submit_form();' ]);
2020-01-08 21:28:01 +01:00
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
echo " </div> \n " ;
2020-03-26 15:55:43 +01:00
if ( permission_exists ( 'device_add' )) {
echo modal :: create ([
'id' => 'modal-copy' ,
'type' => 'general' ,
2023-07-01 04:08:30 +02:00
'message' => $text [ 'message_device' ] . " ...<br /><br /><input class='formfld modal-input' data-continue='btn_copy' style='font-family: monospace;' type='text' id='new_address' maxlength='17' placeholder='FF-FF-FF-FF-FF-FF'> " ,
2020-03-26 15:55:43 +01:00
'actions' => button :: create ([
'type' => 'button' ,
'label' => $text [ 'button-continue' ],
'icon' => 'check' ,
'id' => 'btn_copy' ,
'style' => 'float: right; margin-left: 15px;' ,
'collapse' => 'never' ,
2023-07-01 04:08:30 +02:00
'onclick' => " modal_close(); if (document.getElementById('new_address').value != '') { window.location='device_copy.php?id= " . urlencode ( $device_uuid ? ? '' ) . " &mac=' + document.getElementById('new_address').value; } "
2020-03-26 15:55:43 +01:00
]),
2023-07-01 04:08:30 +02:00
'onclose' => " document.getElementById('new_address').value = ''; " ,
2020-03-26 15:55:43 +01:00
]);
}
if (
permission_exists ( 'device_delete' ) ||
permission_exists ( 'device_line_delete' ) ||
permission_exists ( 'device_key_delete' ) ||
permission_exists ( 'device_setting_delete' )
) {
2020-03-27 00:20:57 +01:00
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(); " ])]);
2020-03-26 15:55:43 +01:00
}
2020-01-08 21:28:01 +01:00
echo $text [ 'description-device' ] . " \n " ;
echo " <br /><br /> \n " ;
2013-05-23 10:18:12 +02:00
2024-09-06 19:20:03 +02:00
echo " <div class='card'> \n " ;
2016-03-25 23:29:20 +01:00
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'> \n " ;
2021-10-29 22:37:11 +02:00
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 " ;
2023-06-30 07:40:11 +02:00
echo " " . $text [ 'label-device_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 " ;
2023-06-30 07:40:11 +02:00
if ( permission_exists ( 'device_address' )) {
2024-07-24 23:26:55 +02:00
echo " <input class='formfld' type='text' name='device_address' id='device_address' style='width: 245px;' maxlength='36' value= \" " . escape ( $device_address ) . " \" /> \n " ;
2015-11-05 20:05:49 +01:00
echo " <br /> \n " ;
2023-06-30 07:40:11 +02:00
echo $text [ 'description-device_address' ] . " \n " ;
2015-11-05 19:56:50 +01:00
}
else {
2023-07-03 16:26:19 +02:00
echo escape ( format_device_address ( $device_address ? ? '' ));
2015-11-05 19:56:50 +01:00
}
2014-08-02 04:16:46 +02:00
echo " <div style='display: none;' id='duplicate_mac_response'></div> \n " ;
2023-11-25 00:38:34 +01:00
if ( ! empty ( $device_provisioned_ip )) {
echo " " . escape ( $device_provisioned_ip ? ? '' ) . " (<a href='http:// " . escape ( $device_provisioned_ip ? ? '' ) . " ' target='_blank'>http</a>|<a href='https:// " . escape ( $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' )) {
2023-05-24 22:52:50 +02:00
echo " <input class='formfld' type='text' name='device_label' maxlength='255' value= \" " . escape ( $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 {
2018-06-08 22:01:07 +02:00
echo escape ( $device_label );
2015-11-05 19:56:50 +01:00
}
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 " ;
2021-10-29 22:37:11 +02:00
echo " <div class='template_select_container'> " ;
2015-11-05 19:56:50 +01:00
$device = new device ;
$template_dir = $device -> get_template_dir ();
2021-10-29 22:37:11 +02:00
echo " <select id='device_template' name='device_template' class='formfld' style='float: left;'> \n " ;
2018-07-03 05:41:48 +02:00
echo " <option value=''></option> \n " ;
2020-02-12 23:24:42 +01:00
if ( is_dir ( $template_dir ) && @ is_array ( $device_vendors )) {
foreach ( $device_vendors as $row ) {
2018-10-24 07:12:24 +02:00
echo " <optgroup label=' " . escape ( $row [ " name " ]) . " '> \n " ;
2020-02-12 23:24:42 +01:00
if ( file_exists ( $template_dir . '/' . $row [ " name " ])) {
$templates = scandir ( $template_dir . '/' . $row [ " name " ]);
if ( is_array ( $templates ) && @ sizeof ( $templates ) != 0 ) {
foreach ( $templates as $dir ) {
2023-05-25 19:42:37 +02:00
if (( ! isset ( $file ) || $file != " . " ) && ( ! isset ( $dir ) || ( $dir != " .. " && $dir [ 0 ] != '.' ))) {
2020-02-12 23:24:42 +01:00
if ( is_dir ( $template_dir . '/' . $row [ " name " ] . '/' . $dir )) {
2023-05-25 19:42:37 +02:00
if ( ! empty ( $device_template ) && $device_template == $row [ " name " ] . " / " . $dir ) {
2020-02-12 23:24:42 +01:00
echo " <option value=' " . escape ( $row [ " name " ]) . " / " . escape ( $dir ) . " ' selected='selected'> " . escape ( $row [ " name " ]) . " / " . escape ( $dir ) . " </option> \n " ;
2021-10-29 22:37:11 +02:00
$current_device = escape ( $dir );
$current_device_path = $template_dir . '/' . $row [ " name " ];
2020-02-12 23:24:42 +01:00
}
else {
echo " <option value=' " . escape ( $row [ " name " ]) . " / " . escape ( $dir ) . " '> " . $row [ " name " ] . " / " . escape ( $dir ) . " </option> \n " ;
}
}
2018-10-24 07:12:24 +02:00
}
2013-06-09 22:46:14 +02:00
}
}
}
2018-10-24 07:12:24 +02:00
echo " </optgroup> \n " ;
2013-06-09 22:46:14 +02:00
}
2018-07-03 05:41:48 +02:00
}
echo " </select> \n " ;
2021-10-29 22:37:11 +02:00
echo " <span style='float: left; clear: left;' " ;
2018-07-03 05:41:48 +02:00
echo " <br /> \n " ;
echo " " . $text [ 'description-device_template' ] . " \n " ;
2021-10-29 22:37:11 +02:00
echo " </span> " ;
echo " </div> " ;
echo "
< style >
. template_select_container {
display : block ;
width : auto ;
float : left ;
}
2022-05-27 05:34:39 +02:00
2021-10-29 22:37:11 +02:00
. device_image {
max - width : 280 px ;
}
2022-05-27 05:34:39 +02:00
2021-10-29 22:37:11 +02:00
. device_image > img {
position : relative ;
max - height : 170 px ;
border - radius : 1 px ;
transition : transform . 6 s ;
z - index : 2 ;
}
2022-05-27 05:34:39 +02:00
2021-10-29 22:37:11 +02:00
. device_image > img : hover {
cursor : zoom - in ;
2022-05-27 05:34:39 +02:00
}
2021-10-29 22:37:11 +02:00
. device_image > img : active {
transform : scale ( 3 );
box - shadow : 0 0 10 px #ccc;
}
</ style >
" ;
2022-05-27 05:34:39 +02:00
2023-05-24 22:52:50 +02:00
$device_image_path = ( $current_device_path ? ? '' ) . '/' ;
$device_image_name = ( $current_device ? ? '' ) . '.jpg' ;
$device_image_full = ( $device_image_path ? ? '' ) . '/' . ( $current_device ? ? '' ) . '/' . ( $device_image_name ? ? '' );
2022-05-27 05:34:39 +02:00
2023-07-01 04:08:30 +02:00
if ( file_exists ( $device_image_full )) {
$device_image = base64_encode ( file_get_contents ( $device_image_full ));
2021-10-29 22:37:11 +02:00
2023-07-01 04:08:30 +02:00
echo " <div class='device_image'> \n " ;
echo " <img src='data:image/jpg;base64, " . $device_image . " ' title=' $current_device '> " ;
echo " </div> " ;
2021-10-29 22:37:11 +02:00
}
2015-11-05 19:56:50 +01:00
echo " </td> \n " ;
echo " </tr> \n " ;
}
2013-06-09 22:46:14 +02:00
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_line_edit' )) {
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'> " ;
2019-10-27 02:53:21 +01:00
echo " <table width='100%' 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 " ;
}
2018-09-12 21:57:33 +02:00
if ( permission_exists ( 'device_line_server_address_primary' )) {
echo " <td class='vtable'> " . $text [ 'label-server_address_primary' ] . " </td> \n " ;
}
if ( permission_exists ( 'device_line_server_address_secondary' )) {
echo " <td class='vtable'> " . $text [ 'label-server_address_secondary' ] . " </td> \n " ;
}
if ( permission_exists ( 'device_line_outbound_proxy_primary' )) {
2016-07-27 05:00:05 +02:00
echo " <td class='vtable'> " . $text [ 'label-outbound_proxy_primary' ] . " </td> \n " ;
}
2018-09-12 21:57:33 +02:00
if ( permission_exists ( 'device_line_outbound_proxy_secondary' )) {
2016-07-27 05:00:05 +02:00
echo " <td class='vtable'> " . $text [ 'label-outbound_proxy_secondary' ] . " </td> \n " ;
}
2022-05-27 05:34:39 +02:00
if ( permission_exists ( 'device_line_label' )) {
echo " <td class='vtable'> " . $text [ 'label-label' ] . " </td> \n " ;
}
if ( permission_exists ( 'device_line_display_name' )) {
echo " <td class='vtable'> " . $text [ 'label-display_name' ] . " </td> \n " ;
}
2016-07-27 05:00:05 +02:00
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 " ;
}
2021-06-25 19:35:27 +02:00
if ( permission_exists ( 'device_line_port' )) {
echo " <td class='vtable'> " . $text [ 'label-sip_port' ] . " </td> \n " ;
}
2016-07-27 05:00:05 +02:00
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 " ;
2020-02-27 18:24:32 +01:00
if ( is_array ( $device_lines ) && @ sizeof ( $device_lines ) > 1 && permission_exists ( 'device_line_delete' )) {
2020-02-28 03:01:21 +01:00
echo " <td class='vtable edit_delete_checkbox_all' onmouseover= \" swap_display('delete_label_lines', 'delete_toggle_lines'); \" onmouseout= \" swap_display('delete_label_lines', 'delete_toggle_lines'); \" > \n " ;
echo " <span id='delete_label_lines'> " . $text [ 'label-delete' ] . " </span> \n " ;
echo " <span id='delete_toggle_lines'><input type='checkbox' id='checkbox_all_lines' name='checkbox_all' onclick= \" edit_all_toggle('lines'); \" ></span> \n " ;
echo " </td> \n " ;
2020-02-27 18:24:32 +01:00
}
2015-11-05 19:19:22 +01:00
echo " </tr> \n " ;
2014-01-20 19:00:45 +01:00
2015-11-05 19:19:22 +01:00
$x = 0 ;
2023-05-24 22:52:50 +02:00
foreach ( $device_lines as $row ) {
2016-07-27 05:00:05 +02:00
//set the defaults
if ( ! permission_exists ( 'device_line_server_address' )) {
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'server_address' ])) { $row [ 'server_address' ] = $_SESSION [ 'domain_name' ]; }
2016-07-27 05:00:05 +02:00
}
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'sip_transport' ])) { $row [ 'sip_transport' ] = $_SESSION [ 'provision' ][ 'line_sip_transport' ][ 'text' ]; }
2024-03-13 18:12:48 +01:00
if ( ! isset ( $row [ 'sip_port' ])) { $row [ 'sip_port' ] = $_SESSION [ 'provision' ][ 'line_sip_port' ][ 'numeric' ]; } //used !isset to support a value of 0 as empty the empty function considers a value of 0 as empty.
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'register_expires' ])) { $row [ 'register_expires' ] = $_SESSION [ 'provision' ][ 'line_register_expires' ][ 'numeric' ]; }
2016-07-27 05:00:05 +02:00
2015-11-05 19:19:22 +01:00
//add the primary key uuid
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_line_uuid' ]) && is_uuid ( $row [ 'device_line_uuid' ])) {
2018-06-08 22:01:07 +02:00
echo " <input name='device_lines[ " . $x . " ][device_line_uuid]' type='hidden' value= \" " . escape ( $row [ 'device_line_uuid' ]) . " \" /> \n " ;
2015-11-05 19:19:22 +01:00
}
2020-10-20 04:19:00 +02:00
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 \" " ;
2019-12-12 17:15:55 +01:00
echo " <select class='formfld' name='device_lines[ " . $x . " ][line_number]'> \n " ;
2015-11-05 19:19:22 +01:00
echo " <option value=''></option> \n " ;
2019-09-23 18:07:00 +02:00
for ( $n = 1 ; $n <= 99 ; $n ++ ) {
2023-07-03 16:26:19 +02:00
echo " <option value=' $n ' " . ( $row [ 'line_number' ] == " $n " ? $selected : " " ) . " > $n </option> \n " ;
2019-09-23 18:07:00 +02:00
}
2015-11-05 19:19:22 +01:00
echo " </select> \n " ;
echo " </td> \n " ;
2018-09-12 21:57:33 +02:00
2016-07-27 05:00:05 +02:00
if ( permission_exists ( 'device_line_server_address' )) {
echo " <td valign='top' align='left' nowrap='nowrap'> \n " ;
2019-10-27 02:53:21 +01:00
echo " <input class='formfld' style='min-width: 100px; width: 100%;' type='text' name='device_lines[ " . $x . " ][server_address]' maxlength='255' value= \" " . escape ( $row [ 'server_address' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
echo " </td> \n " ;
}
else {
2019-10-27 02:53:21 +01:00
echo " <input type='hidden' name='device_lines[ " . $x . " ][server_address]' value= \" " . escape ( $row [ 'server_address' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
}
2014-01-20 19:00:45 +01:00
2018-09-12 21:57:33 +02:00
if ( permission_exists ( 'device_line_server_address_primary' )) {
echo " <td valign='top' align='left' nowrap='nowrap'> \n " ;
2020-10-20 04:19:00 +02:00
if ( isset ( $_SESSION [ 'provision' ][ 'server_address_primary' ]) && ! isset ( $_SESSION [ 'provision' ][ 'server_address_primary' ][ 'text' ])) {
2020-07-11 04:30:25 +02:00
echo " <select class='formfld' style='width: 75px;' name='device_lines[ " . $x . " ][server_address_primary]'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $_SESSION [ 'provision' ][ 'server_address_primary' ] as $field ) {
echo " <option value=' " . $field . " ' " . (( $row [ 'server_address_primary' ] == $field ) ? " selected " : null ) . " > " . $field . " </option> \n " ;
}
echo " </select> \n " ;
}
2020-10-20 04:19:00 +02:00
else {
echo " <input class='formfld' style='width: 100px; width: 100%;' type='text' name='device_lines[ " . $x . " ][server_address_primary]' maxlength='255' value= \" " . escape ( $row [ 'server_address_primary' ]) . " \" /> \n " ;
}
2018-09-12 21:57:33 +02:00
echo " </td> \n " ;
}
2020-07-11 04:30:25 +02:00
2018-09-12 21:57:33 +02:00
if ( permission_exists ( 'device_line_server_address_secondary' )) {
echo " <td valign='top' align='left' nowrap='nowrap'> \n " ;
2020-10-20 04:19:00 +02:00
if ( isset ( $_SESSION [ 'provision' ][ 'server_address_secondary' ]) && ! isset ( $_SESSION [ 'provision' ][ 'server_address_secondary' ][ 'text' ])) {
2020-07-11 04:30:25 +02:00
echo " <select class='formfld' style='width: 75px;' name='device_lines[ " . $x . " ][server_address_secondary]'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $_SESSION [ 'provision' ][ 'server_address_secondary' ] as $field ) {
echo " <option value=' " . $field . " ' " . (( $row [ 'server_address_secondary' ] == $field ) ? " selected " : null ) . " > " . $field . " </option> \n " ;
}
echo " </select> \n " ;
}
2020-10-20 04:19:00 +02:00
else {
echo " <input class='formfld' style='width: 100px; width: 100%;' type='text' name='device_lines[ " . $x . " ][server_address_secondary]' maxlength='255' value= \" " . escape ( $row [ 'server_address_secondary' ]) . " \" /> \n " ;
}
2018-09-12 21:57:33 +02:00
echo " </td> \n " ;
}
if ( permission_exists ( 'device_line_outbound_proxy_primary' )) {
2016-07-27 05:00:05 +02:00
echo " <td align='left'> \n " ;
2020-10-20 04:19:00 +02:00
if ( isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ]) && ! isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ][ 'text' ])) {
2020-07-11 04:30:25 +02:00
echo " <select class='formfld' style='width: 75px;' name='device_lines[ " . $x . " ][outbound_proxy_primary]'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $_SESSION [ 'provision' ][ 'outbound_proxy_primary' ] as $field ) {
echo " <option value=' " . $field . " ' " . (( $row [ 'outbound_proxy_primary' ] == $field ) ? " selected " : null ) . " > " . $field . " </option> \n " ;
}
2022-05-27 05:34:39 +02:00
echo " </select> \n " ;
2020-07-11 04:30:25 +02:00
}
2020-10-20 04:19:00 +02:00
else {
echo " <input class='formfld' style='width: 65px;' type='text' name='device_lines[ " . $x . " ][outbound_proxy_primary]' placeholder= \" " . escape ( $text [ 'label-primary' ]) . " \" maxlength='255' value= \" " . escape ( $row [ 'outbound_proxy_primary' ]) . " \" /> \n " ;
}
2016-07-27 05:00:05 +02:00
echo " </td> \n " ;
}
2020-10-20 04:19:00 +02:00
2018-09-12 21:57:33 +02:00
if ( permission_exists ( 'device_line_outbound_proxy_secondary' )) {
2016-07-27 05:00:05 +02:00
echo " <td align='left'> \n " ;
2020-10-20 04:19:00 +02:00
if ( isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ]) && ! isset ( $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ][ 'text' ])) {
2020-07-11 04:30:25 +02:00
echo " <select class='formfld' style='width: 75px;' name='device_lines[ " . $x . " ][outbound_proxy_secondary]'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $_SESSION [ 'provision' ][ 'outbound_proxy_secondary' ] as $field ) {
echo " <option value=' " . $field . " ' " . (( $row [ 'outbound_proxy_secondary' ] == $field ) ? " selected " : null ) . " > " . $field . " </option> \n " ;
}
2022-05-27 05:34:39 +02:00
echo " </select> \n " ;
2020-07-11 04:30:25 +02:00
}
2020-10-20 04:19:00 +02:00
else {
echo " <input class='formfld' style='width: 65px;' type='text' name='device_lines[ " . $x . " ][outbound_proxy_secondary]' placeholder= \" " . escape ( $text [ 'label-secondary' ]) . " \" maxlength='255' value= \" " . escape ( $row [ 'outbound_proxy_secondary' ]) . " \" /> \n " ;
}
2016-07-27 05:00:05 +02:00
echo " </td> \n " ;
}
2022-05-27 05:34:39 +02:00
if ( permission_exists ( 'device_line_label' )) {
echo " <td align='left'> \n " ;
echo " <input class='formfld' style='min-width: 75px; width: 100%;' type='text' name='device_lines[ " . $x . " ][label]' maxlength='255' value= \" " . escape ( $row [ 'label' ]) . " \" /> \n " ;
echo " </td> \n " ;
}
if ( permission_exists ( 'device_line_display_name' )) {
echo " <td align='left'> \n " ;
echo " <input class='formfld' style='min-width: 75px; width: 100%;' type='text' name='device_lines[ " . $x . " ][display_name]' maxlength='255' value= \" " . escape ( $row [ 'display_name' ]) . " \" /> \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 " ;
2019-10-27 02:53:21 +01:00
echo " <input class='formfld' style='min-width: 50px; width: 100%; max-width: 80px;' type='text' name='device_lines[ " . $x . " ][user_id]' maxlength='255' autocomplete= \" new-password \" value= \" " . escape ( $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 " ;
2019-10-27 02:53:21 +01:00
echo " <input class='formfld' style='min-width: 50px; width: 100%; max-width: 80px;' type='text' name='device_lines[ " . $x . " ][auth_id]' maxlength='255' autocomplete= \" new-password \" value= \" " . escape ( $row [ 'auth_id' ]) . " \" /> \n " ;
2019-04-12 18:18:03 +02:00
echo " <input type='text' style='display: none;' disabled='disabled'> \n " ; //help defeat browser auto-fill
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 " ;
2019-04-12 18:18:03 +02:00
echo " <input type='password' style='display: none;' disabled='disabled'> " ; //help defeat browser auto-fill
2019-10-27 02:53:21 +01:00
echo " <input class='formfld' style='min-width: 75px; width: 100%;' 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= \" " . escape ( $row [ 'password' ]) . " \" /> \n " ;
2015-11-05 19:19:22 +01:00
echo " </td> \n " ;
}
2014-04-27 11:53:45 +02:00
2021-06-25 19:35:27 +02:00
if ( permission_exists ( 'device_line_port' )) {
echo " <td align='left'> \n " ;
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[ " . $x . " ][sip_port]' maxlength='255' value= \" " . escape ( $row [ 'sip_port' ]) . " \" /> \n " ;
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 " ;
2019-10-27 02:53:21 +01:00
echo " <select class='formfld' style='width: 75px;' name='device_lines[ " . $x . " ][sip_transport]'> \n " ;
2016-07-27 05:00:05 +02:00
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 {
2018-06-08 22:01:07 +02:00
echo " <input type='hidden' name='device_lines[ " . $x . " ][sip_transport]' value= \" " . escape ( $row [ 'sip_transport' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
}
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 " ;
2018-06-08 22:01:07 +02:00
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[ " . $x . " ][register_expires]' maxlength='255' value= \" " . escape ( $row [ 'register_expires' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
echo " </td> \n " ;
}
else {
2018-06-08 22:01:07 +02:00
echo " <input type='hidden' name='device_lines[ " . $x . " ][register_expires]' value= \" " . escape ( $row [ 'register_expires' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
}
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 " ;
2018-06-08 22:01:07 +02:00
echo " <input class='formfld' style='width: 50px;' type='text' name='device_lines[ " . $x . " ][shared_line]' maxlength='255' value= \" " . escape ( $row [ 'shared_line' ]) . " \" /> \n " ;
2018-01-23 06:41:55 +01:00
echo " </td> \n " ;
}
else {
2018-06-08 22:01:07 +02:00
echo " <input type='hidden' name='device_lines[ " . $x . " ][shared_line]' value= \" " . escape ( $row [ 'shared_line' ]) . " \" /> \n " ;
2018-01-23 06:41:55 +01:00
}
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 " ;
2023-05-24 22:52:50 +02:00
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' ])) {
2020-09-29 22:38:15 +02:00
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'> \n " ;
echo " <input type='checkbox' name='device_lines_delete[ " . $x . " ][checked]' value='true' class='chk_delete checkbox_lines' onclick= \" edit_delete_action('lines'); \" > \n " ;
echo " <input type='hidden' name='device_lines_delete[ " . $x . " ][uuid]' value=' " . escape ( $row [ 'device_line_uuid' ]) . " ' /> \n " ;
echo " <td> \n " ;
2015-11-05 19:19:22 +01:00
}
2020-02-27 18:24:32 +01:00
echo " </tr> \n " ;
//increment counter
$x ++ ;
2013-06-09 23:06:12 +02:00
}
2015-11-05 19:19:22 +01:00
echo " </table> \n " ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $text [ 'description-lines' ])) {
2015-11-05 19:19:22 +01:00
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
2023-11-02 01:43:53 +01:00
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 " <tr> " ;
echo " <td class='vncell' valign='top'> " . $text [ 'label-profile' ] . " </td> " ;
echo " <td class='vtable' align='left'> " ;
if ( permission_exists ( 'device_profile_select' )) {
echo " <select class='formfld' id='device_profile_uuid' name='device_profile_uuid'> \n " ;
echo " <option value=''></option> \n " ;
foreach ( $device_profiles as $row ) {
echo " <option value=' " . escape ( $row [ 'device_profile_uuid' ]) . " ' " . ( ! empty ( $device_profile_uuid ) && $row [ 'device_profile_uuid' ] == $device_profile_uuid ? " selected='selected' " : null ) . " > " . escape ( $row [ 'device_profile_name' ]) . " " . (( $row [ 'domain_uuid' ] == '' ) ? " ( " . $text [ 'select-global' ] . " ) " : null ) . " </option> \n " ;
}
echo " </select> \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 " <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='fas fa-pencil-alt'></span></button> " ;
echo " <button type='button' class='btn btn-default list_control_icon' onclick= \" window.location='device_profile_edit.php' \" ><span class='fas fa-plus'></span></button> " ;
}
echo " <br> " . $text [ 'description-profile2' ] . " \n " ;
echo " </td> " ;
echo " </tr> " ;
}
unset ( $sql , $parameters , $device_profiles );
}
2015-02-15 01:33:56 +01:00
2015-11-05 20:05:49 +01:00
if ( permission_exists ( 'device_key_edit' )) {
2023-04-04 16:57:41 +02:00
//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
2015-07-08 06:41:24 +02:00
$vendor_count = 0 ;
foreach ( $device_keys as $row ) {
2023-05-24 22:52:50 +02:00
if ( empty ( $row [ 'device_key_vendor' ]) || empty ( $previous_vendor ) || $previous_vendor != $row [ 'device_key_vendor' ]) {
$previous_vendor = $row [ 'device_key_vendor' ] ? ? null ;
2015-07-08 06:41:24 +02:00
$vendor_count ++ ;
}
}
2023-04-04 16:57:41 +02:00
//show the device keys html form
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 " ;
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_id' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_id' ] . " </td> \n " ;
}
2015-07-08 06:41:24 +02:00
echo " <td class='vtable'> " . $text [ 'label-device_key_type' ] . " </td> \n " ;
2023-04-04 16:57:41 +02:00
if ( $show_key_subtype ) {
echo " <td class='vtable'> " . $text [ 'label-device_key_subtype' ] . " </td> \n " ;
}
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_line' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_line' ] . " </td> \n " ;
}
2015-07-08 06:41:24 +02:00
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 " ;
2022-01-25 17:53:03 +01:00
if ( permission_exists ( 'device_key_icon' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_icon' ] . " </td> \n " ;
}
2020-02-27 18:24:32 +01:00
if ( is_array ( $device_keys ) && @ sizeof ( $device_keys ) > 1 && permission_exists ( 'device_key_delete' )) {
2020-02-28 03:01:21 +01:00
echo " <td class='vtable edit_delete_checkbox_all' onmouseover= \" swap_display('delete_label_keys', 'delete_toggle_keys'); \" onmouseout= \" swap_display('delete_label_keys', 'delete_toggle_keys'); \" > \n " ;
2023-11-25 00:29:46 +01:00
echo " <span id='delete_label_keys_ " . $row [ 'device_key_vendor' ] . " '> " . $text [ 'label-delete' ] . " </span> \n " ;
echo " <span id='delete_toggle_keys_ " . $row [ 'device_key_vendor' ] . " '><input type='checkbox' id='checkbox_all_keys' name='checkbox_all' onclick= \" edit_all_toggle('keys'); \" ></span> \n " ;
2020-02-28 03:01:21 +01:00
echo " </td> \n " ;
2020-02-27 18:24:32 +01:00
}
2015-07-08 06:41:24 +02:00
echo " </tr> \n " ;
}
2014-01-20 10:34:04 +01:00
2015-11-05 20:05:49 +01:00
$x = 0 ;
2023-11-25 00:29:46 +01:00
$device_keys_generic_header_displayed = false ;
2023-05-24 22:52:50 +02:00
foreach ( $device_keys as $row ) {
2015-11-05 20:05:49 +01:00
//set the column names
2023-11-25 00:29:46 +01:00
if (( empty ( $row [ 'device_key_vendor' ]) || empty ( $previous_device_key_vendor ) || $previous_device_key_vendor != $row [ 'device_key_vendor' ]) && ! $device_keys_generic_header_displayed ) {
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 " ;
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_id' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_id' ] . " </td> \n " ;
}
2023-05-05 18:46:37 +02:00
if ( $vendor_count > 1 && ! empty ( $row [ 'device_key_vendor' ])) {
2023-11-25 00:29:46 +01:00
echo " <td class='vtable'><i> " . ucwords ( $row [ 'device_key_vendor' ]) . " </i></td> \n " ;
2023-04-04 16:57:41 +02:00
if ( $show_key_subtype ) {
echo " <td class='vtable'> " . $text [ 'label-device_key_subtype' ] . " </td> \n " ;
}
}
else {
2023-11-25 00:29:46 +01:00
$device_keys_generic_header_displayed = true ;
2015-11-05 20:05:49 +01:00
echo " <td class='vtable'> " . $text [ 'label-device_key_type' ] . " </td> \n " ;
2023-04-04 16:57:41 +02:00
if ( $show_key_subtype ) {
echo " <td class='vtable'> " . $text [ 'label-device_key_subtype' ] . " </td> \n " ;
}
2015-07-08 06:41:24 +02:00
}
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_line' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_line' ] . " </td> \n " ;
}
2015-11-05 20:05:49 +01:00
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 " ;
2022-01-25 17:53:03 +01:00
if ( permission_exists ( 'device_key_icon' )) {
echo " <td class='vtable'> " . $text [ 'label-device_key_icon' ] . " </td> \n " ;
}
2023-11-25 00:29:46 +01:00
if ( is_array ( $device_keys ) && @ sizeof ( $device_keys ) > 1 && permission_exists ( 'device_key_delete' ) && ! $device_keys_generic_header_displayed ) {
echo " <td class='vtable edit_delete_checkbox_all' onmouseover= \" swap_display('delete_label_keys_ " . $row [ 'device_key_vendor' ] . " ', 'delete_toggle_keys_ " . $row [ 'device_key_vendor' ] . " '); \" onmouseout= \" swap_display('delete_label_keys_ " . $row [ 'device_key_vendor' ] . " ', 'delete_toggle_keys_ " . $row [ 'device_key_vendor' ] . " '); \" > \n " ;
echo " <span id='delete_label_keys_ " . $row [ 'device_key_vendor' ] . " '> " . $text [ 'label-delete' ] . " </span> \n " ;
echo " <span id='delete_toggle_keys_ " . $row [ 'device_key_vendor' ] . " '><input type='checkbox' id='checkbox_all_keys_ " . $row [ 'device_key_vendor' ] . " ' name='checkbox_all' onclick= \" edit_all_toggle('keys_ " . $row [ 'device_key_vendor' ] . " '); \" ></span> \n " ;
2020-02-28 03:01:21 +01:00
echo " </td> \n " ;
2020-02-27 18:24:32 +01:00
}
2015-11-05 20:05:49 +01:00
echo " </tr> \n " ;
}
2023-11-25 00:29:46 +01:00
2015-11-05 20:05:49 +01:00
//add the primary key uuid
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_key_uuid' ]) && is_uuid ( $row [ 'device_key_uuid' ])) {
2018-06-08 22:01:07 +02:00
echo " <input name='device_keys[ " . $x . " ][device_key_uuid]' type='hidden' value= \" " . escape ( $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 " ;
2023-11-24 23:13:52 +01:00
echo " <option value='line' " . ( $row [ 'device_key_category' ] == " line " ? " selected='selected' " : null ) . " > " . $text [ 'label-line' ] . " </option> \n " ;
2023-05-24 22:52:50 +02:00
if ( empty ( $row [ 'device_key_vendor' ]) || $row [ 'device_key_vendor' ] !== " polycom " ) {
2023-11-24 23:13:52 +01:00
echo " <option value='memory' " . ( $row [ 'device_key_category' ] == " memory " ? " selected='selected' " : null ) . " > " . $text [ 'label-memory' ] . " </option> \n " ;
2015-11-05 20:05:49 +01:00
}
2023-11-24 23:13:52 +01:00
echo " <option value='programmable' " . ( $row [ 'device_key_category' ] == " programmable " ? " selected='selected' " : null ) . " > " . $text [ 'label-programmable' ] . " </option> \n " ;
2023-05-24 22:52:50 +02:00
if ( empty ( $row [ 'device_key_vendor' ]) || $row [ 'device_key_vendor' ] !== " polycom " ) {
2023-05-05 18:46:37 +02:00
if ( empty ( $device_vendor )) {
2023-11-24 23:13:52 +01:00
echo " <option value='expansion' " . ( $row [ 'device_key_category' ] == " expansion " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 1</option> \n " ;
echo " <option value='expansion-2' " . ( $row [ 'device_key_category' ] == " expansion-2 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 2</option> \n " ;
echo " <option value='expansion-3' " . ( $row [ 'device_key_category' ] == " expansion-3 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 3</option> \n " ;
echo " <option value='expansion-4' " . ( $row [ 'device_key_category' ] == " expansion-4 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 4</option> \n " ;
echo " <option value='expansion-5' " . ( $row [ 'device_key_category' ] == " expansion-5 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 5</option> \n " ;
echo " <option value='expansion-6' " . ( $row [ 'device_key_category' ] == " expansion-6 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 6</option> \n " ;
2014-07-20 02:49:27 +02:00
}
else {
2023-05-24 22:52:50 +02:00
if (( ! empty ( $device_vendor ) && strtolower ( $device_vendor ) == " cisco " ) || ( ! empty ( $row [ 'device_key_vendor' ]) && strtolower ( $row [ 'device_key_vendor' ]) == " yealink " )) {
2023-11-24 23:13:52 +01:00
echo " <option value='expansion-1' " . ( $row [ 'device_key_category' ] == " expansion-1 " || $row [ 'device_key_category' ] == " expansion " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 1</option> \n " ;
echo " <option value='expansion-2' " . ( $row [ 'device_key_category' ] == " expansion-2 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 2</option> \n " ;
echo " <option value='expansion-3' " . ( $row [ 'device_key_category' ] == " expansion-3 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 3</option> \n " ;
echo " <option value='expansion-4' " . ( $row [ 'device_key_category' ] == " expansion-4 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 4</option> \n " ;
echo " <option value='expansion-5' " . ( $row [ 'device_key_category' ] == " expansion-5 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 5</option> \n " ;
echo " <option value='expansion-6' " . ( $row [ 'device_key_category' ] == " expansion-6 " ? " selected='selected' " : null ) . " > " . $text [ 'label-expansion' ] . " 6</option> \n " ;
2014-07-20 02:49:27 +02:00
}
else {
2023-11-24 23:13:52 +01:00
echo " <option value='expansion' " . ( $row [ 'device_key_category' ] == " expansion " ? " selected='selected' " : null ) . " > " . $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
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_id' )) {
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 " ;
for ( $i = 1 ; $i <= 255 ; $i ++ ) {
echo " <option value=' $i ' " . ( $row [ 'device_key_id' ] == $i ? " selected " : null ) . " > $i </option> \n " ;
}
echo " </select> \n " ;
echo " </td> \n " ;
2015-11-05 20:05:49 +01:00
}
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";
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'device_key_vendor' ])) {
2015-11-05 20:05:49 +01:00
$device_key_vendor = $row [ 'device_key_vendor' ];
}
else {
$device_key_vendor = $device_vendor ;
}
2020-02-27 18:24:32 +01:00
echo " <input type='hidden' id='key_vendor_ " . $x . " ' name='device_keys[ " . $x . " ][device_key_vendor]' value= \" " . $device_key_vendor . " \" /> \n " ;
2023-11-25 00:29:46 +01:00
echo " <select class='formfld' name='device_keys[ " . $x . " ][device_key_type]' id='key_type_ " . $x . " ' onchange= \" document.getElementById('key_vendor_ " . $x . " ').value = this.options[this.selectedIndex].getAttribute('vendor'); \" > \n " ;
2016-08-03 03:44:07 +02:00
echo " <option value=''></option> \n " ;
$previous_vendor = '' ;
$i = 0 ;
foreach ( $vendor_functions as $function ) {
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'device_key_vendor' ]) && $function [ 'vendor_name' ] != $previous_vendor ) {
2016-08-03 03:44:07 +02:00
if ( $i > 0 ) { echo " </optgroup> \n " ; }
echo " <optgroup label=' " . ucwords ( $function [ 'vendor_name' ]) . " '> \n " ;
}
$selected = '' ;
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_key_vendor' ]) && 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' " ;
}
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'device_key_vendor' ])) {
2023-05-25 19:42:37 +02:00
echo " <option value=' " . $function [ 'value' ] . " ' vendor=' " . $function [ 'vendor_name' ] . " ' $selected > " . ( $text [ 'label-' . $function [ 'type' ] ? ? '' ] ? ? $function [ 'value' ]) . " </option> \n " ;
2016-08-03 03:44:07 +02:00
}
2023-05-05 18:46:37 +02:00
if ( ! empty ( $row [ 'device_key_vendor' ]) && strtolower ( $row [ 'device_key_vendor' ]) == $function [ 'vendor_name' ]) {
2023-05-25 19:42:37 +02:00
echo " <option value=' " . $function [ 'value' ] . " ' vendor=' " . $function [ 'vendor_name' ] . " ' $selected > " . ( $text [ 'label-' . $function [ 'type' ] ? ? '' ] ? ? $function [ 'value' ]) . " </option> \n " ;
2016-08-03 03:44:07 +02:00
}
$previous_vendor = $function [ 'vendor_name' ];
$i ++ ;
}
2023-05-05 18:46:37 +02:00
if ( empty ( $row [ 'device_key_vendor' ])) {
2016-08-03 03:44:07 +02:00
echo " </optgroup> \n " ;
}
echo " </select> \n " ;
2015-11-05 20:05:49 +01:00
echo " </td> \n " ;
2023-04-04 16:57:41 +02:00
2023-04-10 17:29:02 +02:00
if ( $show_key_subtype ) {
echo " <td align='left'> \n " ;
echo " <input class='formfld' type='text' name='device_keys[ " . $x . " ][device_key_subtype]' style='width: 120px;' maxlength='255' value= \" " . escape ( $row [ 'device_key_subtype' ]) . " \" /> \n " ;
echo " </td> \n " ;
}
2023-04-04 16:57:41 +02:00
2020-04-16 01:33:22 +02:00
if ( permission_exists ( 'device_key_line' )) {
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 " ;
2022-10-03 18:40:23 +02:00
for ( $l = 0 ; $l <= 99 ; $l ++ ) {
2020-04-16 01:33:22 +02:00
echo " <option value=' " . $l . " ' " . (( $row [ 'device_key_line' ] == $l ) ? " selected='selected' " : null ) . " > " . $l . " </option> \n " ;
}
echo " </select> \n " ;
echo " </td> \n " ;
2015-11-05 20:05:49 +01:00
}
echo " <td align='left'> \n " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_keys[ " . $x . " ][device_key_value]' style='width: 220px;' maxlength='255' value= \" " . escape ( $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 " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_keys[ " . $x . " ][device_key_extension]' style='width: 110px;' maxlength='255' value= \" " . escape ( $row [ 'device_key_extension' ]) . " \" /> \n " ;
2016-07-27 05:00:05 +02:00
echo " </td> \n " ;
}
2015-11-05 20:05:49 +01:00
echo " <td align='left'> \n " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_keys[ " . $x . " ][device_key_label]' style='width: 220px;' maxlength='255' value= \" " . escape ( $row [ 'device_key_label' ]) . " \" /> \n " ;
2015-11-05 20:05:49 +01:00
echo " </td> \n " ;
2022-01-25 17:53:03 +01:00
if ( permission_exists ( 'device_key_icon' )) {
echo " <td align='left'> \n " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_keys[ " . $x . " ][device_key_icon]' style='width: 110px;' maxlength='255' value= \" " . escape ( $row [ 'device_key_icon' ]) . " \" /> \n " ;
2022-01-25 17:53:03 +01:00
echo " </td> \n " ;
}
2015-11-05 20:05:49 +01:00
2020-02-27 18:24:32 +01:00
if ( is_array ( $device_keys ) && @ sizeof ( $device_keys ) > 1 && permission_exists ( 'device_key_delete' )) {
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_key_uuid' ]) && is_uuid ( $row [ 'device_key_uuid' ])) {
2020-03-04 03:59:41 +01:00
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'> \n " ;
2023-11-25 00:29:46 +01:00
echo " <input type='checkbox' name='device_keys_delete[ " . $x . " ][checked]' value='true' class='chk_delete checkbox_keys_ " . $row [ 'device_key_vendor' ] . " ' onclick= \" edit_delete_action('keys'); \" > \n " ;
2020-02-27 18:24:32 +01:00
echo " <input type='hidden' name='device_keys_delete[ " . $x . " ][uuid]' value=' " . escape ( $row [ 'device_key_uuid' ]) . " ' /> \n " ;
2015-11-05 19:19:22 +01:00
}
2020-03-04 03:59:41 +01:00
else {
echo " <td> \n " ;
}
2015-11-05 20:05:49 +01:00
}
echo " </td> \n " ;
echo " </tr> \n " ;
//set the previous vendor
2023-05-24 22:52:50 +02:00
$previous_device_key_vendor = $row [ 'device_key_vendor' ] ? ? '' ;
2015-11-05 20:05:49 +01:00
//increment the array key
$x ++ ;
}
echo " </table> \n " ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $text [ 'description-keys' ])) {
2015-11-05 20:05:49 +01:00
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' )) {
2023-11-25 00:29:46 +01:00
$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 ;
}
}
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 " ;
2023-11-25 00:29:46 +01:00
if ( is_array ( $device_settings ) && @ sizeof ( $device_settings ) > 1 && permission_exists ( 'device_setting_delete' ) && $device_setting_exists ) {
2020-02-28 03:01:21 +01:00
echo " <td class='vtable edit_delete_checkbox_all' onmouseover= \" swap_display('delete_label_settings', 'delete_toggle_settings'); \" onmouseout= \" swap_display('delete_label_settings', 'delete_toggle_settings'); \" > \n " ;
echo " <span id='delete_label_settings'> " . $text [ 'label-delete' ] . " </span> \n " ;
echo " <span id='delete_toggle_settings'><input type='checkbox' id='checkbox_all_settings' name='checkbox_all' onclick= \" edit_all_toggle('settings'); \" ></span> \n " ;
echo " </td> \n " ;
2020-02-27 18:24:32 +01:00
}
2013-12-10 16:05:16 +01:00
echo " </tr> \n " ;
2014-01-20 10:34:04 +01:00
$x = 0 ;
2023-05-24 22:52:50 +02:00
foreach ( $device_settings as $row ) {
2014-01-20 19:00:45 +01:00
//add the primary key uuid
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_setting_uuid' ]) && is_uuid ( $row [ 'device_setting_uuid' ])) {
2018-06-08 22:01:07 +02:00
echo " <input name='device_settings[ " . $x . " ][device_setting_uuid]' type='hidden' value= \" " . escape ( $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 " ;
2020-02-27 18:24:32 +01:00
2015-05-19 18:09:04 +02:00
echo " <td align='left'> \n " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_settings[ " . $x . " ][device_setting_subcategory]' style='width: 220px;' maxlength='255' value= \" " . escape ( $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 " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_settings[ " . $x . " ][device_setting_value]' style='width: 220px;' maxlength='255' value= \" " . escape ( $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 " ;
2019-09-23 17:29:06 +02:00
echo " <select class='formfld' name='device_settings[ " . $x . " ][device_setting_enabled]' style='width: 90px;'> \n " ;
2020-02-28 03:01:21 +01:00
echo " <option value='true'> " . $text [ 'label-true' ] . " </option> \n " ;
2023-05-24 22:52:50 +02:00
echo " <option value='false' " . ( ! empty ( $row [ 'device_setting_enabled' ]) && $row [ 'device_setting_enabled' ] == " false " ? " selected='selected' " : null ) . " > " . $text [ 'label-false' ] . " </option> \n " ;
2019-09-23 17:29:06 +02:00
echo " </select> \n " ;
2014-01-20 19:00:45 +01:00
echo " </td> \n " ;
2013-12-10 16:05:16 +01:00
2015-05-19 18:09:04 +02:00
echo " <td align='left'> \n " ;
2023-10-27 20:45:25 +02:00
echo " <input class='formfld' type='text' name='device_settings[ " . $x . " ][device_setting_description]' style='width: 220px;' maxlength='255' value= \" " . escape ( $row [ 'device_setting_description' ]) . " \" /> \n " ;
2014-01-20 19:00:45 +01:00
echo " </td> \n " ;
2013-12-10 16:05:16 +01:00
2020-02-27 18:24:32 +01:00
if ( is_array ( $device_settings ) && @ sizeof ( $device_settings ) > 1 && permission_exists ( 'device_setting_delete' )) {
2023-05-24 22:52:50 +02:00
if ( ! empty ( $row [ 'device_setting_uuid' ]) && is_uuid ( $row [ 'device_setting_uuid' ])) {
2020-03-04 03:59:41 +01:00
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'> \n " ;
2020-02-28 03:01:21 +01:00
echo " <input type='checkbox' name='device_settings_delete[ " . $x . " ][checked]' value='true' class='chk_delete checkbox_settings' onclick= \" edit_delete_action('settings'); \" > \n " ;
2020-02-27 18:24:32 +01:00
echo " <input type='hidden' name='device_settings_delete[ " . $x . " ][uuid]' value=' " . escape ( $row [ 'device_setting_uuid' ]) . " ' /> \n " ;
2014-01-20 19:00:45 +01:00
}
2020-03-04 03:59:41 +01:00
else {
echo " <td> \n " ;
}
2020-02-27 18:24:32 +01:00
echo " </td> \n " ;
2014-01-20 19:00:45 +01:00
}
2020-02-27 18:24:32 +01:00
echo " </tr> \n " ;
2014-01-20 19:00:45 +01:00
$x ++ ;
}
2020-02-27 18:24:32 +01:00
echo " </table> \n " ;
2023-05-05 18:46:37 +02:00
if ( ! empty ( $text [ 'description-settings' ])) {
2020-02-27 18:24:32 +01:00
echo " <br> " . $text [ 'description-settings' ] . " \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 ) {
2023-05-24 22:52:50 +02:00
$selected = ! empty ( $device_user_uuid ) && $field [ 'user_uuid' ] == $device_user_uuid ? " selected='selected' " : null ;
echo " <option value=' " . escape ( $field [ 'user_uuid' ]) . " ' " . $selected . " > " . escape ( $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 " ;
2023-05-24 22:52:50 +02:00
echo " <input class='formfld' type='text' name='device_username' id='device_username' autocomplete= \" new-password \" maxlength='255' placeholder= \" " . $text [ 'label-device_username' ] . " \" value= \" " . escape ( $device_username ? ? '' ) . " \" /> \n " ;
echo " <input class='formfld' type='password' name='device_password' id='device_password' autocomplete= \" new-password \" 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= \" " . escape ( $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
2023-05-24 22:52:50 +02:00
if ( permission_exists ( 'device_alternate' ) && ! empty ( $device_uuid_alternate ) && is_uuid ( $device_uuid_alternate )) {
2015-11-05 19:19:22 +01:00
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 " ;
2018-11-03 18:54:11 +01:00
$label = $device_alternate [ 0 ][ 'device_label' ];
2023-05-05 18:46:37 +02:00
if ( empty ( $label )) { $label = $device_alternate [ 0 ][ 'device_description' ]; }
2023-06-30 07:40:11 +02:00
if ( empty ( $label )) { $label = $device_alternate [ 0 ][ 'device_address' ]; }
2018-11-03 18:54:11 +01:00
echo " <table> \n " ;
echo " <tr> \n " ;
echo " <td><a href='?id= " . escape ( $device_uuid_alternate ) . " ' id='device_uuid_alternate_link'> " . escape ( $label ) . " </a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value= \" " . escape ( $device_uuid_alternate ) . " \" /> </td> " ;
2019-09-23 17:29:06 +02: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 " ;
2018-11-03 18:54:11 +01:00
echo " </tr> \n " ;
echo " </table> \n " ;
unset ( $label );
2015-11-05 19:19:22 +01:00
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 " ;
2018-06-08 22:01:07 +02:00
echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value= \" " . escape ( $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
2022-01-18 07:53:55 +01:00
if ( permission_exists ( 'device_location' )) {
echo " <tr> \n " ;
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'> \n " ;
echo " " . $text [ 'label-device_location' ] . " \n " ;
echo " </td> \n " ;
echo " <td class='vtable' align='left'> \n " ;
2023-05-24 22:52:50 +02:00
echo " <input class='formfld' type='text' name='device_location' maxlength='255' value= \" " . escape ( $device_location ? ? '' ) . " \" /> \n " ;
2022-01-18 07:53:55 +01:00
echo " <br /> \n " ;
echo $text [ 'description-device_location' ] . " \n " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
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 " ;
2018-06-08 22:01:07 +02:00
echo " <input class='formfld' type='text' name='device_model' maxlength='255' value= \" " . escape ( $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 " ;
2018-06-08 22:01:07 +02:00
echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value= \" " . escape ( $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 " ;
2019-09-23 17:29:06 +02:00
echo " <select class='formfld' name='domain_uuid' id='domain_uuid'> \n " ;
2019-08-04 04:21:56 +02:00
if ( ! is_uuid ( $domain_uuid )) {
2019-09-23 17:29:06 +02:00
echo " <option value='' selected='selected'> " . $text [ 'select-global' ] . " </option> \n " ;
2014-05-08 11:22:35 +02:00
}
else {
2019-09-23 17:29:06 +02:00
echo " <option value=''> " . $text [ 'select-global' ] . " </option> \n " ;
2014-05-08 11:22:35 +02:00
}
foreach ( $_SESSION [ 'domains' ] as $row ) {
if ( $row [ 'domain_uuid' ] == $domain_uuid ) {
2019-09-23 17:29:06 +02:00
echo " <option value=' " . escape ( $row [ 'domain_uuid' ]) . " ' selected='selected'> " . escape ( $row [ 'domain_name' ]) . " </option> \n " ;
2014-05-08 11:22:35 +02:00
}
else {
2019-09-23 17:29:06 +02:00
echo " <option value=' " . escape ( $row [ 'domain_uuid' ]) . " '> " . escape ( $row [ 'domain_name' ]) . " </option> \n " ;
2014-05-08 11:22:35 +02:00
}
}
2019-09-23 17:29:06 +02:00
echo " </select> \n " ;
2014-05-08 11:22:35 +02:00
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 " ;
2023-02-10 19:14:43 +01:00
if ( substr ( $_SESSION [ 'theme' ][ 'input_toggle_style' ][ 'text' ], 0 , 6 ) == 'switch' ) {
echo " <label class='switch'> \n " ;
echo " <input type='checkbox' id='device_enabled' name='device_enabled' value='true' " . ( $device_enabled == 'true' ? " checked='checked' " : null ) . " > \n " ;
echo " <span class='slider'></span> \n " ;
echo " </label> \n " ;
2015-11-05 19:19:22 +01:00
}
else {
2023-02-10 19:14:43 +01:00
echo " <select class='formfld' id='device_enabled' name='device_enabled'> \n " ;
echo " <option value='true' " . ( $device_enabled == 'true' ? " selected='selected' " : null ) . " > " . $text [ 'option-true' ] . " </option> \n " ;
2023-02-14 19:19:02 +01:00
echo " <option value='false' " . ( $device_enabled == 'false' ? " selected='selected' " : null ) . " > " . $text [ 'option-false' ] . " </option> \n " ;
2023-02-10 19:14:43 +01:00
echo " </select> \n " ;
2015-11-05 19:19:22 +01:00
}
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' )) {
2023-05-24 22:52:50 +02:00
echo " <input class='formfld' type='text' name='device_description' maxlength='255' value= \" " . escape ( $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 {
2018-06-08 22:01:07 +02:00
echo escape ( $device_description ) . " \n " ;
2015-11-05 19:56:50 +01:00
}
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 " ) {
2018-06-08 22:01:07 +02:00
echo " <input type='hidden' name='device_uuid' value=' " . escape ( $device_uuid ) . " '/> \n " ;
2012-06-04 16:58:40 +02:00
}
2019-09-23 18:07:00 +02:00
echo " <input type='hidden' name=' " . $token [ 'name' ] . " ' value=' " . $token [ 'hash' ] . " '> \n " ;
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
echo " </tr> " ;
echo " </table> " ;
2024-09-06 19:20:03 +02:00
echo " </div> \n " ;
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 " ;
2020-03-05 01:54:47 +01:00
// trigger initial onchage to set button state
2019-08-19 18:51:21 +02:00
echo " $ (window).on('load', function(event) { \n " ;
2020-03-05 01:54:47 +01:00
echo " $ ('#device_profile_uuid').trigger('change') " ;
2016-08-15 19:27:35 +02:00
echo " }); \n " ;
2020-03-05 01:54:47 +01:00
//capture device selection events
echo " $ ('#device_profile_uuid').on('change',function(event) { \n " ;
echo " if (this.value == '') { \$ ('#device_profile_edit').hide()} else { \$ ('#device_profile_edit').show()} \n " ;
2016-08-15 19:27:35 +02:00
echo " }); \n " ;
2020-03-05 01:54:47 +01:00
//hide password fields before submit
2016-02-26 02:19:51 +01:00
echo " function submit_form() { \n " ;
2020-03-05 01:54:47 +01:00
echo " hide_password_fields(); \n " ;
2016-02-26 02:19:51 +01:00
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
2024-09-06 19:20:03 +02:00
?>