source: extensions/CryptograPHP/include/contactform.inc.php @ 12617

Last change on this file since 12617 was 12617, checked in by mistic100, 12 years ago

rewrite some prefilters, replace CryptograPHP by Securimage (not abandoned project!)

File size: 1.7 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4add_event_handler('display_contactform', 'add_crypto');
5add_event_handler('check_contactform_params', 'check_crypto');
6
7function add_crypto()
8{
9  global $template;
10
11  if (!is_a_guest()) return;
12
13  $template->set_prefilter('cf_form', 'prefilter_crypto');
14}
15
16function prefilter_crypto($content, $smarty)
17{
18  global $conf;
19 
20  $search = '
21      <tr>
22        <td class="contact-form-left">&nbsp;</td>
23        <td class="contact-form-right"><input class="submit" type="submit" value="{\'cf_submit\'|@translate}"></td>
24      </tr>';
25  $replace = '     
26    <tr>
27      <td class="contact-form-left" style="vertical-align:top;">
28        {\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate}
29        <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
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'].'" />
32        <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
33          <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
34      </td>
35    </tr>'
36  ."\n".$search;
37 
38  return str_replace($search, $replace, $content);
39}
40
41function check_crypto($infos)
42{
43  if (!is_a_guest()) return $infos;
44 
45  include_once(CRYPTO_PATH.'securimage/securimage.php');
46  $securimage = new Securimage();
47 
48  if ($securimage->check($_POST['captcha_code']) == false)
49  {
50    array_push($infos['errors'], l10n('Invalid Captcha'));
51  }
52
53  return $infos;
54}
55
56?>
Note: See TracBrowser for help on using the repository browser.