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