From 259acbf9663f1d7af461e45d23c72cc21a588144 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 8 Mar 2012 07:46:50 -0600 Subject: [PATCH] script to retest a user's notices --- scripts/testuser.php | 95 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 scripts/testuser.php diff --git a/scripts/testuser.php b/scripts/testuser.php new file mode 100644 index 0000000000..8e70a5985f --- /dev/null +++ b/scripts/testuser.php @@ -0,0 +1,95 @@ +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../../..')); + +$shortoptions = 'i:n:a'; +$longoptions = array('id=', 'nickname=', 'all'); + +$helptext = <<orderBy('created'); + $user->limit($offset, $limit); + + $found = $user->find(); + + if ($found) { + while ($user->fetch()) { + testUser($filter, $user); + } + $offset += $found; + } + + } while ($found > 0); +} + +function testUser($filter, $user) { + + $profile = $user->getProfile(); + + $str = new ProfileNoticeStream($profile, $profile); + + $offset = 0; + $limit = 100; + + do { + $notice = $str->getNotices($offset, $limit); + while ($notice->fetch()) { + print "Testing notice " . $notice->id . "..."; + $result = $filter->test($notice); + Spam_score::save($notice, $result); + print (($result->isSpam) ? "SPAM" : "HAM")."\n"; + } + $offset += $notice->N; + } while ($notice->N > 0); +} + +try { + $filter = null; + Event::handle('GetSpamFilter', array(&$filter)); + if (empty($filter)) { + throw new Exception(_("No spam filter.")); + } + if (get_option('a', 'all')) { + testAllUsers($filter); + } else { + $user = getUser(); + testUser($filter, $user); + } +} catch (Exception $e) { + print $e->getMessage()."\n"; + exit(1); +} -- 2.39.5