Fix for r47482: put the RELEASE-NOTES entry in the "bug fixes" section and not the...
[mediawiki.git] / includes / proxy_check.php
blob61995fea42d952850c96c4e0b5a5c2d56b820852
1 <?php
2 /**
3 * Command line script to check for an open proxy at a specified location
4 */
6 if( php_sapi_name() != 'cli' ) {
7 die( 1 );
10 /**
13 $output = '';
15 /**
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";
20 } else {
21 /**
22 * Get parameters
24 $ip = $argv[1];
25 $port = $argv[2];
26 $url = $argv[3];
27 $host = trim(`hostname`);
28 $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
30 # Open socket
31 $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
32 if ($errno == 0 ) {
33 $output .= "Connected\n";
34 # Send payload
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";
40 $request .= "\r\n";
41 @fputs($sock, $request);
42 $response = fgets($sock, 65536);
43 $output .= $response;
44 @fclose($sock);
45 } else {
46 $output .= "No connection\n";
50 $output = escapeshellarg( $output );
52 #`echo $output >> /home/tstarling/open/proxy.log`;