From 470a175f0ba2f434f7536354f20cd5381da12c60 Mon Sep 17 00:00:00 2001
From: Gary Allan <github@gallan.co.uk>
Date: Sat, 4 Mar 2023 18:00:26 +0000
Subject: [PATCH] php8: Compatibility fixes

Revert PHP 8.2 support due to "Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated"
This is used by multiple git submodules. No way to fix without updating submodules and breaking PHP5 and early 7.x compatibility.
---
 README.md                                   | 2 +-
 app/admin/requests/index.php                | 2 +-
 app/dashboard/widgets/access_logs.php       | 4 ++--
 app/dashboard/widgets/bw_calculator.php     | 2 +-
 app/dashboard/widgets/changelog.php         | 4 ++--
 app/dashboard/widgets/customers.php         | 4 ++--
 app/dashboard/widgets/error_logs.php        | 4 ++--
 app/dashboard/widgets/favourite_subnets.php | 2 +-
 app/dashboard/widgets/inactive-hosts.php    | 4 ++--
 app/dashboard/widgets/instructions.php      | 4 ++--
 app/dashboard/widgets/ipcalc.php            | 4 ++--
 app/dashboard/widgets/iprequest.php         | 2 +-
 app/dashboard/widgets/locations.php         | 2 +-
 app/dashboard/widgets/mac-lookup.php        | 2 +-
 app/dashboard/widgets/requests.php          | 4 ++--
 app/dashboard/widgets/statistics.php        | 2 +-
 app/dashboard/widgets/template.php          | 6 +++---
 app/dashboard/widgets/threshold.php         | 4 ++--
 app/dashboard/widgets/tools.php             | 4 ++--
 app/dashboard/widgets/top10_hosts_v4.php    | 4 ++--
 app/dashboard/widgets/top10_hosts_v6.php    | 4 ++--
 app/dashboard/widgets/top10_percentage.php  | 4 ++--
 app/install/install-execute.php             | 2 +-
 app/tools/locations/single-location-map.php | 2 +-
 app/tools/racks/print-single-rack.php       | 1 +
 app/tools/vlan/vlan-details.php             | 6 +++---
 app/tools/vrf/vrf-subnets.php               | 2 +-
 functions/checks/check_php_build.php        | 2 +-
 functions/classes/class.Common.php          | 6 +++---
 functions/classes/class.User.php            | 4 ++--
 30 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/README.md b/README.md
index 8aa4c5e5..a42a4ea7 100755
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ to be able to display javascript quickly and correctly.
 phpIPAM has been developed and tested on the following PHP versions.\
 The use of untested PHP versions is unsupported and may result in compatibility issues.
 
-- MASTER: PHP versions 5.4 to 8.2 (8.x support work-in-progress)
+- MASTER: PHP versions 5.4 to 8.1 (8.x support work-in-progress)
 - 1.5.x: PHP versions 5.4 to 7.4
 - 1.4.x: PHP versions 5.4 to 7.4
 - 1.3.x: PHP versions 5.4 to 7.1
diff --git a/app/admin/requests/index.php b/app/admin/requests/index.php
index 0e6ace7c..3a6d4251 100755
--- a/app/admin/requests/index.php
+++ b/app/admin/requests/index.php
@@ -12,7 +12,7 @@ $active_requests   = $Tools->fetch_multiple_objects ("requests", "processed", 0,
 $inactive_requests = $Tools->fetch_multiple_objects ("requests", "processed", 1, "id", false);
 # set hidden custom fields
 $hidden_cfields = pf_json_decode($User->settings->hiddenCustomFields, true);
-$hidden_cfields = is_array($hidden_cfields['requests']) ? $hidden_cfields['requests'] : array();
+$hidden_cfields = isset($hidden_cfields['requests']) ? $hidden_cfields['requests'] : array();
 ?>
 
 <h4><?php print _('List of all active IP addresses requests'); ?></h4>
diff --git a/app/dashboard/widgets/access_logs.php b/app/dashboard/widgets/access_logs.php
index bc5399c0..f9e2a3fe 100755
--- a/app/dashboard/widgets/access_logs.php
+++ b/app/dashboard/widgets/access_logs.php
@@ -1,7 +1,7 @@
 <?php
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -16,7 +16,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools","logs"));
 }
 
diff --git a/app/dashboard/widgets/bw_calculator.php b/app/dashboard/widgets/bw_calculator.php
index 12644092..61974ee9 100644
--- a/app/dashboard/widgets/bw_calculator.php
+++ b/app/dashboard/widgets/bw_calculator.php
@@ -6,7 +6,7 @@
  *********************************************/
 
 # required functions if requested via AJAX
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
diff --git a/app/dashboard/widgets/changelog.php b/app/dashboard/widgets/changelog.php
index e315b4ee..f556a874 100755
--- a/app/dashboard/widgets/changelog.php
+++ b/app/dashboard/widgets/changelog.php
@@ -5,7 +5,7 @@
  *********************************************/
 
 # required functions if requested via AJAX
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -21,7 +21,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools","changelog"));
 }
 
diff --git a/app/dashboard/widgets/customers.php b/app/dashboard/widgets/customers.php
index 212f20d6..d01d7dce 100644
--- a/app/dashboard/widgets/customers.php
+++ b/app/dashboard/widgets/customers.php
@@ -5,7 +5,7 @@
  *********************************************/
 
 # required functions if requested via AJAX
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -18,7 +18,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools","customers"));
 }
 
diff --git a/app/dashboard/widgets/error_logs.php b/app/dashboard/widgets/error_logs.php
index deb11448..25947277 100755
--- a/app/dashboard/widgets/error_logs.php
+++ b/app/dashboard/widgets/error_logs.php
@@ -1,7 +1,7 @@
 <?php
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -16,7 +16,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools","logs"));
 }
 
diff --git a/app/dashboard/widgets/favourite_subnets.php b/app/dashboard/widgets/favourite_subnets.php
index 6c96aaca..62a12cb3 100755
--- a/app/dashboard/widgets/favourite_subnets.php
+++ b/app/dashboard/widgets/favourite_subnets.php
@@ -14,7 +14,7 @@ if(!isset($User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools","favourites"));
 }
 ?>
diff --git a/app/dashboard/widgets/inactive-hosts.php b/app/dashboard/widgets/inactive-hosts.php
index f1a543eb..d4e9bce6 100644
--- a/app/dashboard/widgets/inactive-hosts.php
+++ b/app/dashboard/widgets/inactive-hosts.php
@@ -4,7 +4,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -35,7 +35,7 @@ $m = 0;
 $widget = $Tools->fetch_object ("widgets", "wfile", "inactive-hosts");
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_GET['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/dashboard/widgets/instructions.php b/app/dashboard/widgets/instructions.php
index e2cf67a8..52268738 100644
--- a/app/dashboard/widgets/instructions.php
+++ b/app/dashboard/widgets/instructions.php
@@ -4,7 +4,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -35,7 +35,7 @@ $m = 0;
 $widget = $Tools->fetch_object ("widgets", "wfile", "instructions");
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_REQUEST['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/dashboard/widgets/ipcalc.php b/app/dashboard/widgets/ipcalc.php
index 0fe2ec66..d51c606a 100644
--- a/app/dashboard/widgets/ipcalc.php
+++ b/app/dashboard/widgets/ipcalc.php
@@ -1,6 +1,6 @@
 <?php
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -14,7 +14,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools", "ip-calculator"));
 }
 ?>
diff --git a/app/dashboard/widgets/iprequest.php b/app/dashboard/widgets/iprequest.php
index 46bb2811..495480b8 100644
--- a/app/dashboard/widgets/iprequest.php
+++ b/app/dashboard/widgets/iprequest.php
@@ -1,7 +1,7 @@
 <?php
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
diff --git a/app/dashboard/widgets/locations.php b/app/dashboard/widgets/locations.php
index 561a73bf..f1f3c697 100644
--- a/app/dashboard/widgets/locations.php
+++ b/app/dashboard/widgets/locations.php
@@ -4,7 +4,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
diff --git a/app/dashboard/widgets/mac-lookup.php b/app/dashboard/widgets/mac-lookup.php
index d2d74fc0..534288d1 100644
--- a/app/dashboard/widgets/mac-lookup.php
+++ b/app/dashboard/widgets/mac-lookup.php
@@ -11,7 +11,7 @@ if (!isset($User)) {
 $User->check_user_session();
 
 # if direct request that redirect to tools page
-if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
 	header("Location: " . create_link("tools", "mac-lookup"));
 }
 ?>
diff --git a/app/dashboard/widgets/requests.php b/app/dashboard/widgets/requests.php
index 8983a05f..4504650f 100755
--- a/app/dashboard/widgets/requests.php
+++ b/app/dashboard/widgets/requests.php
@@ -1,7 +1,7 @@
 <?php
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -14,7 +14,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("administration","requests"));
 }
 
diff --git a/app/dashboard/widgets/statistics.php b/app/dashboard/widgets/statistics.php
index 077b909c..ee411602 100755
--- a/app/dashboard/widgets/statistics.php
+++ b/app/dashboard/widgets/statistics.php
@@ -1,7 +1,7 @@
 <?php
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
diff --git a/app/dashboard/widgets/template.php b/app/dashboard/widgets/template.php
index 0ca1ceab..5ffdbeab 100755
--- a/app/dashboard/widgets/template.php
+++ b/app/dashboard/widgets/template.php
@@ -7,7 +7,7 @@ This is a template for creating new widgets
 */
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -19,12 +19,12 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("administration","logs"));
 }
 
 /* You can check who requested this, to adjust parameters  */
-if($_SERVER['HTTP_X_REQUESTED_WITH']=="XMLHttpRequest")	{ $dashboard = true; }
+if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest")	{ $dashboard = true; }
 else													{ $dashboard = false; }
 
 ?>
diff --git a/app/dashboard/widgets/threshold.php b/app/dashboard/widgets/threshold.php
index 249df6a5..7ca02a9c 100644
--- a/app/dashboard/widgets/threshold.php
+++ b/app/dashboard/widgets/threshold.php
@@ -6,7 +6,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -31,7 +31,7 @@ $height = 200;
 $slimit = 5;			//we dont need this, we will recalculate
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_GET['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/dashboard/widgets/tools.php b/app/dashboard/widgets/tools.php
index 5a487b1c..a489833b 100644
--- a/app/dashboard/widgets/tools.php
+++ b/app/dashboard/widgets/tools.php
@@ -1,6 +1,6 @@
 <?php
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -14,7 +14,7 @@ if(!is_object(@$User)) {
 $User->check_user_session ();
 
 # if direct request that redirect to tools page
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	header("Location: ".create_link("tools"));
 }
 
diff --git a/app/dashboard/widgets/top10_hosts_v4.php b/app/dashboard/widgets/top10_hosts_v4.php
index 70ae1baa..f36d82a9 100755
--- a/app/dashboard/widgets/top10_hosts_v4.php
+++ b/app/dashboard/widgets/top10_hosts_v4.php
@@ -6,7 +6,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -27,7 +27,7 @@ $height = 200;
 $slimit = 10;			//we dont need this, we will recalculate
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_GET['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/dashboard/widgets/top10_hosts_v6.php b/app/dashboard/widgets/top10_hosts_v6.php
index fea498d2..b6ce5d6c 100755
--- a/app/dashboard/widgets/top10_hosts_v6.php
+++ b/app/dashboard/widgets/top10_hosts_v6.php
@@ -6,7 +6,7 @@
  **/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -27,7 +27,7 @@ $height = 200;
 $slimit = 10;			//we dont need this, we will recalculate
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_GET['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/dashboard/widgets/top10_percentage.php b/app/dashboard/widgets/top10_percentage.php
index ef449ac2..46e92874 100755
--- a/app/dashboard/widgets/top10_percentage.php
+++ b/app/dashboard/widgets/top10_percentage.php
@@ -4,7 +4,7 @@
  **********************************************/
 
 # required functions
-if(!is_object(@$User)) {
+if(!isset($User)) {
 	require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
 	# classes
 	$Database	= new Database_PDO;
@@ -25,7 +25,7 @@ $height = 200;
 $slimit = 10;			//we dont need this, we will recalculate
 
 # if direct request include plot JS
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")	{
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")	{
 	# get widget details
 	if(!$widget = $Tools->fetch_object ("widgets", "wfile", $_GET['section'])) { $Result->show("danger", _("Invalid widget"), true); }
 	# reset size and limit
diff --git a/app/install/install-execute.php b/app/install/install-execute.php
index 2f7ff79e..c57cb332 100755
--- a/app/install/install-execute.php
+++ b/app/install/install-execute.php
@@ -14,7 +14,7 @@ $Tools	 	= new Tools ($Database);
 $Result 	= new Result ();
 
 # make sure it is properly requested
-if($_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")						{ $Result->show("danger", _("Invalid request"), true); }
+if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")						{ $Result->show("danger", _("Invalid request"), true); }
 
 # if already installed ignore!
 if($Install->check_table ("widgets", false) && @$_POST['dropdb']!="on") {
diff --git a/app/tools/locations/single-location-map.php b/app/tools/locations/single-location-map.php
index 9904b7a7..0fefda0d 100644
--- a/app/tools/locations/single-location-map.php
+++ b/app/tools/locations/single-location-map.php
@@ -8,7 +8,7 @@
 $User->check_user_session();
 
 # fetch location
-if(!$location) {
+if(!isset($location)) {
     $location = $Tools->fetch_object("locations", "id", $location_index);
 }
 
diff --git a/app/tools/racks/print-single-rack.php b/app/tools/racks/print-single-rack.php
index 3ac570b1..6358769f 100755
--- a/app/tools/racks/print-single-rack.php
+++ b/app/tools/racks/print-single-rack.php
@@ -194,6 +194,7 @@ if ($User->settings->enableCustomers=="1" && $User->get_module_permissions ("cus
             reset($rack_contents);
             $prev = false;
             $is_back =  false;
+            $error = "";
             do {
                 if (!($cd = current($rack_devices))) {
                     $cur = current($rack_contents);
diff --git a/app/tools/vlan/vlan-details.php b/app/tools/vlan/vlan-details.php
index 6b0a298c..e4d9ff86 100755
--- a/app/tools/vlan/vlan-details.php
+++ b/app/tools/vlan/vlan-details.php
@@ -11,6 +11,9 @@ $User->check_module_permissions ("vlan", User::ACCESS_R, true, false);
 # get VLAN details
 $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $_GET['sPage']);
 
+# not existing
+if(!isset($vlan['domainId']))		{ $Result->show("danger", _('Invalid VLAN id'), true); }
+
 # fetch l2 domain
 $vlan_domain = $Tools->fetch_object("vlanDomains", "id", $vlan['domainId']);
 if($vlan_domain===false)			{ $Result->show("danger", _("Invalid ID"), true); }
@@ -18,9 +21,6 @@ if($vlan_domain===false)			{ $Result->show("danger", _("Invalid ID"), true); }
 # Check user has read level permission to l2domain (or die with warning)
 $User->check_l2domain_permissions($vlan_domain);
 
-# not existing
-if($vlan[0]===false)				{ $Result->show("danger", _('Invalid VLAN id'), true); }
-
 # get custom VLAN fields
 $custom_fields = $Tools->fetch_custom_fields('vlans');
 
diff --git a/app/tools/vrf/vrf-subnets.php b/app/tools/vrf/vrf-subnets.php
index 99274af1..52910131 100644
--- a/app/tools/vrf/vrf-subnets.php
+++ b/app/tools/vrf/vrf-subnets.php
@@ -59,7 +59,7 @@ else {
 
 			print "<tr>";
 			if($User->get_module_permissions ("vlan")>=User::ACCESS_R)
-		    print "	<td><a href='".create_link("tools","vlan", $vlan->domainId, $vlan->vlanId)."'><span class='badge badge1'>$vlan->number</span></a></td>";
+			print is_object($vlan) ? "	<td><a href='".create_link("tools","vlan", $vlan->domainId, $vlan->vlanId)."'><span class='badge badge1'>$vlan->number</span></a></td>" : "<td></td>";
 		    print "	<td class='small description'><a href='".create_link("subnets",$subnet['sectionId'],$subnet['id'])."'>$subnet[description]</a></td>";
 		    print "	<td><a href='".create_link("subnets",$subnet['sectionId'],$subnet['id'])."'>".$Subnets->transform_address($subnet['subnet'], "dotted")."/$subnet[mask] $fullinfo</a></td>";
 
diff --git a/functions/checks/check_php_build.php b/functions/checks/check_php_build.php
index 54c364c5..b88cd21e 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.3");  // PHP 8.3 or greater is untested & unsupported
+define('PHPIPAM_PHP_UNTESTED', "8.2");  // PHP 8.2 or greater is untested & unsupported
 
 
 # Empty missing arrays to prevent errors
diff --git a/functions/classes/class.Common.php b/functions/classes/class.Common.php
index ff42444a..96055336 100644
--- a/functions/classes/class.Common.php
+++ b/functions/classes/class.Common.php
@@ -903,7 +903,7 @@ class Common_functions  {
 	    $hms = "";
 
 	    // get the number of hours
-	    $hours = intval(intval($sec) / 3600);
+	    $hours = intval($sec / 3600);
 
 	    // add to $hms, with a leading 0 if asked for
 	    $hms .= ($padHours)
@@ -911,13 +911,13 @@ class Common_functions  {
 	          : $hours. ':';
 
 	    // get the seconds
-	    $minutes = intval(($sec / 60) % 60);
+	    $minutes = intval($sec / 60) % 60;
 
 	    // then add to $hms (with a leading 0 if needed)
 	    $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
 
 	    // seconds
-	    $seconds = intval($sec % 60);
+	    $seconds = intval($sec) % 60;
 
 	    // add to $hms, again with a leading 0 if needed
 	    $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
diff --git a/functions/classes/class.User.php b/functions/classes/class.User.php
index cbdce301..263af2bd 100644
--- a/functions/classes/class.User.php
+++ b/functions/classes/class.User.php
@@ -371,7 +371,7 @@ class User extends Common_functions {
         # not authenticated
         if($this->authenticated===false) {
             # error print for AJAX
-            if(@$_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest") {
+            if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest") {
                 # for AJAX always check origin
                 $this->check_referrer ();
                 # kill session
@@ -603,7 +603,7 @@ class User extends Common_functions {
      * @return void
      */
     private function check_referrer () {
-        if ( ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") && ($_SERVER['HTTP_ORIGIN'] != $_SERVER['HTTP_HOST'] ) ) {
+        if ( (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") && ($_SERVER['HTTP_ORIGIN'] != $_SERVER['HTTP_HOST'] ) ) {
             # write log and die
             $this->Log->write ("referrer_check", _('Page not referred properly'), 0 );
             $this->Result->show ("danger", _('Page not referred properly'), true);
-- 
GitLab