Lavalair WML Mods

Started on the old forum in January 2010 · view the original in the archive · old links redirect here

1 reply · 1,070 views · started 16 years ago · 1 min read

bOrN2pwn Developer · 230 posts #2

IP to Country

Heres my WML version working 100% for me....

Add into core.php

//////////////////////Country 
function iptocountry($ip) {
    $numbers = preg_split( "/\./", $ip);
    include("../ip_files/".$numbers[0].".php");
    $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
    foreach($ranges as $key => $value){
        if($key<=$code){
            if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
            }
    }
    if ($two_letter_country_code==""){$two_letter_country_code="unkown";}
    return $two_letter_country_code;
}
function country_name($two_letter_country_code)
    {
     include("ip_files/countries.php");
    $country_name=$countries[$two_letter_country_code][0];
   return $country_name;
    }
function show_flag($two_letter_country_code)
      {
     $file_to_check='./ip_flags/'.strtolower($two_letter_country_code).'.gif';
     if (file_exists($file_to_check)){
                $FLAG= '<img src="'.$file_to_check.'" alt="'.$two_letter_country_code.'"/>';
                }else{
                $FLAG= '<img src="./ip_flags/noflag.gif" alt="'.$two_letter_country_code.'"/>';
                }
       return $FLAG;
       }
//////////////////////Operator theyr using?
function ip()
{
if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR"];}
else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}
if(strpos($ip,",")){
$exp_ip=explode(",",$ip);
$ip=$exp_ip[0];
}
return $ip;
}

function ipinrange($ip, $range1, $range2)
{
$ip=ip2long($ip);
$range1=ip2long($range1);
$range2=ip2long($range2);
return (($ip >= $range1) && ($ip <= $range2));
}
function network($ip,$opt)
{
$result=mysql_query("SELECT * FROM network ORDER BY subone, subtwo");
while($ranges=mysql_fetch_array($result)){
if(ipinrange($ip, $ranges[1], $ranges[2])){
if(is_file("flags/".$ranges["flag"])&&$opt==1){
$flag="<img src=\"flags/".$ranges["flag"]."\" alt=\"".$ranges["flag"]."\"/><br/>";
}
return $flag.$ranges["isp"]." ".$ranges["country"];
}
}
}

Add into index.php in viewuser were you want to display it...

 ////////////////////////////////////////
$uipadd = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'"));
$IPaddress=$uipadd[0];
$two_letter_country_code=iptocountry($IPaddress);
echo "<b>Flag:</b> <img src=\"../flags/$two_letter_country_code.gif\" alt=\"*\" /><br/>\n";
echo "<b>Country:</b> $two_letter_country_code<br/>";
////////////////////////////////////////

Enjoi

BakGat

class Counter {
public:
  void Count();
  int  ReadDisplay();
private:
  int  CurrentCount;
};

External image (may be gone) External image (may be gone) External image (may be gone)

Back up my hard drive? How do I put it in reverse? http://www.hackthissite.org Profile…

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close