Index: trunk/extensions/ConfirmEdit/ReCaptcha.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | |
23 | 23 | $wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php'; |
24 | 24 | |
25 | | -$wgAutoloadClasses['ReCaptcha']= $dir . '/ReCaptcha.class.php'; |
| 25 | +$wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php'; |
26 | 26 | |
27 | 27 | require_once( 'recaptchalib.php' ); |
28 | 28 | |
— | — | @@ -57,9 +57,9 @@ |
58 | 58 | $wgReCaptchaPrivateKey = $recaptcha_private_key; |
59 | 59 | } |
60 | 60 | |
61 | | - if ($wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '') { |
62 | | - die ('You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' . |
| 61 | + if ( $wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '' ) { |
| 62 | + die ( 'You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' . |
63 | 63 | "use the reCAPTCHA plugin. You can sign up for a key <a href='" . |
64 | | - htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>."); |
| 64 | + htmlentities( recaptcha_get_signup_url ( $wgServerName, "mediawiki" ) ) . "'>here</a>." ); |
65 | 65 | } |
66 | 66 | } |
Index: trunk/extensions/ConfirmEdit/HTMLCaptchaField.php |
— | — | @@ -33,11 +33,11 @@ |
34 | 34 | */ |
35 | 35 | private $validationResult; |
36 | 36 | |
37 | | - public function __construct( $params ){ |
| 37 | + public function __construct( $params ) { |
38 | 38 | parent::__construct( $params ); |
39 | 39 | |
40 | 40 | // For differentiating the type of form, mainly |
41 | | - if( isset( $params['prefix'] ) ){ |
| 41 | + if ( isset( $params['prefix'] ) ) { |
42 | 42 | $this->prefix = $params['prefix']; |
43 | 43 | } |
44 | 44 | } |
— | — | @@ -48,29 +48,29 @@ |
49 | 49 | * @param $value String |
50 | 50 | * @return String |
51 | 51 | */ |
52 | | - public function getInputHTML( $value ){ |
| 52 | + public function getInputHTML( $value ) { |
53 | 53 | # TODO |
54 | 54 | } |
55 | 55 | |
56 | | - public function validate( $data, $alldata ){ |
| 56 | + public function validate( $data, $alldata ) { |
57 | 57 | // We sent back the exists status of the captcha before. If it *doesn't* exist |
58 | 58 | // we actually want to validate this as true, because we don't want an angry red |
59 | 59 | // error message, just for the user to put the captcha in again |
60 | | - if( $data === false ){ |
| 60 | + if ( $data === false ) { |
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
64 | | - |
| 64 | + |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @param $request WebRequest |
69 | 69 | * @return void |
70 | 70 | */ |
71 | | - public function loadDataFromRequest( $request ){ |
| 71 | + public function loadDataFromRequest( $request ) { |
72 | 72 | $this->captcha = Captcha::factory(); |
73 | 73 | $this->captcha->loadFromRequest( $request, $this ); |
74 | | - if( !$this->captcha->exists() ){ |
| 74 | + if ( !$this->captcha->exists() ) { |
75 | 75 | // The captcha doesn't exist; probably because it's already been used and |
76 | 76 | // then deleted for security. Load the field up with a new captcha which |
77 | 77 | // will be shown to the user when the validation of said new object fails |
Index: trunk/extensions/ConfirmEdit/ReCaptcha.class.php |
— | — | @@ -1,8 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ReCaptcha extends SimpleCaptcha { |
5 | | - |
6 | | - //reCAPTHCA error code returned from recaptcha_check_answer |
| 5 | + // reCAPTHCA error code returned from recaptcha_check_answer |
7 | 6 | private $recaptcha_error = null; |
8 | 7 | |
9 | 8 | /** |
— | — | @@ -12,10 +11,11 @@ |
13 | 12 | */ |
14 | 13 | function getForm() { |
15 | 14 | global $wgReCaptchaPublicKey, $wgReCaptchaTheme; |
| 15 | + |
16 | 16 | $useHttps = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ); |
17 | 17 | $js = 'var RecaptchaOptions = ' . Xml::encodeJsVar( array( 'theme' => $wgReCaptchaTheme, 'tabindex' => 1 ) ); |
18 | 18 | |
19 | | - return Html::inlineScript( $js ) . recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps); |
| 19 | + return Html::inlineScript( $js ) . recaptcha_get_html( $wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps ); |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
— | — | @@ -27,12 +27,12 @@ |
28 | 28 | function passCaptcha() { |
29 | 29 | global $wgReCaptchaPrivateKey, $wgRequest; |
30 | 30 | |
31 | | - //API is hardwired to return wpCaptchaId and wpCaptchaWord, so use that if the standard two are empty |
| 31 | + // API is hardwired to return wpCaptchaId and wpCaptchaWord, so use that if the standard two are empty |
32 | 32 | $challenge = $wgRequest->getVal( 'recaptcha_challenge_field', $wgRequest->getVal( 'wpCaptchaId' ) ); |
33 | 33 | $response = $wgRequest->getVal( 'recaptcha_response_field', $wgRequest->getVal( 'wpCaptchaWord' ) ); |
34 | 34 | |
35 | 35 | if ( $response === null ) { |
36 | | - //new captcha session |
| 36 | + // new captcha session |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | $response |
45 | 45 | ); |
46 | 46 | |
47 | | - if (!$recaptcha_response->is_valid) { |
| 47 | + if ( !$recaptcha_response->is_valid ) { |
48 | 48 | $this->recaptcha_error = $recaptcha_response->error; |
49 | 49 | return false; |
50 | 50 | } |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | |
58 | 58 | function addCaptchaAPI( &$resultArr ) { |
59 | 59 | global $wgReCaptchaPublicKey; |
| 60 | + |
60 | 61 | $resultArr['captcha']['type'] = 'recaptcha'; |
61 | 62 | $resultArr['captcha']['mime'] = 'image/png'; |
62 | 63 | $resultArr['captcha']['key'] = $wgReCaptchaPublicKey; |
— | — | @@ -72,6 +73,7 @@ |
73 | 74 | function getMessage( $action ) { |
74 | 75 | $name = 'recaptcha-' . $action; |
75 | 76 | $text = wfMsg( $name ); |
| 77 | + |
76 | 78 | # Obtain a more tailored message, if possible, otherwise, fall back to |
77 | 79 | # the default for edits |
78 | 80 | return wfEmptyMsg( $name, $text ) ? wfMsg( 'recaptcha-edit' ) : $text; |
Index: trunk/extensions/ConfirmEdit/Captcha.php |
— | — | @@ -177,12 +177,12 @@ |
178 | 178 | */ |
179 | 179 | function isIPWhitelisted() { |
180 | 180 | global $wgCaptchaWhitelistIP; |
181 | | - |
| 181 | + |
182 | 182 | if ( $wgCaptchaWhitelistIP ) { |
183 | 183 | global $wgRequest; |
184 | | - |
| 184 | + |
185 | 185 | $ip = $wgRequest->getIP(); |
186 | | - |
| 186 | + |
187 | 187 | foreach ( $wgCaptchaWhitelistIP as $range ) { |
188 | 188 | if ( IP::isInRange( $ip, $range ) ) { |
189 | 189 | return true; |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit.php |
— | — | @@ -191,12 +191,12 @@ |
192 | 192 | $wgHooks['APIGetParamDescription'][] = 'ConfirmEditHooks::APIGetParamDescription'; |
193 | 193 | |
194 | 194 | $wgAutoloadClasses['ConfirmEditHooks'] = "$wgConfirmEditIP/ConfirmEditHooks.php"; |
195 | | -$wgAutoloadClasses['SimpleCaptcha']= "$wgConfirmEditIP/Captcha.php"; |
196 | | -$wgAutoloadClasses['CaptchaStore']= "$wgConfirmEditIP/CaptchaStore.php"; |
197 | | -$wgAutoloadClasses['CaptchaSessionStore']= "$wgConfirmEditIP/CaptchaStore.php"; |
198 | | -$wgAutoloadClasses['CaptchaCacheStore']= "$wgConfirmEditIP/CaptchaStore.php"; |
| 195 | +$wgAutoloadClasses['SimpleCaptcha'] = "$wgConfirmEditIP/Captcha.php"; |
| 196 | +$wgAutoloadClasses['CaptchaStore'] = "$wgConfirmEditIP/CaptchaStore.php"; |
| 197 | +$wgAutoloadClasses['CaptchaSessionStore'] = "$wgConfirmEditIP/CaptchaStore.php"; |
| 198 | +$wgAutoloadClasses['CaptchaCacheStore'] = "$wgConfirmEditIP/CaptchaStore.php"; |
199 | 199 | $wgAutoloadClasses['CaptchaSpecialPage'] = "$wgConfirmEditIP/ConfirmEditHooks.php"; |
200 | | -$wgAutoloadClasses['HTMLCaptchaField']= "$wgConfirmEditIP/HTMLCaptchaField.php"; |
| 200 | +$wgAutoloadClasses['HTMLCaptchaField'] = "$wgConfirmEditIP/HTMLCaptchaField.php"; |
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Set up $wgWhitelistRead |
Index: trunk/extensions/ConfirmEdit/ConfirmEditHooks.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ConfirmEditHooks { |
5 | | - |
6 | 5 | /** |
7 | 6 | * Get the global Captcha instance |
8 | 7 | * |
— | — | @@ -9,11 +8,14 @@ |
10 | 9 | */ |
11 | 10 | static function getInstance() { |
12 | 11 | global $wgCaptcha, $wgCaptchaClass; |
| 12 | + |
13 | 13 | static $done = false; |
| 14 | + |
14 | 15 | if ( !$done ) { |
15 | 16 | $done = true; |
16 | 17 | $wgCaptcha = new $wgCaptchaClass; |
17 | 18 | } |
| 19 | + |
18 | 20 | return $wgCaptcha; |
19 | 21 | } |
20 | 22 | |
— | — | @@ -63,20 +65,23 @@ |
64 | 66 | } |
65 | 67 | |
66 | 68 | class CaptchaSpecialPage extends UnlistedSpecialPage { |
67 | | - public function __construct(){ |
| 69 | + public function __construct() { |
68 | 70 | parent::__construct( 'Captcha' ); |
69 | 71 | } |
| 72 | + |
70 | 73 | function execute( $par ) { |
71 | 74 | $this->setHeaders(); |
| 75 | + |
72 | 76 | $instance = ConfirmEditHooks::getInstance(); |
| 77 | + |
73 | 78 | switch( $par ) { |
74 | | - case "image": |
75 | | - if ( method_exists( $instance, 'showImage' ) ) |
76 | | - return $instance->showImage(); |
77 | | - case "help": |
78 | | - default: |
79 | | - return $instance->showHelp(); |
| 79 | + case "image": |
| 80 | + if ( method_exists( $instance, 'showImage' ) ) { |
| 81 | + return $instance->showImage(); |
| 82 | + } |
| 83 | + case "help": |
| 84 | + default: |
| 85 | + return $instance->showHelp(); |
80 | 86 | } |
81 | 87 | } |
82 | 88 | } |
83 | | - |
Index: trunk/extensions/ConfirmEdit/CaptchaStore.php |
— | — | @@ -40,9 +40,9 @@ |
41 | 41 | * @return CaptchaStore |
42 | 42 | */ |
43 | 43 | public final static function get() { |
44 | | - if( !self::$instance instanceof self ){ |
| 44 | + if ( !self::$instance instanceof self ) { |
45 | 45 | global $wgCaptchaStorageClass; |
46 | | - if( in_array( 'CaptchaStore', class_parents( $wgCaptchaStorageClass ) ) ) { |
| 46 | + if ( in_array( 'CaptchaStore', class_parents( $wgCaptchaStorageClass ) ) ) { |
47 | 47 | self::$instance = new $wgCaptchaStorageClass; |
48 | 48 | } else { |
49 | 49 | throw new MWException( "Invalid CaptchaStore class $wgCaptchaStorageClass" ); |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | /** |
56 | 56 | * Protected constructor: no creating instances except through the factory method above |
57 | 57 | */ |
58 | | - protected function __construct(){} |
| 58 | + protected function __construct() {} |
59 | 59 | } |
60 | 60 | |
61 | 61 | class CaptchaSessionStore extends CaptchaStore { |
Index: trunk/extensions/ConfirmEdit/MathCaptcha.class.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | |
41 | 41 | /** Fetch the math */ |
42 | 42 | function fetchMath( $sum ) { |
43 | | - if( MWInit::classExists( 'MathRenderer' ) ){ |
| 43 | + if ( MWInit::classExists( 'MathRenderer' ) ) { |
44 | 44 | $math = new MathRenderer( $sum ); |
45 | 45 | } else { |
46 | 46 | throw new MWException( 'MathCaptcha requires the Math extension for MediaWiki versions 1.18 and above.' ); |
Index: trunk/extensions/ConfirmEdit/recaptchalib.php |
— | — | @@ -35,22 +35,22 @@ |
36 | 36 | /** |
37 | 37 | * The reCAPTCHA server URL's |
38 | 38 | */ |
39 | | -define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api"); |
40 | | -define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api"); |
41 | | -define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); |
| 39 | +define( "RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api" ); |
| 40 | +define( "RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api" ); |
| 41 | +define( "RECAPTCHA_VERIFY_SERVER", "www.google.com" ); |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Encodes the given data into a query string format |
45 | 45 | * @param $data - array of string elements to be encoded |
46 | 46 | * @return string - encoded request |
47 | 47 | */ |
48 | | -function _recaptcha_qsencode ($data) { |
| 48 | +function _recaptcha_qsencode ( $data ) { |
49 | 49 | $req = ""; |
50 | 50 | foreach ( $data as $key => $value ) |
51 | | - $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; |
| 51 | + $req .= $key . '=' . urlencode( stripslashes( $value ) ) . '&'; |
52 | 52 | |
53 | 53 | // Cut the last '&' |
54 | | - $req=substr($req,0,strlen($req)-1); |
| 54 | + $req = substr( $req, 0, strlen( $req ) -1 ); |
55 | 55 | return $req; |
56 | 56 | } |
57 | 57 | |
— | — | @@ -64,29 +64,29 @@ |
65 | 65 | * @param int port |
66 | 66 | * @return array response |
67 | 67 | */ |
68 | | -function _recaptcha_http_post($host, $path, $data, $port = 80) { |
| 68 | +function _recaptcha_http_post( $host, $path, $data, $port = 80 ) { |
69 | 69 | |
70 | | - $req = _recaptcha_qsencode ($data); |
| 70 | + $req = _recaptcha_qsencode ( $data ); |
71 | 71 | |
72 | 72 | $http_request = "POST $path HTTP/1.0\r\n"; |
73 | 73 | $http_request .= "Host: $host\r\n"; |
74 | 74 | $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; |
75 | | - $http_request .= "Content-Length: " . strlen($req) . "\r\n"; |
| 75 | + $http_request .= "Content-Length: " . strlen( $req ) . "\r\n"; |
76 | 76 | $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; |
77 | 77 | $http_request .= "\r\n"; |
78 | 78 | $http_request .= $req; |
79 | 79 | |
80 | 80 | $response = ''; |
81 | | - if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { |
82 | | - die ('Could not open socket'); |
| 81 | + if ( false == ( $fs = @fsockopen( $host, $port, $errno, $errstr, 10 ) ) ) { |
| 82 | + die ( 'Could not open socket' ); |
83 | 83 | } |
84 | 84 | |
85 | | - fwrite($fs, $http_request); |
| 85 | + fwrite( $fs, $http_request ); |
86 | 86 | |
87 | | - while ( !feof($fs) ) |
88 | | - $response .= fgets($fs, 1160); // One TCP-IP packet |
89 | | - fclose($fs); |
90 | | - $response = explode("\r\n\r\n", $response, 2); |
| 87 | + while ( !feof( $fs ) ) |
| 88 | + $response .= fgets( $fs, 1160 ); // One TCP-IP packet |
| 89 | + fclose( $fs ); |
| 90 | + $response = explode( "\r\n\r\n", $response, 2 ); |
91 | 91 | |
92 | 92 | return $response; |
93 | 93 | } |
— | — | @@ -103,26 +103,26 @@ |
104 | 104 | |
105 | 105 | * @return string - The HTML to be embedded in the user's form. |
106 | 106 | */ |
107 | | -function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) |
| 107 | +function recaptcha_get_html ( $pubkey, $error = null, $use_ssl = false ) |
108 | 108 | { |
109 | | - if ($pubkey == null || $pubkey == '') { |
110 | | - die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); |
| 109 | + if ( $pubkey == null || $pubkey == '' ) { |
| 110 | + die ( "To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>" ); |
111 | 111 | } |
112 | 112 | |
113 | | - if ($use_ssl) { |
| 113 | + if ( $use_ssl ) { |
114 | 114 | $server = RECAPTCHA_API_SECURE_SERVER; |
115 | 115 | } else { |
116 | 116 | $server = RECAPTCHA_API_SERVER; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $errorpart = ""; |
120 | | - if ($error) { |
| 120 | + if ( $error ) { |
121 | 121 | $errorpart = "&error=" . $error; |
122 | 122 | } |
123 | | - return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
| 123 | + return '<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
124 | 124 | |
125 | 125 | <noscript> |
126 | | - <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> |
| 126 | + <iframe src="' . $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> |
127 | 127 | <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> |
128 | 128 | <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> |
129 | 129 | </noscript>'; |
— | — | @@ -149,27 +149,27 @@ |
150 | 150 | * @param array $extra_params an array of extra variables to post to the server |
151 | 151 | * @return ReCaptchaResponse |
152 | 152 | */ |
153 | | -function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) |
| 153 | +function recaptcha_check_answer ( $privkey, $remoteip, $challenge, $response, $extra_params = array() ) |
154 | 154 | { |
155 | | - if ($privkey == null || $privkey == '') { |
156 | | - die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); |
| 155 | + if ( $privkey == null || $privkey == '' ) { |
| 156 | + die ( "To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>" ); |
157 | 157 | } |
158 | 158 | |
159 | | - if ($remoteip == null || $remoteip == '') { |
160 | | - die ("For security reasons, you must pass the remote ip to reCAPTCHA"); |
| 159 | + if ( $remoteip == null || $remoteip == '' ) { |
| 160 | + die ( "For security reasons, you must pass the remote ip to reCAPTCHA" ); |
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | 164 | |
165 | | - //discard spam submissions |
166 | | - if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { |
| 165 | + // discard spam submissions |
| 166 | + if ( $challenge == null || strlen( $challenge ) == 0 || $response == null || strlen( $response ) == 0 ) { |
167 | 167 | $recaptcha_response = new ReCaptchaResponse(); |
168 | 168 | $recaptcha_response->is_valid = false; |
169 | 169 | $recaptcha_response->error = 'incorrect-captcha-sol'; |
170 | 170 | return $recaptcha_response; |
171 | 171 | } |
172 | 172 | |
173 | | - $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", |
| 173 | + $response = _recaptcha_http_post ( RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", |
174 | 174 | array ( |
175 | 175 | 'privatekey' => $privkey, |
176 | 176 | 'remoteip' => $remoteip, |
— | — | @@ -178,10 +178,10 @@ |
179 | 179 | ) + $extra_params |
180 | 180 | ); |
181 | 181 | |
182 | | - $answers = explode ("\n", $response [1]); |
| 182 | + $answers = explode ( "\n", $response [1] ); |
183 | 183 | $recaptcha_response = new ReCaptchaResponse(); |
184 | 184 | |
185 | | - if (trim ($answers [0]) == 'true') { |
| 185 | + if ( trim ( $answers [0] ) == 'true' ) { |
186 | 186 | $recaptcha_response->is_valid = true; |
187 | 187 | } |
188 | 188 | else { |
— | — | @@ -199,45 +199,45 @@ |
200 | 200 | * @param string $domain The domain where the page is hosted |
201 | 201 | * @param string $appname The name of your application |
202 | 202 | */ |
203 | | -function recaptcha_get_signup_url ($domain = null, $appname = null) { |
204 | | - return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); |
| 203 | +function recaptcha_get_signup_url ( $domain = null, $appname = null ) { |
| 204 | + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode ( array ( 'domains' => $domain, 'app' => $appname ) ); |
205 | 205 | } |
206 | 206 | |
207 | | -function _recaptcha_aes_pad($val) { |
| 207 | +function _recaptcha_aes_pad( $val ) { |
208 | 208 | $block_size = 16; |
209 | | - $numpad = $block_size - (strlen ($val) % $block_size); |
210 | | - return str_pad($val, strlen ($val) + $numpad, chr($numpad)); |
| 209 | + $numpad = $block_size - ( strlen ( $val ) % $block_size ); |
| 210 | + return str_pad( $val, strlen ( $val ) + $numpad, chr( $numpad ) ); |
211 | 211 | } |
212 | 212 | |
213 | 213 | /* Mailhide related code */ |
214 | 214 | |
215 | | -function _recaptcha_aes_encrypt($val,$ky) { |
216 | | - if (! function_exists ("mcrypt_encrypt")) { |
217 | | - die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); |
| 215 | +function _recaptcha_aes_encrypt( $val, $ky ) { |
| 216 | + if ( ! function_exists ( "mcrypt_encrypt" ) ) { |
| 217 | + die ( "To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed." ); |
218 | 218 | } |
219 | | - $mode=MCRYPT_MODE_CBC; |
220 | | - $enc=MCRYPT_RIJNDAEL_128; |
221 | | - $val=_recaptcha_aes_pad($val); |
222 | | - return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); |
| 219 | + $mode = MCRYPT_MODE_CBC; |
| 220 | + $enc = MCRYPT_RIJNDAEL_128; |
| 221 | + $val = _recaptcha_aes_pad( $val ); |
| 222 | + return mcrypt_encrypt( $enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ); |
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | | -function _recaptcha_mailhide_urlbase64 ($x) { |
227 | | - return strtr(base64_encode ($x), '+/', '-_'); |
| 226 | +function _recaptcha_mailhide_urlbase64 ( $x ) { |
| 227 | + return strtr( base64_encode ( $x ), '+/', '-_' ); |
228 | 228 | } |
229 | 229 | |
230 | 230 | /* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ |
231 | | -function recaptcha_mailhide_url($pubkey, $privkey, $email) { |
232 | | - if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { |
233 | | - die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . |
234 | | - "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>"); |
| 231 | +function recaptcha_mailhide_url( $pubkey, $privkey, $email ) { |
| 232 | + if ( $pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null ) { |
| 233 | + die ( "To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . |
| 234 | + "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>" ); |
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | | - $ky = pack('H*', $privkey); |
239 | | - $cryptmail = _recaptcha_aes_encrypt ($email, $ky); |
| 238 | + $ky = pack( 'H*', $privkey ); |
| 239 | + $cryptmail = _recaptcha_aes_encrypt ( $email, $ky ); |
240 | 240 | |
241 | | - return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); |
| 241 | + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ( $cryptmail ); |
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
— | — | @@ -245,15 +245,15 @@ |
246 | 246 | * eg, given johndoe@example,com return ["john", "example.com"]. |
247 | 247 | * the email is then displayed as john...@example.com |
248 | 248 | */ |
249 | | -function _recaptcha_mailhide_email_parts ($email) { |
250 | | - $arr = preg_split("/@/", $email ); |
| 249 | +function _recaptcha_mailhide_email_parts ( $email ) { |
| 250 | + $arr = preg_split( "/@/", $email ); |
251 | 251 | |
252 | | - if (strlen ($arr[0]) <= 4) { |
253 | | - $arr[0] = substr ($arr[0], 0, 1); |
254 | | - } elseif (strlen ($arr[0]) <= 6) { |
255 | | - $arr[0] = substr ($arr[0], 0, 3); |
| 252 | + if ( strlen ( $arr[0] ) <= 4 ) { |
| 253 | + $arr[0] = substr ( $arr[0], 0, 1 ); |
| 254 | + } elseif ( strlen ( $arr[0] ) <= 6 ) { |
| 255 | + $arr[0] = substr ( $arr[0], 0, 3 ); |
256 | 256 | } else { |
257 | | - $arr[0] = substr ($arr[0], 0, 4); |
| 257 | + $arr[0] = substr ( $arr[0], 0, 4 ); |
258 | 258 | } |
259 | 259 | return $arr; |
260 | 260 | } |
— | — | @@ -264,12 +264,12 @@ |
265 | 265 | * |
266 | 266 | * http://www.google.com/recaptcha/mailhide/apikey |
267 | 267 | */ |
268 | | -function recaptcha_mailhide_html($pubkey, $privkey, $email) { |
269 | | - $emailparts = _recaptcha_mailhide_email_parts ($email); |
270 | | - $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); |
| 268 | +function recaptcha_mailhide_html( $pubkey, $privkey, $email ) { |
| 269 | + $emailparts = _recaptcha_mailhide_email_parts ( $email ); |
| 270 | + $url = recaptcha_mailhide_url ( $pubkey, $privkey, $email ); |
271 | 271 | |
272 | | - return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . |
273 | | - "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]); |
| 272 | + return htmlentities( $emailparts[0] ) . "<a href='" . htmlentities ( $url ) . |
| 273 | + "' onclick=\"window.open('" . htmlentities ( $url ) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ( $emailparts [1] ); |
274 | 274 | |
275 | 275 | } |
276 | 276 | |
Index: trunk/extensions/ConfirmEdit/FancyCaptcha.php |
— | — | @@ -43,8 +43,8 @@ |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * By default the FancyCaptcha rotates among all available captchas. |
47 | | - * Setting $wgCaptchaDeleteOnSolve to true will delete the captcha |
48 | | - * files when they are correctly solved. Thus the user will need |
| 47 | + * Setting $wgCaptchaDeleteOnSolve to true will delete the captcha |
| 48 | + * files when they are correctly solved. Thus the user will need |
49 | 49 | * something like a cron creating new thumbnails to avoid drying up. |
50 | 50 | */ |
51 | 51 | $wgCaptchaDeleteOnSolve = false; |
Index: trunk/extensions/ConfirmEdit/Asirra.class.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | |
36 | 36 | $ticket = $wgRequest->getVal( 'Asirra_Ticket' ); |
37 | 37 | $api = 'http://challenge.asirra.com/cgi/Asirra?'; |
38 | | - $params = array( |
| 38 | + $params = array( |
39 | 39 | 'action' => 'ValidateTicket', |
40 | 40 | 'ticket' => $ticket, |
41 | 41 | ); |