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

@ -524,11 +524,20 @@ class Main extends CI_Controller
function post_encrypted()
{
$this->load->model('pastes');
$_POST['private'] = 1;
$_POST['snipurl'] = 0;
$ret_url = $this->pastes->createPaste();
echo $ret_url;
$this->_valid_authentication();
if ($this->_valid_captcha($this->input->post('captcha')))
{
$this->load->model('pastes');
$_POST['private'] = 1;
$_POST['snipurl'] = 0;
$ret_url = $this->pastes->createPaste();
echo $ret_url;
}
else
{
echo 'E_CAPTCHA';
}
}
function raw()
@ -753,7 +762,11 @@ class Main extends CI_Controller
if (config_item('enable_captcha') && $this->session->userdata('is_human') === null)
{
$this->form_validation->set_message('_valid_captcha', lang('captcha'));
if (isset($this->form_validation))
{
$this->form_validation->set_message('_valid_captcha', lang('captcha'));
}
if ($this->use_recaptcha)
{

View File

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