Long story short, I'm wanting to test my site's anti-bot systems ("bot" here referring to players of the game cheating with programs, not spiders etc.).
I've written my own bot using PHP's CLI. Most of the time, my site is able to detect the bot activity and block it.
However I need to test dealing with dynamic IPs, and since I have a static one this is no easy task as far as I can tell. There are other things I'd like to be able to test that involve multiple IPs.
So, bottom line, is it possible to hide/change the IP address seen by the server when my PHP script connects to it and, if so, how do I do it? (I've never really used proxies before so I don't know much about them).
Try this code: $withProxy = array( 'http' => array( 'proxy' => 'tcp://221.10.40.238:80', 'request_fulluri' => true, ), ); $strProxy = stream_context_create($withProxy); $getPage = file_get_contents("http://www.website.com", False, $strProxy);
Using getenv() function: To get the IP Address,we use getenv(“REMOTE_ADDR”) command. The getenv() function in PHP is used for retrieval of values of an environment variable in PHP. It is used to return the value of a specific environment variable.
you can write a test code which does substitute $_SERVER['REMOTE_ADDR'] at the very beginning of your script and do whatever tests you like.
No, IP is the one of the few things client can't camouflage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With