I was came to the realization that I haven’t been prompted to update the GeoIP database for Little Software Stats in a couple months so I figured I should do a check on whats up. After noticing the date on the GeoIP.dat file was for July, I knew right away that something wasn’t right. Long story short, it turned out there was a problem with file permissions and therefore it wasn’t showing that there was an update (when there was). Everything is fixed now and I also add more checks so I will know right away if there’s any errors or exceptions that come up (if you’d like, I can post the PHP script on here).

Since it hasn’t been updated since July and Little Software Stats only checks for GeoIP updates every 2 weeks, not everyone is going to have their GeoIP database for their Little Software Stats updated right away. So, there’s a couple ways you can force the GeoIP database to be updated…

Option #1

Download the GeoIP database from “http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz” and ungzip it using something like 7-Zip for Windows or by typing “gunzip /path/to/GeoIP.dat.gz” in the console in Linux. Next, upload the GeoIP.dat file to the folder where it is located on the Little Software Stats web server (usually the “inc” subfolder).

Option #2

Depending on your expertise in SQL, you can also force an update of the GeoIP database in Little Software Stats. To do this, login to the SQL server and enter the following:

[highlight lang=”sql”]UPDATE [database].lss_options SET value=’2012-01-01′ WHERE name=’geoips_database_checked’;[/highlight]

You will need to replace [database] with the database name and this can be found in the “config.php” file located in the “inc” directory. What this will do is set the last time the GeoIP database was checked for an update was on January 1, 2012 which is well over 2 weeks ago. All you need to do now is login to Little Software Stats and there should be a popup come up saying an update is available. Once you click it, it should automatically update the GeoIP database.

Option #3

Simply upload the following PHP script to the root directory of Little Software Stats and execute it.

[highlight lang=”php” escape=”false”]
<?php
/*
* Force update of Little Software Stats GeoIP database file
* Created by Little Apps (http://www.little-apps.org)
* This script is public domain
* To use this script, upload it to the root directory of Little Software Stats and execute it
*/

define( ‘LSS_LOADED’, true );
require_once(dirname(__FILE__).’/inc/main.php’);

$update_url = get_option( ‘geoips_database_update_url’ );
$current_version = get_option( ‘geoips_database_version’ );

$xml_contents = get_page_contents( $update_url );

if ( $xml_contents == false ) die( ‘Unable to get current GeoIP version and URL’ );

$xml = simplexml_load_string( $xml_contents );

$last_version = (string)$xml->version;
$download_url = (string)$xml->download;

set_option( ‘geoips_database_checked’, date( “Y-m-d” ) );

$url = $download_url;
$dst_file = get_option( ‘geoips_database’ );

if ( !is_writable( $dst_file ) ) die( ‘The GeoIP database file (‘.$dst_file.’) can not be written. Please check its permissions.’.PHP_EOL );

if ( get_page_contents( $url, $dst_file ) ) {
    set_option( ‘geoips_database_version’, $last_version );

    die( ‘Successfully updated GeoIP file to v’ . $last_version . PHP_EOL );
} else {
    die( ‘There was an error updating the GeoIP file’ . PHP_EOL );
}
[/highlight]

I’m sorry to inconvenience everyone with this but I hope your able to update the GeoIP database without any problems. If your having problems, please feel free to contact me and I will do my best to fix it. I should also say that I have been trying hard to update Little Software Stats and hopefully there will be a new version released soon.