Example #1
0
/**
 * Constructor
 */
function wfSpecialBlockip($par)
{
    global $wgUser, $wgOut, $wgRequest;
    # Can't block when the database is locked
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    # Permission check
    if (!$wgUser->isAllowed('block')) {
        $wgOut->permissionRequired('block');
        return;
    }
    $ipb = new IPBlockForm($par);
    $action = $wgRequest->getVal('action');
    if ('success' == $action) {
        $ipb->showSuccess();
    } else {
        if ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            $ipb->doSubmit();
        } else {
            $ipb->showForm('');
        }
    }
}
Example #2
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('');
     }
 }
	public function execute() {
		$userName = '******'; // <- targer username

		$user = new CentralAuthUser( $userName );
		if ( !$user->exists() ) {
			echo "Cannot unsuppress non-existent user {$userName}!\n";
			exit( 0 );
		}
		$userName = $user->getName(); // sanity
		$wikis = $user->listAttached(); // wikis with attached accounts
		foreach ( $wikis as $wiki ) {
			$lb = wfGetLB( $wiki );
			$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
			# Get local ID like $user->localUserData( $wiki ) does
			$localUserId = $dbw->selectField( 'user', 'user_id',
				array( 'user_name' => $userName ), __METHOD__ );

			$delUserBit = Revision::DELETED_USER;
			$hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
				array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
			echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
			# Unsuppress username on edits
			if ( $hiddenCount > 0 ) {
				echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
				IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
				echo "done!\n\n";
			}
			$lb->reuseConnection( $dbw ); // not really needed
			# Don't lag too bad
			wfWaitForSlaves( 5 );
		}
	}
Example #4
0
/**
 * Constructor
 */
function wfSpecialBlockip($par)
{
    global $wgUser, $wgOut, $wgRequest;
    if (!$wgUser->isAllowed('block')) {
        $wgOut->permissionRequired('block');
        return;
    }
    $ipb = new IPBlockForm($par);
    $action = $wgRequest->getVal('action');
    if ('success' == $action) {
        $ipb->showSuccess();
    } else {
        if ($wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
            $ipb->doSubmit();
        } else {
            $ipb->showForm('');
        }
    }
}
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);
 }
Example #6
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 (is_null($params['user'])) {
         $this->dieUsageMsg(array('missingparam', 'user'));
     }
     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('cantblock'));
     }
     if ($params['hidename'] && !$wgUser->isAllowed('hideuser')) {
         $this->dieUsageMsg(array('canthide'));
     }
     if ($params['noemail'] && !$wgUser->isAllowed('blockemail')) {
         $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);
 }
 /**
  * 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;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['blocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['user'])) {
         $this->dieUsageMsg(array('missingparam', 'user'));
     }
     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('cantblock'));
     }
     if ($params['hidename'] && !$wgUser->isAllowed('hideuser')) {
         $this->dieUsageMsg(array('canthide'));
     }
     if ($params['noemail'] && !$wgUser->isAllowed('blockemail')) {
         $this->dieUsageMsg(array('cantblock-email'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     $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'];
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = $form->doBlock($userID, $expiry);
     if (!empty($retval)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg($retval);
     }
     $dbw->commit();
     $res['user'] = $params['user'];
     $res['userID'] = $userID;
     $res['expiry'] = $expiry == Block::infinity() ? 'infinite' : $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'] = '';
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Example #8
0
 /**
  * Backend code for unblocking. doSubmit() wraps around this.
  * $range is only used when UNBLOCK_BLOCKED_AS_RANGE is returned, in which
  * case it contains the range $ip is part of.
  * @return array array(message key, parameters) on failure, empty array on success
  */
 static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker = null)
 {
     if ($id) {
         $block = Block::newFromID($id);
         if (!$block) {
             return array('ipb_cant_unblock', htmlspecialchars($id));
         }
         $ip = $block->getRedactedName();
     } else {
         $block = new Block();
         $ip = trim($ip);
         if (substr($ip, 0, 1) == "#") {
             $id = substr($ip, 1);
             $block = Block::newFromID($id);
             if (!$block) {
                 return array('ipb_cant_unblock', htmlspecialchars($id));
             }
             $ip = $block->getRedactedName();
         } else {
             $block = Block::newFromDB($ip);
             if (!$block) {
                 return array('ipb_cant_unblock', htmlspecialchars($id));
             }
             if ($block->mRangeStart != $block->mRangeEnd && !strstr($ip, "/")) {
                 /* If the specified IP is a single address, and the block is
                  * a range block, don't unblock the range. */
                 $range = $block->mAddress;
                 return array('ipb_blocked_as_range', $ip, $range);
             }
         }
     }
     // Yes, this is really necessary
     $id = $block->mId;
     # If the name was hidden and the blocking user cannot hide
     # names, then don't allow any block removals...
     if ($blocker && $block->mHideName && !$blocker->isAllowed('hideuser')) {
         return array('ipb_cant_unblock', htmlspecialchars($id));
     }
     # Delete block
     if (!$block->delete()) {
         return array('ipb_cant_unblock', htmlspecialchars($id));
     }
     # Unset _deleted fields as needed
     if ($block->mHideName) {
         IPBlockForm::unsuppressUserName($block->mAddress, $block->mUser);
     }
     # Make log entry
     $log = new LogPage('block');
     $log->addEntry('unblock', Title::makeTitle(NS_USER, $ip), $reason);
     return array();
 }