From 491b48a6b41147393f7a9ea55c9976728f717f60 Mon Sep 17 00:00:00 2001 From: phpipam <miha.petkovsek@telemach.si> Date: Mon, 30 Oct 2023 14:47:49 +0100 Subject: [PATCH] Fixed #3761 allowing all php8 versions --- app/admin/powerDNS/refresh-ptr-records-submit.php | 3 +++ app/subnets/addresses/print-address-table.php | 2 +- functions/checks/check_php_build.php | 2 +- functions/classes/class.Common.php | 6 +++++- functions/classes/class.PDO.php | 4 ++-- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/admin/powerDNS/refresh-ptr-records-submit.php b/app/admin/powerDNS/refresh-ptr-records-submit.php index 64f99260..9293b00d 100644 --- a/app/admin/powerDNS/refresh-ptr-records-submit.php +++ b/app/admin/powerDNS/refresh-ptr-records-submit.php @@ -59,6 +59,9 @@ $Addresses->ptr_unlink_subnet_addresses ($subnet->id); // fetch all hosts $hosts = $Addresses->fetch_subnet_addresses ($subnet->id, "ip_addr", "asc"); +// ignored +$ignored = []; + // create PTR records if (is_array($hosts) && sizeof($hosts)>0) { foreach ($hosts as $h) { diff --git a/app/subnets/addresses/print-address-table.php b/app/subnets/addresses/print-address-table.php index 50ebe3b4..4e4f09e7 100644 --- a/app/subnets/addresses/print-address-table.php +++ b/app/subnets/addresses/print-address-table.php @@ -263,7 +263,7 @@ else { # status icon if($subnet['pingSubnet']=="1") { //calculate - $tDiff = time() - strtotime($addresses[$n]->lastSeen); + $tDiff = !is_null($addresses[$n]->lastSeen)>0 ? time() - strtotime($addresses[$n]->lastSeen) : time(); if($addresses[$n]->excludePing=="1" ) { $hStatus = "padded"; $hTooltip = ""; } elseif(is_null($addresses[$n]->lastSeen)) { $hStatus = "neutral"; $hTooltip = "rel='tooltip' data-container='body' data-html='true' data-placement='left' title='"._("Address was never online")."'"; } elseif($addresses[$n]->lastSeen == "0000-00-00 00:00:00") { $hStatus = "neutral"; $hTooltip = "rel='tooltip' data-container='body' data-html='true' data-placement='left' title='"._("Address is offline")."<hr>"._("Last seen").": "._("Never")."'";} diff --git a/functions/checks/check_php_build.php b/functions/checks/check_php_build.php index 514f230e..a3237bb5 100755 --- a/functions/checks/check_php_build.php +++ b/functions/checks/check_php_build.php @@ -15,7 +15,7 @@ if(!defined('PHPIPAM_PHP_MIN')) define('PHPIPAM_PHP_MIN', "5.4"); if(!defined('PHPIPAM_PHP_UNTESTED')) -define('PHPIPAM_PHP_UNTESTED', "8.2"); // PHP 8.2 or greater is untested & unsupported +define('PHPIPAM_PHP_UNTESTED', "9.0"); // PHP 8.2 or greater is untested & unsupported if (phpversion() >= PHPIPAM_PHP_UNTESTED) { $_SESSION['footer_warnings']['php_version'] = _('Unsupported PHP version ') . phpversion(); diff --git a/functions/classes/class.Common.php b/functions/classes/class.Common.php index f6927f56..2c22f7c1 100644 --- a/functions/classes/class.Common.php +++ b/functions/classes/class.Common.php @@ -1168,7 +1168,11 @@ class Common_functions { * @param bool $permit_root_domain * @return bool|mixed */ - public function validate_hostname($hostname, $permit_root_domain=true) { + public function validate_hostname($hostname = "", $permit_root_domain=true) { + // null hostname is invalid + if(is_null($hostname)) { + return false; + } // first validate hostname $valid = (preg_match("/^([a-z_\d](-*[a-z_\d])*)(\.([a-z_\d](-*[a-z_\d])*))*$/i", $hostname) //valid chars check && preg_match("/^.{1,253}$/", $hostname) //overall length check diff --git a/functions/classes/class.PDO.php b/functions/classes/class.PDO.php index fe2af1e7..ba2d379e 100644 --- a/functions/classes/class.PDO.php +++ b/functions/classes/class.PDO.php @@ -307,7 +307,7 @@ abstract class DB { return $this->ctes_enabled; $db = Config::ValueOf("db"); - $ctes_enabled = filter_var($db['use_cte'], FILTER_VALIDATE_INT, ['options'=>['default' => 1, 'min_range' => 0, 'max_range' => 2]]); + $ctes_enabled = filter_var(@$db['use_cte'], FILTER_VALIDATE_INT, ['options'=>['default' => 1, 'min_range' => 0, 'max_range' => 2]]); if ($ctes_enabled===0) { // Disable CTE Support $this->ctes_enabled = false; @@ -380,7 +380,7 @@ abstract class DB { * Reset engine type if set in config.php (MEMORY or InnoDB) */ $db = Config::ValueOf('db'); - $tmptable_engine_type = ($db['tmptable_engine_type']=="InnoDB") ? "InnoDB" : "MEMORY"; + $tmptable_engine_type = (@$db['tmptable_engine_type']=="InnoDB") ? "InnoDB" : "MEMORY"; try { // Emulate SQL CTE query using temporary tables. -- GitLab