- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/antispam/inc/class.dc.spamfilters.php
r1179 r2566 17 17 private $filters_opt = array(); 18 18 private $core; 19 19 20 20 public function __construct($core) 21 21 { 22 22 $this->core =& $core; 23 23 } 24 24 25 25 public function init($filters) 26 26 { … … 30 30 continue; 31 31 } 32 32 33 33 $r = new ReflectionClass($f); 34 34 $p = $r->getParentClass(); 35 35 36 36 if (!$p || $p->name != 'dcSpamFilter') { 37 37 continue; 38 38 } 39 39 40 40 $this->filters[$f] = new $f($this->core); 41 41 } 42 42 43 43 $this->setFilterOpts(); 44 44 if (!empty($this->filters_opt)) { … … 46 46 } 47 47 } 48 48 49 49 public function getFilters() 50 50 { 51 51 return $this->filters; 52 52 } 53 53 54 54 public function isSpam($cur) 55 55 { … … 59 59 continue; 60 60 } 61 61 62 62 $type = $cur->comment_trackback ? 'trackback' : 'comment'; 63 63 $author = $cur->comment_author; … … 67 67 $content = $cur->comment_content; 68 68 $post_id = $cur->post_id; 69 69 70 70 $is_spam = $f->isSpam($type,$author,$email,$site,$ip,$content,$post_id,$status); 71 71 72 72 if ($is_spam === true) { 73 73 if ($f->auto_delete) { … … 83 83 } 84 84 } 85 85 86 86 return false; 87 87 } 88 88 89 89 public function trainFilters($rs,$status,$filter_name) 90 90 { … … 94 94 continue; 95 95 } 96 96 97 97 $type = $rs->comment_trackback ? 'trackback' : 'comment'; 98 98 $author = $rs->comment_author; … … 101 101 $ip = $rs->comment_ip; 102 102 $content = $rs->comment_content; 103 103 104 104 $f->trainFilter($status,$filter_name,$type,$author,$email,$site,$ip,$content,$rs); 105 105 } 106 106 } 107 107 108 108 public function statusMessage($rs,$filter_name) 109 109 { 110 110 $f = isset($this->filters[$filter_name]) ? $this->filters[$filter_name] : null; 111 111 112 112 if ($f === null) 113 113 { … … 117 117 { 118 118 $status = $rs->exists('comment_spam_status') ? $rs->comment_spam_status : null; 119 119 120 120 return $f->getStatusMessage($status,$rs->comment_id); 121 121 } 122 122 } 123 123 124 124 public function saveFilterOpts($opts,$global=false) 125 125 { … … 130 130 $this->core->blog->settings->antispam->put('antispam_filters',serialize($opts),'string','Antispam Filters',true,$global); 131 131 } 132 132 133 133 private function setFilterOpts() 134 134 { … … 136 136 $this->filters_opt = @unserialize($this->core->blog->settings->antispam->antispam_filters); 137 137 } 138 138 139 139 # Create default options if needed 140 140 if (!is_array($this->filters_opt)) { … … 142 142 $this->filters_opt = array(); 143 143 } 144 144 145 145 foreach ($this->filters_opt as $k => $o) 146 146 { 147 if (isset($this->filters[$k]) && is_array($o)) { 147 if (isset($this->filters[$k]) && is_array($o)) { 148 148 $this->filters[$k]->active = isset($o[0])?$o[0]:false; 149 149 $this->filters[$k]->order = isset($o[1])?$o[1]:0; … … 152 152 } 153 153 } 154 154 155 155 private function orderCallBack($a,$b) 156 156 { … … 158 158 return 0; 159 159 } 160 160 161 161 return $a->order > $b->order ? 1 : -1; 162 162 } 163 163 } 164 ?>
Note: See TracChangeset
for help on using the changeset viewer.