3 # Command line script to check for an open proxy at a specified location
5 # Exit if there are not enough parameters, or if it's not command line mode
8 if ( ( isset( $_REQUEST ) && array_key_exists( "argv", $_REQUEST ) ) ||
count( $argv ) < 4 ) {
9 $output .= "Incorrect parameters\n";
16 $host = trim(`hostname`
);
17 $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
20 $sock = @fsockopen
($ip, $port, $errno, $errstr, 5);
22 $output .= "Connected\n";
24 $request = "GET $url HTTP/1.0\r\n";
25 # $request .= "Proxy-Connection: Keep-Alive\r\n";
26 # $request .= "Pragma: no-cache\r\n";
27 # $request .= "Host: ".$url."\r\n";
28 # $request .= "User-Agent: MediaWiki open proxy check\r\n";
30 @fputs
($sock, $request);
31 $response = fgets($sock, 65536);
35 $output .= "No connection\n";
39 $output = escapeshellarg( $output );
41 #`echo $output >> /home/tstarling/open/proxy.log`;