Record and report memory usage change in profiling.
[lhc/web/wiklou.git] / includes / SpecialUserlogin.php
index d98f6bc..97814b6 100644 (file)
@@ -50,6 +50,7 @@ class LoginForm {
        function execute() {
                if ( !is_null( $this->mCookieCheck ) ) {
                        $this->onCookieRedirectCheck( $this->mCookieCheck );
+                       return;
                } else if( $this->mPosted ) {
                        if( $this->mCreateaccount ) {
                                return $this->addNewAccount();
@@ -128,18 +129,6 @@ class LoginForm {
                global $wgMaxNameChars;
                global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
 
-               if ( $wgAccountCreationThrottle ) {
-                       $key = "$wgDBname:acctcreate:ip:$wgIP";
-                       $value = $wgMemc->incr( $key );
-                       if ( !$value ) {
-                               $wgMemc->set( $key, 0, 86400 );
-                       }
-                       if ( $value > $wgAccountCreationThrottle ) ) {
-                               $this->throttleHit();
-                               return;
-                       }
-               }
-
                if (!$wgUser->isAllowedToCreateAccount()) {
                        $this->userNotPrivilegedMessage();
                        return;
@@ -151,10 +140,12 @@ class LoginForm {
                }
                
                $name = trim( $this->mName );
+               $u = User::newFromName( $name );
                if ( ( "" == $name ) ||
                  preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
                  (strpos( $name, "/" ) !== false) ||
-                 (strlen( $name ) > $wgMaxNameChars) ) 
+                 (strlen( $name ) > $wgMaxNameChars) ||
+                 ucFirst($name) != $u->getName() ) 
                {
                        $this->mainLoginForm( wfMsg( "noname" ) );
                        return;
@@ -163,12 +154,24 @@ class LoginForm {
                        $wgOut->readOnlyPage();
                        return;
                }
-               $u = User::newFromName( $name );
                
                if ( 0 != $u->idForName() ) {
                        $this->mainLoginForm( wfMsg( "userexists" ) );
                        return;
                }
+
+               if ( $wgAccountCreationThrottle ) {
+                       $key = "$wgDBname:acctcreate:ip:$wgIP";
+                       $value = $wgMemc->incr( $key );
+                       if ( !$value ) {
+                               $wgMemc->set( $key, 1, 86400 );
+                       }
+                       if ( $value > $wgAccountCreationThrottle ) {
+                               $this->throttleHit( $wgAccountCreationThrottle );
+                               return;
+                       }
+               }
+
                $u->addToDatabase();
                $u->setPassword( $this->mPassword );
                $u->setEmail( $this->mEmail );
@@ -200,12 +203,9 @@ class LoginForm {
                }
                $u->setId( $id );
                $u->loadFromDatabase();
-               $ep = $u->encryptPassword( $this->mPassword );
-               if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
-                       if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
-                               $this->mainLoginForm( wfMsg( "wrongpassword" ) );
-                               return;
-                       }
+               if (!$u->checkPassword( $this->mPassword )) {
+                       $this->mainLoginForm( wfMsg( "wrongpassword" ) );
+                       return;
                }
 
                # We've verified now, update the real record
@@ -376,11 +376,11 @@ class LoginForm {
                $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
                $action = $titleObj->escapeLocalUrl( $q );
 
-               $encName = wfEscapeHTML( $this->mName );
-               $encPassword = wfEscapeHTML( $this->mPassword );
-               $encRetype = wfEscapeHTML( $this->mRetype );
-               $encEmail = wfEscapeHTML( $this->mEmail );
-               $encRealName = wfEscapeHTML( $this->mRealName );
+               $encName = htmlspecialchars( $this->mName );
+               $encPassword = htmlspecialchars( $this->mPassword );
+               $encRetype = htmlspecialchars( $this->mRetype );
+               $encEmail = htmlspecialchars( $this->mEmail );
+               $encRealName = htmlspecialchars( $this->mRealName );
 
                if ($wgUser->getID() != 0) {
                        $cambutton = "<input tabindex='6' type='submit' name=\"wpCreateaccountMail\" value=\"{$cam}\" />";