-a --all All users
END_OF_SILENCESPAMMER_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
function testAllUsers($filter, $minimum, $percent) {
$found = false;
printfnq("Testing user %s\n", $user->nickname);
- $profile = Profile::staticGet('id', $user->id);
+ $profile = Profile::getKV('id', $user->id);
+ if ($profile->isSilenced()) {
+ printfnq("Already silenced %s\n", $user->nickname);
+ return;
+ }
+
$cnt = $profile->noticeCount();
if ($cnt < $minimum) {
printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
- }
+ return;
+ }
$ss = new Spam_score();
$ss->query(sprintf("SELECT count(*) as spam_count ".
"FROM notice join spam_score on notice.id = spam_score.notice_id ".
- "WHERE notice.profile_id = %d", $profile->id));
+ "WHERE notice.profile_id = %d AND spam_score.is_spam = 1", $profile->id));
while ($ss->fetch()) {
$spam_count = $ss->spam_count;
}
- $spam_percent = ($spam_count * 100 / $cnt);
+ $spam_percent = ($spam_count * 100.0 / $cnt);
if ($spam_percent > $percent) {
- printfnq("Silencing user %d (%0.2f%% spam)\n", $user->nickname, $spam_percent);
+ printfnq("Silencing user %s (%d/%d = %0.2f%% spam)\n", $user->nickname, $spam_count, $cnt, $spam_percent);
try {
$profile->silence();
} catch(Exception $e) {