source: extensions/CryptograPHP/include/register.inc.php @ 13377

Last change on this file since 13377 was 12619, checked in by mistic100, 13 years ago

fix display on some themes, disable on ContactForm for simple and stripped themes (stupid bug)

File size: 1.5 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4add_event_handler('loc_end_page_header', 'add_crypto');
5add_event_handler('register_user_check', 'check_crypto');
6
7function add_crypto()
8{
9  global $template;
10
11  $template->set_prefilter('register', 'prefilter_crypto');
12}
13
14function prefilter_crypto($content, $smarty)
15{
16  global $conf;
17 
18  $search = '#\<\/ul\>(.{0,10})\<\/fieldset\>(.{0,10})\<p class\=\"bottomButtons\"\>#is';
19  $replace = '
20      <li>
21        <span class="property">
22          <label>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image"></label>
23        </span>
24        <input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
25        <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
26          <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
27      </li>
28  </ul>
29
30  </fieldset>
31
32  <p class="bottomButtons">';
33
34  return preg_replace($search, $replace, $content);
35}
36
37function check_crypto($errors)
38{
39  include_once(CRYPTO_PATH.'securimage/securimage.php');
40  $securimage = new Securimage();
41 
42  if ($securimage->check($_POST['captcha_code']) == false)
43  {
44    array_push($errors, l10n('Invalid Captcha'));
45  }
46
47  return $errors;
48}
49
50?>
Note: See TracBrowser for help on using the repository browser.