Last change
on this file since 26968 was
26072,
checked in by mistic100, 11 years ago
|
try to simplify integration of captchas
|
File size:
1.1 KB
|
Line | |
---|
1 | <?php |
---|
2 | defined('CRYPTO_ID') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | $conf['cryptographp']['template'] = 'comment'; |
---|
5 | include(CRYPTO_PATH.'include/common.inc.php'); |
---|
6 | |
---|
7 | add_event_handler('loc_begin_index', 'add_crypto'); |
---|
8 | add_event_handler('user_comment_check_albums', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
9 | |
---|
10 | function add_crypto() |
---|
11 | { |
---|
12 | global $template; |
---|
13 | $template->set_prefilter('comments_on_albums', 'prefilter_crypto'); |
---|
14 | } |
---|
15 | |
---|
16 | function prefilter_crypto($content, $smarty) |
---|
17 | { |
---|
18 | $search = '{$comment_add.CONTENT}</textarea></p>'; |
---|
19 | return str_replace($search, $search."\n{\$CRYPTO.parsed_content}", $content); |
---|
20 | } |
---|
21 | |
---|
22 | function check_crypto($action, $comment) |
---|
23 | { |
---|
24 | global $conf, $page; |
---|
25 | |
---|
26 | include_once(CRYPTO_PATH.'securimage/securimage.php'); |
---|
27 | $securimage = new Securimage(); |
---|
28 | |
---|
29 | if (!is_a_guest()) return $action; |
---|
30 | |
---|
31 | if ($securimage->check($_POST['captcha_code']) == false) |
---|
32 | { |
---|
33 | if ($conf['cryptographp']['comments_action'] == 'reject') $page['errors'][] = l10n('Invalid Captcha'); |
---|
34 | return ($action != 'reject') ? $conf['cryptographp']['comments_action'] : 'reject'; |
---|
35 | } |
---|
36 | |
---|
37 | return $action; |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.