4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[MOD]country flags of your visitors in "Who's online?" in home page

(1/41) > >>

funpersian:
hi all

This mod will show country flags of your visitors in "Who's online?" in home page !!!

demo





Visit the home page of the tools will be used in this mod:
http://www.maxmind.com/app/geoip_country
Read the licence and make sure its NOT conflicts with your usage.

Download the following files:
1) http://www.maxmind.com/download/geoip/api/php/geoip.inc
Save it in includes/ directory of your 4images installation

2) http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz <- Please Download from Attachment!
Extract the content of this archive (u can use WinZIP, WinRAR, 7-Zip or any other archivers)
Save the extracted file (GeoIP.dat) into includes/ directory (make sure u keep the case: its GeoIP.dat not geoip.dat)

3) http://www.maxmind.com/download/geoip/database/flag.zip
or
http://web.tampabay.rr.com/vano/redirect.html?flags.zip

Extract the flags (again, any compatible archivers would work, Windows XP users dont need any 3-party tools for that)
Save the files into flags/ folder in your 4images root directory.
For visitors with "unknown" or LAN IPs, save this image: as lan.gif into flags/ folder as well
For visitors with using satelite service, save this image: as a2.gif into flags/ folder.


4) Open Files :   includes/sessions.php

Find:

Code:

--- Code: ---//-----------------------------------------------------
//--- Start Configuration -----------------------------
//-----------------------------------------------------
--- End code ---

Add above

Code:

--- Code: ---/*
  MOD VISITORS COUNTRY FLAGS
  START INSERT
*/
    if (!class_exists("GeoIP"))
    {
      include(ROOT_PATH."includes/geoip.inc");
    }
    
    $gi = geoip_open(ROOT_PATH."includes/GeoIP.dat",GEOIP_STANDARD);
    $countries = array();
/*
  MOD VISITORS COUNTRY FLAGS
  END INSERT
*/
--- End code ---

Find:
Code:

--- Code: --- $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $row['session_user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$row['session_user_id'];
--- End code ---

Add after

Code:

--- Code: --- /*
  MOD VISITORS COUNTRY FLAGS
  START INSERT
*/
        $cid = geoip_country_code_by_addr($gi, $row['session_ip']);
        if (empty($cid)) $cid = "lan";
        $countries[$cid] = isset($countries[$cid]) ? $countries[$cid]+1 : 1;
        $username = "<img src=\"".ROOT_PATH."flags/".strtolower($cid).".gif"."\" alt=\"".(($cid != "lan") ? $gi->GEOIP_COUNTRY_NAMES[$gi->GEOIP_COUNTRY_CODE_TO_NUMBER[$cid]] : "Unknown or LAN")."\" border=0> ".$username;
/*
  MOD VISITORS COUNTRY FLAGS
  END INSERT
*/  
--- End code ---

Find:

Code:

--- Code: ---$num_guests_online++;
--- End code ---

Add after
Code:

--- Code: ---/*
  MOD VISITORS COUNTRY FLAGS
  START INSERT
*/
        $cid = geoip_country_code_by_addr($gi, $row['session_ip']);
        if (empty($cid)) $cid = "lan";
        $countries[$cid] = isset($countries[$cid]) ? $countries[$cid]+1 : 1;
        $invitado_online_list  = "<font color=\"#00FFFF\">".$num_guests_online."</font><img src=\"".ROOT_PATH."flags/".strtolower($cid).".gif"."\" alt=\"".(($cid != "lan") ? $gi->GEOIP_COUNTRY_NAMES[$gi->GEOIP_COUNTRY_CODE_TO_NUMBER[$cid]] : "Unknown or LAN")."\" border=0> ".$invitado_online_list ;
/*
  MOD VISITORS COUNTRY FLAGS
  END INSERT
*/
if ($num_guests_online > 1){
$invitado_online_list .= " , ";
}
--- End code ---

Find:

Code:

--- Code: ---"num_guests_online" => $num_guests_online,
--- End code ---

Add after

Code:

--- Code: ---"invitado_online_list" => $invitado_online_list,
--- End code ---


save changes


5?) Open templates/<your templates>/whos_online.html

Add


--- Code: ---{invitado_online_list}
--- End code ---

save changes


 :wink: :wink:

artpics:
all okay with V1.71 thank you    :) for this mod

 :wink:

JensF:
Works Great. Thanks for this...

ascanio:
Ok this is a little strange hehehe in the screenshot that is on the first post the flags are showed just to say how many users there are for each country right?
I installed this mod an without modifiging the whos_online.html templates I see a flag next to the name of the user in the whos_online.html and that's cool but then I modify the whos_online.html and  with 20 user online 3 from usa and the rest form spain I just said the there was 3 from spain,2 from spain, 1 from spain :S



V@no:
1) from the code above remove:
--- Code: ---        $invitado_online_list  = "<font color=\"#00FFFF\">".$num_guests_online."</font><img src=\"".ROOT_PATH."flags/".strtolower($cid).".gif"."\" alt=\"".(($cid != "lan") ? $gi->GEOIP_COUNTRY_NAMES[$gi->GEOIP_COUNTRY_CODE_TO_NUMBER[$cid]] : "Unknown or LAN")."\" border=0> ".$invitado_online_list ;

--- End code ---
and
--- Code: ---if ($num_guests_online > 1){
$invitado_online_list .= " , ";
}
--- End code ---

2) find:
--- Code: ---  $num_total_online = $num_registered_online + $num_guests_online;
--- End code ---
Insert above:
--- Code: ---/*
  MOD VISITORS COUNTRY FLAGS
  START INSERT
*/
  $invitado_online_list = array();
  if (!empty($countries))
  {
    asort($countries);
    foreach ($countries as $key => $val)
    {
      $invitado_online_list[] = "<font color=\"#00FFFF\">".$val."</font><img src=\"".ROOT_PATH."/flags/".strtolower($key).".gif\" align=\"middle\" alt=\"".(($key != "lan") ? $gi->GEOIP_COUNTRY_NAMES[$gi->GEOIP_COUNTRY_CODE_TO_NUMBER[$key]] : "Unknown or LAN")."\" border=0>";
    }
  }
  $invitado_online_list = implode(" , ", $invitado_online_list);
/*
  MOD VISITORS COUNTRY FLAGS
  END INSERT
*/
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version