public function SetKeys($pKey, $prKey, $mail = false) { if ($mail) { self::$MPublicKey = $pKey; self::$MPrivateKey = $prKey; return; } self::$PublicKey = $pKey; self::$PrivateKey = $prKey; }
public function executeNewuser(sfWebRequest $request) { $this->form = new UserForm(); // check if the data is coming from POST method if ($request->isMethod('post')) { // bind the form $this->form->bind($request->getParameter($this->form->getName())); $captcha = new reCaptcha(); $responsecaptcha = $captcha->recaptcha_check_answer($_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); //check capcha if (!$responsecaptcha->is_valid) { $this->getUser()->setFlash('message', 'Invalid Sequrity Code,Please enter again'); } else { $formData = $this->form->getValues(); $checkUsernameAndEmail = Doctrine::getTable('User')->func_checkUsernameAndEmail($formData['email_address'], $formData['username']); if (count($checkUsernameAndEmail)) { $this->getUser()->setFlash('message', 'UserName or Email is already taken'); } else { $user = new User(); $user->setUsername($formData['username']); $getSalt = Doctrine::getTable('User')->func_generateSalt(); $getPassword = Doctrine::getTable('User')->func_generatePassword($getSalt, $formData['pass']); $user->setSalt($getSalt); $user->setPass($getPassword); $user->setIsActive(0); $user->setFirstName($formData['first_name']); $user->setLastName($formData['last_name']); $user->setEmailAddress($formData['email_address']); $user->save(); Doctrine::getTable('User')->func_sendVerificationEmail($formData['first_name'], $formData['email_address'], $getSalt); $this->getUser()->setFlash('message', 'Thanks for registration. Account activation link has been sent into your email address.'); $this->redirect('@login'); } // if the username and email does not exist } } // check if the method is POST }
public function ACT_doregister() { if (!$this->acl->check('guest')) { $this->deny(); } if (!$this->config->getVar('register_allowed')) { $this->deny(); } $user = array('user_name' => $_POST['user_name'], 'user_password' => $_POST['user_password'], 'user_password_repeat' => $_POST['user_password_repeat'], 'user_nickname' => $_POST['user_nickname'], 'email' => $_POST['email'], 'website' => $_POST['website'], 'memo' => $_POST['memo']); //Plugin: reCaptcha Validate Start---------------------------------------- if ($this->config->getVar('register_captcha') == 1 && method_exists('reCaptcha', 'validate')) { $validation = reCaptcha::validate(); if ($validation !== true) { $request['specifier'] = $validation; $this->locator->redirect('error_register_failed', $request); } } //Plugin: reCaptcha Validate End---------------------------------------- MDL_User_Edit::create($user); $this->locator->redirect('passport_login'); }
?> ", incorrect_try_again : "<?php echo __('Incorrect. Try again.'); ?> ", }, <?php } ?> lang : '<?php echo reCaptcha::config('lang'); ?> ', <?php if (reCaptcha::config('theme') === 'custom') { ?> custom_theme_widget : '<?php echo reCaptcha::config('custom_theme_widget'); ?> ', <?php } ?> theme : '<?php echo reCaptcha::config('theme'); ?> ' }; </script>
<tr> <td>邮箱</td> <td><input name="email" id="email" type="text" maxlength="64" /></td> </tr> <tr> <td>个人网站</td> <td><input name="website" type="text" maxlength="256" /></td> </tr> <tr> <td>备注</td> <td><textarea name="memo" cols="60" rows="6" id="memo">我很懒,什么也不写。</textarea></td> </tr> <?php if ($this->captcha) { ?> <tr> <td>验证码</td> <td><?php echo reCaptcha::showValidate(); ?> </td> </tr> <?php } ?> </table> <input type="submit" value="注册" /> </form> <?php $this->display('footer.php');
/** * Initialize */ public static function initialize() { $config = MDL_Config::getInstance(); self::$private_key = $config->getVar('plugin_ReCaptcha_private_key'); self::$public_key = $config->getVar('plugin_ReCaptcha_public_key'); }
?> </a></div> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')"><?php echo __('Get a visual challenge'); ?> </a></div> <div><a href="javascript:Recaptcha.showhelp()"><?php echo __('Help'); ?> </a></div> </div> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=<?php echo reCaptcha::config('public_key'); ?> "> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=<?php echo reCaptcha::config('public_key'); ?> " height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript>
<table> <tr> <td><h1>New User</h1></td> </tr> <?php echo $sf_user->getFlash('message'); ?> <?php echo $form; ?> <tfoot> <tr> <td colspan="2"> <?php $captcha = new reCaptcha(); $error = null; $publickey = "6LfLkscSAAAAAMK-TGcFnUOTgbDmdVC-A_4CT57h"; echo $captcha->recaptcha_get_html($publickey, $error); ?> <br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="register" value="Submit" /> </td> </tr> </tfoot> </table> </form>
<?php // here we store the result from reCAPTCHA $recaptcha = false; // if the form is sent if (isset($_POST)) { require_once 'recaptcha.php'; // create new recaptcha object and set a secret $captcha = new reCaptcha(); $captcha->setSecret('your-secret-key'); // the site-verification itself $recaptcha = $captcha->verify(); } ?> <!DOCTYPE> <html> <head> <script src='https://www.google.com/recaptcha/api.js' async defer></script> </head> <body> <?php if ($recaptcha) { echo "You're in"; } else { echo <<<END <form method="POST"> \t<input type="text" name="name"> \t<div class="g-recaptcha" data-sitekey="your-public-site-key"></div> \t<input type="submit"> </form> END;
<td><?php echo $this->escape($user->getName()); ?> </td> </tr> <tr> <td>昵称</td> <td><?php echo $this->escape($user->getNickname()); ?> </td> </tr> <tr> <td>Email</td> <td><?php echo reCaptcha::showEmail($user_info['email']); ?> </td> </tr> <tr> <td>个人网站</td> <td><a href="<?php echo $this->escape($user_info['website']); ?> " target="_blank" rel="nofollow"><?php echo $this->escape($user_info['website']); ?> </a></td> </tr> <tr> <td>身份</td>
# version 2 for more details. You should have received a copy of the GNU # General Public License version 2 along with this program. If not, see # <http://www.gnu.org/licenses/>. require_once "captcha_lib.php"; class reCaptcha extends BaseCaptchaProvider { function get_key() { return 'sixapart_rc'; } function get_name() { return 'reCaptcha'; } function get_classname() { return 'reCaptcha'; } function form_fields($blog_id) { global $mt; $config = $mt->db->fetch_plugin_config('reCaptcha', 'blog:' . $blog_id); if ($config) { $publickey = $config['recaptcha_publickey']; } $fields = "\n<div id=\"recaptcha_script\" style=\"display:block\">\n<script type=\"text/javascript\"\n src=\"http://api.recaptcha.net/challenge?k={$publickey}\">\n</script>\n\n<noscript>\n <iframe src=\"http://api.recaptcha.net/noscript?k={$publickey}\"\n height=\"300\" width=\"500\" frameborder=\"0\"></iframe><br>\n <textarea name=\"recaptcha_challenge_field\" rows=\"3\" cols=\"40\">\n </textarea>\n <input type=\"hidden\" name=\"recaptcha_response_field\"\n value=\"manual_challenge\">\n</noscript>\n</div>\n<script type=\"text/javascript\">\nif ( typeof(mtCaptchaVisible) != \"undefined\" )\n mtCaptchaVisible = true;\nelse if ( typeof(commenter_name) != \"undefined\" ) {\n var div = document.getElementById(\"recaptcha_script\");\n if (commenter_name)\n div.style.display = \"none\";\n else\n div.style.display = \"block\";\n}\n</script>\n"; return $fields; } } $provider = new reCaptcha(); $_captcha_providers[$provider->get_key()] = $provider;