Пример #1
0
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest;
     # Can't block when the database is locked
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # Permission check
     if (!$this->userCanExecute($wgUser)) {
         $wgOut->permissionRequired('block');
         return;
     }
     $this->setup($par);
     # bug 15810: blocked admins should have limited access here
     if ($wgUser->isBlocked()) {
         $status = IPBlockForm::checkUnblockSelf($this->BlockAddress);
         if ($status !== true) {
             throw new ErrorPageError('badaccess', $status);
         }
     }
     $action = $wgRequest->getVal('action');
     if ('success' == $action) {
         $this->showSuccess();
     } elseif ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
         $this->doSubmit();
     } else {
         $this->showForm('');
     }
 }
Пример #2
0
 /**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['unblocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['id']) && is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-notarget'));
     }
     if (!is_null($params['id']) && !is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-idanduser'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     # bug 15810: blocked admins should have limited access here
     if ($wgUser->isBlocked()) {
         $status = IPBlockForm::checkUnblockSelf($params['user']);
         if ($status !== true) {
             $this->dieUsageMsg(array($status));
         }
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if ($retval) {
         $this->dieUsageMsg($retval);
     }
     $res['id'] = intval($id);
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Пример #3
0
 /**
  * Blocks the user specified in the parameters for the given expiry, with the
  * given reason, and with all other settings provided in the params. If the block
  * succeeds, produces a result containing the details of the block and notice
  * of success. If it fails, the result will specify the nature of the error.
  */
 public function execute()
 {
     global $wgUser, $wgBlockAllowsUTEdit;
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['blocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantblock'));
     }
     # bug 15810: blocked admins should have limited access here
     if ($wgUser->isBlocked()) {
         $status = IPBlockForm::checkUnblockSelf($params['user']);
         if ($status !== true) {
             $this->dieUsageMsg(array($status));
         }
     }
     if ($params['hidename'] && !$wgUser->isAllowed('hideuser')) {
         $this->dieUsageMsg(array('canthide'));
     }
     if ($params['noemail'] && !IPBlockForm::canBlockEmail($wgUser)) {
         $this->dieUsageMsg(array('cantblock-email'));
     }
     $form = new IPBlockForm('');
     $form->BlockAddress = $params['user'];
     $form->BlockReason = is_null($params['reason']) ? '' : $params['reason'];
     $form->BlockReasonList = 'other';
     $form->BlockExpiry = $params['expiry'] == 'never' ? 'infinite' : $params['expiry'];
     $form->BlockOther = '';
     $form->BlockAnonOnly = $params['anononly'];
     $form->BlockCreateAccount = $params['nocreate'];
     $form->BlockEnableAutoblock = $params['autoblock'];
     $form->BlockEmail = $params['noemail'];
     $form->BlockHideName = $params['hidename'];
     $form->BlockAllowUsertalk = $params['allowusertalk'] && $wgBlockAllowsUTEdit;
     $form->BlockReblock = $params['reblock'];
     $userID = $expiry = null;
     $retval = $form->doBlock($userID, $expiry);
     if (count($retval)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg($retval);
     }
     $res['user'] = $params['user'];
     $res['userID'] = intval($userID);
     $res['expiry'] = $expiry == Block::infinity() ? 'infinite' : wfTimestamp(TS_ISO_8601, $expiry);
     $res['reason'] = $params['reason'];
     if ($params['anononly']) {
         $res['anononly'] = '';
     }
     if ($params['nocreate']) {
         $res['nocreate'] = '';
     }
     if ($params['autoblock']) {
         $res['autoblock'] = '';
     }
     if ($params['noemail']) {
         $res['noemail'] = '';
     }
     if ($params['hidename']) {
         $res['hidename'] = '';
     }
     if ($params['allowusertalk']) {
         $res['allowusertalk'] = '';
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Пример #4
0
 /**
  * Main execution point
  *
  * @param $ip part of title: Special:Ipblocklist/<ip>.
  */
 function execute($ip)
 {
     global $wgUser, $wgOut, $wgRequest;
     $this->setHeaders();
     $this->outputHeader();
     $ip = $wgRequest->getVal('ip', $ip);
     $this->ip = trim($wgRequest->getVal('wpUnblockAddress', $ip));
     $this->id = $wgRequest->getVal('id');
     $this->reason = $wgRequest->getText('wpUnblockReason');
     $this->hideuserblocks = $wgRequest->getBool('hideuserblocks');
     $this->hidetempblocks = $wgRequest->getBool('hidetempblocks');
     $this->hideaddressblocks = $wgRequest->getBool('hideaddressblocks');
     $action = $wgRequest->getText('action');
     $successip = $wgRequest->getVal('successip');
     if ($action == 'unblock' || $action == 'submit' && $wgRequest->wasPosted()) {
         # Check permissions
         if (!$wgUser->isAllowed('block')) {
             $wgOut->permissionRequired('block');
             return;
         }
         # Check for database lock
         if (wfReadOnly()) {
             $wgOut->readOnlyPage();
             return;
         }
         # bug 15810: blocked admins should have limited access here
         if ($wgUser->isBlocked()) {
             if ($this->id) {
                 # This doesn't pick up on autoblocks, but admins
                 # should have the ipblock-exempt permission anyway
                 $block = Block::newFromID($this->id);
                 $user = User::newFromName($block->mAddress);
             } else {
                 $user = User::newFromName($this->ip);
             }
             $status = IPBlockForm::checkUnblockSelf($user);
             if ($status !== true) {
                 throw new ErrorPageError('badaccess', $status);
             }
         }
         if ($action == 'unblock') {
             # Show unblock form
             $this->showForm('');
         } elseif ($action == 'submit' && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
             # Remove blocks and redirect user to success page
             $this->doSubmit();
         }
     } elseif ($action == 'success') {
         # Inform the user of a successful unblock
         # (No need to check permissions or locks here,
         # if something was done, then it's too late!)
         if (substr($successip, 0, 1) == '#') {
             // A block ID was unblocked
             $this->showList($wgOut->parse(wfMsg('unblocked-id', $successip)));
         } else {
             // A username/IP was unblocked
             $this->showList($wgOut->parse(wfMsg('unblocked', $successip)));
         }
     } else {
         # Just show the block list
         $this->showList('');
     }
 }