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

Untrack the GeoLite2 database and vendor/

GeoLite2-City.mmdb was 69 MB of the repo's ~69 MB. It is MaxMind-licensed with
attribution terms and stale the day after it is downloaded, so it does not
belong in git; README.nfo now says where to get it. vendor/ goes too —
composer.lock already pins it.

Since the database is no longer present by default, a missing one now returns
null instead of throwing, and the geo fields are null-coalesced, so the page
serves without the geolocation block rather than failing.

The source link pointed at git.cleberg.net, which no longer resolves.
 .gitignore   |  8 ++++++++
 README.nfo   |  8 ++++++++
 ifconfig.php | 21 ++++++++++++++-------
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d6d42e8
--- /dev/null
+++ b/.gitignore
@@ -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
diff --git a/README.nfo b/README.nfo
index 54d072e..466efe2 100644
--- a/README.nfo
+++ b/README.nfo
@@ -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 .
diff --git a/ifconfig.php b/ifconfig.php
index 549bde9..5bd2c41 100644
--- a/ifconfig.php
+++ b/ifconfig.php
@@ -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)