MediaWiki  REL1_20
proxy_check.php
Go to the documentation of this file.
00001 <?php
00024 if( php_sapi_name() != 'cli' ) {
00025         die( 1 );
00026 }
00027 
00031 $output = '';
00032 
00036 if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
00037         $output .= "Incorrect parameters\n";
00038 } else {
00042         $ip = $argv[1];
00043         $port = $argv[2];
00044         $url = $argv[3];
00045         $host = trim(`hostname`);
00046         $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
00047 
00048         # Open socket
00049         $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
00050         if ($errno == 0 ) {
00051                 $output .= "Connected\n";
00052                 # Send payload
00053                 $request = "GET $url HTTP/1.0\r\n";
00054 #               $request .= "Proxy-Connection: Keep-Alive\r\n";
00055 #               $request .= "Pragma: no-cache\r\n";
00056 #               $request .= "Host: ".$url."\r\n";
00057 #               $request .= "User-Agent: MediaWiki open proxy check\r\n";
00058                 $request .= "\r\n";
00059                 @fputs($sock, $request);
00060                 $response = fgets($sock, 65536);
00061                 $output .= $response;
00062                 @fclose($sock);
00063         } else {
00064                 $output .= "No connection\n";
00065         }
00066 }
00067 
00068 $output = escapeshellarg( $output );
00069 
00070 #`echo $output >> /home/tstarling/open/proxy.log`;