PriviMetrics
Version 1.0.9 • 43 files • 278.98 KB
Files
.last_check
admin.php
assets/.htaccess
assets/dashboard-chart.php
assets/dashboard-logic.php
assets/dashboard-modals.php
assets/dashboard-tables.php
assets/dashboard-template.php
assets/trends-template.php
chosen-limits.php
dashboard.php
data/.htaccess
extensions-load.php
extensions.php
extensions.xml
extensions/.htaccess
extensions/extensions_off.txt
functions.php
getCountryFrom/db-ip.php
getCountryFrom/geo-lite.php
getCountryFrom/ip-api-com.php
getCountryFrom/ip-info.php
getCountryFrom/ip-stack.php
getCountryFrom/ip2location-io.php
getCountryFrom/privacy-friendly.php
index.html
install.php
limits-options.php
new_version.php
privimetrics-div.js
privimetrics.php
public.php
scripts.js
settings-config.php
settings.php
signup.php
storage.php
styles-mobile.css
styles.css
trends.css
trends.php
updater/index.php
version.txt
getCountryFrom/geo-lite.php
<?php
require 'vendor/autoload.php'; // @user-config
use MaxMind\Db\Reader;
function fetch_location($ip) {
$dbFile = '/path/to/GeoLite2-Country.mmdb'; // @user-config // Path to your GeoLite2 Country database file
try {
$reader = new Reader($dbFile);
$record = $reader->get($ip);
$reader->close();
if ($record && isset($record['country']['iso_code'], $record['country']['names']['en'])) {
return [
'country' => $record['country']['names']['en'],
'code' => $record['country']['iso_code']
];
}
} catch (\Exception $e) {
}
return ['country' => 'Unknown', 'code' => 'XX'];
}
// Example usage
$location = fetch_location('8.8.8.8');
print_r($location);