2012-07-05 20:22:02 +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>
|
2019-05-01 07:09:24 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
2012-07-05 20:22:02 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2017-01-13 07:47:44 +01:00
|
|
|
//process this code online once
|
|
|
|
|
if ($domains_processed == 1) {
|
2017-11-14 07:41:02 +01:00
|
|
|
|
2017-01-13 07:47:44 +01:00
|
|
|
//normalize the mac address
|
2023-06-30 07:40:11 +02:00
|
|
|
$sql = "select device_uuid, device_address ";
|
2013-04-10 00:33:42 +02:00
|
|
|
$sql .= "from v_devices ";
|
2023-06-30 07:40:11 +02:00
|
|
|
$sql .= "where (device_address like '%-%' or device_address like '%:%') ";
|
2019-08-29 05:02:08 +02:00
|
|
|
$result = $database->select($sql, null, 'all');
|
2024-06-23 03:28:04 +02:00
|
|
|
if (!empty($result)) {
|
2019-08-29 05:02:08 +02:00
|
|
|
foreach ($result as $row) {
|
|
|
|
|
//define update values
|
2017-01-10 09:03:27 +01:00
|
|
|
$device_uuid = $row["device_uuid"];
|
2023-06-30 07:40:11 +02:00
|
|
|
$device_address = $row["device_address"];
|
|
|
|
|
$device_address = strtolower($device_address);
|
|
|
|
|
$device_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_address);
|
2019-08-29 05:02:08 +02:00
|
|
|
//build update array
|
|
|
|
|
$array['devices'][0]['device_uuid'] = $device_uuid;
|
2023-06-30 07:40:11 +02:00
|
|
|
$array['devices'][0]['device_address'] = $device_address;
|
2019-08-29 05:02:08 +02:00
|
|
|
//grant temporary permissions
|
2024-11-29 21:57:01 +01:00
|
|
|
$p = permissions::new();
|
2019-08-29 05:02:08 +02:00
|
|
|
$p->add('device_add', 'temp');
|
|
|
|
|
//execute update
|
|
|
|
|
$database->app_name = 'provision';
|
|
|
|
|
$database->app_uuid = 'abf28ead-92ef-3de6-ebbb-023fbc2b6dd3';
|
2021-12-24 20:42:16 +01:00
|
|
|
$database->save($array, false);
|
2019-08-29 05:02:08 +02:00
|
|
|
unset($array);
|
|
|
|
|
//revoke temporary permissions
|
|
|
|
|
$p->delete('device_add', 'temp');
|
2012-07-05 20:22:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 03:28:04 +02:00
|
|
|
unset($sql, $result, $row, $p);
|
2017-11-14 07:41:02 +01:00
|
|
|
|
2019-05-01 07:09:24 +02:00
|
|
|
//update http_auth_enabled set to true
|
2020-03-23 23:28:41 +01:00
|
|
|
$sql = "select count(*) from v_default_settings ";
|
2019-05-01 07:09:24 +02:00
|
|
|
$sql .= "where default_setting_subcategory = 'http_auth_disable' ";
|
2020-03-23 23:28:41 +01:00
|
|
|
if ($database->select($sql, null, 'column') > 0) {
|
|
|
|
|
//build update array
|
|
|
|
|
$array['default_settings'][$x]['default_setting_uuid'] = 'c998c762-6a43-4911-a465-a9653eeb793d';
|
|
|
|
|
$array['default_settings'][$x]['default_setting_subcategory'] = 'http_auth_enabled';
|
|
|
|
|
$array['default_settings'][$x]['default_setting_value'] = 'true';
|
|
|
|
|
$array['default_settings'][$x]['default_setting_enabled'] = 'true';
|
|
|
|
|
|
|
|
|
|
//grant temporary permissions
|
2024-11-29 21:57:01 +01:00
|
|
|
$p = permissions::new();
|
2020-03-23 23:28:41 +01:00
|
|
|
$p->add('default_setting_edit', 'temp');
|
2019-08-29 05:02:08 +02:00
|
|
|
|
2020-03-23 23:28:41 +01:00
|
|
|
//execute update
|
|
|
|
|
$database->app_name = 'provision';
|
|
|
|
|
$database->app_uuid = 'abf28ead-92ef-3de6-ebbb-023fbc2b6dd3';
|
2021-12-24 20:42:16 +01:00
|
|
|
$database->save($array, false);
|
2020-03-23 23:28:41 +01:00
|
|
|
unset($array);
|
|
|
|
|
|
2024-06-23 03:28:04 +02:00
|
|
|
//revoke temporary permissions
|
2020-03-23 23:28:41 +01:00
|
|
|
$p->delete('default_setting_edit', 'temp');
|
2024-06-23 03:28:04 +02:00
|
|
|
unset($p);
|
2019-05-01 07:09:24 +02:00
|
|
|
}
|
2020-03-23 23:28:41 +01:00
|
|
|
unset($sql);
|
2019-05-01 07:09:24 +02:00
|
|
|
|
2024-10-23 02:58:03 +02:00
|
|
|
//update default settings in category provision set enabled to use type boolean
|
|
|
|
|
$sql = "update v_default_settings ";
|
|
|
|
|
$sql .= "set default_setting_name = 'boolean' ";
|
|
|
|
|
$sql .= "where default_setting_category = 'provision' ";
|
|
|
|
|
$sql .= "and default_setting_subcategory = 'enabled' ";
|
|
|
|
|
$sql .= "and default_setting_name <> 'boolean' ";
|
|
|
|
|
$database->execute($sql);
|
|
|
|
|
|
2018-03-18 00:50:32 +01:00
|
|
|
//update default settings
|
2017-11-14 07:41:02 +01:00
|
|
|
$sql = "update v_default_settings set ";
|
|
|
|
|
$sql .= "default_setting_value = 'true', ";
|
|
|
|
|
$sql .= "default_setting_name = 'boolean', ";
|
|
|
|
|
$sql .= "default_setting_enabled = 'true' ";
|
2018-10-25 02:30:39 +02:00
|
|
|
$sql .= "where default_setting_category = 'provision' ";
|
|
|
|
|
$sql .= "and default_setting_subcategory = 'http_domain_filter' ";
|
2017-11-14 07:41:02 +01:00
|
|
|
$sql .= "and default_setting_name = 'text' ";
|
|
|
|
|
$sql .= "and default_setting_value = 'false' ";
|
|
|
|
|
$sql .= "and default_setting_enabled = 'false' ";
|
2019-08-29 05:02:08 +02:00
|
|
|
$database->execute($sql);
|
2017-11-14 07:41:02 +01:00
|
|
|
|
2018-03-18 00:50:32 +01:00
|
|
|
//update default settings
|
|
|
|
|
$sql = "update v_default_settings set ";
|
|
|
|
|
$sql .= "default_setting_name = 'array' ";
|
2018-10-25 02:30:39 +02:00
|
|
|
$sql .= "where default_setting_category = 'provision' ";
|
|
|
|
|
$sql .= "and default_setting_subcategory = 'http_auth_password' ";
|
2018-03-18 00:50:32 +01:00
|
|
|
$sql .= "and default_setting_name = 'text' ";
|
2019-08-29 05:02:08 +02:00
|
|
|
$database->execute($sql);
|
2018-03-18 00:50:32 +01:00
|
|
|
|
|
|
|
|
//update domain settings
|
|
|
|
|
$sql = "update v_domain_settings set ";
|
|
|
|
|
$sql .= "domain_setting_name = 'array' ";
|
2018-10-25 02:30:39 +02:00
|
|
|
$sql .= "where domain_setting_category = 'provision' ";
|
|
|
|
|
$sql .= "and domain_setting_subcategory = 'http_auth_password' ";
|
2018-03-18 00:50:32 +01:00
|
|
|
$sql .= "and domain_setting_name = 'text' ";
|
2019-08-29 05:02:08 +02:00
|
|
|
$database->execute($sql);
|
2018-03-18 00:50:32 +01:00
|
|
|
|
2024-10-23 23:10:31 +02:00
|
|
|
//update if the type is boolean with value of 0 or 1 use type text, or if type numeric use type text.
|
|
|
|
|
//explanation: the template default setting use string for the template values, boolean type only used with conditions
|
|
|
|
|
$sql = "update v_default_settings ";
|
|
|
|
|
$sql .= "set default_setting_name = 'text' ";
|
|
|
|
|
$sql .= "where ";
|
|
|
|
|
$sql .= "( ";
|
|
|
|
|
$sql .= " default_setting_category = 'provision' ";
|
|
|
|
|
$sql .= " and default_setting_value in ('0', '1') ";
|
|
|
|
|
$sql .= " and default_setting_name = 'boolean' ";
|
|
|
|
|
$sql .= ") ";
|
|
|
|
|
$sql .= "or ";
|
|
|
|
|
$sql .= "( ";
|
|
|
|
|
$sql .= "default_setting_category = 'provision' ";
|
|
|
|
|
$sql .= "and default_setting_name = 'numeric' ";
|
|
|
|
|
$sql .= ") ";
|
|
|
|
|
$database->execute($sql);
|
|
|
|
|
|
2017-01-12 23:46:33 +01:00
|
|
|
}
|
2012-08-12 00:52:50 +02:00
|
|
|
|
2016-10-23 01:20:24 +02:00
|
|
|
?>
|