diff --git a/lam/lib/modules/courierMailAccount.inc b/lam/lib/modules/courierMailAccount.inc index d024e6f2b..0330191fb 100644 --- a/lam/lib/modules/courierMailAccount.inc +++ b/lam/lib/modules/courierMailAccount.inc @@ -1,7 +1,7 @@ get_scope(), [ - 'user' - ]); + return $this->get_scope() === 'user'; } /** @@ -148,7 +146,7 @@ class courierMailAccount extends baseModule { ]; // profile options $profileContainer = new htmlResponsiveRow(); - $profileContainer->add(new htmlResponsiveInputCheckbox('courierMailAccount_addExt', false, _('Automatically add this extension'), 'autoAdd'), 12); + $profileContainer->add(new htmlResponsiveInputCheckbox('courierMailAccount_addExt', false, _('Automatically add this extension'), 'autoAdd')); $return['profile_options'] = $profileContainer; // PDF fields $return['PDF_fields'] = [ @@ -291,13 +289,13 @@ class courierMailAccount extends baseModule { $return->addField($tempTable); // check boxes for account access control $disableimap = isset($this->attributes['disableimap'][0]) && ($this->attributes['disableimap'][0] != 0); - $return->add(new htmlResponsiveInputCheckbox('disableimap', $disableimap, _('Disable IMAP access'), 'disableimap'), 12); + $return->add(new htmlResponsiveInputCheckbox('disableimap', $disableimap, _('Disable IMAP access'), 'disableimap')); $disablepop3 = isset($this->attributes['disablepop3'][0]) && ($this->attributes['disablepop3'][0] != 0); - $return->add(new htmlResponsiveInputCheckbox('disablepop3', $disablepop3, _('Disable POP3 access'), 'disablepop3'), 12); + $return->add(new htmlResponsiveInputCheckbox('disablepop3', $disablepop3, _('Disable POP3 access'), 'disablepop3')); $disablewebmail = isset($this->attributes['disablewebmail'][0]) && ($this->attributes['disablewebmail'][0] != 0); - $return->add(new htmlResponsiveInputCheckbox('disablewebmail', $disablewebmail, _('Disable webmail access'), 'disablewebmail'), 12); + $return->add(new htmlResponsiveInputCheckbox('disablewebmail', $disablewebmail, _('Disable webmail access'), 'disablewebmail')); $disableshared = isset($this->attributes['disableshared'][0]) && ($this->attributes['disableshared'][0] != 0); - $return->add(new htmlResponsiveInputCheckbox('disableshared', $disableshared, _('Disable shared folder access'), 'disableshared'), 12); + $return->add(new htmlResponsiveInputCheckbox('disableshared', $disableshared, _('Disable shared folder access'), 'disableshared')); // remove extension $return->addVerticalSpacer('2rem'); $remButton = new htmlButton('remObjectClass', _('Remove Courier mail extension')); @@ -305,7 +303,7 @@ class courierMailAccount extends baseModule { $return->add($remButton, 12, 12, 12, 'text-center'); } else { - $return->add(new htmlButton('addObjectClass', _('Add Courier mail extension')), 12); + $return->add(new htmlButton('addObjectClass', _('Add Courier mail extension'))); } return $return; } diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index 30e587b35..e77e76448 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -47,7 +47,7 @@ class ddns extends baseModule { * @return boolean true if module fits */ public function can_manage() { - return in_array($this->get_scope(), ['dhcp']); + return $this->get_scope() === 'dhcp'; } /** @@ -301,7 +301,7 @@ class ddns extends baseModule { } for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 5) == 'zone ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'zone ')) { unset($this->attributes['dhcpStatements'][$i]); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); $i--; @@ -356,21 +356,21 @@ class ddns extends baseModule { return $return; } // DHCP main settings - $return->add(new htmlResponsiveInputCheckbox('active', $this->isDynDNSActivated(), _('Activate DynDNS'), 'active'), 12); - $return->add(new htmlResponsiveInputCheckbox('insert_fixed', $this->addFixIPs(), _('Add fix IP addresses to DNS'), 'fixed_ips'), 12); - $return->add(new htmlResponsiveInputCheckbox('client_insert', $this->isIgnoreClientUpdates(), _('Disable client updates'), 'client_insert'), 12); + $return->add(new htmlResponsiveInputCheckbox('active', $this->isDynDNSActivated(), _('Activate DynDNS'), 'active')); + $return->add(new htmlResponsiveInputCheckbox('insert_fixed', $this->addFixIPs(), _('Add fix IP addresses to DNS'), 'fixed_ips')); + $return->add(new htmlResponsiveInputCheckbox('client_insert', $this->isIgnoreClientUpdates(), _('Disable client updates'), 'client_insert')); $keyInput = new htmlResponsiveInputField(_('Path to key for DNS updates'), 'key_path', $this->getUpdateKey(), 'keypath'); - $return->add($keyInput, 12); + $return->add($keyInput); } else { // Account edit if (!$this->check_if_ddns_is_enable()) { - $return->add(new htmlOutputText(_("DDNS is not activated. You can activate it in the DHCP settings (DDNS).")), 12); + $return->add(new htmlOutputText(_("DDNS is not activated. You can activate it in the DHCP settings (DDNS)."))); } else { // DNS server $serverInput = new htmlResponsiveInputField(_('IP address of the DNS server'), 'ip', $this->getDNSServer(), 'dns'); - $return->add($serverInput, 12); + $return->add($serverInput); $zones = $this->getZoneNames(); $zone = ''; @@ -383,10 +383,10 @@ class ddns extends baseModule { } // zone name $zoneInput = new htmlResponsiveInputField(_('Zone name'), 'zone', $zone, 'zone'); - $return->add($zoneInput, 12); + $return->add($zoneInput); // reverse zone name $revZoneInput = new htmlResponsiveInputField(_('Reverse zone name'), 'zone_reverse', $revzone, 'zone_reverse'); - $return->add($revZoneInput, 12); + $return->add($revZoneInput); } } @@ -423,11 +423,10 @@ class ddns extends baseModule { * @return String IP address */ private function getDNSServer() { - $return = null; if (isset($this->attributes['dhcpStatements'][0])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 5) == 'zone ') { - if (strpos($this->attributes['dhcpStatements'][$i], ' primary ') === false) { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'zone ')) { + if (!str_contains($this->attributes['dhcpStatements'][$i], ' primary ')) { continue; } $parts = explode(". { primary ", $this->attributes['dhcpStatements'][$i]); @@ -437,7 +436,7 @@ class ddns extends baseModule { } } } - return $return; + return null; } /** @@ -451,10 +450,10 @@ class ddns extends baseModule { $revZone = ''; if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 5) == 'zone ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'zone ')) { $parts = explode(" ", substr($this->attributes['dhcpStatements'][$i], 5)); $value = substr(array_shift($parts), 0, -1); - if (strpos($value, 'in-addr.arpa') === false) { + if (!str_contains($value, 'in-addr.arpa')) { $zone = $value; } else { @@ -494,7 +493,7 @@ class ddns extends baseModule { private function setDynDNSActivated($activated) { if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 18) == 'ddns-update-style ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'ddns-update-style ')) { unset($this->attributes['dhcpStatements'][$i]); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); } @@ -534,7 +533,7 @@ class ddns extends baseModule { private function setFixIPs($add) { if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 21) == 'update-static-leases ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'update-static-leases ')) { unset($this->attributes['dhcpStatements'][$i]); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); } @@ -594,7 +593,7 @@ class ddns extends baseModule { $return = null; if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 8) == 'include ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'include ')) { $return = substr($this->attributes['dhcpStatements'][$i], 9, strlen($this->attributes['dhcpStatements'][$i]) - 10); break; } @@ -613,7 +612,7 @@ class ddns extends baseModule { $this->attributes['dhcpStatements'] = []; } for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if (substr($this->attributes['dhcpStatements'][$i], 0, 8) == 'include ') { + if (str_starts_with($this->attributes['dhcpStatements'][$i], 'include ')) { unset($this->attributes['dhcpStatements'][$i]); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); } @@ -650,7 +649,7 @@ class ddns extends baseModule { // principal name if (!check_ip($rawAccounts[$i][$ids['ddns_DNSserver']])) { $error = $this->messages['ip'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } else { diff --git a/lam/lib/modules/dhcp_settings.inc b/lam/lib/modules/dhcp_settings.inc index b1a3040b4..68d832371 100644 --- a/lam/lib/modules/dhcp_settings.inc +++ b/lam/lib/modules/dhcp_settings.inc @@ -79,17 +79,17 @@ if (!function_exists('check_ip')) { */ class dhcp_settings extends baseModule { - const UNKNOWN_CLIENTS = 'unknown-clients'; - const DEFAULT_LEASE_TIME = 'default-lease-time'; - const MAX_LEASE_TIME = 'max-lease-time'; - const AUTHORITATIVE = 'authoritative'; - const DOMAIN_SEARCH = 'domain-search'; - const DOMAIN_NAME = 'domain-name'; - const DOMAIN_NAME_SERVERS = 'domain-name-servers'; - const ROUTERS = 'routers'; - const NETBIOS_NAME_SERVERS = 'netbios-name-servers'; - const NETBIOS_NODE_TYPE = 'netbios-node-type'; - const SUBNET_MASK = 'subnet-mask'; + private const UNKNOWN_CLIENTS = 'unknown-clients'; + private const DEFAULT_LEASE_TIME = 'default-lease-time'; + private const MAX_LEASE_TIME = 'max-lease-time'; + private const AUTHORITATIVE = 'authoritative'; + private const DOMAIN_SEARCH = 'domain-search'; + private const DOMAIN_NAME = 'domain-name'; + private const DOMAIN_NAME_SERVERS = 'domain-name-servers'; + private const ROUTERS = 'routers'; + private const NETBIOS_NAME_SERVERS = 'netbios-name-servers'; + private const NETBIOS_NODE_TYPE = 'netbios-node-type'; + private const SUBNET_MASK = 'subnet-mask'; /** all netbios node types */ private $all_netbios_node_types; @@ -126,7 +126,7 @@ class dhcp_settings extends baseModule { * @return boolean true if module fits */ public function can_manage() { - return in_array($this->get_scope(), ['dhcp']); + return $this->get_scope() === 'dhcp'; } /** @@ -620,7 +620,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I if ($this->isRootNode() && !in_array_ignore_case('dhcpService', $this->attributes['objectClass']) && !in_array_ignore_case('dhcpServer', $this->attributes['objectClass'])) { - $return->add(new htmlStatusMessage('ERROR', _('Please set your LDAP suffix to an LDAP entry with object class "dhcpService" or "dhcpServer".')), 12); + $return->add(new htmlStatusMessage('ERROR', _('Please set your LDAP suffix to an LDAP entry with object class "dhcpService" or "dhcpServer".'))); return $return; } // Subnet name @@ -631,26 +631,26 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } $subnetInput = new htmlResponsiveInputField(_('Subnet'), 'cn', $cn, 'subnet'); $subnetInput->setRequired(true); - $return->add($subnetInput, 12); + $return->add($subnetInput); } // description $description = ''; if (isset($this->attributes['dhcpComments'][0])) { $description = $this->attributes['dhcpComments'][0]; } - $return->add(new htmlResponsiveInputField(_('Description'), 'description', $description, 'description'), 12); + $return->add(new htmlResponsiveInputField(_('Description'), 'description', $description, 'description')); // domain name - $return->add(new htmlResponsiveInputField(_('Domain name'), 'domainname', $this->getDHCPOption(self::DOMAIN_NAME), 'domainname'), 12); + $return->add(new htmlResponsiveInputField(_('Domain name'), 'domainname', $this->getDHCPOption(self::DOMAIN_NAME), 'domainname')); // lease Time $leasetimeInput = new htmlResponsiveInputField(_('Lease time'), 'lease_time', $this->getDefaultLeaseTime(), 'leasetime'); $leasetimeInput->setMinimumAndMaximumNumber(); - $return->add($leasetimeInput, 12); + $return->add($leasetimeInput); // max lease time $max_leasetimeInput = new htmlResponsiveInputField(_('Maximum lease time'), 'max_lease_time', $this->getMaxLeaseTime(), 'max_leasetime'); $max_leasetimeInput->setMinimumAndMaximumNumber(); - $return->add($max_leasetimeInput, 12); + $return->add($max_leasetimeInput); // DNS - $return->add(new htmlResponsiveInputField(_('DNS'), 'dns', $this->getDHCPOption(self::DOMAIN_NAME_SERVERS), 'dns'), 12); + $return->add(new htmlResponsiveInputField(_('DNS'), 'dns', $this->getDHCPOption(self::DOMAIN_NAME_SERVERS), 'dns')); // domain search $domainSearchEntries = $this->getDHCPOption(self::DOMAIN_SEARCH); if ($domainSearchEntries === null) { @@ -660,9 +660,9 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I $this->attributes['INFO_domain-search'] = $domainSearchEntries; $this->addMultiValueInputTextField($return, 'INFO_domain-search', _('Search domains')); // gateway - $return->add(new htmlResponsiveInputField(_('Default gateway'), 'routers', $this->getDHCPOption(self::ROUTERS), 'gateway'), 12); + $return->add(new htmlResponsiveInputField(_('Default gateway'), 'routers', $this->getDHCPOption(self::ROUTERS), 'gateway')); // netbios name servers - $return->add(new htmlResponsiveInputField(_('Netbios name servers'), 'netbios', $this->getDHCPOption(self::NETBIOS_NAME_SERVERS), 'netbios'), 12); + $return->add(new htmlResponsiveInputField(_('Netbios name servers'), 'netbios', $this->getDHCPOption(self::NETBIOS_NAME_SERVERS), 'netbios')); // netbios node type $nodeType = $this->getDHCPOption(self::NETBIOS_NODE_TYPE); if ($nodeType == '') { @@ -983,8 +983,8 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I if (!empty($this->attributes['dhcpStatements'])) { foreach ($this->attributes['dhcpStatements'] as $statement) { if (($statement !== self::AUTHORITATIVE) - && (strpos($statement, self::DEFAULT_LEASE_TIME) !== 0) - && (strpos($statement, self::MAX_LEASE_TIME) !== 0) + && (!str_starts_with($statement, self::DEFAULT_LEASE_TIME)) + && (!str_starts_with($statement, self::MAX_LEASE_TIME)) && (strpos($statement, self::UNKNOWN_CLIENTS) !== (strlen($statement) - strlen(self::UNKNOWN_CLIENTS)))) { $extraStatements[] = $statement; } @@ -1005,8 +1005,8 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I $toDelete = []; foreach ($this->attributes['dhcpStatements'] as $statement) { if (($statement !== self::AUTHORITATIVE) - && (strpos($statement, self::DEFAULT_LEASE_TIME) !== 0) - && (strpos($statement, self::MAX_LEASE_TIME) !== 0) + && (!str_starts_with($statement, self::DEFAULT_LEASE_TIME)) + && (!str_starts_with($statement, self::MAX_LEASE_TIME)) && (strpos($statement, self::UNKNOWN_CLIENTS) !== (strlen($statement) - strlen(self::UNKNOWN_CLIENTS)))) { $toDelete[] = $statement; } @@ -1024,13 +1024,13 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I $extraOptions = []; if (!empty($this->attributes['dhcpOption'])) { foreach ($this->attributes['dhcpOption'] as $option) { - if ((strpos($option, self::DOMAIN_NAME) !== 0) - && (strpos($option, self::DOMAIN_NAME_SERVERS) !== 0) - && (strpos($option, self::DOMAIN_SEARCH) !== 0) - && (strpos($option, self::ROUTERS) !== 0) - && (strpos($option, self::NETBIOS_NAME_SERVERS) !== 0) - && (strpos($option, self::NETBIOS_NODE_TYPE) !== 0) - && (strpos($option, self::SUBNET_MASK) !== 0) + if ((!str_starts_with($option, self::DOMAIN_NAME)) + && (!str_starts_with($option, self::DOMAIN_NAME_SERVERS)) + && (!str_starts_with($option, self::DOMAIN_SEARCH)) + && (!str_starts_with($option, self::ROUTERS)) + && (!str_starts_with($option, self::NETBIOS_NAME_SERVERS)) + && (!str_starts_with($option, self::NETBIOS_NODE_TYPE)) + && (!str_starts_with($option, self::SUBNET_MASK)) ) { $extraOptions[] = $option; } @@ -1050,13 +1050,13 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } $toDelete = []; foreach ($this->attributes['dhcpOption'] as $option) { - if ((strpos($option, self::DOMAIN_NAME) !== 0) - && (strpos($option, self::DOMAIN_NAME_SERVERS) !== 0) - && (strpos($option, self::DOMAIN_SEARCH) !== 0) - && (strpos($option, self::ROUTERS) !== 0) - && (strpos($option, self::NETBIOS_NAME_SERVERS) !== 0) - && (strpos($option, self::NETBIOS_NODE_TYPE) !== 0) - && (strpos($option, self::SUBNET_MASK) !== 0) + if ((!str_starts_with($option, self::DOMAIN_NAME)) + && (!str_starts_with($option, self::DOMAIN_NAME_SERVERS)) + && (!str_starts_with($option, self::DOMAIN_SEARCH)) + && (!str_starts_with($option, self::ROUTERS)) + && (!str_starts_with($option, self::NETBIOS_NAME_SERVERS)) + && (!str_starts_with($option, self::NETBIOS_NODE_TYPE)) + && (!str_starts_with($option, self::SUBNET_MASK)) ) { $toDelete[] = $option; } @@ -1085,7 +1085,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['cn'][3]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } // domain name @@ -1095,7 +1095,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['domainname'][5]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1106,7 +1106,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['lease_time'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1117,7 +1117,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['max_lease_time'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1135,7 +1135,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['dns'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1156,7 +1156,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['INFO_domain-search'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1167,7 +1167,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['routers'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1185,7 +1185,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['netbios'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1207,7 +1207,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['netbios_node_type'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1223,7 +1223,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['unknownClients'][0]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1236,7 +1236,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['authoritative'][0]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } } @@ -1246,7 +1246,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I } else { $error = $this->messages['subnet'][1]; - array_push($error, [$i]); + $error[] = [$i]; $messages[] = $error; } // net mask