Esempio n. 1
0
 protected function handleLogin($socket)
 {
     $penguin = $this->penguins[$socket];
     if ($penguin->handshakeStep !== "randomKey") {
         return $this->removePenguin($penguin);
     }
     $this->databaseManager->add($penguin);
     $username = Packet::$Data['body']['login']['nick'];
     $password = Packet::$Data['body']['login']['pword'];
     if ($penguin->database->usernameExists($username) === false) {
         $penguin->send("%xt%e%-1%101%");
         return $this->removePenguin($penguin);
     }
     $penguinData = $penguin->database->getColumnsByName($username, array("ID", "Username", "Password", "SWID", "Email", "Banned"));
     $encryptedPassword = Hashing::getLoginHash($penguinData["Password"], $penguin->randomKey);
     if ($encryptedPassword != $password) {
         $penguin->send("%xt%e%-1%101%");
         return $this->removePenguin($penguin);
     } elseif ($penguinData["Banned"] > strtotime("now") || $penguinData["Banned"] == "perm") {
         if (is_numeric($penguinData["Banned"])) {
             $hours = round(($penguinData["Banned"] - strtotime("now")) / (60 * 60));
             $penguin->send("%xt%e%-1%601%{$hours}%");
             $this->removePenguin($penguin);
         } else {
             $penguin->send("%xt%e%-1%603%");
             $this->removePenguin($penguin);
         }
     } else {
         $confirmationHash = md5($penguin->randomKey);
         $friendsKey = md5($penguinData["ID"]);
         // May need to change this later!
         $loginTime = time();
         $penguin->database->updateColumnById($penguinData["ID"], "ConfirmationHash", $confirmationHash);
         $penguin->database->updateColumnById($penguinData["ID"], "LoginKey", $encryptedPassword);
         $penguin->handshakeStep = "login";
         $penguin->send("%xt%l%-1%{$penguinData["ID"]}|{$penguinData["SWID"]}|{$penguinData["Username"]}|{$encryptedPassword}|1|45|2|false|true|{$loginTime}%{$confirmationHash}%{$friendsKey}%101,1%{$penguinData["Email"]}%");
     }
 }
Esempio n. 2
0
 protected function handleRandomKey($socket)
 {
     $penguin = $this->penguins[$socket];
     if ($penguin->handshakeStep === "versionCheck") {
         $penguin->randomKey = Hashing::generateRandomKey();
         $penguin->send("<msg t='sys'><body action='rndK' r='-1'><k>" . $penguin->randomKey . "</k></body></msg>");
         $penguin->handshakeStep = "randomKey";
         return true;
     }
     $this->removePenguin($penguin);
 }