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