utils: avoid weak comparisons

This commit is contained in:
Dylan K. Taylor 2025-01-06 22:53:35 +00:00
parent 97c5902ae2
commit 0358b7dce4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 7 additions and 7 deletions

View File

@ -100,7 +100,7 @@ class Internet{
}
$ip = self::getURL("http://ifconfig.me/ip");
if($ip !== null && ($addr = trim($ip->getBody())) != ""){
if($ip !== null && ($addr = trim($ip->getBody())) !== ""){
return self::$ip = $addr;
}

View File

@ -134,7 +134,7 @@ abstract class Timezone{
$offset = $matches[2];
if($offset == ""){
if($offset === ""){
return "UTC";
}
@ -156,7 +156,7 @@ abstract class Timezone{
$offset = trim(exec('date +%:z'));
if($offset == "+00:00"){
if($offset === "+00:00"){
return "UTC";
}
@ -195,7 +195,7 @@ abstract class Timezone{
$offset = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
//After date_parse is done, put the sign back
if($negative_offset == true){
if($negative_offset){
$offset = -abs($offset);
}
@ -204,7 +204,7 @@ abstract class Timezone{
//That's been a bug in PHP since 2008!
foreach(timezone_abbreviations_list() as $zones){
foreach($zones as $timezone){
if($timezone['timezone_id'] !== null && $timezone['offset'] == $offset){
if($timezone['timezone_id'] !== null && $timezone['offset'] === $offset){
return $timezone['timezone_id'];
}
}

View File

@ -220,7 +220,7 @@ final class Utils{
$mac = implode("\n", $mac);
if(preg_match_all("#Physical Address[. ]{1,}: ([0-9A-F\\-]{17})#", $mac, $matches) > 0){
foreach($matches[1] as $i => $v){
if($v == "00-00-00-00-00-00"){
if($v === "00-00-00-00-00-00"){
unset($matches[1][$i]);
}
}
@ -234,7 +234,7 @@ final class Utils{
$mac = implode("\n", $mac);
if(preg_match_all("#HWaddr[ \t]{1,}([0-9a-f:]{17})#", $mac, $matches) > 0){
foreach($matches[1] as $i => $v){
if($v == "00:00:00:00:00:00"){
if($v === "00:00:00:00:00:00"){
unset($matches[1][$i]);
}
}