source: extensions/CryptograPHP/include/category.inc.php @ 26072

Revision 26072, 1.1 KB checked in by mistic100, 6 years ago (diff)

try to simplify integration of captchas

Line 
1<?php
2defined('CRYPTO_ID') or die('Hacking attempt!');
3
4$conf['cryptographp']['template'] = 'comment';
5include(CRYPTO_PATH.'include/common.inc.php');
6
7add_event_handler('loc_begin_index', 'add_crypto');
8add_event_handler('user_comment_check_albums', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
9
10function add_crypto()
11{
12  global $template;
13  $template->set_prefilter('comments_on_albums', 'prefilter_crypto');
14}
15
16function 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
22function 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.