$wgIPBlockExpiration = 86400; # IP blocks expire after this many seconds, 0=infinite
$wgUserBlockExpiration = 0; # As above, but for logged-in users
+# User agent/range blocking
+# Blocks all users using a particular user agent, possibly restricted to a
+# set of IP ranges. Note: you can't block all user agents by leaving
+# $wgBadUserAgents blank. That would block nothing.
+$wgBadRanges = false; # e.g. array(array("1.2.3.0", "1.2.3.255"))
+$wgBadUserAgents = false; # e.g. array("OfflineExplorer/1.0")
+$wgRangeBlockUser = 0; # The block is attributed to this user ID
+$wgRangeBlockReason = ""; # This reason is given (should be in wfMsg, obviously)
+
# Client-side caching:
$wgCachePages = true; # Allow client-side caching of pages
return;
}
list( $limit, $offset ) = wfCheckLimits( 50, "" );
+ $offlimit = $limit + $offset;
$nt = Title::newFromURL( $target );
$nt->setNamespace( Namespace::getUser() );
if ( 0 == $id ) {
$sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment FROM cur " .
"WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
- "ORDER BY inverse_timestamp LIMIT {$offset}, {$limit}";
+ "ORDER BY inverse_timestamp LIMIT {$offlimit}";
$res1 = wfQuery( $sql, DB_READ, $fname );
$sql = "SELECT old_namespace,old_title,old_timestamp,old_comment FROM old " .
"WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " .
- "ORDER BY inverse_timestamp LIMIT {$offset}, {$limit}";
+ "ORDER BY inverse_timestamp LIMIT {$offlimit}";
$res2 = wfQuery( $sql, DB_READ, $fname );
} else {
$sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment FROM cur " .
- "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$offset}, {$limit}";
+ "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$offlimit}";
$res1 = wfQuery( $sql, DB_READ, $fname );
$sql = "SELECT old_namespace,old_title,old_timestamp,old_comment FROM old " .
- "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$offset}, {$limit}";
+ "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$offlimit}";
$res2 = wfQuery( $sql, DB_READ, $fname );
}
$nCur = wfNumRows( $res1 );
if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); }
$wgOut->addHTML( "<ul>\n" );
- while ( $limit ) {
+ for( $n = 0; $n < $offlimit; $n++ ) {
if ( 0 == $nCur && 0 == $nOld ) { break; }
if ( ( 0 == $nOld ) ||
$topmark = false;
--$nOld;
}
- ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment );
-
- --$limit;
+ if( $n >= $offset )
+ ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment );
}
$wgOut->addHTML( "</ul>\n" );
}
/* private */ function getBlockedStatus()
{
+ global $wgBadRanges, $wgBadUserAgents, $wgRangeBlockUser, $wgRangeBlockReason;
+
if ( -1 != $this->mBlockedby ) { return; }
+
+ # Range/user-agent blocking
+
+ $fBlock = false; # Mmmm, Hungarian
+ if ( ( !is_array( $wgBadUserAgents ) ||
+ array_key_exists( getenv( "HTTP_USER_AGENT" ), $wgBadUserAgents ) ) &&
+ is_array( $wgBadRanges ) )
+ {
+ $iIp = ip2long( getenv( "REMOTE_ADDR" ) );
+ foreach ( $wgBadRanges as $range ) {
+ $start = ip2long( $range[0] );
+ $end = ip2long( $range[1] );
+ if ( $iIp >= $start && $iIp <= $end ) {
+ $fBlock = true;
+ break;
+ }
+ }
+ }
+
+ if ( $fBlock ) {
+ $this->mBlockedby = $wgRangeBlockUser;
+ $this->mBlockReason = $wgRangeBlockReason;
+ return;
+ }
+
+ # User/IP blocking
$block = new Block();
if ( !$block->load( getenv( "REMOTE_ADDR" ), $this->mId ) ) {
$this->mBlockedby = 0;
return;
}
-
+
$this->mBlockedby = $block->mBy;
$this->mBlockreason = $block->mReason;
}