force encrypted pastes to use the captcha. fixes #425

This commit is contained in:
Claude 2017-09-29 10:22:34 +02:00
parent 9f3f7b326c
commit 0490766273
2 changed files with 23 additions and 8 deletions

View File

@ -523,6 +523,10 @@ class Main extends CI_Controller
} }
function post_encrypted() function post_encrypted()
{
$this->_valid_authentication();
if ($this->_valid_captcha($this->input->post('captcha')))
{ {
$this->load->model('pastes'); $this->load->model('pastes');
$_POST['private'] = 1; $_POST['private'] = 1;
@ -530,6 +534,11 @@ class Main extends CI_Controller
$ret_url = $this->pastes->createPaste(); $ret_url = $this->pastes->createPaste();
echo $ret_url; echo $ret_url;
} }
else
{
echo 'E_CAPTCHA';
}
}
function raw() function raw()
{ {
@ -752,8 +761,12 @@ class Main extends CI_Controller
{ {
if (config_item('enable_captcha') && $this->session->userdata('is_human') === null) if (config_item('enable_captcha') && $this->session->userdata('is_human') === null)
{
if (isset($this->form_validation))
{ {
$this->form_validation->set_message('_valid_captcha', lang('captcha')); $this->form_validation->set_message('_valid_captcha', lang('captcha'));
}
if ($this->use_recaptcha) if ($this->use_recaptcha)
{ {

View File

@ -173,11 +173,13 @@ ST.crypto = function() {
'code': encrypted, 'code': encrypted,
'lang': $('#lang').val(), 'lang': $('#lang').val(),
'expire': $('#expire').val(), 'expire': $('#expire').val(),
'captcha': $('#captcha').val(),
'reply': $('input[name=reply]').val() 'reply': $('input[name=reply]').val()
}, },
function(redirect_url) { function(redirect_url) {
if (redirect_url.indexOf('invalid') > -1) { if (redirect_url.indexOf('E_CAPTCHA') > -1) {
$('#create_encrypted').parent().html('<p>' + redirect_url + '#' + key + '</p>'); $('.content .container .message').remove();
$('.content .container').prepend('<div class="message error"><div class="container">The captcha is incorrect.</div></div>');
} else { } else {
window.location.href = base_url + redirect_url + '#' + key; window.location.href = base_url + redirect_url + '#' + key;
} }