php8 style issues - fix PHP Deprecated: ... Passing null to parameter errors

This commit is contained in:
Ad Schellevis 2023-01-25 13:24:07 +01:00
parent 2dba52b856
commit b6a097c7b4
4 changed files with 7 additions and 7 deletions

View File

@ -250,7 +250,7 @@ function session_auth()
if (isset($_COOKIE[session_name()])) {
$secure = $config['system']['webgui']['protocol'] == "https";
setcookie(session_name(), '', time() - 42000, '/', null, $secure, true);
setcookie(session_name(), '', time() - 42000, '/', '', $secure, true);
}
/* and destroy it */
@ -352,7 +352,7 @@ function display_login_form($Login_Error)
$themename = htmlspecialchars(get_current_theme());
$product = product::getInstance();
setcookie("cookie_test", bin2hex(random_bytes(16)), time() + 3600, '/', null, $config['system']['webgui']['protocol'] == "https", true);
setcookie("cookie_test", bin2hex(random_bytes(16)), time() + 3600, '/', '', $config['system']['webgui']['protocol'] == "https", true);
$have_cookies = isset($_COOKIE["cookie_test"]);
?><!doctype html>
<html lang="en" class="no-js">

View File

@ -281,11 +281,11 @@ abstract class Rule
}
if (isset($rule['protocol']) && in_array(strtolower($rule['protocol']), array("tcp","udp","tcp/udp"))) {
$port = !empty($rule[$tag]['port']) ? str_replace('-', ':', $rule[$tag]['port']) : null;
if (strpos($port, ':any') !== false xor strpos($port, 'any:') !== false) {
if ($port == null || $port == 'any') {
$port = null;
} elseif (strpos($port, ':any') !== false xor strpos($port, 'any:') !== false) {
// convert 'any' to upper or lower bound when provided in range. e.g. 80:any --> 80:65535
$port = str_replace('any', strpos($port, ':any') !== false ? '65535' : '1', $port);
} elseif ($port == 'any') {
$port = null;
}
if (Util::isPort($port)) {
$rule[$target . "_port"] = $port;

View File

@ -252,7 +252,7 @@ class Util
*/
public static function isPort($number, $allow_range = true)
{
$tmp = explode(':', $number);
$tmp = $number !== null ? explode(':', $number) : [];
foreach ($tmp as $port) {
if (
(filter_var($port, FILTER_VALIDATE_INT, array(

View File

@ -48,7 +48,7 @@ class LegacyCSRF
);
session_start();
$secure = $config['system']['webgui']['protocol'] == 'https';
setcookie(session_name(), session_id(), null, '/', null, $secure, true);
setcookie(session_name(), session_id(), 0, '/', '', $secure, true);
}
ob_start(array($this,'csrfRewriteHandler'), 5242880);
}