Skip to content

Commit 099483a

Browse files
added log file for user registrations (for analyzing spammers)
1 parent 9fa67fe commit 099483a

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# config contains passwords ...
22
bb-config.php
33

4+
# logging for spam observations ...
5+
registrations.log
6+
47
# OS X folders
58
.DS_Store
69

my-plugins/stop-forum-spam.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
add_action( 'bb_init', 'registration_validation',12); // registration
1313

1414
$general_questions = array();
15-
$general_questions[] = array("If you increment the number 255, what's the result?", "256");
16-
$general_questions[] = array("If you decrement the number 129, what's the result?", "128");
15+
$general_questions[] = array("If you increment the number 17, what's the result?", "18");
16+
$general_questions[] = array("If you decrement the number 25, what's the result?", "24");
1717
$general_questions[] = array("Take the square root of nine and add the number of hands attached to a typical human body. What's the result? (Enter the digit)", "5");
1818
$general_questions[] = array("Which mobile operating system has currently the biggest market share? (Hint: the one from Google)", "Android");
1919
$general_questions[] = array("What was the favorite fruit of Steve Jobs? (Singular)", "Apple");
@@ -51,6 +51,16 @@ function registration_validation()
5151
$is_spammer_by_ip = is_spammer('ip', $_SERVER['REMOTE_ADDR']);
5252
$is_spammer_by_location = strcasecmp(trim($_POST['from']), 'shenzhen') == 0;
5353

54+
// log registration attempts
55+
$file = fopen("registrations.log", "a");
56+
fwrite($file, "\n\n***** Registration Attempt *****");
57+
fwrite($file, "\nUser_IP => " . $_SERVER['REMOTE_ADDR']);
58+
foreach ($_POST as $key => $value)
59+
{
60+
if (!empty($value))
61+
fwrite($file, "\n" . $key . " => " . $value);
62+
}
63+
5464
if (!is_correct_answer($_POST["question_id"], $_POST["human_test_answer"]) || $is_spammer_by_ip || $is_spammer_by_location
5565
// || is_spammer('ip',$_SERVER['REMOTE_ADDR'])
5666
// || is_spammer('username',$_POST["user_login"])
@@ -69,13 +79,24 @@ function registration_validation()
6979
{
7080
echo "<p>Your IP address was listed as being malicious by " .
7181
"<a href='http://www.stopforumspam.com/'>stopforumspam.com</a>. ".
72-
"<br/>Just send me a quick mail (to daniel AT my company's domain) ".
73-
"if this is happening unjustifiably.</p>";
82+
"<br/>Just send me a quick mail (to daniel AT my company's domain) ".
83+
"if this is happening unjustifiably.</p>";
7484
}
7585

7686
bb_get_footer();
87+
88+
// close file
89+
fwrite($file, "\n=> Rejected, probably spam!");
90+
fclose($file);
91+
7792
exit;
7893
}
94+
else
95+
{
96+
// close file
97+
fwrite($file, "\n=> Accepted.");
98+
fclose($file);
99+
}
79100
}
80101
}
81102

0 commit comments

Comments
 (0)