Fix XmlTypeCheck docs
[mediawiki.git] / maintenance / proxyCheck.php
blobb52f20fb5080dde92452e9810fc9e0872858daa3
1 <?php
2 /**
3 * Command line script to check for an open proxy at a specified location.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Maintenance
24 if ( PHP_SAPI != 'cli' ) {
25 die( 1 );
28 /**
31 $output = '';
33 /**
34 * Exit if there are not enough parameters, or if it's not command line mode
36 if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
37 $output .= "Incorrect parameters\n";
38 } else {
39 /**
40 * Get parameters
42 $ip = $argv[1];
43 $port = $argv[2];
44 $url = $argv[3];
45 $host = trim( `hostname` );
46 $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
48 # Open socket
49 $sock = @fsockopen( $ip, $port, $errno, $errstr, 5 );
50 if ( $errno == 0 ) {
51 $output .= "Connected\n";
52 # Send payload
53 $request = "GET $url HTTP/1.0\r\n";
54 # $request .= "Proxy-Connection: Keep-Alive\r\n";
55 # $request .= "Pragma: no-cache\r\n";
56 # $request .= "Host: ".$url."\r\n";
57 # $request .= "User-Agent: MediaWiki open proxy check\r\n";
58 $request .= "\r\n";
59 @fputs( $sock, $request );
60 $response = fgets( $sock, 65536 );
61 $output .= $response;
62 @fclose( $sock );
63 } else {
64 $output .= "No connection\n";
68 $output = escapeshellarg( $output );
70 #`echo $output >> /home/tstarling/open/proxy.log`;