update license and adopt PSR2 coding style
parent
8ed255dac8
commit
3e2e840dd9
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,28 +1,26 @@
|
||||||
|
whiteListCom 0.7 - 2021-08-19
|
||||||
|
* fix PSR2 coding style
|
||||||
|
* update license
|
||||||
|
|
||||||
whiteListCom 0.6 - 2013-11-13
|
whiteListCom 0.6 - 2013-11-13
|
||||||
===========================================================
|
|
||||||
* Clean up code
|
* Clean up code
|
||||||
|
|
||||||
whiteListCom 0.5 - 2011-01-19
|
whiteListCom 0.5 - 2011-01-19
|
||||||
===========================================================
|
|
||||||
* Fixed calls to blog object
|
* Fixed calls to blog object
|
||||||
* Fixed (hope so) postgreSQL compatibility
|
* Fixed (hope so) postgreSQL compatibility
|
||||||
* Added messages on admin
|
* Added messages on admin
|
||||||
* New year copyright
|
* New year copyright
|
||||||
|
|
||||||
whiteListCom 0.4 - 2010-06-05
|
whiteListCom 0.4 - 2010-06-05
|
||||||
===========================================================
|
|
||||||
* Switched to DC 2.2
|
* Switched to DC 2.2
|
||||||
|
|
||||||
whiteListCom 0.3 - 2009-11-08
|
whiteListCom 0.3 - 2009-11-08
|
||||||
===========================================================
|
|
||||||
* Fixed whitout comment_trackback in admin comments list
|
* Fixed whitout comment_trackback in admin comments list
|
||||||
* Fixed typo
|
* Fixed typo
|
||||||
* Added LICENSE
|
* Added LICENSE
|
||||||
|
|
||||||
whiteListCom 0.2 - 2009-09-27
|
whiteListCom 0.2 - 2009-09-27
|
||||||
===========================================================
|
|
||||||
* Changed to antispam system
|
* Changed to antispam system
|
||||||
|
|
||||||
whiteListCom 0.1 - 2009-09-16
|
whiteListCom 0.1 - 2009-09-16
|
||||||
===========================================================
|
|
||||||
* First lab release
|
* First lab release
|
|
@ -23,3 +23,9 @@ Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||||
Enable and configure "Unmoderated authors" of "Reserved names"
|
Enable and configure "Unmoderated authors" of "Reserved names"
|
||||||
from antispam manager.
|
from antispam manager.
|
||||||
Note: User must write a comment before able to be added to the list.
|
Note: User must write a comment before able to be added to the list.
|
||||||
|
|
||||||
|
## MORE
|
||||||
|
|
||||||
|
* License : GNU GPL v2
|
||||||
|
* Source & contribution : [GitHub Page](https://github.com/JcDenis/whiteListCom)
|
||||||
|
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/whiteListCom)
|
||||||
|
|
39
_define.php
39
_define.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -12,23 +11,21 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */
|
'Whitelist comments',
|
||||||
"Whitelist comments",
|
'Whitelists for comments moderation',
|
||||||
/* Description*/
|
'Jean-Christian Denis and Contributors',
|
||||||
"Whitelists for comments moderation",
|
'0.7',
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
'permissions' => 'admin',
|
||||||
/* Version */
|
'priority' => 200,
|
||||||
'0.6',
|
'type' => 'plugin',
|
||||||
array(
|
'dc_min' => '2.18',
|
||||||
'permissions' => 'admin',
|
'support' => 'https://github.com/JcDenis/whiteListCom',
|
||||||
'priority' => 200,
|
'details' => 'https://plugins.dotaddict.org/dc2/details/whiteListCom'
|
||||||
'type' => 'plugin',
|
]
|
||||||
'dc_min' => '2.6',
|
);
|
||||||
'support' => 'http://jcd.lv/q=whiteListCom',
|
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/whiteListCom'
|
|
||||||
)
|
|
||||||
);
|
|
20
_prepend.php
20
_prepend.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,22 +12,21 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = dirname(__FILE__).'/inc/lib.whitelistcom.php';
|
$d = dirname(__FILE__).'/inc/lib.whitelistcom.php';
|
||||||
|
|
||||||
$__autoload['whiteListCom'] = $d;
|
$__autoload['whiteListCom'] = $d;
|
||||||
$__autoload['whiteListComBehaviors'] = $d;
|
$__autoload['whiteListComBehaviors'] = $d;
|
||||||
$__autoload['whiteListComReservedFilter'] = $d;
|
$__autoload['whiteListComReservedFilter'] = $d;
|
||||||
$__autoload['whiteListComModeratedFilter'] = $d;
|
$__autoload['whiteListComModeratedFilter'] = $d;
|
||||||
|
|
||||||
$core->spamfilters[] = 'whiteListComModeratedFilter';
|
$core->spamfilters[] = 'whiteListComModeratedFilter';
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'publicAfterCommentCreate',
|
'publicAfterCommentCreate',
|
||||||
array('whiteListComBehaviors', 'switchStatus')
|
['whiteListComBehaviors', 'switchStatus']
|
||||||
);
|
);
|
||||||
|
|
||||||
$core->spamfilters[] = 'whiteListComReservedFilter';
|
$core->spamfilters[] = 'whiteListComReservedFilter';
|
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,8 +12,7 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,121 +24,125 @@ if (!defined('DC_RC_PATH')) {
|
||||||
*/
|
*/
|
||||||
class whiteListComModeratedFilter extends dcSpamFilter
|
class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
{
|
{
|
||||||
public $name = 'Unmoderated authors';
|
public $name = 'Unmoderated authors';
|
||||||
public $has_gui = true;
|
public $has_gui = true;
|
||||||
|
|
||||||
protected function setInfo()
|
protected function setInfo()
|
||||||
{
|
{
|
||||||
$this->name = __('Unmoderated authors');
|
$this->name = __('Unmoderated authors');
|
||||||
$this->description = __('Whitelist of unmoderated authors');
|
$this->description = __('Whitelist of unmoderated authors');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
||||||
{
|
{
|
||||||
if ($type != 'comment'
|
if ($type != 'comment'
|
||||||
|| $this->core->blog === null
|
|| $this->core->blog === null
|
||||||
|| $this->core->blog->settings->system->comments_pub
|
|| $this->core->blog->settings->system->comments_pub) {
|
||||||
) {
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$wlc = new whiteListCom($this->core);
|
$wlc = new whiteListCom($this->core);
|
||||||
if ($wlc->isUnmoderated($email)) {
|
if ($wlc->isUnmoderated($email)) {
|
||||||
$status = 'unmoderated';
|
$status = 'unmoderated';
|
||||||
|
|
||||||
# return true in order to change comment_status after
|
# return true in order to change comment_status after
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function gui($url)
|
}
|
||||||
{
|
}
|
||||||
try {
|
|
||||||
$wlc = new whiteListCom($this->core);
|
|
||||||
|
|
||||||
if (!empty($_POST['update_unmoderated'])) {
|
public function gui($url)
|
||||||
$wlc->emptyUnmoderated();
|
{
|
||||||
foreach($_POST['unmoderated'] as $email) {
|
try {
|
||||||
$wlc->addUnmoderated($email);
|
$wlc = new whiteListCom($this->core);
|
||||||
}
|
|
||||||
$wlc->commit();
|
|
||||||
}
|
|
||||||
$posts = $wlc->getPostsUsers();
|
|
||||||
$comments = $wlc->getCommentsUsers();
|
|
||||||
}
|
|
||||||
catch (Exception $e) {
|
|
||||||
$this->core->error->add($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = '';
|
if (!empty($_POST['update_unmoderated'])) {
|
||||||
|
$wlc->emptyUnmoderated();
|
||||||
|
foreach($_POST['unmoderated'] as $email) {
|
||||||
|
$wlc->addUnmoderated($email);
|
||||||
|
}
|
||||||
|
$wlc->commit();
|
||||||
|
}
|
||||||
|
$posts = $wlc->getPostsUsers();
|
||||||
|
$comments = $wlc->getCommentsUsers();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->core->error->add($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->core->blog->settings->system->comments_pub) {
|
$res = '';
|
||||||
$res .=
|
|
||||||
'<p class="message">'.
|
|
||||||
__('This filter is used only if comments are moderates').
|
|
||||||
'</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
if ($this->core->blog->settings->system->comments_pub) {
|
||||||
'<form action="'.html::escapeURL($url).'" method="post">'.
|
$res .=
|
||||||
'<p>'.__('Check the users who can make comments without being moderated.').'</p>'.
|
'<p class="message">' .
|
||||||
'<div class="two-cols">'.
|
__('This filter is used only if comments are moderates') .
|
||||||
'<div class="col">'.
|
'</p>';
|
||||||
'<p>'.__('Posts authors list').'</p>'.
|
}
|
||||||
'<table class="clear">'.
|
|
||||||
'<thead><tr><th>'.__('Name').'</th><th>'.__('Email').'</th></tr></thead>'.
|
|
||||||
'<tbody>';
|
|
||||||
|
|
||||||
foreach($posts as $user) {
|
$res .=
|
||||||
$res .=
|
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||||
'<tr class="line">'.
|
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
|
||||||
'<td class="nowrap">'.
|
'<div class="two-cols">' .
|
||||||
form::checkbox(array('unmoderated[]'), $user['email'],
|
'<div class="col">' .
|
||||||
$wlc->isUnmoderated($user['email'])).' '.
|
'<p>' . __('Posts authors list') . '</p>' .
|
||||||
$user['name'].'</td>'.
|
'<table class="clear">' .
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
'<thead><tr><th>' . __('Name') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
'</tr>';
|
'<tbody>';
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
foreach($posts as $user) {
|
||||||
'</tbody>'.
|
$res .=
|
||||||
'</table>'.
|
'<tr class="line">' .
|
||||||
'</div>'.
|
'<td class="nowrap">' .
|
||||||
'<div class="col">'.
|
form::checkbox(
|
||||||
'<p>'.__('Comments authors list').'</p>'.
|
array('unmoderated[]'),
|
||||||
'<table class="clear">'.
|
$user['email'],
|
||||||
'<thead><tr><th>'.__('Author').'</th><th>'.__('Email').'</th></tr></thead>'.
|
$wlc->isUnmoderated($user['email'])
|
||||||
'<tbody>';
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
foreach($comments as $user) {
|
$res .=
|
||||||
$res .=
|
'</tbody>' .
|
||||||
'<tr class="line">'.
|
'</table>' .
|
||||||
'<td class="nowrap">'.
|
'</div>' .
|
||||||
form::checkbox(array('unmoderated[]'), $user['email'],
|
'<div class="col">' .
|
||||||
$wlc->isUnmoderated($user['email'])).' '.
|
'<p>' . __('Comments authors list') . '</p>' .
|
||||||
$user['name'].'</td>'.
|
'<table class="clear">' .
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
'<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
'</tr>';
|
'<tbody>';
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
foreach($comments as $user) {
|
||||||
'</tbody>'.
|
$res .=
|
||||||
'</table>'.
|
'<tr class="line">' .
|
||||||
'</div>'.
|
'<td class="nowrap">' .
|
||||||
'</div>'.
|
form::checkbox(
|
||||||
'<p><input type="submit" name="update_unmoderated" value="'.__('Save').'" />'.
|
array('unmoderated[]'),
|
||||||
$this->core->formNonce().'</p>'.
|
$user['email'],
|
||||||
'</form>';
|
$wlc->isUnmoderated($user['email'])
|
||||||
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
$res .=
|
||||||
}
|
'</tbody>' .
|
||||||
|
'</table>' .
|
||||||
|
'</div>' .
|
||||||
|
'</div>' .
|
||||||
|
'<p><input type="submit" name="update_unmoderated" value="' . __('Save') . '" />' .
|
||||||
|
$this->core->formNonce() . '</p>' .
|
||||||
|
'</form>';
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,95 +152,95 @@ class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
*/
|
*/
|
||||||
class whiteListComReservedFilter extends dcSpamFilter
|
class whiteListComReservedFilter extends dcSpamFilter
|
||||||
{
|
{
|
||||||
public $name = 'Reserved names';
|
public $name = 'Reserved names';
|
||||||
public $has_gui = true;
|
public $has_gui = true;
|
||||||
|
|
||||||
protected function setInfo()
|
protected function setInfo()
|
||||||
{
|
{
|
||||||
$this->name = __('Reserved names');
|
$this->name = __('Reserved names');
|
||||||
$this->description = __('Whitelist of reserved names of users');
|
$this->description = __('Whitelist of reserved names of users');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
||||||
{
|
{
|
||||||
if ($type != 'comment') {
|
if ($type != 'comment') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
$throw = false;
|
||||||
}
|
try {
|
||||||
|
$wlc = new whiteListCom($this->core);
|
||||||
|
|
||||||
$throw = false;
|
if (true === $wlc->isReserved($author, $email)) {
|
||||||
try {
|
$status = 'reserved name';
|
||||||
$wlc = new whiteListCom($this->core);
|
//return true;
|
||||||
|
$throw = true;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
if (true === $wlc->isReserved($author, $email)) {
|
}
|
||||||
$status = 'reserved name';
|
|
||||||
//return true;
|
|
||||||
$throw = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
return null;
|
# This message is show to author even if comments are moderated, comment is not saved
|
||||||
}
|
if($throw) {
|
||||||
}
|
throw new Exception(__('This name is reserved to an other user.'));
|
||||||
catch (Exception $e) {}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# This message is show to author even if comments are moderated, comment is not saved
|
public function getStatusMessage($status, $comment_id)
|
||||||
if($throw) {
|
{
|
||||||
throw new Exception(__('This name is reserved to an other user.'));
|
return __('This name is reserved to an other user.');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getStatusMessage($status,$comment_id)
|
public function gui($url)
|
||||||
{
|
{
|
||||||
return __('This name is reserved to an other user.');
|
try {
|
||||||
}
|
$wlc = new whiteListCom($this->core);
|
||||||
|
|
||||||
public function gui($url)
|
if (!empty($_POST['update_reserved'])) {
|
||||||
{
|
$wlc->emptyReserved();
|
||||||
try {
|
foreach($_POST['reserved'] as $email => $name) {
|
||||||
$wlc = new whiteListCom($this->core);
|
$wlc->addReserved($name, $email);
|
||||||
|
}
|
||||||
|
$wlc->commit();
|
||||||
|
}
|
||||||
|
$comments = $wlc->getCommentsUsers();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->core->error->add($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST['update_reserved'])) {
|
$res =
|
||||||
$wlc->emptyReserved();
|
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||||
foreach($_POST['reserved'] as $email => $name) {
|
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
|
||||||
$wlc->addReserved($name, $email);
|
'<p>' . __('Comments authors list') . '</p>' .
|
||||||
}
|
'<table class="clear">' .
|
||||||
$wlc->commit();
|
'<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
}
|
'<tbody>';
|
||||||
$comments = $wlc->getCommentsUsers();
|
|
||||||
}
|
|
||||||
catch (Exception $e) {
|
|
||||||
$this->core->error->add($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$res =
|
foreach($comments as $user) {
|
||||||
'<form action="'.html::escapeURL($url).'" method="post">'.
|
$res .=
|
||||||
'<p>'.__('Check the users who can make comments without being moderated.').'</p>'.
|
'<tr class="line">' .
|
||||||
'<p>'.__('Comments authors list').'</p>'.
|
'<td class="nowrap">' .
|
||||||
'<table class="clear">'.
|
form::checkbox(
|
||||||
'<thead><tr><th>'.__('Author').'</th><th>'.__('Email').'</th></tr></thead>'.
|
array('reserved[' . $user['email'] . ']'),
|
||||||
'<tbody>';
|
$user['name'],
|
||||||
|
(null === $wlc->isReserved($user['name'], $user['email']))
|
||||||
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
foreach($comments as $user) {
|
$res .=
|
||||||
$res .=
|
'</tbody>' .
|
||||||
'<tr class="line">'.
|
'</table>' .
|
||||||
'<td class="nowrap">'.
|
'<p><input type="submit" name="update_reserved" value="' . __('Save') . '" />' .
|
||||||
form::checkbox(array('reserved['.$user['email'].']'), $user['name'],
|
$this->core->formNonce() . '</p>' .
|
||||||
(null === $wlc->isReserved($user['name'], $user['email']))).' '.
|
'</form>';
|
||||||
$user['name'].'</td>'.
|
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
|
||||||
'</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
return $res;
|
||||||
'</tbody>'.
|
}
|
||||||
'</table>'.
|
|
||||||
'<p><input type="submit" name="update_reserved" value="'.__('Save').'" />'.
|
|
||||||
$this->core->formNonce().'</p>'.
|
|
||||||
'</form>';
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -248,159 +250,155 @@ class whiteListComReservedFilter extends dcSpamFilter
|
||||||
*/
|
*/
|
||||||
class whiteListCom
|
class whiteListCom
|
||||||
{
|
{
|
||||||
public $core;
|
public $core;
|
||||||
public $con;
|
public $con;
|
||||||
public $blog;
|
public $blog;
|
||||||
public $settings;
|
public $settings;
|
||||||
|
|
||||||
private $unmoderated = array();
|
private $unmoderated = array();
|
||||||
private $reserved = array();
|
private $reserved = array();
|
||||||
|
|
||||||
public function __construct($core)
|
public function __construct($core)
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
$this->core = $core;
|
||||||
$this->con = $core->con;
|
$this->con = $core->con;
|
||||||
$this->blog = $core->con->escape($core->blog->id);
|
$this->blog = $core->con->escape($core->blog->id);
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('whiteListCom');
|
$core->blog->settings->addNamespace('whiteListCom');
|
||||||
$this->settings = $core->blog->settings->whiteListCom;
|
$this->settings = $core->blog->settings->whiteListCom;
|
||||||
|
|
||||||
$unmoderated = $this->settings->whiteListCom_unmoderated;
|
$unmoderated = $this->settings->whiteListCom_unmoderated;
|
||||||
$this->unmoderated = self::decode($unmoderated);
|
$this->unmoderated = self::decode($unmoderated);
|
||||||
|
|
||||||
$reserved = $this->settings->whiteListCom_reserved;
|
$reserved = $this->settings->whiteListCom_reserved;
|
||||||
$this->reserved = self::decode($reserved);
|
$this->reserved = self::decode($reserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
$this->settings->put(
|
$this->settings->put(
|
||||||
'whiteListCom_unmoderated',
|
'whiteListCom_unmoderated',
|
||||||
self::encode($this->unmoderated),
|
self::encode($this->unmoderated),
|
||||||
'string',
|
'string',
|
||||||
'Whitelist of unmoderated users on comments',
|
'Whitelist of unmoderated users on comments',
|
||||||
true,false
|
true,false
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->settings->put(
|
$this->settings->put(
|
||||||
'whiteListCom_reserved',
|
'whiteListCom_reserved',
|
||||||
self::encode($this->reserved),
|
self::encode($this->reserved),
|
||||||
'string',
|
'string',
|
||||||
'Whitelist of reserved names on comments',
|
'Whitelist of reserved names on comments',
|
||||||
true,false
|
true,false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return
|
# Return
|
||||||
# true if it is a reserved name with wrong email
|
# true if it is a reserved name with wrong email
|
||||||
# false if it is not a reserved name
|
# false if it is not a reserved name
|
||||||
# null if it is a reserved name with right email
|
# null if it is a reserved name with right email
|
||||||
public function isReserved($author, $email)
|
public function isReserved($author, $email)
|
||||||
{
|
{
|
||||||
if (!isset($this->reserved[$author])) {
|
if (!isset($this->reserved[$author])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} elseif ($this->reserved[$author] != $email) {
|
||||||
elseif ($this->reserved[$author] != $email) {
|
return true;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
# You must do a commit to save this change
|
||||||
}
|
public function addReserved($author, $email)
|
||||||
else {
|
{
|
||||||
|
$this->reserved[$author] = $email;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
# You must do a commit to save this change
|
||||||
}
|
public function emptyReserved()
|
||||||
}
|
{
|
||||||
|
$this->reserved = array();
|
||||||
|
}
|
||||||
|
|
||||||
# You must do a commit to save this change
|
# Return
|
||||||
public function addReserved($author, $email)
|
# true if it is known as an unmoderated email else false
|
||||||
{
|
public function isUnmoderated($email)
|
||||||
$this->reserved[$author] = $email;
|
{
|
||||||
return true;
|
return in_array($email, $this->unmoderated);
|
||||||
}
|
}
|
||||||
|
|
||||||
# You must do a commit to save this change
|
# You must do a commit to save this change
|
||||||
public function emptyReserved()
|
public function addUnmoderated($email)
|
||||||
{
|
{
|
||||||
$this->reserved = array();
|
if (!in_array($email,$this->unmoderated)) {
|
||||||
}
|
$this->unmoderated[] = $email;
|
||||||
|
|
||||||
# Return
|
return true;
|
||||||
# true if it is known as an unmoderated email else false
|
}
|
||||||
public function isUnmoderated($email)
|
|
||||||
{
|
|
||||||
return in_array($email, $this->unmoderated);
|
|
||||||
}
|
|
||||||
|
|
||||||
# You must do a commit to save this change
|
return null;
|
||||||
public function addUnmoderated($email)
|
}
|
||||||
{
|
|
||||||
if (!in_array($email,$this->unmoderated)) {
|
|
||||||
$this->unmoderated[] = $email;
|
|
||||||
|
|
||||||
return true;
|
# You must do a commit to save this change
|
||||||
}
|
public function emptyUnmoderated()
|
||||||
|
{
|
||||||
|
$this->unmoderated = array();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
public function getPostsUsers()
|
||||||
}
|
{
|
||||||
|
$users = array();
|
||||||
|
$rs = $this->core->blog->getPostsUsers();
|
||||||
|
while($rs->fetch()) {
|
||||||
|
$name = dcUtils::getUserCN(
|
||||||
|
$rs->user_id,
|
||||||
|
$rs->user_name,
|
||||||
|
$rs->user_firstname,
|
||||||
|
$rs->user_displayname
|
||||||
|
);
|
||||||
|
$users[] = array(
|
||||||
|
'name' => $name,
|
||||||
|
'email' => $rs->user_email
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# You must do a commit to save this change
|
return $users;
|
||||||
public function emptyUnmoderated()
|
}
|
||||||
{
|
|
||||||
$this->unmoderated = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPostsUsers()
|
public function getCommentsUsers()
|
||||||
{
|
{
|
||||||
$users = array();
|
$users = array();
|
||||||
$rs = $this->core->blog->getPostsUsers();
|
$rs = $this->con->select(
|
||||||
while($rs->fetch()) {
|
'SELECT comment_author, comment_email ' .
|
||||||
$name = dcUtils::getUserCN(
|
'FROM ' . $this->core->prefix . 'comment C ' .
|
||||||
$rs->user_id,
|
'LEFT JOIN ' . $this->core->prefix . 'post P ON C.post_id=P.post_id ' .
|
||||||
$rs->user_name,
|
"WHERE blog_id='" . $this->blog . "' AND comment_trackback=0 " .
|
||||||
$rs->user_firstname,
|
'GROUP BY comment_email, comment_author ' // Added author to fix postgreSql
|
||||||
$rs->user_displayname
|
);
|
||||||
);
|
while($rs->fetch()) {
|
||||||
$users[] = array(
|
$users[] = array(
|
||||||
'name' => $name,
|
'name' => $rs->comment_author,
|
||||||
'email' => $rs->user_email
|
'email' => $rs->comment_email
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommentsUsers()
|
public static function encode($x)
|
||||||
{
|
{
|
||||||
$users = array();
|
$y = is_array($x) ? $x : array();
|
||||||
$rs = $this->con->select(
|
|
||||||
'SELECT comment_author, comment_email '.
|
|
||||||
'FROM '.$this->core->prefix.'comment C '.
|
|
||||||
'LEFT JOIN '.$this->core->prefix.'post P ON C.post_id=P.post_id '.
|
|
||||||
"WHERE blog_id='".$this->blog."' AND comment_trackback=0 ".
|
|
||||||
'GROUP BY comment_email, comment_author ' // Added author to fix postgreSql
|
|
||||||
);
|
|
||||||
while($rs->fetch()) {
|
|
||||||
$users[] = array(
|
|
||||||
'name' => $rs->comment_author,
|
|
||||||
'email' => $rs->comment_email
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $users;
|
return base64_encode(serialize($y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function encode($x)
|
public static function decode($x)
|
||||||
{
|
{
|
||||||
$y = is_array($x) ? $x : array();
|
$y = @unserialize(@base64_decode($x));
|
||||||
|
|
||||||
return base64_encode(serialize($y));
|
return is_array($y) ? $y : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function decode($x)
|
|
||||||
{
|
|
||||||
$y = @unserialize(@base64_decode($x));
|
|
||||||
|
|
||||||
return is_array($y) ? $y : array();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,31 +408,29 @@ class whiteListCom
|
||||||
*/
|
*/
|
||||||
class whiteListComBehaviors
|
class whiteListComBehaviors
|
||||||
{
|
{
|
||||||
# from behavior publicAfterCommentCreate
|
# from behavior publicAfterCommentCreate
|
||||||
public static function switchStatus($cur,$id)
|
public static function switchStatus($cur, $id)
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
if ($core->blog === null
|
if ($core->blog === null
|
||||||
|| $core->blog->settings->system->comments_pub
|
|| $core->blog->settings->system->comments_pub) {
|
||||||
) {
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($cur->comment_spam_filter == 'whiteListComModeratedFilter'
|
if ($cur->comment_spam_filter == 'whiteListComModeratedFilter'
|
||||||
&& $cur->comment_spam_status == 'unmoderated'
|
&& $cur->comment_spam_status == 'unmoderated') {
|
||||||
) {
|
$core->con->writeLock($core->prefix.'comment');
|
||||||
$core->con->writeLock($core->prefix.'comment');
|
|
||||||
|
|
||||||
$cur->comment_status = 1;
|
$cur->comment_status = 1;
|
||||||
$cur->comment_spam_status = 0;
|
$cur->comment_spam_status = 0;
|
||||||
$cur->comment_spam_filter = 0;
|
$cur->comment_spam_filter = 0;
|
||||||
$cur->update('WHERE comment_id = '.$id.' ');
|
$cur->update('WHERE comment_id = ' . $id . ' ');
|
||||||
|
|
||||||
$core->con->unlock();
|
$core->con->unlock();
|
||||||
|
|
||||||
$core->blog->triggerComment($id);
|
$core->blog->triggerComment($id);
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue