aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Block.php
diff options
context:
space:
mode:
authornobody <nobody@localhost>2004-06-27 00:05:32 +0000
committernobody <nobody@localhost>2004-06-27 00:05:32 +0000
commit0c1d741ff4792d486258b390cf50cf3f9e229511 (patch)
tree55961c46b433ade0739763bee2ba3c4843d13751 /includes/Block.php
parentd5c8171a3157337557bc54ecb730d7dd35778ca3 (diff)
parent1aaed5fd7c7f4d7ea7abbfc7915bab5954d60a30 (diff)
downloadmediawikicore-1.3.0beta4a.tar.gz
mediawikicore-1.3.0beta4a.zip
This commit was manufactured by cvs2svn to create tag1.3.0beta4a
'REL1_3_0beta4a'.
Diffstat (limited to 'includes/Block.php')
-rw-r--r--includes/Block.php42
1 files changed, 23 insertions, 19 deletions
diff --git a/includes/Block.php b/includes/Block.php
index d98b07baebb7..e8a53e0efdd3 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -15,8 +15,8 @@ class Block
/* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry;
/* private */ var $mNetworkBits, $mIntegerAddr;
- function Block( $address = "", $user = "", $by = 0, $reason = "",
- $timestamp = "" , $auto = 0, $expiry = "" )
+ function Block( $address = '', $user = '', $by = 0, $reason = '',
+ $timestamp = '' , $auto = 0, $expiry = '' )
{
$this->mAddress = $address;
$this->mUser = $user;
@@ -38,18 +38,22 @@ class Block
function clear()
{
- $mAddress = $mReason = $mTimestamp = "";
+ $mAddress = $mReason = $mTimestamp = '';
$mUser = $mBy = 0;
}
# Get a ban from the DB, with either the given address or the given username
- function load( $address, $user = 0, $killExpired = true )
+ function load( $address = "", $user = 0, $killExpired = true )
{
- $fname = "Block::load";
+ $fname = 'Block::load';
$ret = false;
$killed = false;
- if ( 0 == $user ) {
+ if ( 0 == $user && $address=="" ) {
+ $sql = "SELECT * from ipblocks";
+ } elseif ($address=="") {
+ $sql = "SELECT * FROM ipblocks WHERE ipb_user={$user}";
+ } elseif ($user=="") {
$sql = "SELECT * FROM ipblocks WHERE ipb_address='" . wfStrencode( $address ) . "'";
} else {
$sql = "SELECT * FROM ipblocks WHERE (ipb_address='" . wfStrencode( $address ) .
@@ -109,7 +113,7 @@ class Block
function initialiseRange()
{
if ( $this->mUser == 0 ) {
- $rangeParts = explode( "/", $this->mAddress );
+ $rangeParts = explode( '/', $this->mAddress );
if ( count( $rangeParts ) == 2 ) {
$this->mNetworkBits = $rangeParts[1];
} else {
@@ -125,8 +129,8 @@ class Block
# Callback with a Block object for every block
/*static*/ function enumBlocks( $callback, $tag, $killExpired = true )
{
- $sql = "SELECT * FROM ipblocks ORDER BY ipb_timestamp DESC";
- $res = wfQuery( $sql, DB_READ, "Block::enumBans" );
+ $sql = 'SELECT * FROM ipblocks ORDER BY ipb_timestamp DESC';
+ $res = wfQuery( $sql, DB_READ, 'Block::enumBans' );
$block = new Block();
while ( $row = wfFetchObject( $res ) ) {
@@ -144,25 +148,25 @@ class Block
function delete()
{
- $fname = "Block::delete";
+ $fname = 'Block::delete';
if ( $this->mAddress == "" ) {
$sql = "DELETE FROM ipblocks WHERE ipb_id={$this->mId}";
} else {
$sql = "DELETE FROM ipblocks WHERE ipb_address='" .
wfStrencode( $this->mAddress ) . "'";
}
- wfQuery( $sql, DB_WRITE, "Block::delete" );
+ wfQuery( $sql, DB_WRITE, 'Block::delete' );
$this->clearCache();
}
function insert()
{
- $sql = "INSERT INTO ipblocks
- (ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry )
- VALUES ('" . wfStrencode( $this->mAddress ) . "', {$this->mUser}, {$this->mBy}, '" .
+ $sql = 'INSERT INTO ipblocks ' .
+ '(ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry )' .
+ "VALUES ('" . wfStrencode( $this->mAddress ) . "', {$this->mUser}, {$this->mBy}, '" .
wfStrencode( $this->mReason ) . "','{$this->mTimestamp}', {$this->mAuto}, '{$this->mExpiry}')";
- wfQuery( $sql, DB_WRITE, "Block::insert" );
+ wfQuery( $sql, DB_WRITE, 'Block::insert' );
$this->clearCache();
}
@@ -188,7 +192,7 @@ class Block
function isValid()
{
- return $this->mAddress != "";
+ return $this->mAddress != '';
}
function updateTimestamp()
@@ -197,10 +201,10 @@ class Block
$this->mTimestamp = wfTimestampNow();
$this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
- wfQuery( "UPDATE ipblocks SET " .
+ wfQuery( 'UPDATE ipblocks SET ' .
"ipb_timestamp='" . $this->mTimestamp . "', " .
"ipb_expiry='" . $this->mExpiry . "' " .
- "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, "Block::updateTimestamp" );
+ "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, 'Block::updateTimestamp' );
$this->clearCache();
}
@@ -232,7 +236,7 @@ class Block
/* static */ function normaliseRange( $range )
{
- $parts = explode( "/", $range );
+ $parts = explode( '/', $range );
if ( count( $parts ) == 2 ) {
$shift = 32 - $parts[1];
$ipint = ip2long( $parts[0] );