OMG add tiny spam protection

This commit is contained in:
Hannes Magnusson
2013-11-28 01:32:42 -08:00
parent bb9f3e1577
commit f02d0d7df7
2 changed files with 9 additions and 1 deletions

View File

@ -921,11 +921,12 @@ function register() {
// gather input // gather input
$login = trim($auth->cleanUser($INPUT->post->str('login'))); $login = trim($auth->cleanUser($INPUT->post->str('login')));
$fullname = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('fullname'))); $fullname = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('fullname')));
$spam = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('spam')));
$email = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('email'))); $email = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $INPUT->post->str('email')));
$pass = $INPUT->post->str('pass'); $pass = $INPUT->post->str('pass');
$passchk = $INPUT->post->str('passchk'); $passchk = $INPUT->post->str('passchk');
if(empty($login) || empty($fullname) || empty($email)) { if(empty($login) || empty($fullname) || empty($email) || empty($spam)) {
msg($lang['regmissing'], -1); msg($lang['regmissing'], -1);
return false; return false;
} }
@ -945,6 +946,12 @@ function register() {
msg($lang['regbadmail'], -1); msg($lang['regbadmail'], -1);
return false; return false;
} }
// make sure the secret spam box was filled out correctly
if($spam != "php-webmaster@lists.php.net") {
msg("That wasn't the answer we were expecting",-1);
return false;
}
//okay try to create the user //okay try to create the user
if(!$auth->triggerUserMod('create', array($login, $pass, $fullname, $email))) { if(!$auth->triggerUserMod('create', array($login, $pass, $fullname, $email))) {

View File

@ -1325,6 +1325,7 @@ function html_register(){
} }
$form->addElement(form_makeTextField('fullname', $INPUT->post->str('fullname'), $lang['fullname'], '', 'block', $base_attrs)); $form->addElement(form_makeTextField('fullname', $INPUT->post->str('fullname'), $lang['fullname'], '', 'block', $base_attrs));
$form->addElement(form_makeField('email','email', $INPUT->post->str('email'), $lang['email'], '', 'block', $email_attrs)); $form->addElement(form_makeField('email','email', $INPUT->post->str('email'), $lang['email'], '', 'block', $email_attrs));
$form->addElement(form_makeTextField('spam', $_POST['spam'], "Which email address do you have to mail now?", '', 'block', array('size'=>'50')));
$form->addElement(form_makeButton('submit', '', $lang['btn_register'])); $form->addElement(form_makeButton('submit', '', $lang['btn_register']));
$form->endFieldset(); $form->endFieldset();
html_form('register', $form); html_form('register', $form);