source: extensions/CryptograPHP/contactform.inc.php @ 10837

Last change on this file since 10837 was 10837, checked in by mistic100, 14 years ago

first version of CryptograPHP

File size: 1.3 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5$cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php';
6include($cryptinstall);
7
8add_event_handler('display_contactform', 'add_captcha');
9add_event_handler('check_contactform_params', 'check_captcha');
10
11function add_captcha()
12{
13  global $template, $conf;
14
15  // if (!is_a_guest()) return;
16
17  $template->set_prefilter('cf_form', 'captcha_prefilter');
18  $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'].'.cfg.php',1));
19}
20
21function captcha_prefilter($content, $smarty)
22{
23  $search = '
24      <tr>
25        <td class="contact-form-left">&nbsp;</td>
26        <td class="contact-form-right"><input class="submit" type="submit" value="{\'cf_submit\'|@translate}"></td>
27      </tr>';
28  $replace = '
29    <tr>
30      <td class="contact-form-left" style="vertical-align:top;">{\'Antibot test\'|@translate}</td>
31      <td class="contact-form-right"><input type="text" name="code"> <span style="vertical-align:top;">{$CAPTCHA}</span></td>
32    </tr>'
33  ."\n".$search;
34 
35  return str_replace($search, $replace, $content);
36}
37
38function check_captcha($infos)
39{
40  global $conf;
41
42  if (!is_a_guest()) return $infos;
43
44  if (!chk_crypt($_POST['code']))
45  {
46    load_language('plugin.lang', CRYPTO_PATH);
47    array_push($infos['errors'], l10n('Invalid Captcha'));
48  }
49
50  return $infos;
51}
52
53?>
Note: See TracBrowser for help on using the repository browser.