Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. function handleLogin($arrData, Client $objClient){
  2. $strUser = $arrData['body']['login']['nick'];
  3. $strPass = $arrData['body']['login']['pword'];
  4. Silk\Logger::Log('Client is attempting to login with username \'' . $strUser . '\'');
  5. $blnExist = $this->objDatabase->playerExists($strUser);
  6. if($blnExist === false){
  7. $objClient->sendError(100);
  8. return $this->removeClient($objClient->resSocket);
  9. }
  10. $arrUser = elseif($arrUser["Banned"] == 1){
  11. $objClient->sendError(603);
  12. return $this->removeClient($objClient->resSocket);
  13. }
  14. $arrUser = $this->objDatabase->getRow($strUser);
  15. $intUser = $arrUser['ID'];
  16. $strPassword = $arrUser['Password'];
  17. $strRandom = $objClient->getRandomKey();
  18. if($this->arrServer['Type'] == 'Login'){
  19. Silk\Logger::Log('Handling login hashing', 'DEBUG');
  20. $strUppedPass = strtoupper($strPassword);
  21. $strEncrypt = $strUppedPass;
  22. //if($strEncrypt != $strPass){
  23. if(password_verify($strPass, $strPassword) !== true) {
  24. Silk\Logger::Log('Failed login attempt for user \'' . $strUser . '\'', Silk\Logger::Debug);
  25. $objClient->sendError(101);
  26. $this->removeClient($objClient->resSocket);
  27. }elseif($arrUser['ID'] > 99999999999){
  28. Silk\Logger::Log('Failed login attempt for user \'' . $strUser . '\'', Silk\Logger::Debug);
  29. $objClient->sendError(101);
  30. $this->removeClient($objClient->resSocket);
  31. }else {
  32. // TODO: Implement buddy-on-server smiley thing
  33. $objClient->sendXt('sd', -1, $this->getServers());
  34. $strHash = md5(strrev($objClient->strRandomKey));
  35. Silk\Logger::Log('Random string: ' . $strHash);
  36. $objClient->arrBuddies = json_decode($arrUser['Buddies'], true);
  37. $strServers = $this->objDatabase->getServerPopulation();
  38. $objClient->sendXt('guc', -1, $strServers . ',' . $intBuddiesOnline);
  39. $objClient->sendXt('l', -1, $intUser, $strHash, '', $strServers);
  40. $this->objDatabase->updateColumn($intUser, 'LoginKey', $strHash);
  41. $this->removeClient($objClient->resSocket);
  42. Silk\Logger::Log('User \'' . $strUser . '\' has successfully logged in!', Silk\Logger::Debug);
  43. }
  44. } else {
  45. Silk\Logger::Log('Handling game hashing', Silk\Logger::Debug);
  46. $strLoginKey = $this->objDatabase->getLoginKey($intUser);
  47. $strHash = $this->encryptPassword($strLoginKey . $objClient->strRandomKey) . $strLoginKey;
  48. if($strHash != $strLoginKey){
  49. $objClient->sendXt('f#lb', -1, $strHash);
  50. $objClient->sendXt('l', -1);
  51. $objClient->setClient($arrUser);
  52. $this->updateStats();
  53. } else {
  54. $objClient->sendError(101);
  55. $this->removeClient($objClient->resSocket);
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement