Closed gianlucagiacometti closed 1 year ago
I made some tests. It seems that some arrays are not initialised in variables.inc.php both in the main and in modules. I tied to correct this by putting something like
if (!@is_array($__FM_CONFIG['logging']['categories'])) $__FM_CONFIG['logging']['categories'] = array();
both in sort() and array_merge() functions.
I have to delete the cookies to get the prompt again, but when I log in I get a blank page with lòo errors in the logs
I got a bit further myself, thanks to a quick note from @gianlucagiacometti , I moved the array declaration to the top of the file. Had to add another declaration in another file, and had to disable strict mode for mysqli with notes found in here: https://php.watch/versions/8.1/mysqli-error-mode. I am not sure if there are cleaner ways to handle these changes.
This is now the new error I am getting, and am too tired to go further. Maybe someone else can tag-team a fix. My changes below.
[01-Sep-2022 00:04:49 America/Chicago] PHP Fatal error: Uncaught TypeError: mysqli_free_result(): Argument #1 ($result) must be of type mysqli_result, array given in /opt/dnsadmin/fm-modules/facileManager/classes/class_logins.php:313
Stack trace:
#0 /opt/dnsadmin/fm-modules/facileManager/classes/class_logins.php(313): mysqli_free_result()
#1 /opt/dnsadmin/fm-init.php(132): fm_login->checkPassword()
#2 /opt/dnsadmin/index.php(38): require('...')
#3 {main}
thrown in /opt/dnsadmin/fm-modules/facileManager/classes/class_logins.php on line 313
The changes I made so far are:
diff -ur /opt/facileManager/server/ .
Only in .: config.inc.php
diff -ur /opt/facileManager/server/fm-includes/fm-db.php ./fm-includes/fm-db.php
--- /opt/facileManager/server/fm-includes/fm-db.php 2020-11-11 10:12:19.000000000 -0600
+++ ./fm-includes/fm-db.php 2022-09-01 00:01:09.001539271 -0500
@@ -137,6 +137,9 @@
private function connect($dbuser, $dbpassword, $dbname, $dbhost, $connect_options = 'full check') {
global $__FM_CONFIG;
+
+ /* Disable MySQLi strict errors */
+ mysqli_report(MYSQLI_REPORT_OFF);
if ($this->use_mysqli) {
$this->dbh = @mysqli_init();
@@ -309,4 +312,4 @@
}
-?>
\ No newline at end of file
+?>
diff -ur /opt/facileManager/server/fm-modules/facileManager/variables.inc.php ./fm-modules/facileManager/variables.inc.php
--- /opt/facileManager/server/fm-modules/facileManager/variables.inc.php 2020-10-23 18:21:59.000000000 -0500
+++ ./fm-modules/facileManager/variables.inc.php 2022-08-31 23:21:18.038666438 -0500
@@ -40,6 +40,7 @@
$GLOBALS['FM_URL'] = $GLOBALS['REQUEST_PROTOCOL'] . '://' . $_SERVER['HTTP_HOST'] . $GLOBALS['RELPATH'];
if (!@is_array($__FM_CONFIG)) $__FM_CONFIG = array();
+if (!@is_array($__FM_CONFIG['logging']['categories'])) $__FM_CONFIG['logging']['categories'] = array();
/** Images */
$__FM_CONFIG['icons']['fail'] = sprintf('<i class="fa fa-times fa-lg fail" alt="%1$s" title="%1$s" aria-hidden="true"></i>', _('Failed'));
diff -ur /opt/facileManager/server/fm-modules/fmDNS/variables.inc.php ./fm-modules/fmDNS/variables.inc.php
--- /opt/facileManager/server/fm-modules/fmDNS/variables.inc.php 2022-06-29 14:54:56.000000000 -0500
+++ ./fm-modules/fmDNS/variables.inc.php 2022-09-01 00:04:05.832652143 -0500
@@ -28,6 +28,7 @@
*/
if (!@is_array($__FM_CONFIG)) $__FM_CONFIG = array();
+if (!@is_array($__FM_CONFIG['icons'])) $__FM_CONFIG['icons'] = array();
/** Module Information */
$__FM_CONFIG['fmDNS'] = array(
Signed up just to comment. I recently ran into the same issue(s) after upgrading Ubuntu. I am not a php guru, but here are the changes I made that get things back to a somewhat usable state, and fixed some warnings.
diff -ur ./fm-includes/fm-db.php /var/www/html/facileManager/fm-includes/fm-db.php
--- ./fm-includes/fm-db.php 2022-09-24 10:13:32.074742609 -0700
+++ /var/www/html/facileManager/fm-includes/fm-db.php 2022-09-24 10:46:17.134849319 -0700
@@ -138,12 +138,15 @@
private function connect($dbuser, $dbpassword, $dbname, $dbhost, $connect_options = 'full check') {
global $__FM_CONFIG;
+ /* Disable MySQLi strict errors */
+ mysqli_report(MYSQLI_REPORT_OFF);
+
if ($this->use_mysqli) {
$this->dbh = @mysqli_init();
/** Set SSL */
if (isset($__FM_CONFIG['db']['key'])) {
- mysqli_ssl_set($this->dbh, $__FM_CONFIG['db']['key'], $__FM_CONFIG['db']['cert'], $__FM_CONFIG['db']['ca'], $__FM_CONFIG['db']['capth'], $__FM_CONFIG['db']['cipher']);
+ mysqli_ssl_set($this->dbh, $__FM_CONFIG['db']['key'], $__FM_CONFIG['db']['cert'], $__FM_CONFIG['db']['ca'], $__FM_CONFIG['db']['capath'], $__FM_CONFIG['db']['cipher']);
}
if (!@mysqli_real_connect($this->dbh, $dbhost, $dbuser, $dbpassword)) {
@@ -309,4 +312,4 @@
}
-?>
\ No newline at end of file
+?>
diff -ur ./fm-modules/facileManager/functions.php /var/www/html/facileManager/fm-modules/facileManager/functions.php
--- ./fm-modules/facileManager/functions.php 2022-09-24 10:13:32.082742642 -0700
+++ /var/www/html/facileManager/fm-modules/facileManager/functions.php 2022-09-24 19:13:40.739390705 -0700
@@ -408,7 +408,7 @@
</div>
HTML;
- if (FM_INCLUDE_SEARCH === true) {
+ if ('FM_INCLUDE_SEARCH' === true) {
$search = '<div id="topheadpartright">
<a class="single_line search" href="#" title="' . _('Search this page') . '"><i class="fa fa-search fa-lg"></i></a>' .
displaySearchForm() . '</div>';
@@ -532,7 +532,7 @@
}
/** Build submenus */
- if (!count($classes) && count($filtered_submenu[$slug]) > 1) {
+ if (!count($classes) && count((array)$filtered_submenu[$slug]) > 1) {
array_push($classes, 'has-sub');
foreach ($filtered_submenu[$slug] as $submenu_array) {
if (!empty($submenu_array[0])) {
@@ -864,8 +864,8 @@
$type_options.="<option$selected value=\"{$options[$i][1]}\">{$options[$i][0]}</option>\n";
}
} else {
- for ($i = 0; $i < count($options); $i++) {
- $selected = ($option_select == $options[$i] || @in_array($options[$i], $option_select)) ? ' selected' : '';
+ for ($i = 0; $i < count((array)$options); $i++) {
+ $selected = ($option_select == $options[$i] || @in_array($options[$i], (array) $option_select)) ? ' selected' : '';
$type_options.="<option$selected>$options[$i]</option>\n";
}
}
@@ -3155,6 +3155,7 @@
* @return int Number of dimensions
*/
function countArrayDimensions($array) {
+ if (!@is_array($array)) $array = array();
if (is_array(@reset($array))) {
$count = countArrayDimensions(reset($array)) + 1;
} else {
@@ -3307,7 +3308,7 @@
global $fm_name;
/** Check if super admin */
- if (@array_key_exists('do_everything', $allowed_capabilities[$fm_name])) return true;
+ if (@array_key_exists('do_everything', (array)$allowed_capabilities[$fm_name])) return true;
/** Handle multiple capabilities */
if (is_array($capability)) {
@@ -3322,7 +3323,7 @@
}
/** Check capability */
- if (@array_key_exists($capability, $allowed_capabilities[$module])) {
+ if (@array_key_exists($capability, (array)$allowed_capabilities[$module])) {
if (is_array($allowed_capabilities[$module][$capability])) {
/** Explode module groups */
foreach ($allowed_capabilities[$module][$capability] as $cap_id) {
diff -ur ./fm-modules/facileManager/variables.inc.php /var/www/html/facileManager/fm-modules/facileManager/variables.inc.php
--- ./fm-modules/facileManager/variables.inc.php 2022-09-24 10:13:32.094742691 -0700
+++ /var/www/html/facileManager/fm-modules/facileManager/variables.inc.php 2022-09-24 10:08:46.433566231 -0700
@@ -40,6 +40,7 @@
$GLOBALS['FM_URL'] = $GLOBALS['REQUEST_PROTOCOL'] . '://' . $_SERVER['HTTP_HOST'] . $GLOBALS['RELPATH'];
if (!@is_array($__FM_CONFIG)) $__FM_CONFIG = array();
+if (!@is_array($__FM_CONFIG['logging']['categories'])) $__FM_CONFIG['logging']['categories'] = array();
/** Images */
$__FM_CONFIG['icons']['fail'] = sprintf('<i class="fa fa-times fa-lg fail" alt="%1$s" title="%1$s" aria-hidden="true"></i>', _('Failed'));
diff -ur ./fm-modules/fmDHCP/classes/class_hosts.php /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_hosts.php
--- ./fm-modules/fmDHCP/classes/class_hosts.php 2022-09-24 10:13:32.094742691 -0700
+++ /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_hosts.php 2022-09-24 15:46:56.946115212 -0700
@@ -147,10 +147,10 @@
/** Get child elements */
if (!isset($hardware_address_entry)) {
- $hardware_address_entry = explode(' ', $this->getConfig($config_id, 'hardware'));
+ $hardware_address_entry = $config_id ? explode(' ', $this->getConfig($config_id, 'hardware')): "";
}
$hardware_address = isset($hardware_address_entry[1]) ? $hardware_address_entry[1] : null;
- $hw_address_types = buildSelect('hardware-type', 'hardware-type', $hw_address_types, $hardware_address_entry[0]);
+ $hw_address_types = buildSelect('hardware-type', 'hardware-type', $hw_address_types, !empty($hardware_address_entry));
if (!isset($fixed_address)) {
$fixed_address = $this->getConfig($config_id, 'fixed-address');
}
diff -ur ./fm-modules/fmDHCP/classes/class_objects.php /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_objects.php
--- ./fm-modules/fmDHCP/classes/class_objects.php 2022-09-24 10:13:32.094742691 -0700
+++ /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_objects.php 2022-09-24 15:43:53.577333019 -0700
@@ -308,7 +308,7 @@
/** Reassigned children */
$query = "$sql_start config_parent_id=0 WHERE config_parent_id={$post['config_id']} AND config_is_parent='yes'";
$result = $fmdb->query($query);
- $query = "$sql_start config_parent_id={$post['config_id']} WHERE config_id IN (" . join(',', $post['config_children']) . ")";
+ $query = "$sql_start config_parent_id={$post['config_id']} WHERE config_id IN (" . join(',', (array) $post['config_children']) . ")";
$result = $fmdb->query($query);
return true;
@@ -469,47 +469,47 @@
}
/** Get child elements */
- $lease_time = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'default-lease-time'));
- $max_lease_time = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'max-lease-time'));
- $boot_filename = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'filename'));
- $boot_file_server = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'next-server'));
- $server_name = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'server-name'));
- $bootp_lease_length = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dynamic-bootp-lease-length'));
- $bootp_lease_cutoff = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dynamic-bootp-lease-cutoff'));
- $ddns = buildSelect('ddns-updates', 'ddns-updates', $on_off, $this->getConfig($config_id, 'ddns-updates'));
- $ddns_domain_name = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-domainname'));
- $ddns_rev_domain_name = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-rev-domainname'));
- $ddns_hostname = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-hostname'));
+ $lease_time = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'default-lease-time')): "";
+ $max_lease_time = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'max-lease-time')): "";
+ $boot_filename = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'filename')): "";
+ $boot_file_server = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'next-server')): "";
+ $server_name = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'server-name')): "";
+ $bootp_lease_length = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dynamic-bootp-lease-length')): "";
+ $bootp_lease_cutoff = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dynamic-bootp-lease-cutoff')): "";
+ $ddns = buildSelect('ddns-updates', 'ddns-updates', $on_off, $this->getConfig($config_id, 'ddns-updates'));
+ $ddns_domain_name = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-domainname')): "";
+ $ddns_rev_domain_name = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-rev-domainname')): "";
+ $ddns_hostname = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ddns-hostname')): "";
$unknown_clients = buildSelect('unknown-clients', 'unknown-clients', $allow_deny_ignore, $this->getConfig($config_id, 'unknown-clients'));
$client_updates = buildSelect('client-updates', 'client-updates', $allow_deny_ignore, $this->getConfig($config_id, 'client-updates'));
- $host_name = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'host-name'));
- $routers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'routers'));
- $subnet_mask = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'subnet-mask'));
- $domain_name_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-name-servers'));
- $broadcast_address = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'broadcast-address'));
- $domain_name = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-name'));
- $domain_search = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-search'));
- $time_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'time-servers'));
- $log_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'log-servers'));
- $swap_server = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'swap-server'));
- $root_path = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'root-path'));
- $nis_domain = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'nis-domain'));
- $nis_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'nis-servers'));
- $font_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'font-servers'));
- $x_display_manager = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'x-display-manager'));
- $ntp_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ntp-servers'));
- $netbios_name_servers = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-name-servers'));
- $netbios_scope = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-scope'));
- $netbios_node_type = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-node-type'));
- $time_offset = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'time-offset'));
- $dhcp_server_identifier = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dhcp-server-identifier'));
- $slp_directory_agent_entry = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'slp-directory-agent'));
+ $host_name = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'host-name')): "";
+ $routers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'routers')): "";
+ $subnet_mask = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'subnet-mask')): "";
+ $domain_name_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-name-servers')): "";
+ $broadcast_address = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'broadcast-address')): "";
+ $domain_name = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-name')): "";
+ $domain_search = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'domain-search')): "";
+ $time_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'time-servers')): "";
+ $log_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'log-servers')): "";
+ $swap_server = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'swap-server')): "";
+ $root_path = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'root-path')): "";
+ $nis_domain = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'nis-domain')): "";
+ $nis_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'nis-servers')): "";
+ $font_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'font-servers')): "";
+ $x_display_manager = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'x-display-manager')): "";
+ $ntp_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'ntp-servers')): "";
+ $netbios_name_servers = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-name-servers')): "";
+ $netbios_scope = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-scope')): "";
+ $netbios_node_type = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'netbios-node-type')): "";
+ $time_offset = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'time-offset')): "";
+ $dhcp_server_identifier = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'dhcp-server-identifier')): "";
+ $slp_directory_agent_entry = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'slp-directory-agent')): "";
if ($slp_directory_agent_entry) {
list($slp_directory_agent_only, $slp_directory_agent) = explode(' ', $slp_directory_agent_entry);
$slp_directory_agent_only_checked = ($slp_directory_agent_only == 'true') ? 'checked' : null;
}
- $slp_service_scope_entry = str_replace(array('"', "'"), '', $this->getConfig($config_id, 'slp-service-scope'));
+ $slp_service_scope_entry = $config_id ? str_replace(array('"', "'"), '', $this->getConfig($config_id, 'slp-service-scope')): "";
if ($slp_service_scope_entry) {
list($slp_service_scope_only, $slp_service_scope) = explode(' ', $slp_service_scope_entry);
$slp_service_scope_only_checked = ($slp_service_scope_only == 'true') ? 'checked' : null;
diff -ur ./fm-modules/fmDHCP/classes/class_peers.php /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_peers.php
--- ./fm-modules/fmDHCP/classes/class_peers.php 2022-09-24 10:13:32.094742691 -0700
+++ /var/www/html/facileManager/fm-modules/fmDHCP/classes/class_peers.php 2022-09-24 16:08:54.759720010 -0700
@@ -136,9 +136,9 @@
$primary_port = $this->getConfig($config_id, 'port');
$secondary = buildSelect('peer-address', 'peer-address', $avail_servers, $this->getConfig($config_id, 'peer-address'), 1, null, true);
$secondary_port = $this->getConfig($config_id, 'peer-port');
- $load_balancing_entry = explode(' ', $this->getConfig($config_id, 'load-balancing'));
+ $load_balancing_entry = $config_id ? explode(' ', $this->getConfig($config_id, 'load-balancing')): "";
$load_balancing_hash = isset($load_balancing_entry[1]) ? $load_balancing_entry[1] : null;
- $load_balancing = buildSelect('load-balancing', 'load-balancing', array('hba', 'split'), $load_balancing_entry[0]);
+ $load_balancing = buildSelect('load-balancing', 'load-balancing', array('hba', 'split'), !empty($load_balancing_entry));
$max_response_delay = $this->getConfig($config_id, 'max-response-delay');
$max_unacked_updates = $this->getConfig($config_id, 'max-unacked-updates');
$mclt = $this->getConfig($config_id, 'mclt');
diff -ur ./fm-modules/fmDHCP/variables.inc.php /var/www/html/facileManager/fm-modules/fmDHCP/variables.inc.php
--- ./fm-modules/fmDHCP/variables.inc.php 2022-09-24 10:13:32.098742708 -0700
+++ /var/www/html/facileManager/fm-modules/fmDHCP/variables.inc.php 2022-09-23 21:01:58.919312698 -0700
@@ -28,6 +28,9 @@
*/
if (!@is_array($__FM_CONFIG)) $__FM_CONFIG = array();
+if (!@is_array($__FM_CONFIG['icons'])) $__FM_CONFIG['icons'] = array();
+if (!@is_array($__FM_CONFIG['module']['icons'])) $__FM_CONFIG['module']['icons'] = array();
+if (!@is_array($__FM_CONFIG['clean']['prefixes'])) $__FM_CONFIG['clean']['prefixes'] = array();
/** Module Version */
$__FM_CONFIG['fmDHCP'] = array(
diff -ur ./fm-modules/fmDNS/classes/class_acls.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_acls.php
--- ./fm-modules/fmDNS/classes/class_acls.php 2022-09-24 10:13:32.102742725 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_acls.php 2022-09-24 16:11:59.820504813 -0700
@@ -301,7 +301,7 @@
extract(get_object_vars($data[0]));
}
- $acl_addresses = str_replace(',', "\n", rtrim(str_replace(' ', '', $acl_addresses), ';'));
+ $acl_addresses = $acl_addresses ? str_replace(',', "\n", rtrim(str_replace(' ', '', $acl_addresses), ';')): "";
/** Get field length */
$acl_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'acls', 'acl_name');
diff -ur ./fm-modules/fmDNS/classes/class_controls.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_controls.php
--- ./fm-modules/fmDNS/classes/class_controls.php 2022-09-24 10:13:32.106742741 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_controls.php 2022-09-24 16:16:22.185616709 -0700
@@ -235,9 +235,9 @@
extract(get_object_vars($data[0]));
}
- $control_addresses = str_replace(';', "\n", rtrim(str_replace(' ', '', $control_addresses), ';'));
+ $control_addresses = $control_addresses ? str_replace(';', "\n", rtrim(str_replace(' ', '', $control_addresses), ';')): "";
if ($type == 'controls') {
- $control_keys = buildSelect('control_keys', 'control_keys', $fm_module_servers->availableItems('key', 'nonempty', 'AND key_type="tsig"'), explode(';', $control_keys), 1, null, true, null, null, __('Select one or more keys'));
+ $control_keys = $control_keys ? buildSelect('control_keys', 'control_keys', $fm_module_servers->availableItems('key', 'nonempty', 'AND key_type="tsig"'), explode(';', $control_keys), 1, null, true, null, null, __('Select one or more keys')): "";
$control_key_form = sprintf('<tr>
<th width="33%" scope="row"><label for="control_keys">%s</label></th>
<td width="67%">%s</td>
diff -ur ./fm-modules/fmDNS/classes/class_logging.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_logging.php
--- ./fm-modules/fmDNS/classes/class_logging.php 2022-09-24 10:13:32.106742741 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_logging.php 2022-09-24 16:14:09.521054577 -0700
@@ -537,7 +537,7 @@
$cfg_print_category = buildSelect('print-category', 'print-category', $__FM_CONFIG['logging']['options']['print-category'], $this->getChannel($cfg_id, 'print-category'));
$cfg_print_severity = buildSelect('print-severity', 'print-severity', $__FM_CONFIG['logging']['options']['print-severity'], $this->getChannel($cfg_id, 'print-severity'));
$cfg_print_time = buildSelect('print-time', 'print-time', $__FM_CONFIG['logging']['options']['print-time'], $this->getChannel($cfg_id, 'print-time'));
- $raw_cfg_file_path = explode(' ', str_replace('"', '', $this->getChannel($cfg_id, 'file')));
+ $raw_cfg_file_path = explode(' ', $cfg_id ? str_replace('"', '', $this->getChannel($cfg_id, 'file')): "");
$cfg_file_path = $raw_cfg_file_path[0];
$cfg_file_versions = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_versions'], $raw_cfg_file_path[array_search('versions', $raw_cfg_file_path) + 1]);
$cfg_file_size = (isset($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1])) ? substr($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1], 0, -1) : null;
diff -ur ./fm-modules/fmDNS/classes/class_masters.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_masters.php
--- ./fm-modules/fmDNS/classes/class_masters.php 2022-09-24 10:13:32.106742741 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_masters.php 2022-09-24 16:12:28.136624850 -0700
@@ -246,7 +246,7 @@
if (isset($master_parent_id)) $parent_id = $_POST['parent_id'] = $master_parent_id;
}
- $master_addresses = str_replace(',', "\n", rtrim(str_replace(' ', '', $master_addresses), ';'));
+ $master_addresses = $master_addresses ? str_replace(',', "\n", rtrim(str_replace(' ', '', $master_addresses), ';')): "";
/** Get field length */
$master_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'masters', 'master_name');
@@ -408,7 +408,7 @@
$temp_masters[] = $temp_master_array['id'];
}
$i = count($available_masters);
- foreach (explode(',', $saved_masters) as $saved_master) {
+ foreach (explode(',', $saved_masters ?? '') as $saved_master) {
if (!$saved_master) continue;
if (array_search($saved_master, $temp_masters) === false) {
$available_masters[$i]['id'] = $saved_master;
diff -ur ./fm-modules/fmDNS/classes/class_options.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_options.php
--- ./fm-modules/fmDNS/classes/class_options.php 2022-09-24 10:13:32.106742741 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_options.php 2022-09-24 16:05:07.634756220 -0700
@@ -131,8 +131,8 @@
$tmp_domain_name = isset($post['domain_id']) ? "\nZone: " . displayFriendlyDomainName(getNameFromID($post['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')) : null;
include_once(ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_acls.php');
- $cfg_data = (strpos($post['cfg_data'], 'acl_') !== false || strpos($post['cfg_data'], 'key_') !== false || \
- strpos($post['cfg_data'], 'domain_') !== false || \
+ $cfg_data = (strpos($post['cfg_data'], 'acl_') !== false || strpos($post['cfg_data'], 'key_') !== false ||
+ strpos($post['cfg_data'], 'domain_') !== false ||
strpos($post['cfg_data'], 'master_') !== false) ? $fm_dns_acls->parseACL($post['cfg_data']) : $post['cfg_data'];
addLogEntry("Added option:\nName: $tmp_name\nValue: $cfg_data\nServer: $tmp_server_name\nView: {$tmp_view_name}{$tmp_domain_name}\nComment: {$post['cfg_comment']}");
return true;
@@ -197,8 +197,8 @@
$tmp_domain_name = isset($post['domain_id']) ? "\nZone: " . displayFriendlyDomainName(getNameFromID($post['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')) : null;
include_once(ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_acls.php');
- $cfg_data = (strpos($post['cfg_data'], 'acl_') !== false || strpos($post['cfg_data'], 'key_') !== false || \
- strpos($post['cfg_data'], 'domain_') !== false || \
+ $cfg_data = (strpos($post['cfg_data'], 'acl_') !== false || strpos($post['cfg_data'], 'key_') !== false ||
+ strpos($post['cfg_data'], 'domain_') !== false ||
strpos($post['cfg_data'], 'master_') !== false) ? $fm_dns_acls->parseACL($post['cfg_data']) : $post['cfg_data'];
addLogEntry("Updated option '$old_name' to:\nName: {$post['cfg_name']}\nValue: {$cfg_data}\nServer: $tmp_server_name\nView: {$tmp_view_name}{$tmp_domain_name}\nComment: {$post['cfg_comment']}");
return true;
@@ -680,9 +680,9 @@
include(ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_acls.php');
}
- return (strpos($cfg_data, 'acl_') !== false || strpos($cfg_data, 'key_') !== false || \
- strpos($cfg_data, 'domain_') !== false || strpos($def_type, 'address_match_element') !== false || \
- strpos($cfg_data, 'master_') !== false || \
+ return (strpos($cfg_data, 'acl_') !== false || strpos($cfg_data, 'key_') !== false ||
+ strpos($cfg_data, 'domain_') !== false || strpos($def_type, 'address_match_element') !== false ||
+ strpos($cfg_data, 'master_') !== false ||
strpos($def_type, 'domain_name') !== false) ? $fm_dns_acls->parseACL($cfg_data) : str_replace(',', '; ', $cfg_data);
}
@@ -703,7 +703,7 @@
global $fmdb, $__FM_CONFIG, $fm_dns_acls;
$raw_def_type_array = explode(')', str_replace('(', '', $def_type));
- $saved_data = explode(' ', $cfg_data);
+ $saved_data = explode(' ', $cfg_data ?? '');
$i = 0;
$dropdown = null;
foreach ($raw_def_type_array as $raw_def_type) {
diff -ur ./fm-modules/fmDNS/classes/class_servers.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_servers.php
--- ./fm-modules/fmDNS/classes/class_servers.php 2022-09-24 10:13:32.106742741 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_servers.php 2022-09-24 16:11:14.160311227 -0700
@@ -678,7 +678,7 @@
$keys = $this->getConfig($server_id, 'keys');
$keys = ($keys) ? explode(',', $keys) : null;
$keys = buildSelect('keys', 'keys', $this->availableItems('key', 'blank', 'AND `key_type`="tsig"', 'key_'), $keys, 1, '', true);
- $transfers = str_replace(array('"', "'"), '', $this->getConfig($server_id, 'transfers'));
+ $transfers = $server_id ? str_replace(array('"', "'"), '', $this->getConfig($server_id, 'transfers')): "";
$bogus = $this->buildConfigOptions('bogus', $this->getConfig($server_id, 'bogus'));
$edns = $this->buildConfigOptions('edns', $this->getConfig($server_id, 'edns'));
$transfer_format = $this->buildConfigOptions('transfer-format', $this->getConfig($server_id, 'transfer-format'));
diff -ur ./fm-modules/fmDNS/classes/class_zones.php /var/www/html/facileManager/fm-modules/fmDNS/classes/class_zones.php
--- ./fm-modules/fmDNS/classes/class_zones.php 2022-09-24 10:13:32.110742758 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/classes/class_zones.php 2022-09-24 16:10:28.688118419 -0700
@@ -861,7 +861,7 @@
$response = ($response) ? sprintf('<a href="#" class="tooltip-top mini-icon" data-tooltip="%s"><i class="fa fa-question-circle" aria-hidden="true"></i></a>', $response) : null;
- $class = 'class="' . implode(' ', $classes) . '"';
+ $class = 'class="' . implode(' ', (array) $classes) . '"';
if (is_array($icons)) {
$icons = implode(' ', $icons);
}
@@ -955,7 +955,7 @@
}
}
- $domain_name = function_exists('idn_to_utf8') ? idn_to_utf8($domain_name, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : $domain_name;
+ $domain_name = $domain_name ? function_exists('idn_to_utf8') ? idn_to_utf8($domain_name, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : $domain_name : "";
/** Process multiple views */
if (strpos($domain_view, ';')) {
@@ -1283,7 +1283,7 @@
$return = $limited_ids = null;
if (isset($user_capabilities)) {
- $limited_ids = (array_key_exists('access_specific_zones', $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) ? 'AND domain_id IN (' . join(',', $this->getZoneAccessIDs($user_capabilities[$_SESSION['module']]['access_specific_zones'])) . ')' : null;
+ $limited_ids = (array_key_exists('access_specific_zones', (array) $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) ? 'AND domain_id IN (' . join(',', $this->getZoneAccessIDs($user_capabilities[$_SESSION['module']]['access_specific_zones'])) . ')' : null;
}
basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', $domain_id, 'domain_', 'domain_clone_domain_id', $limited_ids . ' AND domain_template="no" ORDER BY domain_name');
if ($fmdb->num_rows) {
@@ -1540,7 +1540,7 @@
$start = 0;
$return = array();
- if ($extra == 'all' && !@in_array(0, $exclude)) {
+ if ($extra == 'all' && !@in_array(0, (array)$exclude)) {
$start = 1;
$return = array(array(__('All Zones'), 0));
}
diff -ur ./fm-modules/fmDNS/pages/templates-zones.php /var/www/html/facileManager/fm-modules/fmDNS/pages/templates-zones.php
--- ./fm-modules/fmDNS/pages/templates-zones.php 2022-09-24 10:13:32.114742774 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/pages/templates-zones.php 2022-09-24 16:17:20.465863594 -0700
@@ -55,7 +55,7 @@
/** Get zones based on access */
$user_capabilities = getUserCapabilities($_SESSION['user']['id'], 'all');
-$limited_domain_ids = (array_key_exists('access_specific_zones', $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) ? "AND domain_id IN (" . implode(',', $fm_dns_zones->getZoneAccessIDs($user_capabilities[$_SESSION['module']]['access_specific_zones'])) . ")" : null;
+$limited_domain_ids = (array_key_exists('access_specific_zones', (array) $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) ? "AND domain_id IN (" . implode(',', $fm_dns_zones->getZoneAccessIDs($user_capabilities[$_SESSION['module']]['access_specific_zones'])) . ")" : null;
include(dirname(__FILE__) . '/templates.php');
diff -ur ./fm-modules/fmDNS/pages/zone-records-validate.php /var/www/html/facileManager/fm-modules/fmDNS/pages/zone-records-validate.php
--- ./fm-modules/fmDNS/pages/zone-records-validate.php 2022-09-24 10:13:32.114742774 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/pages/zone-records-validate.php 2022-09-24 10:39:41.001217635 -0700
@@ -133,11 +133,11 @@
if (is_array($value[$id])) $value[$id]['action'] = $action;
}
- if (array_key_exists('soa_template_chosen', $value)) {
+ if (array_key_exists('soa_template_chosen', (array) $value)) {
unset($value['soa_template_chosen']);
}
foreach ($value as $id => $array) {
- if (count($input_error[$id]['errors'])) {
+ if (count((array)$input_error[$id]['errors'])) {
$img = $__FM_CONFIG['icons']['fail'];
$action = __('None');
} else {
@@ -265,7 +265,7 @@
}
}
- if (!count($messages['errors'])) {
+ if (!count((array)$messages['errors'])) {
$html .= buildInputReturn($action, $id, $key, $val);
} else $html = null;
}
diff -ur ./fm-modules/fmDNS/pages/zones.php /var/www/html/facileManager/fm-modules/fmDNS/pages/zones.php
--- ./fm-modules/fmDNS/pages/zones.php 2022-09-24 10:13:32.114742774 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/pages/zones.php 2022-09-24 09:57:42.842850940 -0700
@@ -152,7 +152,7 @@
$user_capabilities = getUserCapabilities($_SESSION['user']['id'], 'all');
$limited_domain_ids = ')';
- if (array_key_exists('access_specific_zones', $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) {
+ if (array_key_exists('access_specific_zones', (array) $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0]) {
$limited_domain_ids = "OR domain_clone_domain_id>0) AND domain_id IN (";
$limited_domain_ids .= join(',', $fm_dns_zones->getZoneAccessIDs($user_capabilities[$_SESSION['module']]['access_specific_zones'])) . ')';
}
diff -ur ./fm-modules/fmDNS/variables.inc.php /var/www/html/facileManager/fm-modules/fmDNS/variables.inc.php
--- ./fm-modules/fmDNS/variables.inc.php 2022-09-24 10:13:32.118742790 -0700
+++ /var/www/html/facileManager/fm-modules/fmDNS/variables.inc.php 2022-09-23 19:16:58.417988792 -0700
@@ -28,6 +28,7 @@
*/
if (!@is_array($__FM_CONFIG)) $__FM_CONFIG = array();
+if (!@is_array($__FM_CONFIG['icons'])) $__FM_CONFIG['icons'] = array();
/** Module Information */
$__FM_CONFIG['fmDNS'] = array(
diff -ur ./fm-modules/shared/classes/class_servers.php /var/www/html/facileManager/fm-modules/shared/classes/class_servers.php
--- ./fm-modules/shared/classes/class_servers.php 2022-09-24 10:13:32.138742873 -0700
+++ /var/www/html/facileManager/fm-modules/shared/classes/class_servers.php 2022-09-24 15:49:19.834724475 -0700
@@ -371,7 +371,7 @@
$response .= "</pre>\n";
} else {
- $response = "<p>[$server_name] " . $post_result[0] . '</p>';
+ $response = "<p>[$server_name] " . !empty($post_result) . '</p>';
}
}
break;
@@ -426,4 +426,4 @@
}
-?>
\ No newline at end of file
+?>
Hi @gianlucagiacometti,
I tried downgrading my PHP version to 7.4.33 but still i am getting this issue:
[Sat Dec 24 20:12:40.903743 2022] [proxy_fcgi:error] [pid 9290] [client 10.35.35.16:52315] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: sort(): Argument #1 ($array) must be of type array, null given in /var/www/html/dnsadmin/fm-modules/facileManager/variables.inc.php:109\nStack trace:\n#0 /var/www/html/dnsadmin/fm-modules/facileManager/variables.inc.php(109): sort()\n#1 /var/www/html/dnsadmin/fm-modules/facileManager/functions.php(71): include('...')\n#2 /var/www/html/dnsadmin/fm-includes/init.php(30): require_once('...')\n#3 /var/www/html/dnsadmin/fm-install.php(47): require_once('...')\n#4 {main}\n thrown in /var/www/html/dnsadmin/fm-modules/facileManager/variables.inc.php on line 109'
Just hit this problem by upgrading to the latest FreeBSD Ports quarterly branch... since I have zero competence on PHP and programming in general, the only way I guess can contribute with is to sponsor the work of someone. If anyone is interested, you can contact me directly via email. Thanks!
Commit added to the master-prerelease-bugfixes branch for PHP 8.2 support. Use at your own risk or wait until it's included in an official release.
Thank you so much @WillyXJ , I just tried the prerelease in a test lab and the first actions (login, server config rebuild) went OK. Unfortunately, a problem raised when I tried to modify a zone (changing or adding a RR). It stopped with this output when I click "validate":
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/pages/zone-records-validate.php:136 Stack trace: #0 /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/pages/zone-records-validate.php(69): createOutput() #1 /usr/local/www/apache24/data/demo/facilemanager/index.php(57): include('...') #2 {main} thrown in /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/pages/zone-records-validate.php on line 136
It returns another error when trying to add a new forward zone:
Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/classes/class_records.php:564 Stack trace: #0 /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/classes/class_records.php(564): in_array() #1 /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/classes/class_records.php(43): fm_dns_records->getInputForm() #2 /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/pages/zone-records.php(180): fm_dns_records->rows() #3 /usr/local/www/apache24/data/demo/facilemanager/index.php(57): include('...') #4 {main} thrown in /usr/local/www/apache24/data/demo/facilemanager/fm-modules/fmDNS/classes/class_records.php on line 564
Thanks for giving us and maintain facileManager!
Thank you @WillyXJ
@sidantaa , I downgraded to 7.4.33, too, and everything went fine with no changing in the released code
Additional commits have been added to https://github.com/WillyXJ/facileManager/compare/master-prerelease-bugfixes containing more PHP 8 fixes as all modules and functionality is getting regression-tested.
Sorry, only today I get the chance to try your latest commits. Creating, modifying and deleting forward zones and resource records is OK now: thanks @WillyXJ ! I'll try to test it more in the following days, but as for now it looks like good for production to me (I'm running PHP 8.0).
Please prefix your issue title with one of the following: [BUG], [ISSUE], [FEATURE REQUEST], [MODULE REQUEST], [OTHER].
Replace everything between stars with current version of your facileManager and module installations:
fM Version : 4.3.0
In raising this issue, I confirm the following (please check boxes, eg [X]):
[Fri Jul 01 09:05:01.968854 2022] [php:error] [pid 1601] [client X.X.X.X:39540] PHP Fatal error: Uncaught TypeError: sort(): Argument #1 ($array) must be of type array, null given in /web/sites/manager/fm-modules/facile Manager/variables.inc.php:109\nStack trace:\n#0 /web/sites/manager/fm-modules/facileManager/variables.inc.php(109): sort()\n#1 /web/sites/manager/fm-modules/facileManager/functions.php(71): include('...')\n# 2 /web/sites/manage/config.inc.php(23): require_once('...')\n#3 /web/sites/manager/fm-init.php(58): require_once('...')\n#4 /web/sites/manager/index.php(38): require('...')\n#5 {main}\n thro wn in /web/sites/manager/fm-modules/facileManager/variables.inc.php on line 109
If I comment the line or set a if isset && is_array the result is a blank page with just a "1" in output
With PHP 7.4.30 everything works fine