spambot-detector-v2
Code (php)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
#########
##testspambot.php
#########
function checkSpambots($mail,$ip,$name){
$spambot = false;
//put the main domains in the array
$main_domains = array('mail.ru','bigmir.net');
//check the e-mail adress
$xml_string = file_get_contents('http://www.stopforumspam.com/api?email='.$mail);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spambot = true;
}elseif($spambot != true){
//e-mail not found in the database, now check the ip
$xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spambot = true;
}
}
//check the main domains if there is still no spammer found, you can add more if you want in the $main_domains array
if($spambot != true){
for($i = 0; $i < count($main_domains); $i++){
if(ereg($main_domains[$i],$mail) == 1){
$spambot = true;
}
}
}
// create an .txt file with the info of the spambot, if this one already exists, increase its amount of try's
if($spambot == true){
if(file_exists('spambots/'.$mail.'.txt')){
$spambot_old_info = file_get_contents('spambots/'.$mail.'.txt');
$spambot_old_info = explode(',',$spambot_old_info);
$spambot_old_info[2] = $spambot_old_info[2]+1;
$spambot_old_info = implode(',',$spambot_old_info);
file_put_contents('spambots/'.$mail.'.txt',$spambot_old_info);
}else{
$spambot_info = $ip.','.$name.',1';
file_put_contents('spambots/'.$mail.'.txt',$spambot_info);
}
}
return $spambot;
}
if($_POST['submit']){
$spambot = checkSpambots($_POST['email'],$_SERVER['REMOTE_ADDR'],$_POST['name']);
if($spambot == true){
echo "Je bent een spambot!";
}else{
echo "Je kunt gewoon doorgaan met registreren, je bent geen spambot";
}
}
?>
<form method='post'>
Name: <input type='text' name='name'><br>
E-mail: <input type='text' name='email'><br>
<input type='submit' name='submit' value='check'>
</form>
<a href='spambots_uitlezen.php'>View Spambots</a>
#########
##testspambot.php
#########
function checkSpambots($mail,$ip,$name){
$spambot = false;
//put the main domains in the array
$main_domains = array('mail.ru','bigmir.net');
//check the e-mail adress
$xml_string = file_get_contents('http://www.stopforumspam.com/api?email='.$mail);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spambot = true;
}elseif($spambot != true){
//e-mail not found in the database, now check the ip
$xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spambot = true;
}
}
//check the main domains if there is still no spammer found, you can add more if you want in the $main_domains array
if($spambot != true){
for($i = 0; $i < count($main_domains); $i++){
if(ereg($main_domains[$i],$mail) == 1){
$spambot = true;
}
}
}
// create an .txt file with the info of the spambot, if this one already exists, increase its amount of try's
if($spambot == true){
if(file_exists('spambots/'.$mail.'.txt')){
$spambot_old_info = file_get_contents('spambots/'.$mail.'.txt');
$spambot_old_info = explode(',',$spambot_old_info);
$spambot_old_info[2] = $spambot_old_info[2]+1;
$spambot_old_info = implode(',',$spambot_old_info);
file_put_contents('spambots/'.$mail.'.txt',$spambot_old_info);
}else{
$spambot_info = $ip.','.$name.',1';
file_put_contents('spambots/'.$mail.'.txt',$spambot_info);
}
}
return $spambot;
}
if($_POST['submit']){
$spambot = checkSpambots($_POST['email'],$_SERVER['REMOTE_ADDR'],$_POST['name']);
if($spambot == true){
echo "Je bent een spambot!";
}else{
echo "Je kunt gewoon doorgaan met registreren, je bent geen spambot";
}
}
?>
<form method='post'>
Name: <input type='text' name='name'><br>
E-mail: <input type='text' name='email'><br>
<input type='submit' name='submit' value='check'>
</form>
<a href='spambots_uitlezen.php'>View Spambots</a>
en het uitlezen van de bestanden:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
#######
##spambots_uitlezen.php
#######
$spambots = scandir('spambots');
echo "<table border=1 style='border: 1px dotted #2a2a2a; padding: 2px; border-collapse: collapse;'>";
echo "<tr> <td><b>Name</b></td><td><b>E-mail Adress</b></td><td><b>Ip-Adress</b></td><td><b>Amount of trys</b></td></tr>";
foreach($spambots as $value){
if($value != '.' && $value != '..'){
$spambot_info = file_get_contents('spambots/'.$value);
$spambot_array = explode(',',$spambot_info);
$mail = substr($value, 0, -4);
echo "<tr><td>".$spambot_array[1]."</td><td>".$mail."</td><td>".$spambot_array[0]."</td><td>".$spambot_array[2]."</td></tr>";
}
}
echo "</table>";
?>
<a href='testspambot.php'>The Spambot Detector</a>
#######
##spambots_uitlezen.php
#######
$spambots = scandir('spambots');
echo "<table border=1 style='border: 1px dotted #2a2a2a; padding: 2px; border-collapse: collapse;'>";
echo "<tr> <td><b>Name</b></td><td><b>E-mail Adress</b></td><td><b>Ip-Adress</b></td><td><b>Amount of trys</b></td></tr>";
foreach($spambots as $value){
if($value != '.' && $value != '..'){
$spambot_info = file_get_contents('spambots/'.$value);
$spambot_array = explode(',',$spambot_info);
$mail = substr($value, 0, -4);
echo "<tr><td>".$spambot_array[1]."</td><td>".$mail."</td><td>".$spambot_array[0]."</td><td>".$spambot_array[2]."</td></tr>";
}
}
echo "</table>";
?>
<a href='testspambot.php'>The Spambot Detector</a>