source: extensions/EasyCaptcha/include/register.inc.php @ 30607

Last change on this file since 30607 was 26069, checked in by mistic100, 11 years ago

try to simplify integration of captchas

File size: 800 bytes
Line 
1<?php
2defined('EASYCAPTCHA_ID') or die('Hacking attempt!');
3
4$conf['EasyCaptcha']['template'] = 'register';
5include(EASYCAPTCHA_PATH.'include/common.inc.php');
6
7add_event_handler('loc_end_page_header', 'add_easycaptcha');
8add_event_handler('register_user_check', 'check_easycaptcha');
9
10function add_easycaptcha()
11{
12  global $template;
13  $template->set_prefilter('register', 'prefilter_easycaptcha');
14}
15
16function prefilter_easycaptcha($content, $smarty)
17{
18  $search = '<input type="checkbox" name="send_password_by_mail" id="send_password_by_mail" value="1" checked="checked">';
19  return str_replace($search, $search."\n{\$EASYCAPTCHA.parsed_content}", $content);
20}
21
22function check_easycaptcha($errors)
23{
24  if (!easycaptcha_check())
25  {
26    $errors[] = l10n('Invalid answer');
27  }
28
29  return $errors;
30}
Note: See TracBrowser for help on using the repository browser.