Country Flags On Who's Online Block Country Flags On Who's Online Block
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

Main Menu

Country Flags On Who's Online Block

Started by will, February 11, 2007, 10:06:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

will

I was just lookin at Nibblers coppermine site and noticed that when a member comes online it shows a country flag next to there username, I was just wondering weather anybody or nibbler would be able to let me know how to show them on my site

Thanks ;D

Nibbler

Pickup the GeoIP binary database from http://www.maxmind.com/app/geoip_country
Decompress it into the onlinestats plugin folder
Get http://www.maxmind.com/download/geoip/api/php/geoip.inc and put it in the same place

into the codebase.php add this code


include_once("plugins/onlinestats/geoip.inc");
$gi = geoip_open("plugins/onlinestats/GeoIP.dat",GEOIP_STANDARD);


into the top of the online_mainpage() function

and further down the while loop becomes


while ($row = mysql_fetch_assoc($result)) {

$cc = strtolower(geoip_country_code_by_addr($gi, $row['user_ip']));
$value = '';
if (file_exists("images/flags/$cc.gif")) $value = ' <img src="images/flags/'.$cc.'.gif" alt="flag"/>';

$logged_in_array[] = "<a href=\"profile.php?uid={$row['user_id']}\">{$row['user_name']}</a> $value";
}


and make sure you get the user_ip from the db query

$result = cpg_db_query("SELECT user_id, user_name, user_ip FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id <> 0");

My code probably differs from the plugin so you'll have to work out the exact code for yourself.


will