Rev | Line | |
---|
[24215] | 1 | <?php |
---|
| 2 | defined('EASYCAPTCHA_ID') or die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | include(EASYCAPTCHA_PATH.'include/common.inc.php'); |
---|
| 5 | add_event_handler('loc_begin_index', 'add_easycaptcha'); |
---|
| 6 | add_event_handler('user_comment_check_albums', 'check_easycaptcha', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 7 | |
---|
| 8 | function add_easycaptcha() |
---|
| 9 | { |
---|
| 10 | global $template; |
---|
| 11 | $template->set_prefilter('comments_on_albums', 'prefilter_easycaptcha'); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | function prefilter_easycaptcha($content, $smarty) |
---|
| 15 | { |
---|
| 16 | $search = '{$comment_add.CONTENT}</textarea></p>'; |
---|
| 17 | return str_replace($search, $search."\n{\$EASYCAPTCHA}", $content); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | function check_easycaptcha($action, $comment) |
---|
| 21 | { |
---|
| 22 | global $conf, $page; |
---|
| 23 | |
---|
| 24 | if (!is_a_guest()) return $action; |
---|
| 25 | |
---|
| 26 | if (!easycaptcha_check()) |
---|
| 27 | { |
---|
| 28 | if ($conf['EasyCaptcha']['comments_action'] == 'reject') $page['errors'][] = l10n('Invalid answer'); |
---|
| 29 | return ($action != 'reject') ? $conf['EasyCaptcha']['comments_action'] : 'reject'; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | return $action; |
---|
| 33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.