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

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

update for 2.4
deactivated for smartpocket, now compatible with simple and stripped on ContactForm
live update of preview on admin page

File size: 1.8 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4load_language('plugin.lang', CRYPTO_PATH);
5add_event_handler('loc_end_picture', 'add_crypto');
6add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
7
8function add_crypto()
9{
10  global $template;
11 
12  if (!is_a_guest()) return;
13 
14  $template->set_prefilter('picture', 'prefilter_crypto');
15}
16
17function prefilter_crypto($content, $smarty)
18{
19  global $conf;
20 
21  $search = '<p><textarea name="content" id="contentid" rows="5" cols="50">{$comment_add.CONTENT}</textarea></p>';
22  $replace = $search.'
23                                <p><label>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :</label></p>
24                                <p>
25                                  <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
26                                  <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
27                                    <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
28          <input type="text" name="captcha_code" style="width:'.$conf['cryptographp']['code_length'].'em;" maxlength="'.$conf['cryptographp']['code_length'].'" />
29                                </p>';
30
31  return str_replace($search, $replace, $content);
32}
33
34function check_crypto($action, $comment)
35{
36  global $conf, $page;
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    if ($conf['cryptographp']['comments_action'] == 'reject') array_push($page['errors'], l10n('Invalid Captcha'));
49    return $conf['cryptographp']['comments_action'];
50  }
51
52  return $action;
53}
54
55?>
Note: See TracBrowser for help on using the repository browser.