Last change
on this file since 26069 was
26069,
checked in by mistic100, 10 years ago
|
try to simplify integration of captchas
|
File size:
982 bytes
|
Rev | Line | |
---|
[24215] | 1 | <?php |
---|
| 2 | defined('EASYCAPTCHA_ID') or die('Hacking attempt!'); |
---|
| 3 | |
---|
[26069] | 4 | $conf['EasyCaptcha']['template'] = 'comment'; |
---|
[24215] | 5 | include(EASYCAPTCHA_PATH.'include/common.inc.php'); |
---|
[26069] | 6 | |
---|
[24215] | 7 | add_event_handler('loc_end_picture', 'add_easycaptcha'); |
---|
| 8 | add_event_handler('user_comment_check', 'check_easycaptcha', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 9 | |
---|
| 10 | function add_easycaptcha() |
---|
| 11 | { |
---|
| 12 | global $template; |
---|
| 13 | $template->set_prefilter('picture', 'prefilter_easycaptcha'); |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | function prefilter_easycaptcha($content, $smarty) |
---|
| 17 | { |
---|
| 18 | $search = '{$comment_add.CONTENT}</textarea></p>'; |
---|
[26069] | 19 | return str_replace($search, $search."\n{\$EASYCAPTCHA.parsed_content}", $content); |
---|
[24215] | 20 | } |
---|
| 21 | |
---|
| 22 | function check_easycaptcha($action, $comment) |
---|
| 23 | { |
---|
| 24 | global $conf, $page; |
---|
| 25 | |
---|
| 26 | if (!is_a_guest()) return $action; |
---|
| 27 | |
---|
| 28 | if (!easycaptcha_check()) |
---|
| 29 | { |
---|
| 30 | if ($conf['EasyCaptcha']['comments_action'] == 'reject') $page['errors'][] = l10n('Invalid answer'); |
---|
| 31 | return ($action != 'reject') ? $conf['EasyCaptcha']['comments_action'] : 'reject'; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | return $action; |
---|
| 35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.