+ 2

How to know the IP of a person who visited of our site?? Is it possible with js???

16th May 2018, 8:52 PM
Sina
Sina - avatar
7 ответов
+ 3
<?php // Function to get the client ip address function get_client_ip_env() { $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if(getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if(getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if(getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if(getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if(getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; return $ipaddress; ?>
17th May 2018, 9:36 AM
Xpl0it
Xpl0it - avatar
+ 1
oh thanks
16th May 2018, 9:23 PM
Sina
Sina - avatar
+ 1
Use php if you want to see if the user is using a proxy. You can check for their forwarded IP address if they are using a crappy proxy to get their real IP address.
17th May 2018, 12:26 AM
Xpl0it
Xpl0it - avatar
+ 1
How ? can you write the php code?? plz
17th May 2018, 9:33 AM
Sina
Sina - avatar
+ 1
You can use the WebRTC method to get the ip via JavaScript, or you can do as Xploit suggested. His method would honestly be the best; utilizing php
17th May 2018, 3:33 PM
Corey
Corey - avatar
0
I'd also recommend storing the value either as a session variable or into a database and for each page of whatever site you have, cross referencing the IP against the stored value by setting a token of some kind to make sure the user is who they say they are. It shouldn't take too much effort to add that functionality if you're designing this for security purposes.
17th May 2018, 9:40 AM
Xpl0it
Xpl0it - avatar