Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump geoip2/geoip2 from 2.13.0 to 3.0.0 in /_backend #3421

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified _backend/GeoLite2-City.mmdb
Binary file not shown.
7 changes: 5 additions & 2 deletions _backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"config": {
"platform": {
"php": "8.1"
},
"allow-plugins": {
"php-http/discovery": true
}
},
"autoload": {
Expand All @@ -14,12 +17,12 @@
"stripe/stripe-php": "13.14.0",
"sentry/sdk": "^3.3.0",
"erusev/parsedown-extra": "^0.8",
"geoip2/geoip2": "^2.0",
"geoip2/geoip2": "^3.0",
"ext-intl": ">=7",
"ext-json": ">=7"
},
"require-dev": {
"league/climate": "^3.2",
"squizlabs/php_codesniffer": "3.*"
}
}
}
60 changes: 30 additions & 30 deletions _backend/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

require_once 'classify.functions.php';
require_once 'classify.get_ip.php';
require_once 'geolocate.functions.php';
require_once 'geolocate.guess_ip.php';

// provides $region, $timecode, $download_link

$region = getDownloadRegion($ip);
if (is_array($region)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,33 +129,6 @@ function getIPHash($hostname, $debug = false)
}
}

function getCurrentCountry($hostname, $debug = false)
{

try {
if (!class_exists('GeoIp2\Database\Reader')) {
throw new \Exception('Class GeoIp2\Database\Reader not found');
}
$reader = new Reader(__DIR__.'/GeoLite2-City.mmdb');
$record = $reader->city($hostname);
$country = $record->country->isoCode;
} catch (\Exception $e) {
if ($debug) {
echo $e->getMessage();
} else {
error_log($e->getMessage());
}
$country = false;
}

if ($debug) {
echo 'Country: "'.$country.'"'."\n";
}

return $country;
}


function getCurrentLocation($hostname, $debug = false)
{

Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions _backend/geolocate.test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require_once __DIR__.'/geolocate.functions.php';
require_once __DIR__.'/geolocate.guess_ip.php';

$region = getDownloadRegion($ip);
$hash = getIPHash($ip);
if (is_array($region)) {
$region = $region[$hash];
}
$currentLocation = getCurrentLocation($ip);

var_dump($ip, $region, $hash, $currentLocation);
72 changes: 0 additions & 72 deletions _backend/here-miss.php

This file was deleted.

6 changes: 0 additions & 6 deletions _backend/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
require __DIR__ . '/bootstrap.php';
require_once __DIR__.'/log-echo.php';

// Honor the IE do-not-track-header,
// even though it's set automatically.
$respectIE = true;
// Set the DNT variables.
require_once __DIR__.'/here-miss.php';

date_default_timezone_set('UTC');

$sitewide['title'] = 'elementary';
Expand Down
6 changes: 2 additions & 4 deletions api/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* Live-generated JSON configuration for use in client side javascript
*/

require_once __DIR__.'/../_backend/classify.current.php';
require_once __DIR__.'/../_backend/geolocate.download.php'; // provides $region, $timecode
require_once __DIR__.'/../_backend/config.loader.php';
require_once __DIR__.'/../_backend/here-miss.php';

$output = array(
'release' => array(
Expand All @@ -27,8 +26,7 @@
'user' => array(
'ip' => $ip,
'region' => $region,
'timecode' => $timecode,
'trackme' => $trackme
'timecode' => $timecode
)
);

Expand Down
4 changes: 2 additions & 2 deletions api/geolocate.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require_once __DIR__.'/../_backend/classify.functions.php';
require_once __DIR__.'/../_backend/classify.get_ip.php';
require_once __DIR__.'/../_backend/geolocate.functions.php'; // provides getCurrentLocation()
require_once __DIR__.'/../_backend/geolocate.guess_ip.php'; // provides $ip
require_once __DIR__.'/../_backend/store/address.php';
require_once __DIR__.'/../_backend/store/api.php';

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once __DIR__.'/_backend/classify.current.php';
require_once __DIR__.'/_backend/geolocate.download.php'; // provides $download_link
require_once __DIR__.'/_backend/preload.php';
require_once __DIR__.'/_backend/os-payment.php';

Expand Down
2 changes: 1 addition & 1 deletion previous.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once __DIR__.'/_backend/classify.current.php';
require_once __DIR__.'/_backend/geolocate.download.php'; // provides $download_link
require_once __DIR__.'/_backend/preload.php';
require_once __DIR__.'/_backend/os-payment.php';

Expand Down
Loading