diff --git a/README.md b/README.md index 14ccdc9..8f66f3e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mapcode Library for PHP -Copyright (C) 2014-2020 Stichting Mapcode Foundation (http://www.mapcode.com) +Copyright (C) 2014-2022 Stichting Mapcode Foundation (http://www.mapcode.com) ---- @@ -44,6 +44,10 @@ limitations under the License. ## Version History +### 2.2.3 + +* Updated to support PHP version 8.1.4 (thanks, Bert Hooyman). + ### 2.2.2 * Fixed PHP errors for new version of PHP. diff --git a/mapcode_api.php b/mapcode_api.php index ccd9718..88e5d45 100644 --- a/mapcode_api.php +++ b/mapcode_api.php @@ -1,7 +1,7 @@ lon; @@ -961,7 +961,7 @@ function decodeAutoHeader($input, $extensionchars, $m) } $value *= (961 * 31); $triple = decodeTriple(substr($input, strlen($input) - 3)); - if ($triple == 0) { + if (!$triple) { return new MapcodeZone(); } for (; Codex($m) == $codexm; $m++) { @@ -1239,7 +1239,7 @@ function to_ascii($str) } $p = strrpos($result, ' '); if ($p === false) $p = 0; else $p++; - if ($result[$p] == 'A') { + if ((strlen($result)) && ($result[$p] == 'A')) { $result = substr($result, 0, $p) . aeu_pack(aeu_unpack(substr($result, $p))); } return $result; @@ -1454,7 +1454,7 @@ function decode($mapcodeString, $territory = -1) } else { return master_decode($mapcodeString, $contextTerritoryNumber); } - return 0; + return null; } function encodeSixWide($x, $y, $width, $height) @@ -1783,7 +1783,7 @@ function mapcoderEngine($enc, $tn, $getshortest, $isrecursive, $state_override, if (is_numeric($tn) && $tn >= 0 && $tn <= $uptoRun) { $fromRun = $tn; $uptoRun = $tn; - } else if ($GLOBALS['redivar']) { + } else if (array_key_exists('redivar', $GLOBALS)) { $use_redivar = 1; $HOR = 1; $i = 0; // pointer into redivar @@ -1949,4 +1949,4 @@ function encodeShortestWithPrecision($latitudeDegrees, $longitudeDegrees, $preci function encodeShortest($latitudeDegrees, $longitudeDegrees, $territory = -1) { return encodeShortestWithPrecision($latitudeDegrees, $longitudeDegrees, 0, $territory); -} \ No newline at end of file +} diff --git a/mapcode_library_php.doc b/mapcode_library_php.doc index de58677..01d41cf 100644 Binary files a/mapcode_library_php.doc and b/mapcode_library_php.doc differ diff --git a/sample.php b/sample.php index 43ea735..35431cc 100644 --- a/sample.php +++ b/sample.php @@ -34,7 +34,11 @@ echo '