Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function handleLogin($arrData, Client $objClient){
- $strUser = $arrData['body']['login']['nick'];
- $strPass = $arrData['body']['login']['pword'];
- Silk\Logger::Log('Client is attempting to login with username \'' . $strUser . '\'');
- $blnExist = $this->objDatabase->playerExists($strUser);
- if($blnExist === false){
- $objClient->sendError(100);
- return $this->removeClient($objClient->resSocket);
- }
- $arrUser = elseif($arrUser["Banned"] == 1){
- $objClient->sendError(603);
- return $this->removeClient($objClient->resSocket);
- }
- $arrUser = $this->objDatabase->getRow($strUser);
- $intUser = $arrUser['ID'];
- $strPassword = $arrUser['Password'];
- $strRandom = $objClient->getRandomKey();
- if($this->arrServer['Type'] == 'Login'){
- Silk\Logger::Log('Handling login hashing', 'DEBUG');
- $strUppedPass = strtoupper($strPassword);
- $strEncrypt = $strUppedPass;
- //if($strEncrypt != $strPass){
- if(password_verify($strPass, $strPassword) !== true) {
- Silk\Logger::Log('Failed login attempt for user \'' . $strUser . '\'', Silk\Logger::Debug);
- $objClient->sendError(101);
- $this->removeClient($objClient->resSocket);
- }elseif($arrUser['ID'] > 99999999999){
- Silk\Logger::Log('Failed login attempt for user \'' . $strUser . '\'', Silk\Logger::Debug);
- $objClient->sendError(101);
- $this->removeClient($objClient->resSocket);
- }else {
- // TODO: Implement buddy-on-server smiley thing
- $objClient->sendXt('sd', -1, $this->getServers());
- $strHash = md5(strrev($objClient->strRandomKey));
- Silk\Logger::Log('Random string: ' . $strHash);
- $objClient->arrBuddies = json_decode($arrUser['Buddies'], true);
- $strServers = $this->objDatabase->getServerPopulation();
- $objClient->sendXt('guc', -1, $strServers . ',' . $intBuddiesOnline);
- $objClient->sendXt('l', -1, $intUser, $strHash, '', $strServers);
- $this->objDatabase->updateColumn($intUser, 'LoginKey', $strHash);
- $this->removeClient($objClient->resSocket);
- Silk\Logger::Log('User \'' . $strUser . '\' has successfully logged in!', Silk\Logger::Debug);
- }
- } else {
- Silk\Logger::Log('Handling game hashing', Silk\Logger::Debug);
- $strLoginKey = $this->objDatabase->getLoginKey($intUser);
- $strHash = $this->encryptPassword($strLoginKey . $objClient->strRandomKey) . $strLoginKey;
- if($strHash != $strLoginKey){
- $objClient->sendXt('f#lb', -1, $strHash);
- $objClient->sendXt('l', -1);
- $objClient->setClient($arrUser);
- $this->updateStats();
- } else {
- $objClient->sendError(101);
- $this->removeClient($objClient->resSocket);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement