|
Revision 10837, 1.1 KB
(checked in by mistic100, 2 years ago)
|
|
first version of CryptograPHP
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
|---|
| 4 | |
|---|
| 5 | $cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php'; |
|---|
| 6 | include($cryptinstall); |
|---|
| 7 | |
|---|
| 8 | add_event_handler('loc_end_page_header', 'add_captcha'); |
|---|
| 9 | add_event_handler('register_user_check', 'check_captcha'); |
|---|
| 10 | |
|---|
| 11 | function add_captcha() |
|---|
| 12 | { |
|---|
| 13 | global $template, $conf; |
|---|
| 14 | |
|---|
| 15 | $template->set_prefilter('register', 'captcha_prefilter'); |
|---|
| 16 | $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'].'.cfg.php',1)); |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | function captcha_prefilter($content, $smarty) |
|---|
| 20 | { |
|---|
| 21 | load_language('plugin.lang', CRYPTO_PATH); |
|---|
| 22 | |
|---|
| 23 | $search = '<p class="bottomButtons">'; |
|---|
| 24 | $replace = ' |
|---|
| 25 | <fieldset> |
|---|
| 26 | <legend>{\'Antibot test\'|@translate}</legend> |
|---|
| 27 | <ul> |
|---|
| 28 | <li> |
|---|
| 29 | <span class="property"> |
|---|
| 30 | <label>{$CAPTCHA}</label> |
|---|
| 31 | </span> |
|---|
| 32 | <input type="text" name="code"> |
|---|
| 33 | </li> |
|---|
| 34 | </ul> |
|---|
| 35 | </fieldset>' |
|---|
| 36 | ."\n".$search; |
|---|
| 37 | |
|---|
| 38 | return str_replace($search, $replace, $content); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | function check_captcha($errors) |
|---|
| 42 | { |
|---|
| 43 | global $conf; |
|---|
| 44 | |
|---|
| 45 | if (!chk_crypt($_POST['code'])) |
|---|
| 46 | { |
|---|
| 47 | load_language('plugin.lang', CRYPTO_PATH); |
|---|
| 48 | array_push($errors, l10n('Invalid Captcha')); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | return $errors; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | ?> |
|---|