MediaWiki  REL1_19
proxy_check.php
Go to the documentation of this file.
00001 <?php
00009 if( php_sapi_name() != 'cli' ) {
00010         die( 1 );
00011 }
00012 
00016 $output = '';
00017 
00021 if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
00022         $output .= "Incorrect parameters\n";
00023 } else {
00027         $ip = $argv[1];
00028         $port = $argv[2];
00029         $url = $argv[3];
00030         $host = trim(`hostname`);
00031         $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
00032 
00033         # Open socket
00034         $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
00035         if ($errno == 0 ) {
00036                 $output .= "Connected\n";
00037                 # Send payload
00038                 $request = "GET $url HTTP/1.0\r\n";
00039 #               $request .= "Proxy-Connection: Keep-Alive\r\n";
00040 #               $request .= "Pragma: no-cache\r\n";
00041 #               $request .= "Host: ".$url."\r\n";
00042 #               $request .= "User-Agent: MediaWiki open proxy check\r\n";
00043                 $request .= "\r\n";
00044                 @fputs($sock, $request);
00045                 $response = fgets($sock, 65536);
00046                 $output .= $response;
00047                 @fclose($sock);
00048         } else {
00049                 $output .= "No connection\n";
00050         }
00051 }
00052 
00053 $output = escapeshellarg( $output );
00054 
00055 #`echo $output >> /home/tstarling/open/proxy.log`;