function doSubmit() { global $wgOut, $wgUser, $wgMemc; /* empty name */ if (strlen($this->mBlockedPhrase) == 0) { $this->showForm(wfMsgHtml('spamregex-warning-1')); return; } /* validate expression */ if (!($simple_regex = wfValidRegex($this->mBlockedPhrase))) { $this->showForm(wfMsgHtml('spamregex-error-1')); 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 == 0 && $this->mBlockedSummary == 0) { $this->showForm(wfMsgHtml('spamregex-warning-2')); return; } $query = "INSERT IGNORE INTO " . wfSpamRegexGetTable() . " (spam_id, spam_text, spam_timestamp, spam_user, spam_textbox, spam_summary)\n\t\t\t VALUES (null,\n\t\t\t \t {$dbw->addQuotes($this->mBlockedPhrase)},\n\t\t\t\t {$timestamp},\n\t\t\t\t {$dbw->addQuotes($name)},\n\t\t\t\t {$this->mBlockedTextbox},\n\t\t\t\t {$this->mBlockedSummary}\n\t\t\t\t )"; $dbw->query($query); /* duplicate entry */ if (!$dbw->affectedRows()) { $this->showForm(wfMsgHtml('spamregex-already-blocked', $this->mBlockedPhrase)); return; } wfSpamRegexUnsetKeys($name); /* redirect */ $titleObj = Title::makeTitle(NS_SPECIAL, 'Spamregex'); $wgOut->redirect($titleObj->getFullURL('action=success_block&text=' . urlencode($this->mBlockedPhrase) . "&" . wfSpamRegexGetListBits())); }
function doSubmit() { global $wgOut, $wgUser, $wgMemc; /* empty name */ if (strlen($this->mRegexBlockedAddress) == 0) { $this->showForm(wfMsg('regexblock-form-submit-empty')); return; } /* castrate regexes */ if (!($simple_regex = wfValidRegex($this->mRegexBlockedAddress))) { /* now, very generic comment - should the conditions change, this should too */ $this->showForm(wfMsg('regexblock-form-submit-regex')); return; } /* check expiry */ if (strlen($this->mRegexBlockedExpire) == 0) { $this->showForm(wfMsg('regexblock-form-submit-expiry')); return; } /* TODO - check infinite */ if ($this->mRegexBlockedExpire != 'infinite') { $expiry = strtotime($this->mRegexBlockedExpire); if ($expiry < 0 || $expiry === false) { $this->showForm(wfMsg('ipb_expiry_invalid')); return; } $expiry = wfTimestamp(TS_MW, $expiry); } else { $expiry = $this->mRegexBlockedExpire; } /* make insert */ $dbw =& wfGetDB(DB_MASTER); $name = $wgUser->getName(); $timestamp = wfTimestampNow(); $query = "INSERT IGNORE INTO " . wfRegexBlockGetTable() . "\n\t\t\t (blckby_id, blckby_name, blckby_blocker, blckby_timestamp, blckby_expire, blckby_exact, blckby_create, blckby_reason)\n\t\t\t VALUES (null,\n\t\t\t\t {$dbw->addQuotes($this->mRegexBlockedAddress)},\n\t\t\t\t {$dbw->addQuotes($name)},\n\t\t\t\t '{$timestamp}',\n\t\t\t\t '{$expiry}',\n\t\t\t\t {$this->mRegexBlockedExact},\n\t\t\t\t {$this->mRegexBlockedCreation},\n\t\t\t\t {$dbw->addQuotes($this->mRegexBlockedReason)}\n\t\t\t\t )"; $dbw->query($query); /* duplicate entry */ if (!$dbw->affectedRows()) { $this->showForm(wfMsg('regexblock-already-blocked', $this->mRegexBlockedAddress)); return; } wfRegexBlockUnsetKeys($name, $this->mRegexBlockedAddress); /* redirect */ $titleObj = Title::makeTitle(NS_SPECIAL, 'Regexblock'); $wgOut->redirect($titleObj->getFullURL('action=success_block&ip=' . urlencode($this->mRegexBlockedAddress) . "&" . wfGetListBits())); }