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