Author Topic: [MOD]country flags of your visitors in "Who's online?" in home page  (Read 264220 times)

0 Members and 1 Guest are viewing this topic.

Offline funpersian

  • Newbie
  • *
  • Posts: 23
    • View Profile
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: [Select]
//-----------------------------------------------------
//--- Start Configuration -----------------------------
//-----------------------------------------------------

Add above

Code:
Code: [Select]
/*
  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
*/

Find:
Code:
Code: [Select]
$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'];
Add after

Code:
Code: [Select]
/*
  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
*/  

Find:

Code:
Code: [Select]
$num_guests_online++;
Add after
Code:
Code: [Select]
/*
  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 .= " , ";
}

Find:

Code:
Code: [Select]
"num_guests_online" => $num_guests_online,
Add after

Code:
Code: [Select]
"invitado_online_list" => $invitado_online_list,

save changes


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

Add

Code: [Select]
{invitado_online_list}
save changes


 :wink: :wink:
« Last Edit: January 11, 2012, 06:27:18 PM by Rembrandt »

Offline artpics

  • Full Member
  • ***
  • Posts: 173
    • View Profile
    • my site
all okay with V1.71 thank you    :) for this mod

 :wink:

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Works Great. Thanks for this...
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
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




Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
1) from the code above remove:
Code: [Select]
        $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 ;
and
Code: [Select]
if ($num_guests_online > 1){
$invitado_online_list .= " , ";
}

2) find:
Code: [Select]
  $num_total_online = $num_registered_online + $num_guests_online;Insert above:
Code: [Select]
/*
  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
*/
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Thanks !! but I get this error :S
Code: [Select]
Parse error: parse error, unexpected ')' in /home/ascanio/domains/girlsandgirls.net/public_html/includes/sessions.php on line 512

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
fixed now.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
thanks! now it worked :)

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
hmm. I get a white page when I alter sessions.php  (included below, without V@no's changes - )

Ideas what's interfering?  thx - - 8)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
maybe step 1 - 3 were not done properly? check permissions?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline callimero

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD]country flags of your visitors in "Who's online?" in home page
« Reply #10 on: May 14, 2005, 12:38:26 PM »
hmmm....habe glaub ich alles so gemacht wie beschrieben, es geht aber nicht !

Fatal error: Call to undefined function: geoip_open() in /home/virtual/site249/fst/var/www/html/4_images/includes/sessions.php on line 389

was ist falsch ?

www.netzpfosten.de

Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: [MOD]country flags of your visitors in "Who's online?" in home page
« Reply #11 on: May 15, 2005, 09:36:21 PM »
Hi!

habe den mod denke ich korrekt installiert.
alles funktioniert.
Jedoch erhalte ich keine Flagge zu sehen sondern einen "Platzhalter" (weißes Feld) mit rotem Kreuz.
Was mache ich falsch? Kann mir jemand helfen?
Vielleicht hängt es auch damit zusammen, daß ich trasparente Gifs über die Galeriebilder als Diebstahlschutz gelegt habe.
Aber es ist doch eine andere HTML Datei (Whos_online.htm).

Bitte um Hilfe, ansonsten muß ich wohl alles rückgängig machen.

In bad english:
Could u please help me.
I ve installed the mod correctly.
but i can only see a spaceholder (red cross on white ground) instead of the flag gif.
i ve also installed transparent gif protection for gallery pics. perhaps thats the mistake. i dont know.
any ideas or solutions?
thanks

Offline artpics

  • Full Member
  • ***
  • Posts: 173
    • View Profile
    • my site
Re: [MOD]country flags of your visitors in "Who's online?" in home page
« Reply #12 on: May 15, 2005, 11:52:33 PM »
try putting the flag directory in a different folder  :wink:

Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: [MOD]country flags of your visitors in "Who's online?" in home page
« Reply #13 on: May 16, 2005, 12:45:57 AM »
@artpics

in which folder do u mean?

i put it in the root folder /4images but there are no flags shown.


Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: [MOD]country flags of your visitors in "Who's online?" in home page
« Reply #14 on: May 16, 2005, 12:59:17 AM »
ok i found out.

there was a little mistake.
the flag folder in the download link was named flag.
but in the code was written flags.

it cost me a lot of time to find out.
please change that for other users of the mod in future.

now i am happy.  :mrgreen: