source: extensions/CryptograPHP/include/picture.inc.php @ 11375

Last change on this file since 11375 was 11370, checked in by mistic100, 13 years ago

change functions names (avoid errors if Captcha is also loaded)

File size: 1.2 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_begin_picture', 'add_crypto');
9add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
10
11function add_crypto()
12{
13  global $template, $conf;
14 
15  if (!is_a_guest()) return;
16 
17  $template->set_prefilter('picture', 'prefilter_crypto');
18  $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
19}
20
21function prefilter_crypto($content, $smarty)
22{
23  load_language('plugin.lang', CRYPTO_PATH);
24 
25  $search = '<input type="hidden" name="key" value="{$comment_add.KEY}">';
26  $replace = $search.'
27  <label>{$CAPTCHA}<input type="text" name="code"></label>';
28
29  return str_replace($search, $replace, $content);
30}
31
32function check_crypto($action, $comment)
33{
34  global $conf, $user;
35 
36  $my_action = ($conf['cryptographp_theme'][1] == 'reject') ? 'reject':'moderate';
37
38  if ($action == 'reject' OR $action == $my_action OR !is_a_guest())
39  {
40    return $action;
41  }
42
43  if (!chk_crypt($_POST['code']))
44  {
45    return $my_action;
46  }
47  else
48  {
49    return $action;
50  }
51}
52
53?>
Note: See TracBrowser for help on using the repository browser.