diff --git a/html/main.php b/html/main.php index 6cc1799e886e126a4948cb65d812019a6ea1f65f..d5ac9e11c411dad7cc4be53ff08453f21939054c 100644 --- a/html/main.php +++ b/html/main.php @@ -222,7 +222,7 @@ $smarty->assign("contents", $display); $smarty->assign("sessionLifetime", $config->get_cfg_value("sessionLifetime", 60 * 60 * 2)); /* If there's some post, take a look if everything is there... */ -if (isset($_POST) && count($_POST) && !isset($_POST['php_c_check'])) { +if (count($_POST) && !isset($_POST['php_c_check'])) { throw new FatalError( htmlescape(_('Fatal error: not all POST variables have been transfered by PHP - please inform your administrator!')) ); diff --git a/include/class_ldap.inc b/include/class_ldap.inc index c858401bb6a699c8da94c3950de887aac5af5f1c..5d3b33f7af580d419bf0245dcc861076427522c1 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -488,7 +488,6 @@ class LDAP */ function fetch ($srp, bool $cleanUpNumericIndices = FALSE) { - $att = []; if ($this->hascon) { if ($this->hasres[$srp]) { if ($this->start[$srp] == 0) { @@ -501,6 +500,7 @@ class LDAP } else { $this->re[$srp] = @ldap_next_entry($this->cid, $this->re[$srp]); } + $att = []; if ($this->re[$srp]) { $att = @ldap_get_attributes($this->cid, $this->re[$srp]); $att['dn'] = trim(@ldap_get_dn($this->cid, $this->re[$srp])); @@ -513,9 +513,6 @@ class LDAP } } $this->error = @ldap_error($this->cid); - if (!isset($att)) { - $att = []; - } logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'fetch()'); return $att; } else { @@ -761,6 +758,7 @@ class LDAP reset($delarray); /* Really Delete ALL dn's in subtree */ + $r = TRUE; foreach (array_keys($delarray) as $key) { $r = @ldap_delete($this->cid, $key); if ($r === FALSE) { @@ -1313,7 +1311,9 @@ class LDAP $this->connect(); } - $ret = FALSE; + $ret = FALSE; + $dn = NULL; + $operation = NULL; /* If dn is an index of data, we should try to insert the data */ if (isset($data['dn'])) { @@ -1377,6 +1377,7 @@ class LDAP $error->display(); } + return $ret; } @@ -1411,11 +1412,12 @@ class LDAP if (preg_match('/^[0-9]+$/', $val)) { continue; } - $name = "OID"; - $pattern = explode(' ', $val); - $ocname = preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val); + $name = 'OID'; + $pattern = explode(' ', $val); + $ocname = preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val); $objectclasses[$ocname] = []; + $value = ''; foreach ($pattern as $chunk) { switch ($chunk) { diff --git a/include/class_tests.inc b/include/class_tests.inc index 9313583d9bdbc41420bfc5cd1cd14551ca0e6c74..60d8d3ff4effa77cf6abee79cad95614d274040d 100644 --- a/include/class_tests.inc +++ b/include/class_tests.inc @@ -336,6 +336,8 @@ class tests $ad = explode('.', $address); /* Generate inverted netmask */ + $ni = []; + $la = []; for ($i = 0; $i < 4; $i++) { $ni[$i] = 255 - $nm[$i]; $la[$i] = $nw[$i] | $ni[$i]; diff --git a/include/functions.inc b/include/functions.inc index 7d5a3daadf12f59d7c23768d2fbdeceb3b63f643..735f4341c16326f8c59a807287498fe88da5bc50 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -53,29 +53,6 @@ define('LDAP_DEL', 4); define('LDAP_SEARCH', 5); define('LDAP_AUTH', 6); -/* Rewrite german 'umlauts' and spanish 'accents' - to get better results */ -$REWRITE = [ "ä" => "ae", - "ö" => "oe", - "ü" => "ue", - "Ä" => "Ae", - "Ö" => "Oe", - "Ü" => "Ue", - "ß" => "ss", - "á" => "a", - "é" => "e", - "Ã" => "i", - "ó" => "o", - "ú" => "u", - "Ã" => "A", - "É" => "E", - "Ã" => "I", - "Ó" => "O", - "Ú" => "U", - "ñ" => "ny", - "Ñ" => "Ny" ]; - - /*! * \brief Does autoloading for classes used in FusionDirectory. * @@ -1010,10 +987,32 @@ function to_string ($value) */ function rewrite ($s) { - global $REWRITE; + /* Rewrite german 'umlauts' and spanish 'accents' + to get better results */ + static $REWRITE = [ + 'ä' => 'ae', + 'ö' => 'oe', + 'ü' => 'ue', + 'Ä' => 'Ae', + 'Ö' => 'Oe', + 'Ü' => 'Ue', + 'ß' => 'ss', + 'á' => 'a', + 'é' => 'e', + 'Ã' => 'i', + 'ó' => 'o', + 'ú' => 'u', + 'Ã' => 'A', + 'É' => 'E', + 'Ã' => 'I', + 'Ó' => 'O', + 'Ú' => 'U', + 'ñ' => 'ny', + 'Ñ' => 'Ny', + ]; foreach ($REWRITE as $key => $val) { - $s = str_replace("$key", "$val", $s); + $s = str_replace($key, $val, $s); } return $s; diff --git a/include/functions_debug.inc b/include/functions_debug.inc index b09700afc74e4280911b762f6e8b9e0006f7a819..489ed9717d0458ab67c7a75b67101e644d57c0f1 100644 --- a/include/functions_debug.inc +++ b/include/functions_debug.inc @@ -123,6 +123,7 @@ class printAClass // lighten up the background color for the key td's =) if ($iteration) { + $tmp_key_bg_color = ''; for ($i = 0; $i < 6; $i += 2) { $c = substr($key_bg_color, $i, 2); $c = hexdec($c); @@ -130,9 +131,6 @@ class printAClass if ($c > 255) { $c = 255; } - if (!isset($tmp_key_bg_color)) { - $tmp_key_bg_color = ''; - } $tmp_key_bg_color .= sprintf("%02X", $c); } $key_bg_color = $tmp_key_bg_color; diff --git a/include/password-methods/class_passwordMethod.inc b/include/password-methods/class_passwordMethod.inc index 22a99730dcefedeaddd745f941da4ad50155deb4..31e3e19c893b044ac69ddef30e65f4f94f3d75d7 100644 --- a/include/password-methods/class_passwordMethod.inc +++ b/include/password-methods/class_passwordMethod.inc @@ -311,7 +311,7 @@ abstract class passwordMethod if (isset($methods['class']['passwordMethodEmpty']) && (passwordMethodEmpty::_extract_method($password_hash) != '')) { /* Test empty method first as it gets priority */ - $method = new passwordMethodEmpty($dn); + $method = new passwordMethodEmpty(); return $method; } @@ -324,7 +324,7 @@ abstract class passwordMethod } } - $method = new passwordMethodClear($dn); + $method = new passwordMethodClear(); return $method; } diff --git a/include/password-methods/class_passwordMethodCrypt.inc b/include/password-methods/class_passwordMethodCrypt.inc index bda6bc9a77d498780d23184cbefc1b425469e808..924e0c602ace46070e7292ca532399a58cc8b6b5 100644 --- a/include/password-methods/class_passwordMethodCrypt.inc +++ b/include/password-methods/class_passwordMethodCrypt.inc @@ -59,45 +59,37 @@ class passwordMethodCrypt extends passwordMethod */ public function generate_hash (string $pwd, bool $locked = FALSE): string { + $salt = ''; + if ($this->hash == "crypt/standard-des") { $salt = ""; for ($i = 0; $i < 2; $i++) { $salt .= get_random_char(); } - } - - if ($this->hash == "crypt/enhanced-des") { + } elseif ($this->hash == "crypt/enhanced-des") { $salt = "_"; for ($i = 0; $i < 8; $i++) { $salt .= get_random_char(); } - } - - if ($this->hash == "crypt/md5") { + } elseif ($this->hash == "crypt/md5") { $salt = "\$1\$"; for ($i = 0; $i < 8; $i++) { $salt .= get_random_char(); } $salt .= "\$"; - } - - if ($this->hash == "crypt/blowfish") { + } elseif ($this->hash == "crypt/blowfish") { $salt = "\$2a\$07\$"; for ($i = 0; $i < CRYPT_SALT_LENGTH; $i++) { $salt .= get_random_char(); } $salt .= "\$"; - } - - if ($this->hash == "crypt/sha-256") { + } elseif ($this->hash == "crypt/sha-256") { $salt = "\$5\$"; for ($i = 0; $i < 16; $i++) { $salt .= get_random_char(); } $salt .= "\$"; - } - - if ($this->hash == "crypt/sha-512") { + } elseif ($this->hash == "crypt/sha-512") { $salt = "\$6\$"; for ($i = 0; $i < 16; $i++) { $salt .= get_random_char(); diff --git a/phpstan.neon b/phpstan.neon index a46124f2327a24bed64665d63a5bd792db2835b0..40acfd635a7264022a74d27ffd4efc617921c78a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,8 +2,13 @@ parameters: bootstrapFiles: - include/php_setup.inc - include/class_msg_dialog.inc + - include/class_userinfo.inc scanDirectories: - /usr/share/php fileExtensions: - php - inc + universalObjectCratesClasses: + - simplePlugin + excludes_analyse: + - */class_sieve*.inc