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

Last change on this file since 15837 was 15837, checked in by rvelices, 12 years ago

sometimes akismet has false positives - try to get rid of them

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
RevLine 
[6506]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();
[7610]15  $url = duplicate_picture_url( array('image_id'=>$comment['image_id']) );
[6506]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  );
[13799]23  if (isset($_POST['url']) && strlen($_POST['url']))
24    $aki_comm['comment_author_url'] = $_POST['url'];
[6506]25
26  $akismet = new Akismet(get_absolute_root_url(), $conf['akismet_api_key'], $aki_comm);
27
28  if( !$akismet->errorsExist() )
29  {
30    $counters = explode('/', $conf['akismet_counters']);
31    if ( $akismet->isSpam() )
32    {
33      $action = $conf['akismet_spam_action'];
[15837]34      if ('reject'==$action && !is_a_guest() && isset($_SESSION['csi']))
35        $action='moderate';
[6506]36      if ('reject'!=$action) set_status_header(403);
37      $counters[0]++;
[13799]38      $_POST['cr'][] = 'aki';
[6506]39    }
[13799]40    else
[15837]41    {
[13799]42      $_POST['cr'][] = 'aki-ok';
[15837]43      if (!isset($_SESSION['csi']) && isset($_POST['url']) && strlen($_POST['url']) )
44      {
45        $action = 'reject';
46        $_POST['cr'][] = 'csi url';
47      }
48    }
[6506]49    $counters[1]++;
50    $conf['akismet_counters'] = implode('/', $counters);
51    $query = 'UPDATE '.CONFIG_TABLE.' SET value="'.$conf['akismet_counters'].'" WHERE param="akismet_counters" LIMIT 1';
52    pwg_query($query);
53  }
[13799]54  else {
55    $_POST['cr'][] = 'aki-FAIL';
56    if (is_admin())
57      var_export( $akismet->getErrors() );
58  }
[6506]59
60  return $action;
61}
62
63?>
Note: See TracBrowser for help on using the repository browser.