summaryrefslogtreecommitdiff
path: root/src/controllers
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-22 23:26:59 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-22 23:26:59 -0400
commitdb3cb85d0992dd49ca2fdf33ea35c0cad60e312f (patch)
treecc93adcf6708dca02e02b4e4acb2aa654d073eca /src/controllers
parentfef0de218e9485ea3db394f3e173b3c64a0463a8 (diff)
Implement ReCaptcha entirely as a plugin, remove all of the ugliness
from my old implementation.
Diffstat (limited to 'src/controllers')
-rw-r--r--src/controllers/Users.class.php22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index ed6f739..a0eebdb 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -60,6 +60,8 @@ class Users extends Controller {
// since there will never be a remainder to `users/new', we can
// use that parameter to pass in some data.
if (!isset($vars['errors'])) $vars['errors'] = array();
+ global $mm; $pm = $mm->pluginManager();
+ $vars['antispam_html'] = $pm->callHook('antispam_html');
$this->showView('users/new', $vars);
}
@@ -124,16 +126,14 @@ class Users extends Controller {
* explained.
*/
private function create_user() {
+ global $mm;
+ $db = $mm->database();
+ $pm = $mm->pluginManager();
+
$vars = array();
@$vars['username' ] = $_POST['auth_name'];
@$vars['password1'] = $_POST['auth_password' ];
@$vars['password2'] = $_POST['auth_password_verify'];
- @$recaptcha_response = $_POST['recaptcha_response_field'];
- @$recaptcha_challenge = $_POST['recaptcha_challenge_field'];
-
- global $mm; $db = $mm->database();
- $publickey = $db->getPluginConf('ReCaptcha', 'public_key');
- $privatekey = $db->getPluginConf('ReCaptcha', 'private_key');
$vars['errors'] = array();
if ($db->getUID($vars['username'])!==false)
@@ -147,14 +147,8 @@ class Users extends Controller {
if ($matches && $vars['password2'] == '') {
$vars['errors'][] = 'no pw';
}
- require_once('recaptchalib.php');
- $resp = recaptcha_check_answer($privatekey,
- $_SERVER['REMOTE_ADDR'],
- $recaptcha_challenge,
- $recaptcha_response);
- if (!$resp->is_valid) {
- $vars['errors'][] = 'recaptcha';
- $vars['recaptcha_error'] = $resp->error;
+ foreach ($pm->callHook('antispam_verify') as $plugin=>$valid) {
+ if (!$valid) $vars['errors'][] = 'plugin_'.$plugin;
}
if (count($vars['errors']) > 0) {