remember humans

This commit is contained in:
Claude 2013-11-07 15:25:05 +01:00
parent 5f13dba509
commit 968fadbc4a
6 changed files with 30 additions and 11 deletions

View File

@ -573,7 +573,7 @@ class Main extends CI_Controller
//get "word"
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ@';
$str = '';
for ($i = 0;$i < 4;$i++)
for ($i = 0;$i < 8;$i++)
{
$str.= substr($pool, mt_rand(0, strlen($pool) - 1) , 1);
}
@ -600,17 +600,35 @@ class Main extends CI_Controller
function _valid_captcha($text)
{
if (config_item('enable_captcha'))
if (config_item('enable_captcha') && $this->db_session->userdata('is_human') === false)
{
$this->form_validation->set_message('_valid_captcha', lang('captcha'));
if ($this->use_recaptcha)
{
return $this->_valid_recaptcha();
if ($this->_valid_recaptcha())
{
$this->db_session->set_userdata('is_human', true);
return true;
}
else
{
return false;
}
}
else
{
return strtolower($text) == strtolower($this->db_session->userdata('captcha'));
if (strtolower($text) == strtolower($this->db_session->userdata('captcha')))
{
$this->db_session->set_userdata('is_human', true);
return true;
}
else
{
return false;
}
}
}
else

View File

@ -286,7 +286,7 @@ if (!function_exists('display_captcha'))
'word' => $word,
'img_path' => '',
'img_url' => '',
'img_width' => '110',
'img_width' => '180',
'img_height' => '40',
'font_path' => '',
'expiration' => 7200

View File

@ -107,7 +107,7 @@
<input type="hidden" value="<?php echo $reply; ?>" name="reply" />
<?php } ?>
<?php if($this->config->item('enable_captcha')){ ?>
<?php if($this->config->item('enable_captcha') && $this->db_session->userdata('is_human') === false){ ?>
<div class="item_group">
<div class="item item_captcha">
<label for="captcha"><?php echo lang('paste_spam'); ?>
@ -116,7 +116,7 @@
<?php if($use_recaptcha){
echo recaptcha_get_html($recaptcha_publickey);
} else { ?>
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="110" height="40" />
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="180" height="40" />
<input value="" type="text" id="captcha" name="captcha" tabindex="2" maxlength="32" />
<?php } ?>
</div>

View File

@ -146,6 +146,7 @@ h4 {
#captcha {
position: relative;
left: 140px;
width: 174px;
}
.form_wrapper .item_group .item input, .form_wrapper .item_group .item select {

View File

@ -104,7 +104,7 @@
<input type="hidden" value="<?php echo $reply; ?>" name="reply" />
<?php } ?>
<?php if($this->config->item('enable_captcha')){ ?>
<?php if($this->config->item('enable_captcha') && $this->db_session->userdata('is_human') === false){ ?>
<div class="item_group">
<div class="item item_captcha">
<label for="captcha"><?php echo lang('paste_spam'); ?>
@ -113,7 +113,7 @@
<?php if($use_recaptcha){
echo recaptcha_get_html($recaptcha_publickey);
} else { ?>
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="110" height="40" />
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="180" height="40" />
<input value="" type="text" id="captcha" name="captcha" tabindex="2" maxlength="32" />
<?php } ?>
</div>

View File

@ -107,7 +107,7 @@
<input type="hidden" value="<?php echo $reply; ?>" name="reply" />
<?php } ?>
<?php if($this->config->item('enable_captcha')){ ?>
<?php if($this->config->item('enable_captcha') && $this->db_session->userdata('is_human') === false){ ?>
<div class="item_group">
<div class="item item_captcha">
<label for="captcha"><?php echo lang('paste_spam'); ?>
@ -116,7 +116,7 @@
<?php if($use_recaptcha){
echo recaptcha_get_html($recaptcha_publickey);
} else { ?>
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="110" height="40" />
<img class="captcha" src="<?php echo site_url('view/captcha'); ?>?<?php echo date('U', mktime()); ?>" alt="captcha" width="180" height="40" />
<input value="" type="text" id="captcha" name="captcha" tabindex="2" maxlength="32" />
<?php } ?>
</div>