* double quotes to single quotes
[mediawiki.git] / includes / proxy_check.php
blobb017f3211c03caad6400ff208c1ebd6533b45d06
1 <?php
2 /**
3 * Command line script to check for an open proxy at a specified location
4 * @package MediaWiki
5 */
7 /**
9 */
10 $output = '';
12 /**
13 * Exit if there are not enough parameters, or if it's not command line mode
15 if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
16 $output .= "Incorrect parameters\n";
17 } else {
18 /**
19 * Get parameters
21 $ip = $argv[1];
22 $port = $argv[2];
23 $url = $argv[3];
24 $host = trim(`hostname`);
25 $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
27 # Open socket
28 $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
29 if ($errno == 0 ) {
30 $output .= "Connected\n";
31 # Send payload
32 $request = "GET $url HTTP/1.0\r\n";
33 # $request .= "Proxy-Connection: Keep-Alive\r\n";
34 # $request .= "Pragma: no-cache\r\n";
35 # $request .= "Host: ".$url."\r\n";
36 # $request .= "User-Agent: MediaWiki open proxy check\r\n";
37 $request .= "\r\n";
38 @fputs($sock, $request);
39 $response = fgets($sock, 65536);
40 $output .= $response;
41 @fclose($sock);
42 } else {
43 $output .= "No connection\n";
47 $output = escapeshellarg( $output );
49 #`echo $output >> /home/tstarling/open/proxy.log`;