diff --git a/backend/getIP.php b/backend/getIP.php index 55ac99b7c..675224acf 100755 --- a/backend/getIP.php +++ b/backend/getIP.php @@ -134,13 +134,14 @@ function getIspInfo_ipinfoApi($ip){ ]); } -require_once("geoip2.phar"); -use MaxMind\Db\Reader; +if (PHP_MAJOR_VERSION >= 8){ + require_once("geoip2.phar"); +} function getIspInfo_ipinfoOfflineDb($ip){ if (!file_exists(OFFLINE_IPINFO_DB_FILE) || !is_readable(OFFLINE_IPINFO_DB_FILE)){ return null; } - $reader = new Reader(OFFLINE_IPINFO_DB_FILE); + $reader = new MaxMind\Db\Reader(OFFLINE_IPINFO_DB_FILE); $data = $reader->get($ip); if(!is_array($data)){ return null; @@ -180,16 +181,21 @@ function formatResponse_simple($ip,$ispName=null){ if (is_string($localIpInfo)) { echo formatResponse_simple($ip,$localIpInfo); }else{ - $r=getIspInfo_ipinfoApi($ip); - if(!is_null($r)){ - echo $r; - }else{ - $r=getIspInfo_ipinfoOfflineDb($ip); + //ipinfo API and offline db require PHP 8 or newer + if (PHP_MAJOR_VERSION >= 8){ + $r=getIspInfo_ipinfoApi($ip); if(!is_null($r)){ echo $r; }else{ - echo formatResponse_simple($ip); + $r=getIspInfo_ipinfoOfflineDb($ip); + if(!is_null($r)){ + echo $r; + }else{ + echo formatResponse_simple($ip); + } } + }else{ + echo formatResponse_simple($ip); } } }else{ diff --git a/doc.md b/doc.md index 21ca721e3..352192846 100755 --- a/doc.md +++ b/doc.md @@ -47,7 +47,7 @@ More guides will be added later Server side, you'll need: * Apache 2 (nginx and IIS also supported). A fast internet connection is required (possibly gigabit), and the web server must accept large POST requests (up to 20MB) -* PHP 5.4 or newer, a 64-bit version is strongly recommended +* PHP 5.4 or newer (8.0 required for ISP and distance detection), a 64-bit version is strongly recommended * OpenSSL and its PHP module (this is usually installed automatically by most distros) * If you want to store test results (telemetry), one of the following: * MySQL/MariaDB and its PHP PDO module @@ -153,7 +153,7 @@ This is the server that your users will first connect to. It hosts the UI, the J Requirements: * Apache 2 (nginx and IIS also supported). A fast connection is not mandatory, but is still recommended -* PHP 5.4 or newer +* PHP 5.4 or newer, a 64-bit version is strongly recommended * If you want to store test results (telemetry), one of the following: * MySQL/MariaDB and its PHP PDO module * PostgreSQL and its PHP PDO module @@ -241,7 +241,7 @@ These are the servers that will actually be used to perform the test. Requirements: * Apache 2 (nginx and IIS also supported). A fast internet connection is required (possibly gigabit), and the web server must accept large POST requests (up to 20MB) -* PHP 5.4 or newer +* PHP 5.4 or newer (8.0 required for ISP and distance detection) * OpenSSL and its PHP module (this is usually installed automatically by most distros) To install a backend, simply copy all the files in the `backend` folder to your backend server.