コード例 #1
0
 function wfSpamBlacklistLoader(&$title, $text, $section)
 {
     require_once "SpamBlacklist_body.php";
     static $spamObj = false;
     global $wgSpamBlacklistFiles, $wgSpamBlacklistSettings, $wgPreSpamFilterCallback;
     if ($spamObj === false) {
         $spamObj = new SpamBlacklist($wgSpamBlacklistSettings);
         if ($wgSpamBlacklistFiles) {
             $spamObj->files = $wgSpamBlacklistFiles;
             $spamObj->previousFilter = $wgPreSpamFilterCallback;
         }
     }
     return $spamObj->filter($title, $text, $section);
 }
コード例 #2
0
ファイル: SpamBlacklist.php プロジェクト: ErdemA/wikihow
 function wfValidateSpamblacklist(&$article, &$user, &$text)
 {
     require_once "SpamBlacklist_body.php";
     global $wgSpamBlacklistFiles, $wgDBname, $wgOut, $wgValidateErrorOffset;
     $t = $article->getTitle();
     foreach ($wgSpamBlacklistFiles as $fileName) {
         if (preg_match('/^DB: (\\w*) (.*)$/', $fileName, $matches)) {
             if ($wgDBname == $matches[1] && $t && $t->getPrefixedDBkey() == $matches[2]) {
                 $lines = split("\n", $text);
                 $regexes = SpamBlacklist::buildRegexes($lines);
                 foreach ($regexes as $regex) {
                     if (preg_match($regex, "adfasdfasdfasdf") === false) {
                         $wgOut->errorPage('invalidspamexpression_title', 'invalidspamexpression');
                         return false;
                     }
                 }
             }
         }
     }
     //check the white list
     if ($t->getPrefixedDBKey() == 'MediaWiki:Spam-whitelist') {
         $lines = split("\n", $text);
         $regexes = SpamBlacklist::buildRegexes($lines);
         foreach ($regexes as $regex) {
             if (preg_match($regex, "adfasdfasdfasdf") === false) {
                 $wgOut->errorPage('invalidspamexpression_title', 'invalidspamexpression');
                 return false;
             }
         }
     }
     return true;
 }
コード例 #3
0
        }
        foreach ($wgPostCommitUpdateList as $update) {
            $update->doUpdate();
        }
        $wgDeferredUpdateList = array();
        $wgPostCommitUpdateList = array();
    }
}
//------------------------------------------------------------------------------
$wgUser = User::newFromName('Spam cleanup script');
if (isset($options['n'])) {
    $dryRun = true;
} else {
    $dryRun = false;
}
$sb = new SpamBlacklist($wgSpamBlacklistSettings);
if ($wgSpamBlacklistFiles) {
    $sb->files = $wgSpamBlacklistFiles;
}
$regex = $sb->getRegex();
if (!$regex) {
    print "Invalid regex, can't clean up spam\n";
    exit(1);
}
$dbr =& wfGetDB(DB_SLAVE);
$maxID = $dbr->selectField('page', 'MAX(page_id)');
$reportingInterval = 100;
print "Regex is " . strlen($regex) . " bytes\n";
if (strlen($regex) < 10000 || strlen($regex) > 32000) {
    print "wrong size, exiting\n";
    exit(1);
コード例 #4
0
ファイル: cleanup.php プロジェクト: Tarendai/spring-website
$username = '******';
$wgUser = User::newFromName($username);
if ($wgUser->idForName() == 0) {
    // Create the user
    $status = $wgUser->addToDatabase();
    if ($status === null || $status->isOK()) {
        $dbw = wfGetDB(DB_MASTER);
        $dbw->update('user', array('user_password' => 'nologin'), array('user_name' => $username), $username);
    }
}
if (isset($options['n'])) {
    $dryRun = true;
} else {
    $dryRun = false;
}
$sb = new SpamBlacklist($wgSpamBlacklistSettings);
if ($wgSpamBlacklistFiles) {
    $sb->files = $wgSpamBlacklistFiles;
}
$regexes = $sb->getBlacklists();
if (!$regexes) {
    print "Invalid regex, can't clean up spam\n";
    exit(1);
}
$dbr = wfGetDB(DB_SLAVE);
$maxID = $dbr->selectField('page', 'MAX(page_id)');
$reportingInterval = 100;
print "Regexes are " . implode(', ', array_map('count', $regexes)) . " bytes\n";
print "Searching for spam in {$maxID} pages...\n";
if ($dryRun) {
    print "Dry run only\n";