● Implementing Flags into your site

Sun Oct 23, 2016 5:08 pm
Clan Leader
Top Dog
Nuke Dev / Coder
3015 Posts
coRpSE
Currently Offline
Offline

Most Played:
This week: 77.7hrs.
Total Played: 195hrs.


  
There is life outside of the game.
Reputation: 7317.9
votes: 7
This here is a section for the tutorial that has been requested on the code used to display the flags on blocks and what not from their IP. This is code that is taken right from the Honeypot and I go over a bit in the video on what it does. Implementing it will take a bit of advance knowledge of how coding is, but I hope it helps some of you get on your way to improving not only your site, but your coding skills.

Below is the code I go over in the video and is taken right from my Honeypot script.
Link to the video tutorial:
Please login to see this link
Get registered or Log in


Here is the function:

PHP:  [ Select all ]

function get_country_info($tempip)
  {
    global 
$prefix$db;
    
$tempip str_replace(".*"".0"$tempip);
    
$tempip sprintf("%u"ip2long($tempip));
    
$result $db->sql_query("SELECT * FROM `".$prefix."_nsnst_ip2country` WHERE `ip_lo`<='$tempip' AND `ip_hi`>='$tempip' LIMIT 0,1");
    
$countryinfo $db->sql_fetchrow($result);
    
$db->sql_freeresult($result);
    return 
$countryinfo;
  } 

 

Here is the call on the function and displaying the flag and country name.

PHP:  [ Select all ]

$ip2c get_country_info($row['ip']);    
    
  if (!empty(
$ip2c['c2c'])){
    if(
file_exists("./images/info/flags/".strtolower($ip2c['c2c']).".png")){
        echo 
"<img src=\"images/info/flags/".strtolower($ip2c['c2c']).".png\" border=\"0\" alt=\"".ucfirst (strtolower($ip2c['country']))."\"
         title=\""
.ucfirst (strtolower($ip2c['country']))."\" style=\"max-width: 20px; max-height:15px;\" />&nbsp;";
      }else{
        echo 
"<img src=\"./images/info/flags/not_available.png\" border=\"0\" alt=\"".ucfirst (strtolower($ip2c['country']))."\"
         title=\"Missing flag for country c2c code of "
.ucfirst (strtolower($ip2c['c2c'])).", report to coRpSE of headshotdomain.net\"
          style=\"max-width: 20px; max-height:15px;\" />&nbsp;"
;
      }
    }else{
       echo 
"<img src=\"images/info/flags/unknown.png\" border=\"0\" alt=\"UnKnown\" title=\"UnKnown\" 
       style=\"max-width: 20px; max-height:15px;\"/>&nbsp;"
;
 } 

 
hope this helps some of you.


Expand
Sun Oct 23, 2016 8:00 pm
NOOB!!!
37 Posts
Reputation: 256.6
Very Cool coRpSE!! Thanks for posting the code and tut! I've been trying to figure out how yall did this forever  kopfnuss
Sun Oct 23, 2016 8:50 pm
Original Poster
Clan Leader
Top Dog
Nuke Dev / Coder
3015 Posts
coRpSE
Currently Offline
Offline

Most Played:
This week: 77.7hrs.
Total Played: 195hrs.


  
There is life outside of the game.
Reputation: 7317.9
votes: 7
— Sp0rAdiC wrote
Very Cool coRpSE!! Thanks for posting the code and tut! I've been trying to figure out how yall did this forever  kopfnuss


No problem. I would like to put this function in the Evo CMS by default. I would need to discuss that with Lonestar if he thinks that should be in by default.


 
Sun Oct 23, 2016 9:28 pm
NOOB!!!
37 Posts
Reputation: 256.6
— coRpSE wrote

No problem. I would like to put this function in the Evo CMS by default. I would need to discuss that with Lonestar if he thinks that should be in by default.


Seems like a good idea.


 
Sun Oct 29, 2017 2:48 pm
Spammer
113 Posts
Reputation: 335.3
Hey Corpse, where do I exactly place this code script into my CZUser-Info? I'm trying to have mine CZUser-Info showing like your with the flags and Ips at the bottom. I'm not good at this as you already know this but I'm trying!....

Can you tell where I suppose insert this code script?

Thanks Corpse!....


Ghostwarrior
Forums ©