* Indenting and formatting.
[lhc/web/wiklou.git] / includes / User.php
index 2f9fad5..018324f 100644 (file)
@@ -251,8 +251,8 @@ class User {
         * just slightly outta sync and soon corrected - safer to block slightly more that less.
         * And it's cheaper to check slave first, then master if needed, than master always.
         */
-       function getBlockedStatus( $bFromSlave = false ) {
-               global $wgIP, $wgBlockCache, $wgProxyList;
+       function getBlockedStatus() {
+               global $wgIP, $wgBlockCache, $wgProxyList, $wgEnableSorbs, $bFromSlave;
 
                if ( -1 != $this->mBlockedby ) { return; }
 
@@ -265,6 +265,7 @@ class User {
                        if ( $block->load( $wgIP , $this->mId ) ) {
                                $this->mBlockedby = $block->mBy;
                                $this->mBlockreason = $block->mReason;
+                               $this->spreadBlock();
                        }
                }
 
@@ -291,8 +292,46 @@ class User {
                                $this->mBlockreason = wfMsg( 'proxyblockreason' );
                        }
                }
+
+               # DNSBL
+               if ( !$this->mBlockedby && $wgEnableSorbs ) {
+                       if ( $this->inSorbsBlacklist( $wgIP ) ) {
+                               $this->mBlockedby = wfMsg( 'sorbs' );
+                               $this->mBlockreason = wfMsg( 'sorbsreason' );
+                       }
+               }
+                       
        }
 
+       function inSorbsBlacklist( $ip ) {
+               $fname = 'User::inSorbsBlacklist';
+               wfProfileIn( $fname );
+               
+               $found = false;
+               $host = '';
+               
+               if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $m ) ) {
+                       # Make hostname
+                       for ( $i=4; $i>=1; $i-- ) {
+                               $host .= $m[$i] . '.';
+                       }
+                       $host .= 'http.dnsbl.sorbs.net.';
+
+                       # Send query
+                       $ipList = gethostbynamel( $host );
+                       
+                       if ( $ipList ) {
+                               wfDebug( "Hostname $host is {$ipList[0]}, it's a proxy!\n" );
+                               $found = true;
+                       } else {
+                               wfDebug( "Requested $host, not found.\n" );
+                       }
+               }
+
+               wfProfileOut( $fname );
+               return $found;
+       }
+       
        /**
         * Check if user is blocked
         * @return bool True if blocked, false otherwise
@@ -392,7 +431,6 @@ class User {
                                else
                                        wfDebug( "User::loadFromSession() unable to save to memcached\n" );
                        }
-                       $user->spreadBlock();
                        return $user;
                }
                return new User(); # Can't log in from session
@@ -1117,11 +1155,8 @@ class User {
                // it will always be 0 when this function is called by parsercache.
 
                $confstr =        $this->getOption( 'math' );
-               $confstr .= '!' . $this->getOption( 'highlightbroken' );
                $confstr .= '!' . $this->getOption( 'stubthreshold' );
                $confstr .= '!' . $this->getOption( 'editsection' );
-               $confstr .= '!' . $this->getOption( 'editsectiononrightclick' );
-               $confstr .= '!' . $this->getOption( 'showtoc' );
                $confstr .= '!' . $this->getOption( 'date' );
                $confstr .= '!' . $this->getOption( 'numberheadings' );
                $confstr .= '!' . $this->getOption( 'language' );