r96109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96108‎ | r96109 | r96110 >
Date:15:53, 2 September 2011
Author:awjrichards
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/fundraising/deployment/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php (modified) (history)

Diff [purge]

Index: branches/fundraising/deployment/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php
@@ -1,11 +1,11 @@
22 <?php
33 /**
44 * This is a modified PHP library that handles calling reCaptcha
5 - *
 5+ *
66 * This is /different/ from the original PHP API for reCAPTCHA.
77 * This version supports cURL and using an http proxy for network
88 * communications and takes some settings set by MediaWiki.
9 - *
 9+ *
1010 * See below for original license and other info.
1111 */
1212 /*
@@ -42,7 +42,7 @@
4343 */
4444
4545 // global MW variables that should be available
46 -global $wgPayflowRecaptchaUseHTTPProxy, $wgPayflowRecaptchaHTTPProxy,
 46+global $wgPayflowRecaptchaUseHTTPProxy, $wgPayflowRecaptchaHTTPProxy,
4747 $wgPayflowRecaptchaTimeout, $wgPayflowRecaptchaUseSSL, $wgPayflowRecaptchaComsRetryLimit;
4848
4949 /**
@@ -99,7 +99,7 @@
100100 } else {
101101 $response = _recaptcha_http_post_curl( $host, $path, $req, $port );
102102 }
103 -
 103+
104104 $response = explode( "\r\n\r\n", $response, 2 );
105105
106106 return $response;
@@ -114,7 +114,7 @@
115115 * @return array response
116116 */
117117 function _recaptcha_http_post_fsock( $host, $path, $data, $port = 80 ) {
118 -
 118+
119119 $http_request = "POST $path HTTP/1.0\r\n";
120120 $http_request .= "Host: $host\r\n";
121121 $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
@@ -134,8 +134,8 @@
135135 while ( !feof( $fs ) )
136136 $response .= fgets( $fs, 1160 ); // One TCP-IP packet
137137 fclose( $fs );
138 -
139 - return $response;
 138+
 139+ return $response;
140140 }
141141
142142 /**
@@ -148,7 +148,7 @@
149149 */
150150 function _recaptcha_http_post_curl( $host, $path, $data, $port = 80 ) {
151151 $url = "http://" . $host . ":" . $port . $path;
152 -
 152+
153153 $ch = curl_init( $url );
154154 curl_setopt( $ch, CURLOPT_POST, true );
155155 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
@@ -156,15 +156,15 @@
157157 curl_setopt( $ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP' );
158158 curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
159159 curl_setopt( $ch, CURLOPT_HEADER, true );
160 - curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Host: " . $host ) );
161 -
 160+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Host: " . $host ) );
 161+
162162 // set proxy settings if necessary
163163 if ( RECAPTCHA_USE_HTTP_PROXY ) {
164164 PayflowProGateway::log( 'Using http proxy ' . RECAPTCHA_HTTP_PROXY );
165165 curl_setopt( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
166166 curl_setopt( $ch, CURLOPT_PROXY, RECAPTCHA_HTTP_PROXY );
167167 }
168 -
 168+
169169 // try up to three times
170170 for ( $i = 0; $i < RECAPTCHA_RETRY_LIMIT; $i++ ) {
171171 PayflowProGateway::log( 'Preparing to communicate with reCaptcha via cURL at ' . $url . '.' );
@@ -175,13 +175,13 @@
176176 break;
177177 }
178178 }
179 -
 179+
180180 /**
181181 * This is a nasty hack to pretend like things worked when they really didn't
182 - *
183 - * Doing this per instructions from the fundraisers to accept a trxn when we
 182+ *
 183+ * Doing this per instructions from the fundraisers to accept a trxn when we
184184 * are unsuccesful communicating with reCaptcha.
185 - *
 185+ *
186186 * This sets $response to a message that will fool reCaptcha (on our end) into thinking
187187 * the user entered the correct values.
188188 */
@@ -189,7 +189,7 @@
190190 PayflowProGateway::log( 'Failed communicating with reCaptcha: ' . curl_error( $ch ) );
191191 $response = "true\r\n\r\nsuccess";
192192 }
193 -
 193+
194194 return $response;
195195 }
196196
@@ -350,7 +350,7 @@
351351
352352 if ( strlen ( $arr[0] ) <= 4 ) {
353353 $arr[0] = substr ( $arr[0], 0, 1 );
354 - } else if ( strlen ( $arr[0] ) <= 6 ) {
 354+ } elseif ( strlen ( $arr[0] ) <= 6 ) {
355355 $arr[0] = substr ( $arr[0], 0, 3 );
356356 } else {
357357 $arr[0] = substr ( $arr[0], 0, 4 );
Property changes on: branches/fundraising/deployment/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php
___________________________________________________________________
Added: svn:mergeinfo
358358 Merged /trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php:r75657-96108

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77511Updated all wfDebugLog uses in gateway code and related extensions to optiona...awjrichards22:40, 30 November 2010
r77805Follow up r77511. Missing ;...platonides15:14, 5 December 2010
r90286Swap else if for elseif...reedy16:26, 17 June 2011

Status & tagging log