[11316] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[14527] | 4 | load_language('plugin.lang', CRYPTO_PATH); |
---|
[12617] | 5 | add_event_handler('loc_end_picture', 'add_crypto'); |
---|
[11370] | 6 | add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[11316] | 7 | |
---|
[11370] | 8 | function add_crypto() |
---|
[11316] | 9 | { |
---|
[12617] | 10 | global $template; |
---|
[11316] | 11 | |
---|
| 12 | if (!is_a_guest()) return; |
---|
| 13 | |
---|
[11370] | 14 | $template->set_prefilter('picture', 'prefilter_crypto'); |
---|
[11316] | 15 | } |
---|
| 16 | |
---|
[11370] | 17 | function prefilter_crypto($content, $smarty) |
---|
[11316] | 18 | { |
---|
[12617] | 19 | global $conf; |
---|
[11316] | 20 | |
---|
[14527] | 21 | $search = '<p><textarea name="content" id="contentid" rows="5" cols="50">{$comment_add.CONTENT}</textarea></p>'; |
---|
| 22 | $replace = $search.' |
---|
| 23 | <p><label>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :</label></p> |
---|
| 24 | <p> |
---|
| 25 | <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image"> |
---|
| 26 | <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false"> |
---|
| 27 | <img src="'.CRYPTO_PATH.'template/refresh.png"></a> |
---|
| 28 | <input type="text" name="captcha_code" style="width:'.$conf['cryptographp']['code_length'].'em;" maxlength="'.$conf['cryptographp']['code_length'].'" /> |
---|
| 29 | </p>'; |
---|
[11316] | 30 | |
---|
[14527] | 31 | return str_replace($search, $replace, $content); |
---|
[11316] | 32 | } |
---|
| 33 | |
---|
[11370] | 34 | function check_crypto($action, $comment) |
---|
[11316] | 35 | { |
---|
[14527] | 36 | global $conf, $page; |
---|
[11316] | 37 | |
---|
[12617] | 38 | include_once(CRYPTO_PATH.'securimage/securimage.php'); |
---|
| 39 | $securimage = new Securimage(); |
---|
[11316] | 40 | |
---|
[15118] | 41 | if (!is_a_guest()) return $action; |
---|
[11316] | 42 | |
---|
[12617] | 43 | if ($securimage->check($_POST['captcha_code']) == false) |
---|
[11316] | 44 | { |
---|
[14527] | 45 | if ($conf['cryptographp']['comments_action'] == 'reject') array_push($page['errors'], l10n('Invalid Captcha')); |
---|
[15118] | 46 | return ($action != 'reject') ? $conf['cryptographp']['comments_action'] : 'reject'; |
---|
[11316] | 47 | } |
---|
[12617] | 48 | |
---|
| 49 | return $action; |
---|
[11316] | 50 | } |
---|
| 51 | |
---|
| 52 | ?> |
---|