Fix PHP 5.2 compatibility for r77144
[lhc/web/wiklou.git] / includes / User.php
index 6d44b8d..6ab18f6 100644 (file)
@@ -655,8 +655,8 @@ class User {
                ^                      # start of string
                [$rfc5322_atext\\.]+    # user part which is liberal :p
                @                      # 'apostrophe'
-               [$rfc1034_ldh_str]     # Domain first character
-               [$rfc1034_ldh_str\\.]+  # Second char and following can include dot
+               [$rfc1034_ldh_str]+       # First domain part
+               (\\.[$rfc1034_ldh_str]+)+  # Following part prefixed with a dot
                $                      # End of string
                /ix" ; // case Insensitive, eXtended 
 
@@ -1224,34 +1224,10 @@ class User {
                        // Deprecated, but kept for backwards-compatibility config
                        return false;
                }
-
-               wfDebug( "Checking the list of IP addresses excluded from rate limit..\n" );
-
-               // Read list of IP addresses from MediaWiki namespace
-               $message = wfMsgForContentNoTrans( 'ratelimit-excluded-ips' );
-               $lines = explode( "\n", $message );
-               foreach( $lines as $line ) {
-                       // Remove comment lines
-                       $comment = substr( trim( $line ), 0, 1 );
-                       if ( $comment == '#' || $comment == '' ) {
-                               continue;
-                       }
-                       // Remove additional comments after an IP address
-                       $comment = strpos( $line, '#' );
-                       if ( $comment > 0 ) {
-                               $line = trim( substr( $line, 0, $comment-1 ) );
-                               if ( IP::isValid( $line ) ) {
-                                       $wgRateLimitsExcludedIPs[] = IP::sanitizeIP( $line );
-                               }
-                       }
-               }
-
-               $ip = IP::sanitizeIP( wfGetIP() );
-               if( in_array( $ip, $wgRateLimitsExcludedIPs ) ) {
+               if( in_array( wfGetIP(), $wgRateLimitsExcludedIPs ) ) {
                        // No other good way currently to disable rate limits
                        // for specific IPs. :P
                        // But this is a crappy hack and should die.
-                       wfDebug( "IP $ip matches the list of rate limit excluded IPs\n" );
                        return false;
                }
                return !$this->isAllowed('noratelimit');
@@ -1480,7 +1456,7 @@ class User {
 
        /**
         * Get the user's ID.
-        * @return \int The user's ID; 0 if the user is anonymous or nonexistent
+        * @return Integer The user's ID; 0 if the user is anonymous or nonexistent
         */
        function getId() {
                if( $this->mId === null and $this->mName !== null
@@ -2212,11 +2188,12 @@ class User {
        /**
         * Check if user is allowed to access a feature / make an action
         * @param $action \string action to be checked
-        * @return \bool True if action is allowed, else false
+        * @return Boolean: True if action is allowed, else false
         */
        function isAllowed( $action = '' ) {
-               if ( $action === '' )
+               if ( $action === '' ) {
                        return true; // In the spirit of DWIM
+               }
                # Patrolling may not be enabled
                if( $action === 'patrol' || $action === 'autopatrol' ) {
                        global $wgUseRCPatrol, $wgUseNPPatrol;
@@ -2230,7 +2207,7 @@ class User {
 
        /**
         * Check whether to enable recent changes patrol features for this user
-        * @return \bool True or false
+        * @return Boolean: True or false
         */
        public function useRCPatrol() {
                global $wgUseRCPatrol;
@@ -2276,18 +2253,18 @@ class User {
        private function createSkinObject() {
                wfProfileIn( __METHOD__ );
 
-               global $wgHiddenPrefs, $wgRequest;
+               global $wgHiddenPrefs;
                if( !in_array( 'skin', $wgHiddenPrefs ) ) {
+                       global $wgRequest;
                        # get the user skin
                        $userSkin = $this->getOption( 'skin' );
+                       $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
                } else {
                        # if we're not allowing users to override, then use the default
                        global $wgDefaultSkin;
                        $userSkin = $wgDefaultSkin;
                }
 
-               $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
-
                $skin = Skin::newFromKey( $userSkin );
                wfProfileOut( __METHOD__ );
                
@@ -2735,7 +2712,7 @@ class User {
 
        /**
         * Get whether the user is blocked from using Special:Emailuser.
-        * @return \bool True if blocked
+        * @return Boolean: True if blocked
         */
        function isBlockedFromEmailuser() {
                $this->getBlockedStatus();
@@ -2744,7 +2721,7 @@ class User {
 
        /**
         * Get whether the user is allowed to create an account.
-        * @return \bool True if allowed
+        * @return Boolean: True if allowed
         */
        function isAllowedToCreateAccount() {
                return $this->isAllowed( 'createaccount' ) && !$this->isBlockedFromCreateAccount();
@@ -2753,7 +2730,7 @@ class User {
        /**
         * Get this user's personal page title.
         *
-        * @return \type{Title} User's personal page title
+        * @return Title: User's personal page title
         */
        function getUserPage() {
                return Title::makeTitle( NS_USER, $this->getName() );
@@ -2762,7 +2739,7 @@ class User {
        /**
         * Get this user's talk page title.
         *
-        * @return \type{Title} User's talk page title
+        * @return Title: User's talk page title
         */
        function getTalkPage() {
                $title = $this->getUserPage();
@@ -2771,7 +2748,7 @@ class User {
 
        /**
         * Get the maximum valid user ID.
-        * @return \int User ID
+        * @return Integer: User ID
         * @static
         */
        function getMaxID() {
@@ -2788,7 +2765,7 @@ class User {
        /**
         * Determine whether the user is a newbie. Newbies are either
         * anonymous IPs, or the most recently created accounts.
-        * @return \bool True if the user is a newbie
+        * @return Boolean: True if the user is a newbie
         */
        function isNewbie() {
                return !$this->isAllowed( 'autoconfirmed' );
@@ -2796,8 +2773,8 @@ class User {
 
        /**
         * Check to see if the given clear-text password is one of the accepted passwords
-        * @param $password \string user password.
-        * @return \bool True if the given password is correct, otherwise False.
+        * @param $password String: user password.
+        * @return Boolean: True if the given password is correct, otherwise False.
         */
        function checkPassword( $password ) {
                global $wgAuth;
@@ -2837,7 +2814,7 @@ class User {
        /**
         * Check if the given clear-text password matches the temporary password
         * sent by e-mail for password reset operations.
-        * @return \bool True if matches, false otherwise
+        * @return Boolean: True if matches, false otherwise
         */
        function checkTemporaryPassword( $plaintext ) {
                global $wgNewPasswordExpiry;
@@ -2895,7 +2872,7 @@ class User {
         *
         * @param $val \string Input value to compare
         * @param $salt \string Optional function-specific data for hashing
-        * @return \bool Whether the token matches
+        * @return Boolean: Whether the token matches
         */
        function matchEditToken( $val, $salt = '' ) {
                $sessionToken = $this->editToken( $salt );
@@ -2911,7 +2888,7 @@ class User {
         *
         * @param $val \string Input value to compare
         * @param $salt \string Optional function-specific data for hashing
-        * @return \bool Whether the token matches
+        * @return Boolean: Whether the token matches
         */
        function matchEditTokenNoSuffix( $val, $salt = '' ) {
                $sessionToken = $this->editToken( $salt );
@@ -2957,12 +2934,13 @@ class User {
         */
        function sendMail( $subject, $body, $from = null, $replyto = null ) {
                if( is_null( $from ) ) {
-                       global $wgPasswordSender;
-                       $from = $wgPasswordSender;
+                       global $wgPasswordSender, $wgPasswordSenderName;
+                       $sender = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
+               } else {
+                       $sender = new MailAddress( $from );
                }
 
                $to = new MailAddress( $this );
-               $sender = new MailAddress( $from );
                return UserMailer::send( $to, $sender, $subject, $body, $replyto );
        }
 
@@ -3071,7 +3049,7 @@ class User {
        /**
         * Is this user allowed to send e-mails within limits of current
         * site configuration?
-        * @return \bool True if allowed
+        * @return Boolean: True if allowed
         */
        function canSendEmail() {
                global $wgEnableEmail, $wgEnableUserEmail;
@@ -3086,7 +3064,7 @@ class User {
        /**
         * Is this user allowed to receive e-mails within limits of current
         * site configuration?
-        * @return \bool True if allowed
+        * @return Boolean: True if allowed
         */
        function canReceiveEmail() {
                return $this->isEmailConfirmed() && !$this->getOption( 'disablemail' );
@@ -3100,7 +3078,7 @@ class User {
         * confirmed their address by returning a code or using a password
         * sent to the address from the wiki.
         *
-        * @return \bool True if confirmed
+        * @return Boolean: True if confirmed
         */
        function isEmailConfirmed() {
                global $wgEmailAuthentication;
@@ -3121,7 +3099,7 @@ class User {
 
        /**
         * Check whether there is an outstanding request for e-mail confirmation.
-        * @return \bool True if pending
+        * @return Boolean: True if pending
         */
        function isEmailConfirmationPending() {
                global $wgEmailAuthentication;
@@ -3550,7 +3528,7 @@ class User {
         * @param $hash \string Password hash
         * @param $password \string Plain-text password to compare
         * @param $userId \string User ID for old-style password salt
-        * @return \bool
+        * @return Boolean:
         */
        static function comparePasswords( $hash, $password, $userId = false ) {
                $type = substr( $hash, 0, 3 );