Ip2country

Started on the old forum in December 2007 · view the original in the archive · old links redirect here

49 replies · 5,805 views · started 18 years ago · 1 min read

TL;DR · summary of 49 replies
  • Guest asked how to install country flags for Lavalair profiles based on user IPs.
  • Ori provided code snippets and SQL queries, suggesting a solution using the Wapside script functions.
  • Guest had trouble getting the correct flag showing up consistently across all users' profiles.
  • Guest's final working code snippet used ip() function correctly fetching IP from database instead of $_SERVER variables.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

12 participants
Guest #21

4 all of yous that dnt have the country flag images i get mine from here http://www.3dflags.com if yous build up anymmore networks can u list them here fanx

still not working i add this tho the user profiles

$ip = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'")); echo "network: ".network($ip,1);

Guest #22

still not working i add this tho the user profiles

$ip = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'")); echo "network: ".network($ip,1);

please help me out

ori Lead · 512 posts #24

check the directory where the flags are they may just b mislinked... and bling change $ip to $ip[0]

Guest #25

check the directory where the flags are they may just b mislinked... and bling change $ip to $ip[0]

now working the flags only the worng one i see the same at every profile

ori Lead · 512 posts #26

post ur view profile code then and ill edit what u need to get it working

Guest #27

post ur view profile code then and ill edit what u need to get it working

this code i use into my usersprofiles

$ip[0] = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'")); echo "Country:".network($ip,1);

this code i use into the core

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"].""/> "; } return $flag.$ranges["isp"]." ".$ranges["country"]; } } }

KillaKlan Developer · 145 posts #28

this is mine:

$ip = mysql_fetch_array(mysql_query("SELECT ipadd FROM ibwf_users WHERE id='".$who."'")); echo "network: ".network($ip[0]);

and my core

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) { $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"].""/> "; } return $flag.$ranges["isp"]." ".$ranges["country"]; } } }

this works fine for me, just gotta add more networks/ISP lol

ori Lead · 512 posts #29

yeh thats rite way of doing it lol mrbling use the code killaklan put heres mine on my new script pmpl

since u seen my other functions this only 1 in the code that wasnt posted

function subno() { if($_SERVER["HTTP_X_UP_SUBNO"]){$subno=$_SERVER["HTTP_X_UP_SUBNO"];} else{$subno=gethostbyaddr(ip());} if($subno==""){ $exp_ip=explode(",",ip()); $subno=gethostbyaddr($exp_ip[0]); } return $subno; }

$browser=browser();
$ip=ip();
$network=network($ip,1);
$db_network=network($ip,0);
if($network==""||$db_network==""){
$network=subno();
$db_network=subno();
db_query("INSERT INTO logs SET action='network', details='".ip()."', date='".time()."'","i");
}
echo "[b]browser:[/b]

".browser()."

[b]ip:[/b]

".ip()."

[b]network:[/b]

".network(ip(),1);
}
Guest #30

yeh thats rite way of doing it lol mrbling use the code killaklan put heres mine on my new script pmpl

since u seen my other functions this only 1 in the code that wasnt posted

function subno() { if($_SERVER["HTTP_X_UP_SUBNO"]){$subno=$_SERVER["HTTP_X_UP_SUBNO"];} else{$subno=gethostbyaddr(ip());} if($subno==""){ $exp_ip=explode(",",ip()); $subno=gethostbyaddr($exp_ip[0]); } return $subno; }

$browser=browser();
$ip=ip();
$network=network($ip,1);
$db_network=network($ip,0);
if($network==""||$db_network==""){
$network=subno();
$db_network=subno();
db_query("INSERT INTO logs SET action='network', details='".ip()."', date='".time()."'","i");
}
echo "browser:

".browser()."

ip:

".ip()."

network:

".network(ip(),1);
}

dnt work mate sorry

ori Lead · 512 posts #31

i no it dnt differnt script... was jus an example

Write your reply now; next you create a free account (or sign in) and it is posted right away. 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