source: extensions/rv_akismet/check.inc.php @ 7173

Last change on this file since 7173 was 6506, checked in by rvelices, 14 years ago

added rv_akismet extension to svn

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1<?php
2function akismet_user_comment_check($action, $comment)
3{
4  global $conf;
5  if ('reject'==$action or $conf['akismet_spam_action']==$action)
6    return $action; // already rejecting
7  if ( empty($conf['akismet_api_key']) )
8    return $action; // need to config it
9  /*if ( !is_a_guest() )
10    return $action;*/
11
12  include_once( dirname(__FILE__).'/akismet.class.php' );
13
14  set_make_full_url();
15  $url = duplicate_picture_url();
16  unset_make_full_url();
17  $aki_comm = array(
18    'author' => $comment['author'],
19    'body' => $comment['content'],
20    'permalink' => $url,
21    'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
22  );
23
24  $akismet = new Akismet(get_absolute_root_url(), $conf['akismet_api_key'], $aki_comm);
25
26  if( !$akismet->errorsExist() )
27  {
28    $counters = explode('/', $conf['akismet_counters']);
29    if ( $akismet->isSpam() )
30    {
31      $action = $conf['akismet_spam_action'];
32      if ('reject'!=$action) set_status_header(403);
33      $counters[0]++;
34    }
35    $counters[1]++;
36    $conf['akismet_counters'] = implode('/', $counters);
37    $query = 'UPDATE '.CONFIG_TABLE.' SET value="'.$conf['akismet_counters'].'" WHERE param="akismet_counters" LIMIT 1';
38    pwg_query($query);
39  }
40  elseif (is_admin())
41    var_export( $akismet->getErrors() );
42
43  return $action;
44}
45
46?>
Note: See TracBrowser for help on using the repository browser.