Page 1 of 1

Use fsockopen with proxy

Posted: Tue Feb 16, 2010 8:59 am
by klevis miho
Is it possible to use fsockopen by using a proxy server?

Re: Use fsockopen with proxy

Posted: Tue Feb 16, 2010 12:44 pm
by requinix
To the question you're asking, no. A proxy server will not help you use fsockopen.

To the question you're trying to ask, yes. Point fsockopen to the proxy and modify your request headers respectively.

Re: Use fsockopen with proxy

Posted: Thu Feb 25, 2010 7:52 am
by klevis miho
Thnx tasairis, but can you give me an example on how to do this?

Re: Use fsockopen with proxy

Posted: Thu Feb 25, 2010 9:49 am
by requinix
First learn how to send HTTP requests with fsockopen. Try a search engine.

Then (this is going from memory here) you need to:
- connect to the proxy address and port instead of the destination server
- use the full URL, with protocol and domain and everything, in the GET/POST line
- use a Proxy-Connection: instead of a regular Connection:

Re: Use fsockopen with proxy

Posted: Thu Feb 25, 2010 9:57 am
by klevis miho
I did this

$ip = "221.130.7.227"; // proxy IP, change this according to your proxy setting in your IE or NS
$port = 80; // proxy port, change this according to your proxy setting in your IE or NS

$fp = fsockopen($ip,$port); // connect to proxy
fputs($fp, "GET translate_tools Http1.1 Host: http://www.translate.google.com/ User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)");

$data="";
while (!feof($fp)) $data.=fgets($fp,64000);
fclose($fp);

print $data;

Am I missing something here?