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

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

compatible with RV Akismet
compatible with question_mark_in_urls=false

File size: 1.7 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 = '{$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="{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
26                                  <a href="#" onclick="document.getElementById(\'captcha\').src = \'{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
27                                    <img src="{$ROOT_URL}'.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 (!is_a_guest()) return $action;
42
43  if ($securimage->check($_POST['captcha_code']) == false)
44  {
45    if ($conf['cryptographp']['comments_action'] == 'reject') array_push($page['errors'], l10n('Invalid Captcha'));
46    return ($action != 'reject') ? $conf['cryptographp']['comments_action'] : 'reject';
47  }
48
49  return $action;
50}
51
52?>
Note: See TracBrowser for help on using the repository browser.