[10837] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[14527] | 4 | load_language('plugin.lang', CRYPTO_PATH); |
---|
[17484] | 5 | add_event_handler('loc_begin_index', 'add_crypto'); |
---|
| 6 | add_event_handler('contact_form_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[10837] | 7 | |
---|
[11370] | 8 | function add_crypto() |
---|
[10837] | 9 | { |
---|
[12617] | 10 | global $template; |
---|
[10837] | 11 | |
---|
[11316] | 12 | if (!is_a_guest()) return; |
---|
[10837] | 13 | |
---|
[17484] | 14 | $template->set_prefilter('index', 'prefilter_crypto'); |
---|
[10837] | 15 | } |
---|
| 16 | |
---|
[11370] | 17 | function prefilter_crypto($content, $smarty) |
---|
[10837] | 18 | { |
---|
[12617] | 19 | global $conf; |
---|
| 20 | |
---|
[17484] | 21 | $search = '{$contact.content}</textarea></td>'; |
---|
[14527] | 22 | $replace = $search.' |
---|
| 23 | </tr> |
---|
[10837] | 24 | <tr> |
---|
[17484] | 25 | <td class="title"> |
---|
[14527] | 26 | {\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} |
---|
| 27 | </td> |
---|
[17484] | 28 | <td> |
---|
| 29 | <input type="text" name="captcha_code" id="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" /> |
---|
| 30 | <img id="captcha" src="{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image" style="vertical-align:top;"> |
---|
| 31 | <a href="#" id="captcha_refresh" onclick="document.getElementById(\'captcha\').src = \'{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false"> |
---|
| 32 | <img src="{$ROOT_URL}'.CRYPTO_PATH.'template/refresh.png" style="vertical-align:bottom;"></a> |
---|
| 33 | </td> |
---|
| 34 | |
---|
| 35 | {footer_script} |
---|
| 36 | var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true, insertAfterWhatNode: "captcha_refresh" }); |
---|
| 37 | captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{\'Invalid Captcha\'|@translate}" }); |
---|
| 38 | {/footer_script}'; |
---|
[10837] | 39 | |
---|
| 40 | return str_replace($search, $replace, $content); |
---|
| 41 | } |
---|
| 42 | |
---|
[17484] | 43 | function check_crypto($action, $comment) |
---|
[10837] | 44 | { |
---|
[17484] | 45 | global $conf, $page; |
---|
[12617] | 46 | |
---|
| 47 | include_once(CRYPTO_PATH.'securimage/securimage.php'); |
---|
| 48 | $securimage = new Securimage(); |
---|
[17484] | 49 | |
---|
| 50 | if (!is_a_guest()) return $action; |
---|
| 51 | |
---|
[12617] | 52 | if ($securimage->check($_POST['captcha_code']) == false) |
---|
[10837] | 53 | { |
---|
[17484] | 54 | array_push($page['errors'], l10n('Invalid Captcha')); |
---|
| 55 | return 'reject'; |
---|
[10837] | 56 | } |
---|
| 57 | |
---|
[17484] | 58 | return $action; |
---|
[10837] | 59 | } |
---|
| 60 | |
---|
| 61 | ?> |
---|