Ejemplo n.º 1
0
 function spreadBlock()
 {
     # If the (non-anonymous) user is blocked, this function will block any IP address
     # that they successfully log on from.
     $fname = 'User::spreadBlock';
     wfDebug("User:spreadBlock()\n");
     if ($this->mId == 0) {
         return;
     }
     $userblock = Block::newFromDB('', $this->mId);
     if (!$userblock->isValid()) {
         return;
     }
     # Check if this IP address is already blocked
     $ipblock = Block::newFromDB(wfGetIP());
     if ($ipblock->isValid()) {
         # If the user is already blocked. Then check if the autoblock would
         # excede the user block. If it would excede, then do nothing, else
         # prolong block time
         if ($userblock->mExpiry && $userblock->mExpiry < Block::getAutoblockExpiry($ipblock->mTimestamp)) {
             return;
         }
         # Just update the timestamp
         $ipblock->updateTimestamp();
         return;
     }
     # Make a new block object with the desired properties
     wfDebug("Autoblocking {$this->mName}@" . wfGetIP() . "\n");
     $ipblock->mAddress = wfGetIP();
     $ipblock->mUser = 0;
     $ipblock->mBy = $userblock->mBy;
     $ipblock->mReason = wfMsg('autoblocker', $this->getName(), $userblock->mReason);
     $ipblock->mTimestamp = wfTimestampNow();
     $ipblock->mAuto = 1;
     # If the user is already blocked with an expiry date, we don't
     # want to pile on top of that!
     if ($userblock->mExpiry) {
         $ipblock->mExpiry = min($userblock->mExpiry, Block::getAutoblockExpiry($ipblock->mTimestamp));
     } else {
         $ipblock->mExpiry = Block::getAutoblockExpiry($ipblock->mTimestamp);
     }
     # Insert it
     $ipblock->insert();
 }
Ejemplo n.º 2
0
 /**
  * Update the timestamp on autoblocks.
  */
 public function updateTimestamp()
 {
     if ($this->mAuto) {
         $this->mTimestamp = wfTimestamp();
         $this->mExpiry = Block::getAutoblockExpiry($this->mTimestamp);
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('ipblocks', ['ipb_timestamp' => $dbw->timestamp($this->mTimestamp), 'ipb_expiry' => $dbw->timestamp($this->mExpiry)], ['ipb_id' => $this->getId()], __METHOD__);
     }
 }
Ejemplo n.º 3
0
 /**
  * Update the timestamp on autoblocks.
  */
 public function updateTimestamp()
 {
     if ($this->mAuto) {
         $this->mTimestamp = wfTimestamp();
         $this->mExpiry = Block::getAutoblockExpiry($this->mTimestamp);
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('ipblocks', array('ipb_timestamp' => $dbw->timestamp($this->mTimestamp), 'ipb_expiry' => $dbw->timestamp($this->mExpiry)), array('ipb_address' => (string) $this->getTarget()), __METHOD__);
     }
 }
Ejemplo n.º 4
0
 function updateTimestamp()
 {
     if ($this->mAuto) {
         $this->mTimestamp = wfTimestamp();
         $this->mExpiry = Block::getAutoblockExpiry($this->mTimestamp);
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('ipblocks', array('ipb_timestamp' => $dbw->timestamp($this->mTimestamp), 'ipb_expiry' => $dbw->timestamp($this->mExpiry)), array('ipb_address' => $this->mAddress), 'Block::updateTimestamp');
     }
 }