Changeset 60431 in spip-zone
- Timestamp:
- Apr 16, 2012, 10:34:09 PM (9 years ago)
- Location:
- _plugins_/antispam-recaptcha
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/antispam-recaptcha/fonctions_recaptcha.php
r13711 r60431 9 9 if (!defined("_ECRIRE_INC_VERSION")) return; 10 10 11 // http://recaptcha.googlecode.com/files/recaptcha-php-1. 8.zip11 // http://recaptcha.googlecode.com/files/recaptcha-php-1.11.zip 12 12 function get_recaptcha_keys($force = false) { 13 13 if ($force … … 18 18 include_spip('inc/distant'); 19 19 include_spip('inc/texte'); 20 $u = textebrut(recuperer_page('http://mailhide.recaptcha.net/apikey')); 21 if(!preg_match(',Public Key:(.*),i', $u, $r1) 22 OR !preg_match(',Private Key:(.*),i', $u, $r2)) { 20 include_spip('inc/filtres'); 21 $u = translitteration(textebrut(recuperer_page('http://www.google.com/recaptcha/mailhide/apikey'))); 22 if(!preg_match(',Cl([^p]+)publique:(.*),i', $u, $r1) // La page retourne des accents qui (pour l'instant) sont errones, donc ne passent pas la translitteration 23 OR !preg_match(',Cl([^p]+)prive:(.*),i', $u, $r2)) { 23 24 spip_log('erreur recaptcha n\'a pas donne de cle : '.$u); 24 25 return false; … … 26 27 27 28 $keys = array( 28 'public' => trim($r1[ 1]),29 'private' => trim($r2[ 1])29 'public' => trim($r1[2]), 30 'private' => trim($r2[2]) 30 31 ); 32 31 33 ecrire_meta('recaptcha_keys', serialize($keys)); 32 34 ecrire_metas(); 33 } 34 35 } 36 35 37 return $keys; 36 38 } -
_plugins_/antispam-recaptcha/plugin.xml
r52717 r60431 2 2 <nom>Antispam reCAPTCHA</nom> 3 3 <auteur>Fil</auteur> 4 <version>0. 1.0</version>4 <version>0.2.0</version> 5 5 <etat>dev</etat> 6 6 <slogan>Filtre antispam pour vos emails</slogan> … … 8 8 Ce plugin fournit un filtre <code>|antispam</code> (fonction <code>filtre_antispam()</code>) pour protéger les emails avec un test de reCAPTCHA. A sa première utilisation, le plugin va chercher tout seul une clé d'activation sur le site de reCAPTCHA. 9 9 10 Le principal défaut de ce service est qu' il n'est disponible qu'en anglais seulement pour le moment.10 Le principal défaut de ce service est qu'on ne peut pas définir la langue comme on le souhaite 11 11 </description> 12 12 <lien>http://www.spip-contrib.net/reCAPTCHA</lien> … … 18 18 <chemin dir='' /> 19 19 <categorie>performance</categorie> 20 <necessite id="SPIP" version="[1.9.2; 1.9.2]" />20 <necessite id="SPIP" version="[1.9.2;2.1.99]" /> 21 21 </plugin> -
_plugins_/antispam-recaptcha/recaptchalib.php
r13831 r60431 5 5 * http://recaptcha.net/plugins/php/ 6 6 * - Get a reCAPTCHA API Key 7 * http ://recaptcha.net/api/getkey7 * https://www.google.com/recaptcha/admin/create 8 8 * - Discussion group 9 9 * http://groups.google.com/group/recaptcha … … 36 36 * The reCAPTCHA server URL's 37 37 */ 38 $recaptcha_api_server = 'http://api.recaptcha.net'; 39 $recaptcha_api_secure_server = 'https://api-secure.recaptcha.net'; 40 $recaptcha_verify_server = 'api-verify.recaptcha.net'; 41 38 define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api"); 39 define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api"); 40 define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); 42 41 43 42 /** … … 107 106 function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) 108 107 { 109 global $recaptcha_api_server, $recaptcha_api_secure_server;110 111 108 if ($pubkey == null || $pubkey == '') { 112 die ("To use reCAPTCHA you must get an API key from <a href='http ://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");109 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>"); 113 110 } 114 111 115 112 if ($use_ssl) { 116 $server = $recaptcha_api_secure_server;113 $server = RECAPTCHA_API_SECURE_SERVER; 117 114 } else { 118 $server = $recaptcha_api_server; 119 } 115 $server = RECAPTCHA_API_SERVER; 116 } 117 120 118 $errorpart = ""; 121 119 if ($error) { … … 125 123 126 124 <noscript> 127 <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br >125 <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> 128 126 <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> 129 <input type="hidden" name="recaptcha_response_field" value="manual_challenge" >127 <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> 130 128 </noscript>'; 131 129 } … … 149 147 * @param string $challenge 150 148 * @param string $response 149 * @param array $extra_params an array of extra variables to post to the server 151 150 * @return ReCaptchaResponse 152 151 */ 153 function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response )152 function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) 154 153 { 155 154 if ($privkey == null || $privkey == '') { 156 die ("To use reCAPTCHA you must get an API key from <a href='http ://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");155 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 156 } 158 157 … … 171 170 } 172 171 173 global $recaptcha_verify_server; 174 $response = _recaptcha_http_post ($recaptcha_verify_server, "/verify", 172 $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", 175 173 array ( 176 174 'privatekey' => $privkey, … … 178 176 'challenge' => $challenge, 179 177 'response' => $response 180 ) 178 ) + $extra_params 181 179 ); 182 180 … … 203 201 */ 204 202 function recaptcha_get_signup_url ($domain = null, $appname = null) { 205 return "http://recaptcha.net/api/getkey?" . _recaptcha_qsencode (array ('domain' => $domain, 'app' => $appname)); 206 } 207 208 203 return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); 204 } 205 206 function _recaptcha_aes_pad($val) { 207 $block_size = 16; 208 $numpad = $block_size - (strlen ($val) % $block_size); 209 return str_pad($val, strlen ($val) + $numpad, chr($numpad)); 210 } 209 211 210 212 /* Mailhide related code */ … … 216 218 $mode=MCRYPT_MODE_CBC; 217 219 $enc=MCRYPT_RIJNDAEL_128; 218 $val= str_pad($val, (16*(floor(strlen($val) / 16)+(strlen($val) % 16==0?2:1))), chr(16-(strlen($val) % 16)));220 $val=_recaptcha_aes_pad($val); 219 221 return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); 220 222 } … … 229 231 if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { 230 232 die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . 231 "you can do so at <a href='http:// mailhide.recaptcha.net/apikey'>http://mailhide.recaptcha.net/apikey</a>");233 "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>"); 232 234 } 233 235 … … 236 238 $cryptmail = _recaptcha_aes_encrypt ($email, $ky); 237 239 238 return "http:// mailhide.recaptcha.net/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);240 return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); 239 241 } 240 242 … … 261 263 * to get a key, go to: 262 264 * 263 * http:// mailhide.recaptcha.net/apikey265 * http://www.google.com/recaptcha/mailhide/apikey 264 266 */ 265 267 function recaptcha_mailhide_html($pubkey, $privkey, $email) { … … 268 270 269 271 return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . 270 "' onclick=\"window.open( this.href, '', '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 "' 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]); 271 273 272 274 }
Note: See TracChangeset
for help on using the changeset viewer.