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

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

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