My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class SpamCheck_Links extends SpamCheck_Abstract{

protected $max_links=2;

protected $power=2;

protected $field='content';

public function set_max_links($count)
{
$this->max_links=$count;
return $this;
}
public function set_link_penalty($power)
{
$this->power=$power;
return $this;
}
public function set_field($field)
{
$this->field=$field;
return $this;
}

/*
* Check the comment for being spam
*/
public function check(){
$content=strtolower($this->spamcheck->get_field($this->field));

//Algorithm from Geert_DD
$count = substr_count($content, 'http://');
$count = $count+substr_count($content, 'https://');

return ($count < $this->max_links) ? 100 : -1*((int) pow($count, $this->power));

}
}
Show details Hide details

Change log

r93 by maartenvanvliet on Jul 09, 2008   Diff
added threshold for is_spam, set_field for
links check
Go to: 
Project members, sign in to write a code review

Older revisions

r90 by maartenvanvliet on Jun 26, 2008   Diff
Link checker complete
r89 by maartenvanvliet on Jun 26, 2008   Diff
added empty links checker, changed
algorithm
All revisions of this file

File info

Size: 759 bytes, 39 lines
Hosted by Google Code