Improved spam protection

This commit is contained in:
Michael Vogel 2020-01-15 18:55:32 +01:00
parent d6357c97e5
commit 8ebc385772
4 changed files with 44 additions and 15 deletions

View file

@ -121,6 +121,7 @@ class Register extends BaseModule
'$openid' => $openid_url, '$openid' => $openid_url,
'$namelabel' => L10n::t('Your Full Name (e.g. Joe Smith, real or real-looking): '), '$namelabel' => L10n::t('Your Full Name (e.g. Joe Smith, real or real-looking): '),
'$addrlabel' => L10n::t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'), '$addrlabel' => L10n::t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'),
'$addrlabel2' => L10n::t('Please repeat your e-mail address:'),
'$ask_password' => $ask_password, '$ask_password' => $ask_password,
'$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')], '$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')],
'$password2' => ['confirm', L10n::t('Confirm:'), '', ''], '$password2' => ['confirm', L10n::t('Confirm:'), '', ''],
@ -196,6 +197,24 @@ class Register extends BaseModule
$arr = $_POST; $arr = $_POST;
// Is there text in the tar pit?
if (!empty($arr['email'])) {
Logger::info('Tar pit', $arr);
notice(L10n::t('You have entered too much information.'));
DI::baseUrl()->redirect('register/');
}
// Overwriting the "tar pit" field with the real one
$arr['email'] = $arr['field1'];
if ($arr['email'] != $arr['repeat']) {
Logger::info('Mail mismatch', $arr);
notice(L10n::t('Please enter the identical mail address in the second field.'));
$regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
$arr['blocked'] = $blocked; $arr['blocked'] = $blocked;
$arr['verified'] = $verified; $arr['verified'] = $verified;
$arr['language'] = L10nClass::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language')); $arr['language'] = L10nClass::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language'));
@ -263,11 +282,6 @@ class Register extends BaseModule
DI::baseUrl()->redirect('register/'); DI::baseUrl()->redirect('register/');
} }
// Is there text in the tar pit?
if (!empty($_POST['registertarpit'])) {
\notice(L10n::t('You have entered too much information.'));
DI::baseUrl()->redirect('register/');
}
Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']); Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);

View file

@ -14,7 +14,7 @@
{{if $oidlabel}} {{if $oidlabel}}
<div id="register-openid-wrapper" > <div id="register-openid-wrapper" >
<label for="register-openid" id="label-register-openid" >{{$oidlabel}}</label><input type="text" maxlength="60" size="32" name="openid_url" class="openid" id="register-openid" value="{{$openid}}" > <label for="register-openid" id="label-register-openid" >{{$oidlabel}}</label><input type="text" maxlength="60" size="32" name="openid_url" class="openid" id="register-openid" value="{{$openid}}" >
</div> </div>
<div id="register-openid-end" ></div> <div id="register-openid-end" ></div>
{{/if}} {{/if}}
@ -30,17 +30,23 @@
<div id="register-name-wrapper" > <div id="register-name-wrapper" >
<label for="register-name" id="label-register-name" >{{$namelabel}}</label> <label for="register-name" id="label-register-name" >{{$namelabel}}</label>
<input type="text" maxlength="60" size="32" name="username" id="register-name" value="{{$username}}" > <input type="text" maxlength="60" size="32" name="username" id="register-name" value="{{$username}}" required>
</div> </div>
<div id="register-name-end" ></div> <div id="register-name-end" ></div>
<div id="register-email-wrapper" > <div id="register-email-wrapper" >
<label for="register-email" id="label-register-email" >{{$addrlabel}}</label> <label for="register-email" id="label-register-email" >{{$addrlabel}}</label>
<input type="text" maxlength="60" size="32" name="email" id="register-email" value="{{$email}}" > <input type="text" maxlength="60" size="32" name="field1" id="register-email" value="{{$email}}" required>
</div> </div>
<div id="register-email-end" ></div> <div id="register-email-end" ></div>
<div id="register-repeat-wrapper" >
<label for="register-repeat" id="label-register-repeat" >{{$addrlabel2}}</label>
<input type="text" maxlength="60" size="32" name="repeat" id="register-repeat" value="" required>
</div>
<div id="register-repeat-end" ></div>
{{if $ask_password}} {{if $ask_password}}
{{include file="field_password.tpl" field=$password1}} {{include file="field_password.tpl" field=$password1}}
{{include file="field_password.tpl" field=$password2}} {{include file="field_password.tpl" field=$password2}}
@ -50,13 +56,14 @@
<div id="register-nickname-wrapper" > <div id="register-nickname-wrapper" >
<label for="register-nickname" id="label-register-nickname" >{{$nicklabel}}</label> <label for="register-nickname" id="label-register-nickname" >{{$nicklabel}}</label>
<input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" value="{{$nickname}}" ><div id="register-sitename">@{{$sitename}}</div> <input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" value="{{$nickname}}" required><div id="register-sitename">@{{$sitename}}</div>
</div> </div>
<div id="register-nickname-end" ></div> <div id="register-nickname-end" ></div>
<input type="input" id=tarpit" name="email" style="display: none;" placeholder="Don't enter anything here"/>
{{if $permonly}} {{if $permonly}}
{{include file="field_textarea.tpl" field=$permonlybox}} {{include file="field_textarea.tpl" field=$permonlybox}}
<input type="input" id="registertarpit" style="display: none;" placeholder="Don't enter anything here" />
{{/if}} {{/if}}
{{$publish nofilter}} {{$publish nofilter}}

View file

@ -31,17 +31,23 @@
<div id="register-name-wrapper" class="form-group"> <div id="register-name-wrapper" class="form-group">
<label for="register-name" id="label-register-name" >{{$namelabel}}</label> <label for="register-name" id="label-register-name" >{{$namelabel}}</label>
<input type="text" maxlength="60" size="32" name="username" id="register-name" class="form-control" value="{{$username}}"> <input type="text" maxlength="60" size="32" name="username" id="register-name" class="form-control" value="{{$username}}" required>
</div> </div>
<div id="register-name-end" ></div> <div id="register-name-end" ></div>
<div id="register-email-wrapper" class="form-group"> <div id="register-email-wrapper" class="form-group">
<label for="register-email" id="label-register-email" >{{$addrlabel}}</label> <label for="register-email" id="label-register-email" >{{$addrlabel}}</label>
<input type="text" maxlength="60" size="32" name="email" id="register-email" class="form-control" value="{{$email}}"> <input type="text" maxlength="60" size="32" name="field1" id="register-email" class="form-control" value="{{$email}}" required>
</div> </div>
<div id="register-email-end" ></div> <div id="register-email-end" ></div>
<div id="register-repeat-wrapper" class="form-group">
<label for="register-repeat" id="label-register-repeat" >{{$addrlabel2}}</label>
<input type="text" maxlength="60" size="32" name="repeat" id="register-repeat" class="form-control" value="" required>
</div>
<div id="register-repeat-end" ></div>
{{if $ask_password}} {{if $ask_password}}
{{include file="field_password.tpl" field=$password1}} {{include file="field_password.tpl" field=$password1}}
{{include file="field_password.tpl" field=$password2}} {{include file="field_password.tpl" field=$password2}}
@ -49,14 +55,15 @@
<div id="register-nickname-wrapper" class="form-group"> <div id="register-nickname-wrapper" class="form-group">
<label for="register-nickname" id="label-register-nickname" >{{$nicklabel}}</label> <label for="register-nickname" id="label-register-nickname" >{{$nicklabel}}</label>
<input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" class="form-control" value="{{$nickname}}"> <input type="text" maxlength="60" size="32" name="nickname" id="register-nickname" class="form-control" value="{{$nickname}}" required>
<span class="help-block" id="nickname_tip">{{$nickdesc nofilter}}</span> <span class="help-block" id="nickname_tip">{{$nickdesc nofilter}}</span>
</div> </div>
<div id="register-nickname-end" ></div> <div id="register-nickname-end" ></div>
<input type="input" id=tarpit" name="email" style="display: none;" placeholder="Don't enter anything here"/>
{{if $permonly}} {{if $permonly}}
{{include file="field_textarea.tpl" field=$permonlybox}} {{include file="field_textarea.tpl" field=$permonlybox}}
<input type="input" id="registertarpit" style="display: none;" placeholder="Don't enter anything here"/>
{{/if}} {{/if}}
{{$publish nofilter}} {{$publish nofilter}}

View file

@ -2424,6 +2424,7 @@ aside #id_password {
#register-name-end, #register-name-end,
#register-email-end, #register-email-end,
#register-repeat-end,
#register-nickname-end { #register-nickname-end {
clear: both; clear: both;
} }