HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Geo Cities - how to

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

Comments

Sign In or Register to comment.