. */ 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()) { try { testUser($filter, $user); } catch (Exception $e) { printfnq("ERROR testing user %s\n: %s", $user->nickname, $e->getMessage()); } } $offset += $found; } } while ($found > 0); } function testUser($filter, $user) { printfnq("Testing user %s\n", $user->nickname); $profile = Profile::getKV('id', $user->id); $str = new ProfileNoticeStream($profile, $profile); $offset = 0; $limit = 100; do { $notice = $str->getNotices($offset, $limit); while ($notice->fetch()) { try { printfv("Testing notice %d...", $notice->id); $result = $filter->test($notice); Spam_score::save($notice, $result); printfv("%s\n", ($result->isSpam) ? "SPAM" : "HAM"); } catch (Exception $e) { printfnq("ERROR testing notice %d: %s\n", $notice->id, $e->getMessage()); } } $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 (have_option('a', 'all')) { testAllUsers($filter); } else { $user = getUser(); testUser($filter, $user); } } catch (Exception $e) { print $e->getMessage()."\n"; exit(1); }