function wfRegexBlockCheck($current_user)
{
    global $wgMemc, $wgSharedDB;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return;
    }
    $ip_to_check = wfGetIP();
    $key = "{$wgSharedDB}:regexBlockCore:blockers";
    $cached = $wgMemc->get($key);
    if (!is_array($cached)) {
        /* get from database */
        $blockers_array = array();
        $dbr =& wfGetDB(DB_SLAVE);
        $query = "SELECT blckby_blocker FROM " . wfRegexBlockGetTable() . " GROUP BY blckby_blocker";
        $res = $dbr->query($query);
        while ($row = $dbr->fetchObject($res)) {
            wfGetRegexBlocked($row->blckby_blocker, $current_user, $ip_to_check);
            array_push($blockers_array, $row->blckby_blocker);
        }
        $dbr->freeResult($res);
        $wgMemc->set($key, $blockers_array, REGEXBLOCK_EXPIRE);
    } else {
        /* get from cache */
        foreach ($cached as $blocker) {
            wfGetRegexBlocked($blocker, $current_user, $ip_to_check);
        }
    }
    return true;
}
function wfGetSummarySpamRegex($editpage)
{
    global $wgOut;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return true;
    }
    $matches = array();
    /* here we get only the phrases for blocking in summaries... */
    $phrases = wfFetchSpamRegexData(SPAMREGEX_SUMMARY);
    "" != $phrases ? $m_phrases = "/" . $phrases . "/i" : ($m_phrases = false);
    if ($m_phrases && $editpage->summary != '' && preg_match($m_phrases, $editpage->summary, $matches)) {
        /*	...so let's rock with our custom spamPage to indicate that
        			(since some phrases can be safely in the text and not in a summary
        			and we do not want to confuse the good users, right?)
        		*/
        $wgOut->setPageTitle(wfMsg('spamprotectiontitle'));
        $wgOut->setRobotPolicy('noindex,nofollow');
        $wgOut->setArticleRelated(false);
        $wgOut->addWikiText(wfMsg('spamprotectiontext'));
        if ($matches[0]) {
            $wgOut->addWikiText(wfMsg('spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>"));
        }
        $wgOut->addWikiText(wfMsg('spamregex_summary'));
        $wgOut->returnToMain(false);
        return false;
    }
    return true;
}
function wfSpamRegexSetup()
{
    global $IP, $wgMessageCache;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return;
    }
    require_once $IP . '/includes/SpecialPage.php';
    wfLoadExtensionMessages('Spamregex');
    SpecialPage::addPage(new SpecialPage('Spamregex', 'spamregex', true, 'wfSpamRegexSpecial', false));
}
function wfRegexBlockSetup()
{
    global $IP;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return;
    }
    require_once $IP . '/includes/SpecialPage.php';
    SpecialPage::addPage(new SpecialPage('Regexblock', 'regexblock', true, 'wfRegexBlockSpecial', false));
    wfLoadExtensionMessages('RegexBlock');
}
function wfRegexBlockStatsPageSetup()
{
    global $IP;
    if (!wfSimplifiedRegexCheckSharedDB()) {
        return;
    }
    require_once $IP . '/includes/SpecialPage.php';
    /* name, restrictions, */
    SpecialPage::addPage(new SpecialPage('Regexblockstats', 'regexblock', false, 'wfRegexBlockStatsCore', false));
}