source: extensions/CryptograPHP/include/register.inc.php @ 26413

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

try to simplify integration of captchas

File size: 930 bytes
Line 
1<?php
2defined('CRYPTO_ID') or die('Hacking attempt!');
3
4$conf['cryptographp']['template'] = 'register';
5include(CRYPTO_PATH.'include/common.inc.php');
6
7add_event_handler('loc_end_page_header', 'add_crypto');
8add_event_handler('register_user_check', 'check_crypto');
9
10function add_crypto()
11{
12  global $template;
13  $template->set_prefilter('register', 'prefilter_crypto');
14}
15
16function prefilter_crypto($content, $smarty)
17{
18  $search = '#\(\{\'useful when password forgotten\'\|(@?)translate\}\)(\s*)((?:\{/if\})?)#i';
19  $replace = '({\'useful when password forgotten\'|$1translate})$2$3'."\n".'{\$CRYPTO.parsed_content}';
20  return preg_replace($search, $replace, $content);
21}
22
23function check_crypto($errors)
24{
25  include_once(CRYPTO_PATH.'securimage/securimage.php');
26  $securimage = new Securimage();
27 
28  if ($securimage->check($_POST['captcha_code']) == false)
29  {
30    $errors[] = l10n('Invalid Captcha');
31  }
32
33  return $errors;
34}
Note: See TracBrowser for help on using the repository browser.