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

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

compatible with RV Akismet
compatible with question_mark_in_urls=false

File size: 1.7 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4load_language('plugin.lang', CRYPTO_PATH);
5add_event_handler('display_contactform', 'add_crypto');
6add_event_handler('check_contactform_params', 'check_crypto');
7
8function add_crypto()
9{
10  global $template;
11
12  if (!is_a_guest()) return;
13
14  $template->set_prefilter('cf_form', 'prefilter_crypto');
15}
16
17function 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="{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
28          <a href="#" onclick="document.getElementById(\'captcha\').src = \'{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
29            <img src="{$ROOT_URL}'.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
36function 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?>
Note: See TracBrowser for help on using the repository browser.