source: extensions/CryptograPHP/register.inc.php @ 11298

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

first version of CryptograPHP

File size: 1.1 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('loc_end_page_header', 'add_captcha');
9add_event_handler('register_user_check', 'check_captcha');
10
11function add_captcha()
12{
13  global $template, $conf;
14
15  $template->set_prefilter('register', 'captcha_prefilter');
16  $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'].'.cfg.php',1));
17}
18
19function captcha_prefilter($content, $smarty)
20{
21  load_language('plugin.lang', CRYPTO_PATH);
22 
23  $search = '<p class="bottomButtons">';
24  $replace = '
25  <fieldset>
26    <legend>{\'Antibot test\'|@translate}</legend>
27    <ul>
28      <li>
29        <span class="property">
30          <label>{$CAPTCHA}</label>
31        </span>
32        <input type="text" name="code">
33      </li>
34    </ul>
35  </fieldset>'
36."\n".$search;
37
38  return str_replace($search, $replace, $content);
39}
40
41function check_captcha($errors)
42{
43  global $conf;
44
45  if (!chk_crypt($_POST['code']))
46  {
47    load_language('plugin.lang', CRYPTO_PATH);
48    array_push($errors, l10n('Invalid Captcha'));
49  }
50
51  return $errors;
52}
53
54?>
Note: See TracBrowser for help on using the repository browser.