1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | load_language('plugin.lang', CRYPTO_PATH); |
---|
5 | add_event_handler('display_contactform', 'add_crypto'); |
---|
6 | add_event_handler('check_contactform_params', 'check_crypto'); |
---|
7 | |
---|
8 | function add_crypto() |
---|
9 | { |
---|
10 | global $template; |
---|
11 | |
---|
12 | if (!is_a_guest()) return; |
---|
13 | |
---|
14 | $template->set_prefilter('cf_form', 'prefilter_crypto'); |
---|
15 | } |
---|
16 | |
---|
17 | function prefilter_crypto($content, $smarty) |
---|
18 | { |
---|
19 | global $conf; |
---|
20 | |
---|
21 | $search = '<td class="contact-form-right"><textarea name="cf_message" id="cf_message" rows="10" cols="40">{$CF.MESSAGE}</textarea></td>'; |
---|
22 | $replace = $search.' |
---|
23 | </tr> |
---|
24 | <tr> |
---|
25 | <td class="contact-form-left" style="vertical-align:top;"> |
---|
26 | {\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} |
---|
27 | <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image"> |
---|
28 | <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false"> |
---|
29 | <img src="'.CRYPTO_PATH.'template/refresh.png"></a> |
---|
30 | </td> |
---|
31 | <td class="contact-form-right"><input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" /></td>'; |
---|
32 | |
---|
33 | return str_replace($search, $replace, $content); |
---|
34 | } |
---|
35 | |
---|
36 | function check_crypto($infos) |
---|
37 | { |
---|
38 | if (!is_a_guest()) return $infos; |
---|
39 | |
---|
40 | include_once(CRYPTO_PATH.'securimage/securimage.php'); |
---|
41 | $securimage = new Securimage(); |
---|
42 | |
---|
43 | if ($securimage->check($_POST['captcha_code']) == false) |
---|
44 | { |
---|
45 | array_push($infos['errors'], l10n('Invalid Captcha')); |
---|
46 | } |
---|
47 | |
---|
48 | return $infos; |
---|
49 | } |
---|
50 | |
---|
51 | ?> |
---|