Convert many comments to phpdoc style, and document some more functions
[lhc/web/wiklou.git] / includes / proxy_check.php
1 <?php
2 /**
3 * Command line script to check for an open proxy at a specified location
4 * @package MediaWiki
5 */
6
7 /**
8 *
9 */
10 $output = '';
11
12 /**
13 * Exit if there are not enough parameters, or if it's not command line mode
14 */
15 if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
16 $output .= "Incorrect parameters\n";
17 } else {
18 /**
19 * Get parameters
20 */
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";
26
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";
44 }
45 }
46
47 $output = escapeshellarg( $output );
48
49 #`echo $output >> /home/tstarling/open/proxy.log`;
50
51 ?>