From: Evan Prodromou Date: Thu, 8 Mar 2012 13:46:50 +0000 (-0600) Subject: script to retest a user's notices X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=259acbf9663f1d7af461e45d23c72cc21a588144;p=quix0rs-gnu-social.git script to retest a user's notices --- 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); +}