Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide the IP address in a PHP connection?

Tags:

php

proxy

ip

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).

like image 440
Niet the Dark Absol Avatar asked Feb 14 '12 16:02

Niet the Dark Absol


People also ask

How do I hide my IP address in HTML?

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);

How can I get IP address in PHP?

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.


2 Answers

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.

like image 156
Your Common Sense Avatar answered Oct 13 '22 07:10

Your Common Sense


No, IP is the one of the few things client can't camouflage.

like image 44
dynamic Avatar answered Oct 13 '22 06:10

dynamic