Last change
on this file since 26552 was
26072,
checked in by mistic100, 11 years ago
|
try to simplify integration of captchas
|
File size:
930 bytes
|
Line | |
---|
1 | <?php |
---|
2 | defined('CRYPTO_ID') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | $conf['cryptographp']['template'] = 'register'; |
---|
5 | include(CRYPTO_PATH.'include/common.inc.php'); |
---|
6 | |
---|
7 | add_event_handler('loc_end_page_header', 'add_crypto'); |
---|
8 | add_event_handler('register_user_check', 'check_crypto'); |
---|
9 | |
---|
10 | function add_crypto() |
---|
11 | { |
---|
12 | global $template; |
---|
13 | $template->set_prefilter('register', 'prefilter_crypto'); |
---|
14 | } |
---|
15 | |
---|
16 | function 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 | |
---|
23 | function 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.