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

Last change on this file since 26072 was 26072, checked in by mistic100, 10 years ago

try to simplify integration of captchas

File size: 1.0 KB
Line 
1<?php
2defined('CRYPTO_ID') or die('Hacking attempt!');
3
4$conf['cryptographp']['template'] = 'comment';
5include(CRYPTO_PATH.'include/common.inc.php');
6
7add_event_handler('loc_end_picture', 'add_crypto');
8add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
9
10function add_crypto()
11{
12  global $template;
13  $template->set_prefilter('picture', 'prefilter_crypto');
14}
15
16function prefilter_crypto($content, $smarty)
17{
18  $search = '{$comment_add.CONTENT}</textarea></p>';
19  return str_replace($search, $search."\n{\$CRYPTO.parsed_content}", $content);
20}
21
22function check_crypto($action, $comment)
23{
24  global $conf, $page;
25 
26  include_once(CRYPTO_PATH.'securimage/securimage.php');
27  $securimage = new Securimage();
28
29  if (!is_a_guest()) return $action;
30
31  if ($securimage->check($_POST['captcha_code']) == false)
32  {
33    if ($conf['cryptographp']['comments_action'] == 'reject') $page['errors'][] = l10n('Invalid Captcha');
34    return ($action != 'reject') ? $conf['cryptographp']['comments_action'] : 'reject';
35  }
36
37  return $action;
38}
Note: See TracBrowser for help on using the repository browser.