function wfRegexBlockClearExpired($username, $blocker) { $dbw =& wfGetDB(DB_MASTER); $query = "DELETE FROM " . wfRegexBlockGetTable() . " WHERE blckby_name = " . $dbw->addQuotes($username); $dbw->query($query); if ($dbw->affectedRows()) { /* success, remember to delete cache key */ wfRegexBlockUnsetKeys($blocker, $username); return true; } return false; }
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())); }