i am using curl to get some info from a website, however it uses the server ip address but i want it to use the client ip address, so each user send request with their own ip not the servers, how is that possible?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "URL");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
cur开发者_Python百科l_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
$buffer = curl_exec($ch);
curl_close($ch);
It's not. The server IP is sent because the website you're looking at needs to know where to send the data back again.
If you ended up faking the IP, which is something CURL is not capable of (you need something that manipulates raw packets/sockets) then your code would never see the reply.
Heh, that's not possible. You can't use somebody else's IP address as the originating address for calls (except if you're misusing them as a Proxy, or spoofing addresses, of course).
If you elaborate what you want to achieve, maybe somebody comes up with a workaround.
PHP does not run on the client's machine. Any network connections done via PHP will be done with your web server as the connecting client. It may help if you conceptualize it like this: when a client accesses your PHP page, PHP executes on your server and generates an HTML page. It is that generated HTML page that is sent over the network to the client, not any of your PHP code. PHP is just a tool for dynamically generating HTML pages.
The only solution I see is to dynamically alter an iframe's URL then use javascript to parse through the iframe's contents. If you want information delivered back to you, you can use AJAX routines to connect back and deliver any information your javascript gathered from the iframe.
精彩评论