Example #1
0
/**
 * @todo document
 */
function wfSpecialIpblocklist()
{
    global $wgUser, $wgOut, $wgRequest;
    $ip = $wgRequest->getVal('wpUnblockAddress', $wgRequest->getVal('ip'));
    $reason = $wgRequest->getText('wpUnblockReason');
    $action = $wgRequest->getText('action');
    $ipu = new IPUnblockForm($ip, $reason);
    if ("success" == $action) {
        $ipu->showList(wfMsgWikiHtml('unblocked', htmlspecialchars($ip)));
    } else {
        if ("submit" == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            if (!$wgUser->isAllowed('block')) {
                $wgOut->sysopRequired();
                return;
            }
            $ipu->doSubmit();
        } else {
            if ("unblock" == $action) {
                $ipu->showForm("");
            } else {
                $ipu->showList("");
            }
        }
    }
}
 /**
  * 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'));
     }
     $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);
 }
Example #3
0
/**
 * @param $ip part of title: Special:Ipblocklist/<ip>.
 * @todo document
 */
function wfSpecialIpblocklist($ip = '')
{
    global $wgUser, $wgOut, $wgRequest;
    $ip = $wgRequest->getVal('ip', $ip);
    $ip = trim($wgRequest->getVal('wpUnblockAddress', $ip));
    $id = $wgRequest->getVal('id');
    $reason = $wgRequest->getText('wpUnblockReason');
    $action = $wgRequest->getText('action');
    $successip = $wgRequest->getVal('successip');
    $ipu = new IPUnblockForm($ip, $id, $reason);
    if ($action == 'unblock') {
        # Check permissions
        if (!$wgUser->isAllowed('block')) {
            $wgOut->permissionRequired('block');
            return;
        }
        # Check for database lock
        if (wfReadOnly()) {
            $wgOut->readOnlyPage();
            return;
        }
        # Show unblock form
        $ipu->showForm('');
    } elseif ($action == 'submit' && $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
        # Check permissions
        if (!$wgUser->isAllowed('block')) {
            $wgOut->permissionRequired('block');
            return;
        }
        # Check for database lock
        if (wfReadOnly()) {
            $wgOut->readOnlyPage();
            return;
        }
        # Remove blocks and redirect user to success page
        $ipu->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
            $ipu->showList($wgOut->parse(wfMsg('unblocked-id', $successip)));
        } else {
            // A username/IP was unblocked
            $ipu->showList($wgOut->parse(wfMsg('unblocked', $successip)));
        }
    } else {
        # Just show the block list
        $ipu->showList('');
    }
}
 /**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $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 (is_null($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if (!empty($retval)) {
         $this->dieUsageMsg($retval);
     }
     $dbw->commit();
     $res['id'] = $id;
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Example #5
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);
 }