From 83bb880e37b780f6684b1aaea65f289770cb54fa Mon Sep 17 00:00:00 2001 From: Yaroslav Molchan Date: Mon, 3 Feb 2020 15:42:12 +0200 Subject: [PATCH] Add PHP 7.4 support, fix deprecated syntax. --- .gitignore | 1 + README.md | 5 ++-- composer.json | 24 +++++++++++++++---- .../SypexGeo/Composer.php | 2 +- src/{IgI => Freelancehunt}/SypexGeo/SxGeo.php | 10 ++++---- 5 files changed, 29 insertions(+), 13 deletions(-) rename src/{IgI => Freelancehunt}/SypexGeo/Composer.php (99%) rename src/{IgI => Freelancehunt}/SypexGeo/SxGeo.php (97%) diff --git a/.gitignore b/.gitignore index 99251ea..a7a7f59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea nbproject vendor composer.phar diff --git a/README.md b/README.md index 82bf951..c38a1f0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ SypexGeo ========== +This is working copy [igi/sypexgeo](https://github.com/iginikolaev/sypexgeo) with PHP 7.4 support. Sypex Geo - product for location by IP address. Obtaining the IP address, Sypex Geo outputs information about the location of the visitor - country, region, city, @@ -15,7 +16,7 @@ The preferred way to install this extension is through [composer](http://getcomp Add ``` -"igi/sypexgeo": "*" +"freelancehunt/sypexgeo": "^1.0.0" ``` to the require section of your `composer.json` file. @@ -27,7 +28,7 @@ Put "post-install-cmd" event to composer.json ```json "scripts": { "post-install-cmd": [ - "IgI\\SypexGeo\\Composer::installDatabases" + "Freelancehunt\\SypexGeo\\Composer::installDatabases" ] } ``` diff --git a/composer.json b/composer.json index f1b3940..fb3f65b 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,27 @@ { - "name": "igi/sypexgeo", + "name": "freelancehunt/sypexgeo", "type": "library", "description": "PHP library Sypex Geo API (http://sypexgeo.net)", "keywords": ["sxgeo", "sypex", "geoip"], "license": "MIT", - "authors": [{ - "name": "Eugene Bazilenko", - "homepage": "https://github.com/iginikolaev" - }], + "authors": [ + { + "name": "Oleg Topchiy", + "email": "edge@freelancehunt.com" + }, + { + "name": "Vitaliy Misko", + "email": "vitaliy@freelancehunt.com" + }, + { + "name": "Yaroslav Molchan", + "email": "yaroslav@freelancehunt.com" + }, + { + "name": "Eugene Bazilenko", + "homepage": "https://github.com/iginikolaev" + } + ], "require": { "php": ">=5.3.0" }, diff --git a/src/IgI/SypexGeo/Composer.php b/src/Freelancehunt/SypexGeo/Composer.php similarity index 99% rename from src/IgI/SypexGeo/Composer.php rename to src/Freelancehunt/SypexGeo/Composer.php index 4ea01ab..8dc5db2 100644 --- a/src/IgI/SypexGeo/Composer.php +++ b/src/Freelancehunt/SypexGeo/Composer.php @@ -1,6 +1,6 @@ > 7 ? "\xff" : "\0")); break; + case 'm': $v = unpack('l', $val . (ord(substr($val, 2, 1)) >> 7 ? "\xff" : "\0")); break; case 'M': $v = unpack('L', $val . "\0"); break; case 'i': $v = unpack('l', $val); break; case 'I': $v = unpack('L', $val); break; case 'f': $v = unpack('f', $val); break; case 'd': $v = unpack('d', $val); break; - case 'n': $v = current(unpack('s', $val)) / pow(10, $type{1}); break; - case 'N': $v = current(unpack('l', $val)) / pow(10, $type{1}); break; + case 'n': $v = current(unpack('s', $val)) / pow(10, substr($type, 1, 1)); break; + case 'N': $v = current(unpack('l', $val)) / pow(10, substr($type, 1, 1)); break; case 'c': $v = rtrim($val, ' '); break; case 'b': $v = $val; $l++; break;