コード例 #1
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser;
     $this->setHeaders();
     $this->loadParameters($par);
     $wgOut->setPageTitle(wfMsg('globalblocking-block'));
     $wgOut->setSubtitle(GlobalBlocking::buildSubtitleLinks('GlobalBlock'));
     $wgOut->setRobotPolicy("noindex,nofollow");
     $wgOut->setArticleRelated(false);
     $wgOut->enableClientCache(false);
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     $errors = '';
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
         // They want to submit. Let's have a look.
         $errors = $this->trySubmit();
         if (!$errors) {
             // Success!
             return;
         }
     }
     if (GlobalBlocking::getGlobalBlockId($this->mAddress)) {
         $this->mModifyForm = true;
     }
     if ($this->mModifyForm) {
         $dbr = GlobalBlocking::getGlobalBlockingSlave();
         $block = $dbr->selectRow('globalblocks', '*', array('gb_address' => $this->mAddress), __METHOD__);
         if ($block) {
             if ($block->gb_expiry == 'infinity') {
                 $this->mExpirySelection = 'indefinite';
             } else {
                 $this->mExpiry = wfTimestamp(TS_ISO_8601, $block->gb_expiry);
             }
             $this->mAnonOnly = $block->gb_anon_only;
             $this->mReason = $block->gb_reason;
         }
     }
     $errorstr = null;
     if (is_array($errors) && count($errors) > 0) {
         $errorstr = $this->formatErrors($errors);
     }
     $this->form($errorstr);
 }
コード例 #2
0
 protected function getDB()
 {
     return GlobalBlocking::getGlobalBlockingSlave();
 }
コード例 #3
0
 function trySubmit()
 {
     global $wgOut, $wgUser;
     $ip = $this->mAddress;
     // Is it blocked?
     if (!($id = GlobalBlocking::getGlobalBlockId($ip))) {
         return array(array('globalblocking-notblocked', $ip));
     }
     $new_status = $this->mWhitelistStatus;
     $cur_status = $this->mCurrentStatus;
     // Already whitelisted.
     if ($cur_status == $new_status) {
         return array('globalblocking-whitelist-nochange');
     }
     $dbw = wfGetDB(DB_MASTER);
     if ($new_status == true) {
         $gdbr = GlobalBlocking::getGlobalBlockingSlave();
         // Find the expiry of the block. This is important so that we can store it in the
         // global_block_whitelist table, which allows us to purge it when the block has expired.
         $expiry = $gdbr->selectField('globalblocks', 'gb_expiry', array('gb_id' => $id), __METHOD__);
         $row = array('gbw_by' => $wgUser->getId(), 'gbw_by_text' => $wgUser->getName(), 'gbw_reason' => $this->mReason, 'gbw_address' => $ip, 'gbw_expiry' => $expiry, 'gbw_id' => $id);
         $dbw->replace('global_block_whitelist', array('gbw_id'), $row, __METHOD__);
         $page = new LogPage('gblblock');
         $page->addEntry('whitelist', Title::makeTitleSafe(NS_USER, $ip), $this->mReason);
         $wgOut->addWikiMsg('globalblocking-whitelist-whitelisted', $ip, $id);
     } else {
         // Delete the row from the database
         $dbw->delete('global_block_whitelist', array('gbw_id' => $id), __METHOD__);
         $page = new LogPage('gblblock');
         $page->addEntry('dwhitelist', Title::makeTitleSafe(NS_USER, $ip), $this->mReason);
         $wgOut->addWikiMsg('globalblocking-whitelist-dewhitelisted', $ip, $id);
     }
     $link = $wgUser->getSkin()->makeKnownLinkObj(SpecialPage::getTitleFor('GlobalBlockList'), wfMsg('globalblocking-return'));
     $wgOut->addHTML($link);
     $wgOut->setSubtitle(wfMsg('globalblocking-whitelist-successsub'));
     return array();
 }
コード例 #4
0
 function __construct($form, $conds = array())
 {
     $this->mForm = $form;
     $this->mConds = $conds;
     parent::__construct();
     $this->mDb = GlobalBlocking::getGlobalBlockingSlave();
 }
コード例 #5
0
 static function getGlobalBlockId($ip)
 {
     $dbr = GlobalBlocking::getGlobalBlockingSlave();
     if (!($row = $dbr->selectRow('globalblocks', 'gb_id', array('gb_address' => $ip), __METHOD__))) {
         return 0;
     }
     return $row->gb_id;
 }