Ejemplo n.º 1
0
 public function load()
 {
     parent::load();
     $this->SNdata = 0;
     $this->success = FALSE;
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($this->isPost()) {
         if ($this->globalModel->isGameOver()) {
             $this->redirect("over.php");
         } else {
             $name = trim($_POST['name']);
             $email = trim($_POST['email']);
             $pwd = trim($_POST['pwd']);
             $this->err[0] = strlen($name) < 3 ? register_player_txt_notless3 : "";
             if ($this->err[0] == "") {
                 $this->err[0] = preg_match("/[:,\\. \\n\\r\\t\\s]+/", $name) ? register_player_txt_invalidchar : "";
             }
             if ($name == "[ally]" || $name == "admin" || $name == "administrator" || $name == "مدير" || $name == "تتار" || $name == "التتار" || $name == "دعم" || $name == "الدعم" || $name == $this->appConfig['system']['adminName'] || $name == tatar_tribe_player) {
                 $this->err[0] = register_player_txt_reserved;
             }
             $this->err[1] = !preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $email) ? register_player_txt_invalidemail : "";
             $this->err[2] = strlen($pwd) < 4 ? register_player_txt_notless4 : "";
             $this->err[3] = !isset($_POST['tid']) || $_POST['tid'] != 1 && $_POST['tid'] != 2 && $_POST['tid'] != 3 && $_POST['tid'] != 6 && $_POST['tid'] != 7 ? "<li>" . register_player_txt_choosetribe . "</li>" : "";
             $this->err[3] .= !isset($_POST['kid']) || !is_numeric($_POST['kid']) || $_POST['kid'] < 0 || 4 < $_POST['kid'] ? "<li>" . register_player_txt_choosestart . "</li>" : "";
             if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1]) || 0 < strlen($this->err[2]) || 0 < strlen($this->err[3])) {
                 return;
             }
             $m = new RegisterModel();
             $this->err[0] = $m->isPlayerNameExists($name) ? register_player_txt_usedname : "";
             $this->err[1] = $m->isPlayerEmailExists($email) ? register_player_txt_usedemail : "";
             $this->err[1] = $m->isPlayerIpExists($ip) ? "Canot Register IP address already in use" : "";
             if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1])) {
                 $m->dispose();
             } else {
                 $ip = $_SERVER['REMOTE_ADDR'];
                 $villageName = new_village_name_prefix . " " . $name;
                 #removed 'PLAYERTYPE_NORMAL' right after map_size thing. Dunno why it doesnt make him player_type = 1 but owke.
                 $result = $m->createNewPlayer($name, $email, $pwd, $_POST['tid'], $_POST['kid'], $villageName, $this->setupMetadata['map_size'], 1, 1, $this->SNdata, $ip);
                 if ($result['hasErrors']) {
                     $this->err[3] = register_player_txt_fullserver;
                     $m->dispose();
                 } else {
                     $m->dispose();
                     $link = WebHelper::getbaseurl() . "activate.php?id=" . $result['activationCode'];
                     $to = $email;
                     $from = $this->appConfig['system']['email'];
                     $subject = register_player_txt_regmail_sub;
                     $message = sprintf(register_player_txt_regmail_body, $name, $name, $pwd, $link, $link);
                     WebHelper::sendmail($to, $from, $subject, $message);
                     $this->success = TRUE;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function load()
 {
     parent::load();
     if (!$this->globalModel->isGameOver()) {
         exit(0);
     } else {
         $m = new ProfileModel();
         $this->playerData = $m->getWinnerPlayer();
         $m->dispose();
     }
 }
Ejemplo n.º 3
0
 public function load()
 {
     parent::load();
     $m = new PasswordModel();
     if ($this->isPost() && isset($_POST['id']) && isset($_POST['email']) && is_numeric($_POST['id'])) {
         $playerId = intval($_POST['id']);
         $email = $_POST['email'];
         $this->pageState = $m->isPlayerIdHasEmail($playerId, $email) ? 3 : 2;
         if ($this->pageState == 3) {
             $name = $m->getPlayerName($playerId);
             $newPassword = substr(md5(dechex($playerId * mt_rand(10, 100))), mt_rand(1, 5), 7);
             $n = dechex(hexdec($newPassword) ^ hexdec(substr(md5($name), 2, 7)));
             $link = WebHelper::getbaseurl() . "password.php?id=" . $playerId . "&n=" . $n . "&c=" . substr(md5(dechex($playerId) . $name . "777"), 7, 7);
             $to = $email;
             $from = $this->appConfig['system']['email'];
             $subject = forget_password_subject;
             $message = sprintf(forget_password_body, $name, $name, $newPassword, $link, $link);
             WebHelper::sendmail($to, $from, $subject, $message);
         }
     } else {
         if (isset($_GET['id']) && is_numeric($_GET['id'])) {
             $this->playerId = intval($_GET['id']);
             $this->pageState = $m->isPlayerIdExists($this->playerId) ? 1 : 0 - 1;
             if (isset($_GET['n']) && trim($_GET['n']) != "" && isset($_GET['c'])) {
                 if ($this->pageState == 1) {
                     $name = $m->getPlayerName($this->playerId);
                     if (trim($_GET['c']) == substr(md5(dechex($this->playerId) . $name . "777"), 7, 7)) {
                         $newPassword = dechex(hexdec($_GET['n']) ^ hexdec(substr(md5($name), 2, 7)));
                         $m->setPlayerPassword($this->playerId, $newPassword);
                         $this->pageState = 4;
                     } else {
                         $this->pageState = 5;
                     }
                 } else {
                     $this->pageState = 5;
                 }
             }
         }
     }
     $m->dispose();
 }
Ejemplo n.º 4
0
 public function load()
 {
     parent::load();
     $m = new ActivateModel();
     if (isset($_GET['id'])) {
         $this->playerStatus = $m->doActivation($_GET['id']) ? 1 : 2;
     } else {
         if (isset($_GET['uid'])) {
             $this->uid = intval($_GET['uid']);
             $row = $m->getPlayerData($this->uid);
             if ($row == NULL) {
                 $this->uid = 0 - 1;
             } else {
                 $this->uname = $row['name'];
                 if ($this->isPost() && isset($_POST['pw']) && md5($_POST['pw']) == $row['pwd']) {
                     $mj = new QueueJobModel();
                     $mj->deletePlayer($this->uid);
                     $this->playerStatus = 3;
                 }
             }
         }
     }
     $m->dispose();
 }