src/Neuron/Core/Login.php
public function sendLostPassword ($email)
	{
		// Check the database for this user
		$db = Neuron_Core_Database::__getInstance ();
		
		$user = $db->select
		(
			'n_players',
			array ('plid', 'email', 'nickname'),
			"email = '".$db->escape ($email)."' AND email_cert = 1 AND isRemoved = 0"
		);
		
		if (count ($user) != 1)
		{
			$this->warning = 'user_not_found';
			return false;
		}

		// User is found: let's continue the process.
		$password = substr ($this->getRandomPassword (), 0, 6);
		
		// Remove all other temporary password from this user
		$db->remove
		(
			'n_temp_passwords',
			"p_plid = ".$user[0]['plid']." OR p_expire < NOW()"
		);
		
		// Add this new one
		$db->insert
		(
			'n_temp_passwords',
			array
			(
				'p_plid' => $user[0]['plid'],
				'p_pass' => $password,
				'p_expire' => Neuron_Core_Tools::timestampToMysqlDatetime (time () + 60*60*24*2)
			)
		);
		
		// Send this temporary password to the user.
		$this->sendLostPasswordMail ($user[0]['email'], $user[0]['nickname'], $password);
		
		return true;
	}
public function sendLostPassword ($email)
	{
		// Check the database for this user
		$db = Neuron_Core_Database::__getInstance ();
		
		$user = $db->select
		(
			'n_players',
			array ('plid', 'email', 'nickname'),
			"email = '".$db->escape ($email)."' AND email_cert = 1 AND isRemoved = 0"
		);
		
		if (count ($user) != 1)
		{
			$this->warning = 'user_not_found';
			return false;
		}

		// User is found: let's continue the process.
		$password = substr ($this->getRandomPassword (), 0, 6);
		
		// Remove all other temporary password from this user
		$db->remove
		(
			'n_temp_passwords',
			"p_plid = ".$user[0]['plid']." OR p_expire < NOW()"
		);
		
		// Add this new one
		$db->insert
		(
			'n_temp_passwords',
			array
			(
				'p_plid' => $user[0]['plid'],
				'p_pass' => $password,
				'p_expire' => Neuron_Core_Tools::timestampToMysqlDatetime (time () + 60*60*24*2)
			)
		);
		
		// Send this temporary password to the user.
		$this->sendLostPasswordMail ($user[0]['email'], $user[0]['nickname'], $password);
		
		return true;
	}
public function sendLostPassword ( $ email ) { // Check the database for this user $ db = Neuron_Core_Database :: __getInstance ( ) ; $ user = $ db -> select ( 'n_players' , array ( 'plid' , 'email' , 'nickname' ) , "email = '" . $ db -> escape ( $ email ) . "' AND email_cert = 1 AND isRemoved = 0" ) ; if ( count ( $ user ) != 1 ) { $ this -> warning = 'user_not_found' ; return false ; } // User is found: let's continue the process. $ password = substr ( $ this -> getRandomPassword ( ) , 0 , 6 ) ; // Remove all other temporary password from this user $ db -> remove ( 'n_temp_passwords' , "p_plid = " . $ user [ 0 ] [ 'plid' ] . " OR p_expire < NOW()" ) ; // Add this new one $ db -> insert ( 'n_temp_passwords' , array ( 'p_plid' => $ user [ 0 ] [ 'plid' ] , 'p_pass' => $ password , 'p_expire' => Neuron_Core_Tools :: timestampToMysqlDatetime ( time ( ) + 60 * 60 * 24 * 2 ) ) ) ; // Send this temporary password to the user. $ this -> sendLostPasswordMail ( $ user [ 0 ] [ 'email' ] , $ user [ 0 ] [ 'nickname' ] , $ password ) ; return true ; }
/*
Lost password method:
Search the database for user with the right E-mail adress
and send him a temporary password.
/ * Lost password method : Search the database for user with the right E - mail adress and send him a temporary password .