|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public function execute($eventObj, $className, $eventName) { if ($this->useCaptcha === null) { if (isset($eventObj->useCaptcha)) { $this->useCaptcha = $eventObj->useCaptcha; $eventObj->useCaptcha = false; } else { $this->useCaptcha = true; } } if ($this->useCaptcha) { switch ($eventName) { case 'validate': $this->resp = recaptcha_check_answer($this->privateKey, $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"]); if($this->resp->is_valid) { $this->useCaptcha = false; } else { $this->error = $this->resp->error; } break; case 'assignVariables': WCF::getTPL()->assign('captcha', recaptcha_get_html($this->publicKey, $this->error)); break; } } } |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 |
if ($this->useCaptcha == null) { if (isset($eventObj->useCaptcha)) { $this->useCaptcha = $eventObj->useCaptcha; } else { $this->useCaptcha = true; } } $eventObj->useCaptcha = false; |
This post has been edited 1 times, last edit by "Gnex" (Nov 14th 2009, 7:09pm)
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
public function execute($eventObj, $className, $eventName) { // break if(!isset($eventObj->useCaptcha) || !$eventObj->useCaptcha) { return; } // completely disable parent handler $eventObj->useCaptcha = false; // bind $this->eventObj = $eventObj; // call our handler, if method is implemented if(method_exists($this, $eventName)) { $this->$eventName(); } } public function readData() { $this->eventObj->captchaID = Recaptcha::create(); } public function validate() { $this->eventObj->captcha = new Recaptcha($this->eventObj->captchaID); $this->eventObj->captcha->validate($this->eventObj->captchaString); } |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
public function execute($eventObj, $className, $eventName) { #WCF::getSession()->unregister('captchaDone'); // break if(($className != 'RegisterForm' && $className != 'UserLoginForm') && (!isset($eventObj->useCaptcha) || !$eventObj->useCaptcha)) { return; } // completely disable parent handler $eventObj->useCaptcha = false; // bind $this->eventObj = $eventObj; // call our handler, if method is implemented if(method_exists($this, $eventName)) { $this->$eventName(); } } public function validate() { if(!WCF::getSession()->getVar('captchaDone')) { $this->resp = recaptcha_check_answer($this->privateKey, $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"]); if($this->resp->is_valid) { WCF::getSession()->register('captchaDone', true); $this->eventObj->captcha->delete(); } else { $this->error = $this->resp->error; } } } public function validateCaptcha() { if(!WCF::getSession()->getVar('captchaDone')) { $this->resp = recaptcha_check_answer($this->privateKey, $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"]); if($this->resp->is_valid) { WCF::getSession()->register('captchaDone', true); $this->eventObj->captcha->delete(); } else { $this->error = $this->resp->error; } } } public function assignVariables() { if(!WCF::getSession()->getVar('captchaDone')) { WCF::getTPL()->assign('captcha', recaptcha_get_html($this->publicKey, $this->error)); } } |
This post has been edited 2 times, last edit by "Gnex" (Dec 22nd 2009, 5:37pm)