krz/ifconfig.php
A private ifconfig service.
clone: git clone https://gitbay.org/krz/ifconfig.php.git
781e82cbcad9f12838f01c687979027823c1937c
unsigned
author: Christian Cleberg <hello@cleberg.net> · 2026-08-22T23:43:26Z
.gitignore | 8 ++++++++ README.nfo | 8 ++++++++ ifconfig.php | 21 ++++++++++++++------- 3 files changed, 30 insertions(+), 7 deletions(-) new file mode 100644 @@ -0,0 +1,8 @@ +# Composer installs these; composer.lock pins them. +vendor/ + +# MaxMind GeoLite2. Licensed, ~69 MB, and stale the day after it is downloaded — +# see README.nfo for how to fetch it. Never commit it. +*.mmdb + +.DS_Store @@ -36,6 +36,14 @@ DEVELOP composer require maxmind-db/reader:~1.0 composer update + geolite2 database. not in the repo: maxmind-licensed, ~69mb, and stale + the day after you download it. sign up for a free maxmind account, then: + + https://www.maxmind.com/en/accounts/current/geoip/downloads + + download GeoLite2-City in mmdb form and put GeoLite2-City.mmdb next to + ifconfig.php. without it the page still serves, minus the geo block. + dev server: sudo php --server localhost:8080 --docroot . @@ -6,6 +6,13 @@ use MaxMind\Db\Reader; function loadGeo(string $ipAddress): ?array { $databaseFile = 'GeoLite2-City.mmdb'; + + // Not shipped with the source: it is MaxMind-licensed and ~69 MB. Without + // it the page still serves, just with no geolocation block. + if (!is_readable($databaseFile)) { + return null; + } + $reader = new Reader($databaseFile); $results = $reader->get($ipAddress); $reader->close(); @@ -17,7 +24,7 @@ function loadGeo(string $ipAddress): ?array $site_title = 'ip.cleberg.net'; $site_owner_name = 'Christian Cleberg'; $site_owner_url = 'https://cleberg.net'; -$source_repository = 'https://git.cleberg.net/ifconfig.php.git'; +$source_repository = 'https://github.com/krazywarez/ifconfig.php'; // Extract geolocation $geo = loadGeo($_SERVER['REMOTE_ADDR']); @@ -40,12 +47,12 @@ $user = array( 'fwd_ip' => $_SERVER['HTTP_X_FORWARDED_FOR'], 'fwd_host' => (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']) : ""), 'dnt' => $_SERVER['HTTP_DNT'], - 'continent_code' => $geo['continent']['code'], - 'continent_name' => $geo['continent']['names']['en'], - 'country_code' => $geo['country']['geoname_id'], - 'country_iso' => $geo['country']['iso_code'], - 'country_name' => $geo['country']['names']['en'], - 'time_zone' => $geo['location']['time_zone'] + 'continent_code' => $geo['continent']['code'] ?? '', + 'continent_name' => $geo['continent']['names']['en'] ?? '', + 'country_code' => $geo['country']['geoname_id'] ?? '', + 'country_iso' => $geo['country']['iso_code'] ?? '', + 'country_name' => $geo['country']['names']['en'] ?? '', + 'time_zone' => $geo['location']['time_zone'] ?? '' ); // Check request (ex. ifconfig.php?q=ip)