function wfSpamRegexSpecial($par) { global $wgOut, $wgUser, $wgRequest; $wgOut->setPageTitle(wfMsgHtml('spamregex-page-title')); $sRF = new spamRegexForm($par); $sRL = new spamRegexList($par); $action = $wgRequest->getVal('action'); if ('success_block' == $action) { $sRF->showSuccess(); $sRF->showForm(''); } else { if ('success_unblock' == $action) { $sRL->showSuccess(); $sRF->showForm(''); } else { if ('failure_unblock' == $action) { $text = htmlspecialchars($wgRequest->getVal('text')); $sRF->showForm("Error unblocking \"{$text}\". Probably there is no such pattern."); } else { if ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) { $sRF->doSubmit(); } else { if ('delete' == $action) { $sRL->deleteFromList(); } else { $sRF->showForm(''); } } } } } $sRL->showList('', $offset); }
function doSubmit() { wfProfileIn(__METHOD__); global $wgOut, $wgUser; /* empty name */ if (strlen($this->mBlockedPhrase) == 0) { $this->showForm(wfMsgHtml('spamregex-warning-1')); wfProfileOut(__METHOD__); return; } /* validate expression */ if (!($simple_regex = spamRegexList::validateRegex($this->mBlockedPhrase))) { $this->showForm(wfMsgHtml('spamregex-error-1')); wfProfileOut(__METHOD__); return; } /* make insert */ $dbw = wfGetDB(DB_MASTER); $name = $wgUser->getName(); $timestamp = wfTimestampNow(); /* we need at least one block mode specified... we can have them both, of course */ if (!$this->mBlockedTextbox && !$this->mBlockedSummary) { $this->showForm(wfMsgHtml('spamregex-warning-2')); wfProfileOut(__METHOD__); return; } $dbw->insert('spam_regex', array('spam_text' => $this->mBlockedPhrase, 'spam_timestamp' => $timestamp, 'spam_user' => $name, 'spam_textbox' => $this->mBlockedTextbox, 'spam_summary' => $this->mBlockedSummary), __METHOD__, array('IGNORE')); /* duplicate entry */ if (!$dbw->affectedRows()) { $this->showForm(wfMsgHtml('spamregex-already-blocked', $this->mBlockedPhrase)); wfProfileOut(__METHOD__); return; } spamRegexList::unsetKeys(); /* redirect */ $titleObj = SpecialPage::getTitleFor('SpamRegex'); wfProfileOut(__METHOD__); $wgOut->redirect($titleObj->getFullURL('action=success_block&text=' . urlencode($this->mBlockedPhrase) . '&' . spamRegexList::getListBits())); }