Skip to content
Advertisement

PHP Warning: file_get_contents(http://ipecho.net/plain): failed to open stream: Connection timed out in

I have an error here and I don’t know where the problem is exactly. I am trying to make a PHP file and deny anyone to use the script except the IP that I have entered into the code:

JavaScript

When I use the code Ii have problem

JavaScript

Advertisement

Answer

Why you use that site for getting the client’s IP?

You can use this PHP function for getting the client’s IP address.

whenever the application is behind a proxy(e.g, Cloudflare):

JavaScript

and when the application isn’t behind a proxy:

JavaScript

Final code should be like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement