0.6
This commit is contained in:
parent
aec5e023f3
commit
21b1cbbc16
9 changed files with 426 additions and 14 deletions
29
CHANGELOG
Normal file
29
CHANGELOG
Normal file
|
@ -0,0 +1,29 @@
|
|||
v0.6 - 22-04-2015 - Pierre Van Glabeke
|
||||
* Modifs typo
|
||||
* Ajout message
|
||||
* Modif url support
|
||||
|
||||
v0.5 - 2013-11-12
|
||||
* Clean up code
|
||||
|
||||
v0.4 - 2011-01-20
|
||||
* Fixed call to blog object on prepend
|
||||
* New year copyright
|
||||
|
||||
v0.3.2 - 2010-11-12
|
||||
* Fixed install on nightly build
|
||||
|
||||
v0.3.1 - 2010-06-22
|
||||
* Fixed me!
|
||||
|
||||
v0.3 - 2010-06-05
|
||||
* Switched to DC 2.2
|
||||
|
||||
v0.2 - 2009-12-13
|
||||
* Fixed trigger blogs
|
||||
* Enabled min length of comment to filter
|
||||
* Prepared DC 2.2 Break
|
||||
* Added versioning
|
||||
|
||||
v0.1 - 2009-10-09
|
||||
* First lab release
|
23
LICENSE
23
LICENSE
|
@ -1,12 +1,12 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
|
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
|
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
|||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
|
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
|
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
|
|||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
|
|||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
|
@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
|
|||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
|
||||
|
|
24
README.md
24
README.md
|
@ -1,2 +1,22 @@
|
|||
# dcFilterDuplicate
|
||||
Antispam de commentaires en doublon sur un multiblog
|
||||
# README
|
||||
|
||||
## WHAT IS DCFILTERDUPLICATE ?
|
||||
|
||||
dcFilterDuplicate "Dupicate comments filter" is a plugin for the
|
||||
open-source web publishing software called Dotclear.
|
||||
|
||||
Filter as spam same (duplicate) comments from multiple blogs of a Dotclear's install.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
dcFilterDuplicate requires:
|
||||
|
||||
* permissions to manage antispam
|
||||
* Dotclear 2.6
|
||||
|
||||
## USAGE
|
||||
|
||||
First install dcFilterDuplicate, manualy from a zip package or from
|
||||
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||
|
||||
Enable and configure "Dupicate comments filter" from antispam manager.
|
||||
|
|
37
_define.php
Normal file
37
_define.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of dcFilterDuplicate, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */
|
||||
"dcFilterDuplicate",
|
||||
/* Description*/
|
||||
"Antispam for duplicate comments on multiblog",
|
||||
/* Author */
|
||||
"Jean-Christian Denis",
|
||||
/* Version */
|
||||
'0.6',
|
||||
/* Properies */
|
||||
array(
|
||||
'permissions' => 'admin',
|
||||
'priority' => 200,
|
||||
'type' => 'plugin',
|
||||
'dc_min' => '2.6',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332947#p332947',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/dcFilterDuplicate'
|
||||
)
|
||||
);
|
74
_install.php
Normal file
74
_install.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of dcFilterDuplicate, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
# -- Module specs --
|
||||
|
||||
$dc_min = '2.6';
|
||||
$mod_id = 'dcFilterDuplicate';
|
||||
$mod_conf = array(
|
||||
array(
|
||||
'dcfilterduplicate_minlen',
|
||||
'Minimum lenght of comment to filter',
|
||||
30,
|
||||
'integer'
|
||||
)
|
||||
);
|
||||
|
||||
# -- Nothing to change below --
|
||||
|
||||
try {
|
||||
|
||||
# Check module version
|
||||
if (version_compare(
|
||||
$core->getVersion($mod_id),
|
||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||
'>='
|
||||
)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
# Check Dotclear version
|
||||
if (!method_exists('dcUtils', 'versionsCompare')
|
||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||
throw new Exception(sprintf(
|
||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
||||
));
|
||||
}
|
||||
|
||||
# Set module settings
|
||||
$core->blog->settings->addNamespace($mod_id);
|
||||
foreach($mod_conf as $v) {
|
||||
$core->blog->settings->{$mod_id}->put(
|
||||
$v[0], $v[2], $v[3], $v[1], false, true
|
||||
);
|
||||
}
|
||||
|
||||
# Set module version
|
||||
$core->setVersion(
|
||||
$mod_id,
|
||||
$core->plugins->moduleInfo($mod_id, 'version')
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
22
_prepend.php
Normal file
22
_prepend.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of dcFilterDuplicate, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$__autoload['dcFilterDuplicate'] =
|
||||
dirname(__FILE__).'/inc/class.filter.duplicate.php';
|
||||
|
||||
$core->spamfilters[] = 'dcFilterDuplicate';
|
61
_uninstall.php
Normal file
61
_uninstall.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of dcFilterDuplicate, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$mod_id = 'dcFilterDuplicate';
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'settings',
|
||||
/* action */ 'delete_all',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ __('delete all settings')
|
||||
);
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'plugins',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ __('delete plugin files')
|
||||
);
|
||||
|
||||
$this->addUserAction(
|
||||
/* type */ 'versions',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ __('delete the version number')
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
/* type */ 'settings',
|
||||
/* action */ 'delete_all',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
/* type */ 'versions',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ sprintf(__('delete %s version number'), $mod_id)
|
||||
);
|
||||
|
||||
$this->addDirectAction(
|
||||
/* type */ 'plugins',
|
||||
/* action */ 'delete',
|
||||
/* ns */ $mod_id,
|
||||
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
|
||||
);
|
139
inc/class.filter.duplicate.php
Normal file
139
inc/class.filter.duplicate.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of dcFilterDuplicate, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_DCFILTERDUPLICATE
|
||||
* @brief Filter duplicate comments on multiblogs.
|
||||
* @since 2.6
|
||||
*/
|
||||
class dcFilterDuplicate extends dcSpamFilter
|
||||
{
|
||||
public $name = 'Duplicate comment filter';
|
||||
public $has_gui = true;
|
||||
|
||||
protected function setInfo()
|
||||
{
|
||||
$this->name = __('dcFilterDuplicate');
|
||||
$this->description = __('Same comments on others blogs of a multiblog');
|
||||
}
|
||||
|
||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
||||
{
|
||||
if ($type != 'comment') {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen);
|
||||
if (strlen($content) < $minlen) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($this->isDuplicate($content, $ip)) {
|
||||
$this->markDuplicate($content, $ip);
|
||||
$status = 'Duplicate on other blog';
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function isDuplicate($content, $ip)
|
||||
{
|
||||
$rs = $this->core->con->select(
|
||||
'SELECT C.comment_id '.
|
||||
'FROM '.$this->core->prefix.'comment C '.
|
||||
'LEFT JOIN '.$this->core->prefix.'post P ON C.post_id=P.post_id '.
|
||||
"WHERE P.blog_id != '".$this->core->blog->id."' ".
|
||||
"AND C.comment_content='".$this->core->con->escape($content)."' ".
|
||||
"AND C.comment_ip='".$ip."' "
|
||||
);
|
||||
|
||||
return !$rs->isEmpty();
|
||||
}
|
||||
|
||||
public function markDuplicate($content, $ip)
|
||||
{
|
||||
$cur = $this->core->con->openCursor($this->core->prefix.'comment');
|
||||
$this->core->con->writeLock($this->core->prefix.'comment');
|
||||
|
||||
$cur->comment_status = -2;
|
||||
$cur->comment_spam_status = 'Duplicate on other blog';
|
||||
$cur->comment_spam_filter = 'dcFilterDuplicate';
|
||||
|
||||
$cur->update(
|
||||
"WHERE comment_content='".$this->core->con->escape($content)."' ".
|
||||
"AND comment_ip='".$ip."' "
|
||||
);
|
||||
$this->core->con->unlock();
|
||||
|
||||
$this->triggerOtherBlogs($content, $ip);
|
||||
}
|
||||
|
||||
public function gui($url)
|
||||
{
|
||||
$minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen);
|
||||
if (isset($_POST['dcfilterduplicate_minlen'])) {
|
||||
$minlen = abs((integer) $_POST['dcfilterduplicate_minlen']);
|
||||
$this->core->blog->settings->dcFilterDuplicate->put(
|
||||
'dcfilterduplicate_minlen',
|
||||
$minlen,
|
||||
'integer'
|
||||
);
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated.'));
|
||||
http::redirect($url);
|
||||
}
|
||||
|
||||
$res =
|
||||
'<form action="'.html::escapeURL($url).'" method="post">'.
|
||||
'<p><label class="classic">'.__('Minimum content length before check for duplicate:').'<br />'.
|
||||
form::field(array('dcfilterduplicate_minlen'), 65, 255, $minlen).
|
||||
'</label></p>'.
|
||||
'<p><input type="submit" name="save" value="'.__('Save').'" />'.
|
||||
$this->core->formNonce().'</p>'.
|
||||
'</form>';
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function triggerOtherBlogs($content, $ip)
|
||||
{
|
||||
$rs = $this->core->con->select(
|
||||
'SELECT P.blog_id '.
|
||||
'FROM '.$this->core->prefix.'comment C '.
|
||||
'LEFT JOIN '.$this->core->prefix.'post P ON C.post_id=P.post_id '.
|
||||
"WHERE C.comment_content='".$this->core->con->escape($content)."' ".
|
||||
"AND C.comment_ip='".$ip."' "
|
||||
);
|
||||
|
||||
while ($rs->fetch()) {
|
||||
$b = new dcBlog($this, $rs->blog_id);
|
||||
$b->triggerBlog();
|
||||
unset($b);
|
||||
}
|
||||
}
|
||||
}
|
31
locales/fr/main.po
Normal file
31
locales/fr/main.po
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Language: Français
|
||||
# Module: dcFilterDuplicate - 0.5
|
||||
# Date: 2013-11-14 07:24:39
|
||||
# Translated with translater 2013.05.11
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: dcFilterDuplicate 0.5\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2013-11-14T07:24:39+00:00\n"
|
||||
"Last-Translator: Jean-Christian Denis\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: inc/class.filter.duplicate.php:30
|
||||
msgid "Duplicate comment filter"
|
||||
msgstr "Filtre de doublon de commentaires"
|
||||
|
||||
#: inc/class.filter.duplicate.php:31
|
||||
msgid "Same comments on others blogs of a multiblog"
|
||||
msgstr "Commentaires identiques sur les autres blogs du multiblog"
|
||||
|
||||
#: inc/class.filter.duplicate.php:110
|
||||
msgid "Minimum content length before check for duplicate:"
|
||||
msgstr "Longueur minimum du contenu pour faire une vérification :"
|
||||
|
||||
msgid "Antispam for duplicate comments on multiblog"
|
||||
msgstr "Antispam contre les doublons de commentaires sur un multiblog"
|
||||
|
Loading…
Reference in a new issue