Changeset 2305
- Timestamp:
- 06/06/10 01:00:49 (13 years ago)
- Location:
- plugins/dcFilterDuplicate
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcFilterDuplicate/_define.php
r1981 r2305 3 3 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # … … 17 17 /* Description*/ "Antispam for duplicate comments on multiblog", 18 18 /* Author */ "JC Denis", 19 /* Version */ '0. 2',19 /* Version */ '0.3', 20 20 /* Permissions */ 'admin', 21 21 /* Priority */ 200 22 22 ); 23 /* date */ #20 09121323 /* date */ #20100605 24 24 ?> -
plugins/dcFilterDuplicate/_install.php
r1981 r2305 3 3 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # … … 16 16 $new_version = $core->plugins->moduleInfo('dcFilterDuplicate','version'); 17 17 $old_version = $core->getVersion('dcFilterDuplicate'); 18 18 19 # Compare versions 19 20 if (version_compare($old_version,$new_version,'>=')) {return;} 21 20 22 # Install or update 21 try { 22 # Check DC version (dev on) 23 if (!version_compare(DC_VERSION,'2.1.5','>=')) { 24 throw new Exception('Plugin called dcFilterDuplicate requires Dotclear 2.1.5 or higher.'); 23 try 24 { 25 # Check version 26 if (version_compare(DC_VERSION,'2.2-beta','<')) 27 { 28 throw new Exception('dcFilterDuplicate requires Dotclear 2.2'); 25 29 } 26 # Check DC version (new settings) 27 if (version_compare(DC_VERSION,'2.2','>=')) { 28 throw new Exception('Plugin called dcFilterDuplicate requires Dotclear up to 2.2.'); 29 } 30 30 31 # Settings 31 $s = null; 32 $s =& $core->blog->settings; 33 $s->setNameSpace('dcFilterDuplicate'); 34 $s->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true); 35 $s->setNameSpace('system'); 32 $core->blog->settings->addNamespace('dcFilterDuplicate'); 33 $core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true); 34 36 35 # Version 37 36 $core->setVersion('dcFilterDuplicate',$new_version); 38 # All right baby 37 39 38 return true; 40 39 } 41 catch (Exception $e) { 40 catch (Exception $e) 41 { 42 42 $core->error->add($e->getMessage()); 43 43 return false; -
plugins/dcFilterDuplicate/_prepend.php
r1560 r2305 3 3 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # -
plugins/dcFilterDuplicate/_uninstall.php
r1981 r2305 3 3 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # -
plugins/dcFilterDuplicate/inc/class.filter.duplicate.php
r1981 r2305 3 3 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # … … 17 17 public $name = 'Duplicate comment filter'; 18 18 public $has_gui = true; 19 19 20 20 protected function setInfo() 21 21 { 22 22 $this->description = __('Same comments on others blogs of a multiblog.'); 23 23 } 24 24 25 25 public function isSpam($type,$author,$email,$site,$ip,$content,$post_id,&$status) 26 26 { 27 27 if ($type != 'comment') return null; 28 29 $minlen = abs((integer) $this->core->blog->settings->dcfilterduplicate_minlen); 28 29 $this->core->blog->settings->addNamespace('dcFilterDuplicate'); 30 $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 30 31 if (strlen($content) < $minlen) return null; 31 32 32 33 try 33 34 { … … 43 44 } 44 45 } 45 catch (Exception $e) { throw new Exception($e->getMessage()); } 46 catch (Exception $e) 47 { 48 throw new Exception($e->getMessage()); 49 } 46 50 } 47 51 48 52 public function isDuplicate($content,$ip) 49 53 { … … 58 62 return !$rs->isEmpty(); 59 63 } 60 64 61 65 public function markDuplicate($content,$ip) 62 66 { 63 67 $cur = $this->core->con->openCursor($this->core->prefix.'comment'); 64 68 $this->core->con->writeLock($this->core->prefix.'comment'); 65 69 66 70 $cur->comment_status = -2; 67 71 $cur->comment_spam_status = 'Duplicate on other blog'; 68 72 $cur->comment_spam_filter = 'dcFilterDuplicate'; 69 73 70 74 $cur->update( 71 75 "WHERE comment_content='".$this->core->con->escape($content)."' ". … … 73 77 ); 74 78 $this->core->con->unlock(); 75 79 76 80 $this->triggerOtherBlogs($content,$ip); 77 81 } … … 79 83 public function gui($url) 80 84 { 81 $minlen = abs((integer) $this->core->blog->settings->dcfilterduplicate_minlen); 85 $this->blog->settings->addNamespace('dcFilterDuplicate'); 86 $minlen = abs((integer) $this->core->blog->settings->dcFilterDuplicate->dcfilterduplicate_minlen); 82 87 if (isset($_POST['dcfilterduplicate_minlen'])) 83 88 { 84 89 $minlen = abs((integer) $_POST['dcfilterduplicate_minlen']); 85 $this->core->blog->settings->setNameSpace('dcFilterDuplicate'); 86 $this->core->blog->settings->put('dcfilterduplicate_minlen',$minlen,'integer'); 87 $this->core->blog->settings->setNameSpace('system'); 90 $this->core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',$minlen,'integer'); 88 91 } 89 92 90 93 $res = 91 94 '<form action="'.html::escapeURL($url).'" method="post">'. … … 98 101 return $res; 99 102 } 100 103 101 104 public function triggerOtherBlogs($content,$ip) 102 105 { … … 108 111 "AND C.comment_ip='".$ip."' " 109 112 ); 110 113 111 114 while ($rs->fetch()) 112 115 { -
plugins/dcFilterDuplicate/release.txt
r1981 r2305 1 0.3 20100605 2 * Switched to DC 2.2 3 1 4 0.2 20091213 2 5 * Fixed trigger blogs
Note: See TracChangeset
for help on using the changeset viewer.