Having issues with ip address . Every time it gives me very false ips . Here is php code
$client = $_SERVER['HTTP_CLIENT_IP'];
$forward = $_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if (filter_var($client, FILTER_VALIDATE_IP)) $ip = $client;
elseif (filter_var($forward, FILTER_VALIDATE_IP)) $ip = $forward;
else $ip = $remote;
What’s the problem ? is there anyway to solve it ?
What do you need to ip address for?
What do you mean by false IPs? Which IP addresses do you see instead of the actual IP (and which of the three
$_SERVER you check from have this invalid IP)? And do you have this example code uploaded somewhere so we can check what it returns for us?
Check the console http://yoursoft.ga/page.php?id=5
Saying false IPs i mean that i refresh page i get ip like 126.96.36.199 , then i refresh and get
188.8.131.52 . And this happens everytime .
Thanks for sharing the additional information. I see what the issue is here.
The IP addresses you’re seeing are IP address from Cloudflare. That’s because you’re using Cloudflare on your domain name. This means that your browser connects to Cloudflare’s servers, and Cloudflare connects to your hosting account. Since, from our server’s perspective (and by extension, your code), Cloudflare is the party connection to our servers, you see Cloudflare’s IP instead of your own.
Fortunately, Cloudflare does send the IP address you are connecting from as well. Simply check the value of
$_SERVER['HTTP_CF_CONNECTING_IP'] to get the IP address sent to you by Cloudflare.
Have you informed the users who post that IP addresses will be collected. Privacy rights, you know?
I’m still waiting on judges to say something about things like access logs and rate limits. Basically every server in the world collects IP and temporarily stores addresses just to provide basic network security.
Why would a server do that? Other than blocking, the server purpose is to serve pages to the visitor.
Then where can i do ? IPs are collected in database with the ratings , comments.
Why not ask for email address and say email addresses will not be shown?
At some points everyone can give Unreal (?) email address as an input. Collecting ip is good at some points. But it must notify visitors about that.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.