r86898 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86897‎ | r86898 | r86899 >
Date:21:04, 25 April 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
proxy_check.php is probably useful to keep around, but it's not really an includes script

Move it to maintenance/proxy_check.php
Modified paths:
  • /trunk/phase3/includes/proxy_check.php (deleted) (history)
  • /trunk/phase3/maintenance/proxy_check.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/proxy_check.php
@@ -0,0 +1,54 @@
 2+<?php
 3+/**
 4+ * Command line script to check for an open proxy at a specified location
 5+ *
 6+ * @file
 7+ */
 8+
 9+if( php_sapi_name() != 'cli' ) {
 10+ die( 1 );
 11+}
 12+
 13+/**
 14+ *
 15+ */
 16+$output = '';
 17+
 18+/**
 19+ * Exit if there are not enough parameters, or if it's not command line mode
 20+ */
 21+if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
 22+ $output .= "Incorrect parameters\n";
 23+} else {
 24+ /**
 25+ * Get parameters
 26+ */
 27+ $ip = $argv[1];
 28+ $port = $argv[2];
 29+ $url = $argv[3];
 30+ $host = trim(`hostname`);
 31+ $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
 32+
 33+ # Open socket
 34+ $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
 35+ if ($errno == 0 ) {
 36+ $output .= "Connected\n";
 37+ # Send payload
 38+ $request = "GET $url HTTP/1.0\r\n";
 39+# $request .= "Proxy-Connection: Keep-Alive\r\n";
 40+# $request .= "Pragma: no-cache\r\n";
 41+# $request .= "Host: ".$url."\r\n";
 42+# $request .= "User-Agent: MediaWiki open proxy check\r\n";
 43+ $request .= "\r\n";
 44+ @fputs($sock, $request);
 45+ $response = fgets($sock, 65536);
 46+ $output .= $response;
 47+ @fclose($sock);
 48+ } else {
 49+ $output .= "No connection\n";
 50+ }
 51+}
 52+
 53+$output = escapeshellarg( $output );
 54+
 55+#`echo $output >> /home/tstarling/open/proxy.log`;
Property changes on: trunk/phase3/maintenance/proxy_check.php
___________________________________________________________________
Added: svn:eol-style
156 + native
Added: svn:keywords
257 + Author Date Id Revision
Index: trunk/phase3/includes/proxy_check.php
@@ -1,54 +0,0 @@
2 -<?php
3 -/**
4 - * Command line script to check for an open proxy at a specified location
5 - *
6 - * @file
7 - */
8 -
9 -if( php_sapi_name() != 'cli' ) {
10 - die( 1 );
11 -}
12 -
13 -/**
14 - *
15 - */
16 -$output = '';
17 -
18 -/**
19 - * Exit if there are not enough parameters, or if it's not command line mode
20 - */
21 -if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
22 - $output .= "Incorrect parameters\n";
23 -} else {
24 - /**
25 - * Get parameters
26 - */
27 - $ip = $argv[1];
28 - $port = $argv[2];
29 - $url = $argv[3];
30 - $host = trim(`hostname`);
31 - $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
32 -
33 - # Open socket
34 - $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
35 - if ($errno == 0 ) {
36 - $output .= "Connected\n";
37 - # Send payload
38 - $request = "GET $url HTTP/1.0\r\n";
39 -# $request .= "Proxy-Connection: Keep-Alive\r\n";
40 -# $request .= "Pragma: no-cache\r\n";
41 -# $request .= "Host: ".$url."\r\n";
42 -# $request .= "User-Agent: MediaWiki open proxy check\r\n";
43 - $request .= "\r\n";
44 - @fputs($sock, $request);
45 - $response = fgets($sock, 65536);
46 - $output .= $response;
47 - @fclose($sock);
48 - } else {
49 - $output .= "No connection\n";
50 - }
51 -}
52 -
53 -$output = escapeshellarg( $output );
54 -
55 -#`echo $output >> /home/tstarling/open/proxy.log`;

Follow-up revisions

RevisionCommit summaryAuthorDate
r86900Followup r86898, fix $wgProxyScriptPathreedy21:18, 25 April 2011

Comments

#Comment by IAlex (talk | contribs)   21:13, 25 April 2011

You will need to update $wgProxyScriptPath accordingly.

Status & tagging log