source: extensions/EasyCaptcha/include/category.inc.php @ 28345

Last change on this file since 28345 was 28345, checked in by mistic100, 10 years ago

add 'guest_only' option

File size: 956 bytes
Line 
1<?php
2defined('EASYCAPTCHA_ID') or die('Hacking attempt!');
3
4$conf['EasyCaptcha']['template'] = 'comment';
5include(EASYCAPTCHA_PATH.'include/common.inc.php');
6
7add_event_handler('loc_begin_index', 'add_easycaptcha');
8add_event_handler('user_comment_check', 'check_easycaptcha', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
9
10function add_easycaptcha()
11{
12  global $template;
13  $template->set_prefilter('comments_on_albums', 'prefilter_easycaptcha');
14}
15
16function prefilter_easycaptcha($content, $smarty)
17{
18  $search = '{$comment_add.CONTENT}</textarea></p>';
19  return str_replace($search, $search."\n{\$EASYCAPTCHA.parsed_content}", $content);
20}
21
22function check_easycaptcha($action, $comment)
23{
24  global $conf, $page;
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.