Quest for Remote IP Detector

Started on the old forum in August 2009 · view the original in the archive · old links redirect here

#detector #remote-ip

9 replies · 673 views · started 17 years ago · 1 min read

6 participants
anderson Developer · 146 posts #1

Hello, I want a script that can detect user's remote IP. Generally when a user uses opera mini we don't get his real IP. As example, when a user of my site comes with his Nokia Nokia7210Supernova/2.0 his IP is 117.99.1.237 at the same time when he comes with opera mini his IP is 64.225.18.137. It seems that opera mini works here like a proxy IP. I just want his real IP ( 117.99.1.237 ) even when he uses opera mini. That's all.

If any coder can know the code plz post here and help me. Thanks.

Wait...

kiLLeR-eyEd_14 Senior · 382 posts #2

anderson wrote: Hello, I want a script that can detect user's remote IP. Generally when a user uses opera mini we don't get his real IP. As example, when a user of my site comes with his Nokia Nokia7210Supernova/2.0 his IP is 117.99.1.237 at the same time when he comes with opera mini his IP is 64.225.18.137. It seems that opera mini works here like a proxy IP. I just want his real IP ( 117.99.1.237 ) even when he uses opera mini. That's all.

If any coder can know the code plz post here and help me. Thanks.

mate.,hope this would help you..try this one:

 if(!empty($_SERVER['HTTP_CLIENT_IP']))
 {
 $ip = $_SERVER['HTTP_CLIENT_IP'];
 }
 else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
 {
 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
 }
 else if(!empty($_SERVER['REMOTE_ADDR']))
{
 $ip = $_SERVER['REMOTE_ADDR'];
 }else{
 $ip = "Unknown";
 }
echo $ip;
Navjot_Saini Junior · 15 posts #3

hope this may help yuh ....

i use this function in ma script ....call this function anywhere u need original ip of a user....

function getip(){

if (getenv('HTTP_X_FORWARDED_FOR')){

$ip=getenv('HTTP_X_FORWARDED_FOR');

}else{

$ip=getenv('REMOTE_ADDR');

}

return $ip;

}

:(8)

  1. Saini : Devloping The web...😳:(😠
enishant Newbie · 1 posts #4
<?php echo "X-Forworded for : ". $_SERVER['HTTP_X_FORWARDED_FOR']; echo " "; echo "Remote Address : ". $_SERVER['REMOTE_ADDR']; echo " "; echo "+". $_SERVER['HTTP_X_MSISDN']; echo " "; echo "Network : ". $_SERVER['HTTP_X_NETWORK_INFO']; echo " "; echo "Via : ". $_SERVER['HTTP_VIA']; ?>

Nishant Vaity Website : http://www.nixindia.co.cc/ Contact No. : +91-9870041197

anderson Developer · 146 posts #5

I used all of ur codes earlier but none of them working.

Wait...

anderson Developer · 146 posts #6

I am writing here a code. I will be grateful if anyone inform me by testing it if it is working for detecting real IP or not when a user uses proxy/opera mini. Thanks.

function validip($ip) {
 
if (!empty($ip) && ip2long($ip)!=-1) {
 
$reserved_ips = array (
 
array('0.0.0.0','2.255.255.255'),
 
array('10.0.0.0','10.255.255.255'),
 
array('127.0.0.0','127.255.255.255'),
 
array('169.254.0.0','169.254.255.255'),
 
array('172.16.0.0','172.31.255.255'),
 
array('192.0.2.0','192.0.2.255'),
 
array('192.168.0.0','192.168.255.255'),
 
array('255.255.255.0','255.255.255.255')
 
);
 
 
foreach ($reserved_ips as $r) {
 
$min = ip2long($r[0]);
 
$max = ip2long($r[1]);
 
if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
 
}
 
return true;
 
} else {
 
return false;
 
}
 }
 
 function getip() {
 
if (validip($_SERVER["HTTP_CLIENT_IP"])) {
 
return $_SERVER["HTTP_CLIENT_IP"];
 
}
 
foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
 
if (validip(trim($ip))) {
 
return $ip;
 
}
 
}
 
if (validip($_SERVER["HTTP_X_FORWARDED"])) {
 
return $_SERVER["HTTP_X_FORWARDED"];
 
} elseif (validip($_SERVER["HTTP_FORWARDED_FOR"])) {
 
return $_SERVER["HTTP_FORWARDED_FOR"];
 
} elseif (validip($_SERVER["HTTP_FORWARDED"])) {
 
return $_SERVER["HTTP_FORWARDED"];
 
} elseif (validip($_SERVER["HTTP_X_FORWARDED"])) {
 
return $_SERVER["HTTP_X_FORWARDED"];
 
} else {
 
return $_SERVER["REMOTE_ADDR"];
 
}
 }
 ?>

Wait...

Leviathan73 Senior · 260 posts #9

but this function must be put in core.php file or another file?

Guest #10

anderson wrote: Hello, I want a script that can detect user's remote IP. Generally when a user uses opera mini we don't get his real IP. As example, when a user of my site comes with his Nokia Nokia7210Supernova/2.0 his IP is 117.99.1.237 at the same time when he comes with opera mini his IP is 64.225.18.137. It seems that opera mini works here like a proxy IP. I just want his real IP ( 117.99.1.237 ) even when he uses opera mini. That's all.

If any coder can know the code plz post here and help me. Thanks.

Here is the code to get the remote IP and real browser when a member use Opera Mini. Opera Mini | Charlie's BLOG

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