-<?
+<?php
# Blocks and bans object
#
#TODO: This could be used everywhere, but it isn't.
#
# To use delete(), you only need to fill $mAddress
-# Globals used: $wgIPBlockCache, $wgAutoblockExpiry
+# Globals used: $wgBlockCache, $wgAutoblockExpiry
class Block
{
function isExpired()
{
- return wfTimestampNow() > $this->mExpiry;
+ if ( !$this->mExpiry ) {
+ return false;
+ } else {
+ return wfTimestampNow() > $this->mExpiry;
+ }
}
function isValid()
return $this->mAddress != "";
}
- function updateTimestamp() {
-
- $this->mTimestamp = wfTimestampNow();
- $this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
-
- wfQuery( "UPDATE ipblocks SET " .
- "ipb_timestamp='" . $this->mTimestamp . "', " .
- "ipb_expiry='" . $this->mExpiry . "' " .
- "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, "Block::updateTimestamp" );
-
- $this->clearCache();
+ function updateTimestamp()
+ {
+ if ( $this->mAuto ) {
+ $this->mTimestamp = wfTimestampNow();
+ $this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
+
+ wfQuery( "UPDATE ipblocks SET " .
+ "ipb_timestamp='" . $this->mTimestamp . "', " .
+ "ipb_expiry='" . $this->mExpiry . "' " .
+ "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, "Block::updateTimestamp" );
+
+ $this->clearCache();
+ }
}
/* private */ function clearCache()