Exemple #1
0
 protected function _login()
 {
     $name = Dura::post('name');
     $icon = Dura::post('icon');
     $language = Dura::post('language');
     $name = trim($name);
     $icon = trim($icon);
     $language = trim($language);
     if ($name === '') {
         throw new Exception(t("Please input name."));
     }
     if (mb_strlen($name) > 10) {
         throw new Exception(t("Name should be less than 10 letters."));
     }
     $token = Dura::post('token');
     if (!Dura_Class_Ticket::check($token)) {
         throw new Exception(t("Login error happened."));
     }
     if (!isset($this->icons[$icon])) {
         $icons = array_keys($this->icons);
         $icon = reset($icons);
     }
     $user =& Dura_Class_User::getInstance();
     $user->login($name, $icon, $language);
     Dura_Class_Ticket::destory();
     Dura::redirect('lounge');
 }
 protected function _message()
 {
     $message = Dura::post('message');
     $message = trim($message);
     $messageId = md5(microtime() . mt_rand());
     if (!$message) {
         return;
     }
     foreach ($this->roomModels as $roomId => $roomModel) {
         $talk = $roomModel->addChild('talks');
         $talk->addChild('id', $messageId);
         $talk->addChild('uid', Dura::user()->getId());
         $talk->addChild('name', Dura::user()->getName());
         $talk->addChild('message', $message);
         $talk->addChild('icon', Dura::user()->getIcon());
         $talk->addChild('time', time());
         $id = Dura::user()->getId();
         foreach ($roomModel->users as $user) {
             if ($id == (string) $user->id) {
                 $user->update = time();
             }
         }
         while (count($roomModel->talks) > DURA_LOG_LIMIT) {
             unset($roomModel->talks[0]);
         }
         $this->roomHandler->save($roomId, $roomModel);
     }
     Dura::redirect('admin_announce');
 }
 protected function _getInput()
 {
     $this->input['name'] = Dura::post('name');
     $this->input['limit'] = Dura::post('limit');
     $this->input['language'] = Dura::post('language');
     $this->input['name'] = trim($this->input['name']);
     $this->input['language'] = trim($this->input['language']);
 }
Exemple #4
0
 protected function _login()
 {
     $name = Dura::post('name');
     $pass = Dura::post('pass');
     $name = trim($name);
     $pass = trim($pass);
     if ($name === '') {
         throw new Exception(t("Please input name."));
     }
     $token = Dura::post('token');
     if (!Dura_Class_Ticket::check($token)) {
         throw new Exception(t("Login error happened."));
     }
     if ($name !== DURA_ADMIN_NAME or $pass !== DURA_ADMIN_PASS) {
         throw new Exception(t("ID or password is wrong."));
     }
     $user =& Dura_Class_User::getInstance();
     $user->login($name, 'admin', DURA_LANGUAGE, true);
     Dura_Class_Ticket::destory();
     Dura::redirect('lounge');
 }
Exemple #5
0
 protected function _banUser()
 {
     if (!$this->_isHost()) {
         die(t("You are not host."));
     }
     $userId = Dura::post('ban_user');
     if ($userId === '') {
         die(t("User is invaild."));
     }
     $userFound = false;
     $userOffset = 0;
     foreach ($this->roomModel->users as $user) {
         if ($userId == (string) $user->id) {
             $userFound = true;
             $userName = (string) $user->name;
             break;
         }
         $userOffset++;
     }
     if (!$userFound) {
         die(t("User not found."));
     }
     unset($this->roomModel->users[$userOffset]);
     $this->_npcDisconnect($userName);
     $this->roomHandler->save($this->id, $this->roomModel);
     die(t("Banned {1}.", $userName));
 }