protected function checkSpamStatus($comment, $publicProfile) { if (!$this->_captcha) { $this->_captcha = MollomCaptcha::check($this->_captchaResponse); if ($this->_captcha) { return false; } else { $comment->spamStatus = PropertySpamStatus::OK; } } else { $this->commentCaptcha = $this->_captcha; return false; } }
public function testCheckCaptchaInvalidKeys() { CoOrg::config()->set('mollom/public', 'novalid-pub-key'); CoOrg::config()->set('mollom/private', 'novalid-priv-key'); Session::set('mollom/sessionid', 'some-session'); $captcha = MollomCaptcha::check('valid'); $this->assertNotNull($captcha); $this->assertTrue($captcha instanceof MollomInvalidConfigCaptcha); }
/** * @post */ public function confirmreset($username, $email, $response, $image = null, $audio = null, $refresh = null) { $newCaptcha = false; if (!($image || $audio || $refresh)) { $error = ''; if ($username != null) { $user = User::getUserByName($username); if (! $user) $error = t('Username not found'); } else if ($email != null) { $user = User::getUserByEmail($email); if (! $user) $error = t('Email not found'); } else { $error = t('You have to give your username or email'); } if (! $error) { $captcha = MollomCaptcha::check($response); if ($captcha) { $error = t('Resetting your password failed'); } } else { $captcha = MollomCaptcha::refresh(); } } else { $error = false; if ($image) { $captcha = MollomCaptcha::refresh('image'); } else if ($audio) { $captcha = MollomCaptcha::refresh('audio'); } else { $captcha = MollomCaptcha::refresh(); } $newCaptcha = true; } // Still all ok if (!$newCaptcha && ! $error) { // prepare reset; $mail = $this->mail(); $mail->username = $user->username; $site = CoOrg::config()->get('site/title'); $key = $user->resetPassword(); $user->save(); $mail->site = $site; $mail->renewURL = CoOrg::createFullURL(array('user/password/renew', $user->username, $key)); $mail->to($user->email) ->subject(t('%site: Your account information', array('site' => $site))) ->send('mails/passwordreset'); $this->notice(t('A mail has been sent to you. Please follow the directions to set a new password for your account.')); $this->redirect('/'); } else { $reset = new ResetPassword; $reset->username = $username; $reset->email = $email; $this->resetPassword = $reset; $this->resetCaptcha = $captcha; if ($error) { $this->error($error); } $this->render('resetpassword'); } }