Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Vanilla 2.6.1 is here with critical security patches. One of them has been publicly disclosed.

Geo Cities - how to

This discussion is related to the GeoIPFlags addon.
edited May 2012 in Localization

1 . download two files:

php classes: http://www.maxmind.com/download/geoip/api/php/php-1.11.tar.gz

and cities database (17 Mb unpacked): http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

2 . Put to the the /forum/plugins/geoipusers/extras/

  • GeoLiteCity.dat
  • geoipregionvars.php
  • geoipcity.inc
  • geoip.inc

(and you may remove GeoIP.dat and geoip.php ).

3 . replace UserController_UserCell_Handler($Sender) function in \forum\plugins\ geoipusers \default.php

` public function UserController_UserCell_Handler($Sender)
{

    if (empty($Sender->EventArgs['User']->LastIPAddress))
        echo '<th>GeoIP Country</th>';
    else 
    {
          $plpath=dirname(__FILE__).'/extras/';     
          $ip=$Sender->EventArgs['User']->LastIPAddress;

          include_once($plpath."geoipcity.inc");
          include_once($plpath."geoipregionvars.php"); 

          $gi = geoip_open($plpath."GeoLiteCity.dat",GEOIP_STANDARD);
          $record = geoip_record_by_addr($gi,$ip);
          geoip_close($gi);

          $countrycode = $record->country_code;
          $Title  = $record->country_name . ", ";
          $Title .= $record->city;


        echo '<td><img title="'.$Title.'" src="/forum/plugins/geoipusers/flags/' .  
        strtolower($countrycode) . '.png" alt="' . $countrycode . '" /></td>';
    }

`

In result You can see the city name and name of country by mouse over the flag

matt

Comments

Sign In or Register to comment.