diff --git a/lam/templates/login.php b/lam/templates/login.php index 7808eb128..9f3c834c3 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -22,7 +22,7 @@ use ServerProfilePersistenceManager; This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Michael Duergner - 2005 - 2022 Roland Gruber + 2005 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -210,8 +210,12 @@ function display_LoginPage(?LAMLicenseValidator $licenseValidator, ?string $erro // save both in cookie $cookieOptions = lamDefaultCookieOptions(); $cookieOptions['expires'] = 0; - setcookie("Key", base64_encode($key), $cookieOptions); - setcookie("IV", base64_encode($iv), $cookieOptions); + if ($key !== false) { + setcookie("Key", base64_encode($key), $cookieOptions); + } + if ($iv !== false) { + setcookie("IV", base64_encode($iv), $cookieOptions); + } $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); $profiles = $serverProfilePersistenceManager->getProfiles(); diff --git a/lam/templates/upload/massBuildAccounts.php b/lam/templates/upload/massBuildAccounts.php index 522ebe588..5068b4710 100644 --- a/lam/templates/upload/massBuildAccounts.php +++ b/lam/templates/upload/massBuildAccounts.php @@ -131,8 +131,10 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { $handle = fopen ($_FILES['inputfile']['tmp_name'], "r"); if ($handle !== false) { if (($head = fgetcsv($handle, 2000)) !== false ) { // head row - foreach ($head as $i => $headItem) { - $ids[$headItem] = $i; + if (($head !== null) && ($head !== false)) { + foreach ($head as $i => $headItem) { + $ids[$headItem] = $i; + } } } while (($line = fgetcsv($handle, 2000)) !== false ) { // account rows @@ -193,7 +195,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { if (sizeof($values_given) != sizeof($values_unique)) { $duplicates = array(); foreach ($values_given as $key => $value) { - if (!isset($values_unique[$key])) { + if (!isset($values_unique[$key]) && ($value !== null)) { $duplicates[] = htmlspecialchars($value); } } diff --git a/phpstan.neon b/phpstan.neon index 719c55f09..c23094336 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -23,15 +23,17 @@ parameters: - '#Throwing object of an unknown class [a-zA-Z0-9\\_-]+.#' - '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#' - '#Call to an undefined method object::.*#' - - '#Parameter \#2 \$string of function explode expects string, array\|string given.#' - - '#Parameter \#2 \$result of function ldap_get_entries expects LDAP\\Result, array\|LDAP\\Result given.#' + - '#Parameter \#2 \$str of function explode expects string, array\|string given.#' + - '#Parameter \#1 \$link_identifier of function ldap_.* expects resource, LDAP\\Connection given.#' + - '#Parameter \#1 \$link of function ldap_read expects array\|resource, LDAP\\Connection given.#' - '#Cannot assign new offset to array\|string.#' - - '#Cannot access offset .* on array\|int.#' + - '#Cannot access offset .* on mixed.#' - '#Parameter \#1 \$haystack of function strpos expects string, int\|string given.#' - '#Parameter \#1 \$string of function htmlspecialchars expects string, array\|string given.#' - '#Parameter \#1 \$name of function LAM\\ACCOUNTLIST\\search_username expects string, array\|string given.#' - - '#Cannot access offset int\|string on mixed.#' - - '#Parameter \#1 \$array of function array_keys expects array, mixed given.#' - - '#Cannot access offset .+ on mixed.#' + - '#Parameter \#1 \$input of function array_keys expects array, mixed given.#' + - '#Offset int does not exist on array\|null.#' - '#Argument of an invalid type mixed supplied for foreach, only iterables are supported.#' - - '#Parameter \#2 \$args of function call_user_func_array expects array, mixed given.#' + - '#Parameter \#2 \$parameters of function call_user_func_array expects array, mixed given.#' + - '#Parameter \#1 \$input of method LAM\\AJAX\\Ajax::managePasswordChange\(\) expects array, mixed given.#' + - '#Strict comparison using === between array and false will always evaluate to false.#'