[15996] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | load_language('plugin.lang', CRYPTO_PATH); |
---|
| 5 | add_event_handler('loc_begin_index', 'add_crypto'); |
---|
| 6 | add_event_handler('user_comment_check_guestbook', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 7 | |
---|
| 8 | function add_crypto() |
---|
| 9 | { |
---|
| 10 | global $template; |
---|
| 11 | |
---|
| 12 | if (!is_a_guest()) return; |
---|
| 13 | |
---|
| 14 | $template->set_prefilter('index', 'prefilter_crypto'); |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function prefilter_crypto($content, $smarty) |
---|
| 18 | { |
---|
| 19 | global $conf; |
---|
| 20 | |
---|
| 21 | $search = '<p><textarea name="content" id="contentid" rows="5" cols="60">{$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>'; |
---|
| 30 | |
---|
| 31 | return str_replace($search, $replace, $content); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | function check_crypto($action, $comment) |
---|
| 35 | { |
---|
| 36 | global $conf, $page; |
---|
| 37 | |
---|
| 38 | include_once(CRYPTO_PATH.'securimage/securimage.php'); |
---|
| 39 | $securimage = new Securimage(); |
---|
| 40 | |
---|
| 41 | if (!is_a_guest()) return $action; |
---|
| 42 | |
---|
| 43 | if ($securimage->check($_POST['captcha_code']) == false) |
---|
| 44 | { |
---|
| 45 | array_push($page['errors'], l10n('Invalid Captcha')); |
---|
| 46 | return 'reject'; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | return $action; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | ?> |
---|