예제 #1
0
 private function doSubmit()
 {
     global $wgOut, $wgUser;
     wfProfileIn(__METHOD__);
     /* empty name */
     if (strlen($this->mRegexBlockedAddress) == 0) {
         $this->mError = wfMsg('regexblock-form-submit-empty');
         wfProfileOut(__METHOD__);
         return false;
     }
     /* castrate regexes */
     if (RegexBlockData::isValidRegex($this->mRegexBlockedAddress)) {
         $this->mError = wfMsg('regexblock-form-submit-regex');
         wfProfileOut(__METHOD__);
         return false;
     }
     /* check expiry */
     if (strlen($this->mRegexBlockedExpire) == 0) {
         $this->mError = wfMsg('regexblock-form-submit-expiry');
         wfProfileOut(__METHOD__);
         return false;
     }
     if ($this->mRegexBlockedExpire != 'infinite') {
         $expiry = strtotime($this->mRegexBlockedExpire);
         if ($expiry < 0 || $expiry === false) {
             $this->mError = wfMsg('ipb_expiry_invalid');
             wfProfileOut(__METHOD__);
             return false;
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
     } else {
         $expiry = $this->mRegexBlockedExpire;
     }
     $result = RegexBlockData::blockUser($this->mRegexBlockedAddress, $expiry, $this->mRegexBlockedExact, $this->mRegexBlockedCreation, $this->mRegexBlockedReason);
     /* clear memcached */
     $uname = $wgUser->getName();
     RegexBlock::unsetKeys($this->mRegexBlockedAddress);
     wfProfileOut(__METHOD__);
     /* redirect */
     $wgOut->redirect($this->mTitle->getFullURL('action=success_block&ip=' . urlencode($this->mRegexBlockedAddress) . "&" . $this->makeListUrlParams()));
     return;
 }
예제 #2
0
 private function doSubmit()
 {
     global $wgOut, $wgUser, $wgMemc;
     wfProfileIn(__METHOD__);
     /* empty name */
     if (strlen($this->mRegexBlockedAddress) == 0) {
         $this->mError = wfMsg('regexblock_give_username_ip');
         wfProfileOut(__METHOD__);
         return false;
     }
     /* castrate regexes */
     if (RegexBlockData::isValidRegex($this->mRegexBlockedAddress)) {
         $this->mError = wfMsg('regexblock_invalid_expr');
         wfProfileOut(__METHOD__);
         return false;
     }
     /* check expiry */
     if (strlen($this->mRegexBlockedExpire) == 0) {
         $this->mError = wfMsg('regexblock_invalid_period');
         wfProfileOut(__METHOD__);
         return false;
     }
     if ($this->mRegexBlockedExpire != 'infinite') {
         $expiry = strtotime($this->mRegexBlockedExpire);
         if ($expiry < 0 || $expiry === false) {
             $this->mError = wfMsg('ipb_expiry_invalid');
             wfProfileOut(__METHOD__);
             return false;
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
     } else {
         $expiry = $this->mRegexBlockedExpire;
     }
     # add new regex to the list
     RegexBlockData::blockUser($this->mRegexBlockedAddress, $expiry, $this->mRegexBlockedExact, $this->mRegexBlockedCreation, $this->mRegexBlockedReason);
     /* clear memcache */
     wfRegexBlockUpdateMemcKeys($this->mRegexBlockedAddress);
     wfProfileOut(__METHOD__);
     /* redirect */
     $titleObj = Title::makeTitle(NS_SPECIAL, 'RegexBlock');
     $wgOut->redirect($titleObj->getFullURL('action=success_block&ip=' . urlencode($this->mRegexBlockedAddress) . "&" . $this->makeListUrlParams()));
     return true;
 }