Changeset 3262
- Timestamp:
- 11/14/13 08:32:17 (10 years ago)
- Location:
- plugins/dcFilterDuplicate
- Files:
-
- 2 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcFilterDuplicate/_define.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_RC_PATH')){return;} 15 if (!defined('DC_RC_PATH')) { 16 17 return null; 18 } 14 19 15 20 $this->registerModule( 16 /* Name */ "Duplicate comment filter", 17 /* Description*/ "Antispam for duplicate comments on multiblog", 18 /* Author */ "JC Denis", 19 /* Version */ '0.4', 20 /* Permissions */ 'admin', 21 /* Priority */ 200 21 /* Name */ 22 "Duplicate comment filter", 23 /* Description*/ 24 "Antispam for duplicate comments on multiblog", 25 /* Author */ 26 "Jean-Christian Denis", 27 /* Version */ 28 '0.5', 29 /* Properies */ 30 array( 31 'permissions' => 'admin', 32 'priority' => 200, 33 'type' => 'plugin', 34 'dc_min' => '2.6', 35 'support' => 'http://jcd.lv/q=dcFilterDuplicate', 36 'details' => 'http://plugins.dotaddict.org/dc2/details/dcFilterDuplicate' 37 ) 22 38 ); 23 /* date */ #2011012024 ?> -
plugins/dcFilterDuplicate/_install.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_CONTEXT_ADMIN')) {return;}15 if (!defined('DC_CONTEXT_ADMIN')) { 14 16 15 # Get new version 16 $new_version = $core->plugins->moduleInfo('dcFilterDuplicate','version'); 17 $old_version = $core->getVersion('dcFilterDuplicate'); 17 return null; 18 } 18 19 19 # Compare versions 20 if (version_compare($old_version,$new_version,'>=')) {return;} 20 # -- Module specs -- 21 21 22 # Install or update 23 try 24 { 25 # Check version 26 if (version_compare(str_replace("-r","-p",DC_VERSION),'2.2-alpha','<')) 27 { 28 throw new Exception('dcFilterDuplicate requires Dotclear 2.2'); 22 $dc_min = '2.6'; 23 $mod_id = 'dcFilterDuplicate'; 24 $mod_conf = array( 25 array( 26 'dcfilterduplicate_minlen', 27 'Minimum lenght of comment to filter', 28 30, 29 'integer' 30 ) 31 ); 32 33 # -- Nothing to change below -- 34 35 try { 36 37 # Check module version 38 if (version_compare( 39 $core->getVersion($mod_id), 40 $core->plugins->moduleInfo($mod_id, 'version'), 41 '>=' 42 )) { 43 44 return null; 29 45 } 30 31 # Settings32 $core->blog->settings->addNamespace('dcFilterDuplicate');33 $core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true);34 46 35 # Version 36 $core->setVersion('dcFilterDuplicate',$new_version); 47 # Check Dotclear version 48 if (!method_exists('dcUtils', 'versionsCompare') 49 || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { 50 throw new Exception(sprintf( 51 '%s requires Dotclear %s', $mod_id, $dc_min 52 )); 53 } 54 55 # Set module settings 56 $core->blog->settings->addNamespace($mod_id); 57 foreach($mod_conf as $v) { 58 $core->blog->settings->{$mod_id}->put( 59 $v[0], $v[2], $v[3], $v[1], false, true 60 ); 61 } 62 63 # Set module version 64 $core->setVersion( 65 $mod_id, 66 $core->plugins->moduleInfo($mod_id, 'version') 67 ); 37 68 38 69 return true; 39 70 } 40 catch (Exception $e) 41 { 71 catch (Exception $e) { 42 72 $core->error->add($e->getMessage()); 73 43 74 return false; 44 75 } 45 ?> -
plugins/dcFilterDuplicate/_prepend.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_RC_PATH')) {return;}15 if (!defined('DC_RC_PATH')) { 14 16 15 global $__autoload, $core; 17 return null; 18 } 16 19 17 20 $__autoload['dcFilterDuplicate'] = … … 19 22 20 23 $core->spamfilters[] = 'dcFilterDuplicate'; 21 ?> -
plugins/dcFilterDuplicate/_uninstall.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_CONTEXT_ADMIN')){return;} 15 if (!defined('DC_CONTEXT_ADMIN')) { 16 17 return null; 18 } 19 20 $mod_id = 'dcFilterDuplicate'; 14 21 15 22 $this->addUserAction( 16 /* type */ 17 /* action */ 18 /* ns */ 'dcFilterDuplicate',19 /* desc ription */__('delete all settings')23 /* type */ 'settings', 24 /* action */ 'delete_all', 25 /* ns */ $mod_id, 26 /* desc */ __('delete all settings') 20 27 ); 21 28 22 29 $this->addUserAction( 23 /* type */ 24 /* action */ 25 /* ns */ 'dcFilterDuplicate',26 /* desc ription */__('delete plugin files')30 /* type */ 'plugins', 31 /* action */ 'delete', 32 /* ns */ $mod_id, 33 /* desc */ __('delete plugin files') 27 34 ); 28 35 29 36 $this->addUserAction( 30 /* type */ 31 /* action */ 32 /* ns */ 'dcFilterDuplicate',33 /* desc ription */__('delete the version number')37 /* type */ 'versions', 38 /* action */ 'delete', 39 /* ns */ $mod_id, 40 /* desc */ __('delete the version number') 34 41 ); 35 42 36 43 $this->addDirectAction( 37 /* type */ 38 /* action */ 39 /* ns */ 'dcFilterDuplicate',40 /* desc ription */ sprintf(__('delete all %s settings'),'dcFilterDuplicate')44 /* type */ 'settings', 45 /* action */ 'delete_all', 46 /* ns */ $mod_id, 47 /* desc */ sprintf(__('delete all %s settings'), $mod_id) 41 48 ); 42 49 43 50 $this->addDirectAction( 44 /* type */ 45 /* action */ 46 /* ns */ 'dcFilterDuplicate',47 /* desc ription */ sprintf(__('delete %s version number'),'dcFilterDuplicate')51 /* type */ 'versions', 52 /* action */ 'delete', 53 /* ns */ $mod_id, 54 /* desc */ sprintf(__('delete %s version number'), $mod_id) 48 55 ); 49 56 50 57 $this->addDirectAction( 51 /* type */ 52 /* action */ 53 /* ns */ 'dcFilterDuplicate',54 /* desc ription */ sprintf(__('delete %s plugin files'),'dcFilterDuplicate')58 /* type */ 'plugins', 59 /* action */ 'delete', 60 /* ns */ $mod_id, 61 /* desc */ sprintf(__('delete %s plugin files'), $mod_id) 55 62 ); 56 ?> -
plugins/dcFilterDuplicate/inc/class.filter.duplicate.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_RC_PATH')) {return;}15 if (!defined('DC_RC_PATH')) { 14 16 17 return null; 18 } 19 20 /** 21 * @ingroup DC_PLUGIN_DCFILTERDUPLICATE 22 * @brief Filter duplicate comments on multiblogs. 23 * @since 2.6 24 */ 15 25 class dcFilterDuplicate extends dcSpamFilter 16 26 { 17 27 public $name = 'Duplicate comment filter'; 18 28 public $has_gui = true; 19 29 20 30 protected function setInfo() 21 31 { 32 $this->name = __('Duplicate comment filter'); 22 33 $this->description = __('Same comments on others blogs of a multiblog.'); 23 34 } 24 35 25 public function isSpam($type, $author,$email,$site,$ip,$content,$post_id,&$status)36 public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status) 26 37 { 27 if ($type != 'comment') return null; 28 38 if ($type != 'comment') { 39 40 return null; 41 } 42 29 43 $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 30 if (strlen($content) < $minlen) return null; 31 32 try 33 { 34 if ($this->isDuplicate($content,$ip)) 35 { 36 $this->markDuplicate($content,$ip); 44 if (strlen($content) < $minlen) { 45 46 return null; 47 } 48 49 try { 50 if ($this->isDuplicate($content, $ip)) { 51 $this->markDuplicate($content, $ip); 37 52 $status = 'Duplicate on other blog'; 53 38 54 return true; 39 55 } 40 else 41 { 56 else { 57 42 58 return null; 43 59 } 44 60 } 45 catch (Exception $e) 46 { 61 catch (Exception $e) { 47 62 throw new Exception($e->getMessage()); 48 63 } 49 64 } 50 51 public function isDuplicate($content, $ip)65 66 public function isDuplicate($content, $ip) 52 67 { 53 68 $rs = $this->core->con->select( … … 59 74 "AND C.comment_ip='".$ip."' " 60 75 ); 76 61 77 return !$rs->isEmpty(); 62 78 } 63 79 64 public function markDuplicate($content, $ip)80 public function markDuplicate($content, $ip) 65 81 { 66 82 $cur = $this->core->con->openCursor($this->core->prefix.'comment'); 67 83 $this->core->con->writeLock($this->core->prefix.'comment'); 68 84 69 85 $cur->comment_status = -2; 70 86 $cur->comment_spam_status = 'Duplicate on other blog'; 71 87 $cur->comment_spam_filter = 'dcFilterDuplicate'; 72 88 73 89 $cur->update( 74 90 "WHERE comment_content='".$this->core->con->escape($content)."' ". … … 76 92 ); 77 93 $this->core->con->unlock(); 78 79 $this->triggerOtherBlogs($content, $ip);94 95 $this->triggerOtherBlogs($content, $ip); 80 96 } 81 97 … … 83 99 { 84 100 $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 85 if (isset($_POST['dcfilterduplicate_minlen'])) 86 { 101 if (isset($_POST['dcfilterduplicate_minlen'])) { 87 102 $minlen = abs((integer) $_POST['dcfilterduplicate_minlen']); 88 $this->core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',$minlen,'integer'); 103 $this->core->blog->settings->dcFilterDuplicate->put( 104 'dcfilterduplicate_minlen', 105 $minlen, 106 'integer' 107 ); 89 108 } 90 109 91 110 $res = 92 111 '<form action="'.html::escapeURL($url).'" method="post">'. 93 112 '<p><label class="classic">'.__('Minimum content length before check for duplicate:').'<br />'. 94 form::field(array('dcfilterduplicate_minlen'), 65,255,$minlen).113 form::field(array('dcfilterduplicate_minlen'), 65, 255, $minlen). 95 114 '</label></p>'. 96 '<p><input type="submit" name="save" value="'.__(' save').'" />'.115 '<p><input type="submit" name="save" value="'.__('Save').'" />'. 97 116 $this->core->formNonce().'</p>'. 98 117 '</form>'; 118 99 119 return $res; 100 120 } 101 102 public function triggerOtherBlogs($content, $ip)121 122 public function triggerOtherBlogs($content, $ip) 103 123 { 104 124 $rs = $this->core->con->select( … … 109 129 "AND C.comment_ip='".$ip."' " 110 130 ); 111 112 while ($rs->fetch()) 113 { 114 $b = new dcBlog($this,$rs->blog_id); 131 132 while ($rs->fetch()) { 133 $b = new dcBlog($this, $rs->blog_id); 115 134 $b->triggerBlog(); 116 135 unset($b); … … 118 137 } 119 138 } 120 ?> -
plugins/dcFilterDuplicate/locales/fr/main.lang.php
r1981 r3262 1 1 <?php 2 // Language: français3 // Module: dcFilterDuplicate - 0. 24 // Date: 20 09-12-13 20:05:545 // Translated with dcTranslater - 1.32 // Language: Français 3 // Module: dcFilterDuplicate - 0.5 4 // Date: 2013-11-14 07:24:38 5 // Translated with dcTranslater - 2013.05.11 6 6 7 #inc/class.filter.duplicate.php:22 7 #inc/class.filter.duplicate.php:30 8 $GLOBALS['__l10n']['Duplicate comment filter'] = 'Filtre de doublon de commentaires'; 9 10 #inc/class.filter.duplicate.php:31 8 11 $GLOBALS['__l10n']['Same comments on others blogs of a multiblog.'] = 'Commentaires identiques sur les autres blogs du multiblog.'; 9 12 10 #inc/class.filter.duplicate.php: 9213 #inc/class.filter.duplicate.php:110 11 14 $GLOBALS['__l10n']['Minimum content length before check for duplicate:'] = 'Longueur minimum du contenu pour faire une vérification :'; 12 15 16 $GLOBALS['__l10n']['Antispam for duplicate comments on multiblog'] = 'Antispam contre les doublons de commentaires sur un multiblog'; 17 13 18 ?> -
plugins/dcFilterDuplicate/locales/fr/main.po
r1981 r3262 1 # Language: français2 # Module: dcFilterDuplicate - 0. 23 # Date: 20 09-12-13 20:05:544 # Translated with translater 1.31 # Language: Français 2 # Module: dcFilterDuplicate - 0.5 3 # Date: 2013-11-14 07:24:39 4 # Translated with translater 2013.05.11 5 5 6 6 msgid "" 7 7 msgstr "" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 "Project-Id-Version: dcFilterDuplicate 0. 2\n"9 "Project-Id-Version: dcFilterDuplicate 0.5\n" 10 10 "POT-Creation-Date: \n" 11 "PO-Revision-Date: 20 09-12-13T20:05:54+00:00\n"12 "Last-Translator: J CDenis\n"11 "PO-Revision-Date: 2013-11-14T07:24:39+00:00\n" 12 "Last-Translator: Jean-Christian Denis\n" 13 13 "Language-Team: \n" 14 14 "MIME-Version: 1.0\n" 15 15 "Content-Transfer-Encoding: 8bit\n" 16 16 17 #: inc/class.filter.duplicate.php:22 17 #: inc/class.filter.duplicate.php:30 18 msgid "Duplicate comment filter" 19 msgstr "Filtre de doublon de commentaires" 20 21 #: inc/class.filter.duplicate.php:31 18 22 msgid "Same comments on others blogs of a multiblog." 19 23 msgstr "Commentaires identiques sur les autres blogs du multiblog." 20 24 21 #: inc/class.filter.duplicate.php: 9225 #: inc/class.filter.duplicate.php:110 22 26 msgid "Minimum content length before check for duplicate:" 23 27 msgstr "Longueur minimum du contenu pour faire une vérification :" 24 28 29 msgid "Antispam for duplicate comments on multiblog" 30 msgstr "Antispam contre les doublons de commentaires sur un multiblog" 31
Note: See TracChangeset
for help on using the changeset viewer.