Add automatic and manual reloading of captchas
This commit is contained in:
parent
a1bdba3770
commit
89b2a8af97
|
@ -1786,7 +1786,7 @@
|
||||||
$config['error']['securimage']=array(
|
$config['error']['securimage']=array(
|
||||||
'missing'=>'The captcha field was missing. Please try again',
|
'missing'=>'The captcha field was missing. Please try again',
|
||||||
'empty'=>'Please fill out the captcha',
|
'empty'=>'Please fill out the captcha',
|
||||||
'bad'=>'Incorrect captcha',
|
'bad'=>'Incorrect or expired captcha',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Meta keywords. It's probably best to include these in per-board configurations.
|
// Meta keywords. It's probably best to include these in per-board configurations.
|
||||||
|
|
|
@ -56,6 +56,7 @@ $(window).ready(function() {
|
||||||
return xhr;
|
return xhr;
|
||||||
},
|
},
|
||||||
success: function(post_response) {
|
success: function(post_response) {
|
||||||
|
reloadCaptcha(); // For securimage captcha. TODO doesn't always need reloading
|
||||||
if (post_response.error) {
|
if (post_response.error) {
|
||||||
if (post_response.banned) {
|
if (post_response.banned) {
|
||||||
// You are banned. Must post the form normally so the user can see the ban message.
|
// You are banned. Must post the form normally so the user can see the ban message.
|
||||||
|
|
|
@ -286,6 +286,17 @@ function dopost(form) {
|
||||||
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reloadCaptcha() {
|
||||||
|
// Reload captcha images (date reduces chance of caching)
|
||||||
|
// If no securimage captcha is enabled, no elements will be found
|
||||||
|
captchaImgs = document.querySelectorAll('[id=captcha-img]');
|
||||||
|
for (var i = 0; i < captchaImgs.length; ++i)
|
||||||
|
captchaImgs[i].src = "/captcha.php?"+Date.now();
|
||||||
|
captchas = document.querySelectorAll('[id=captcha]');
|
||||||
|
for (var i = 0; i < captchas.length; ++i)
|
||||||
|
captchas[i].value = "";
|
||||||
|
}
|
||||||
|
|
||||||
function citeReply(id, with_link) {
|
function citeReply(id, with_link) {
|
||||||
var textarea = document.getElementById('body');
|
var textarea = document.getElementById('body');
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@
|
||||||
Captcha
|
Captcha
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<img src="{{ config.root }}/captcha.php"><br />
|
<img name="captcha-img" id="captcha-img" src="/captcha.php" onClick="this.src='/captcha.php?'+Date.now();document.getElementById('captcha').value = '';"><br />
|
||||||
<input type="text" name="captcha" size="25" maxlength="10" autocomplete="off">
|
<input type="text" name="captcha" id="captcha" size="25" maxlength="10" autocomplete="off">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue