source: extensions/CryptograPHP/include/category.inc.php @ 12617

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

rewrite some prefilters, replace CryptograPHP by Securimage (not abandoned project!)

File size: 1.6 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4add_event_handler('loc_begin_index', 'add_crypto');
5add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
6
7function add_crypto()
8{
9  global $template;
10 
11  if (!is_a_guest()) return;
12 
13  $template->set_prefilter('comments_on_albums', 'prefilter_crypto');
14}
15
16function prefilter_crypto($content, $smarty)
17{
18  global $conf;
19 
20  $search = '<input type="hidden" name="key" value="{$comment_add.KEY}">';
21  $replace = $search.'
22  <label>
23    <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
24    <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
25      <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
26    <br>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :
27    <input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
28   
29  </label>';
30
31  return str_replace($search, $replace, $content);
32}
33
34function check_crypto($action, $comment)
35{
36  global $conf;
37 
38  include_once(CRYPTO_PATH.'securimage/securimage.php');
39  $securimage = new Securimage();
40
41  if ( $action == 'reject' or $action == $conf['cryptographp']['comments_action'] or !is_a_guest() )
42  {
43    return $action;
44  }
45
46  if ($securimage->check($_POST['captcha_code']) == false)
47  {
48    return $conf['cryptographp']['comments_action'];
49  }
50
51  return $action;
52}
53
54?>
Note: See TracBrowser for help on using the repository browser.