コード例 #1
0
 private function commonInitiate()
 {
     $this->_config_channel = GameManager::getChannel($this->_data["uid"]);
     $config_temp = new Zend_Config(array('database' => array('adapter' => $this->_config_channel->adapter, 'params' => $this->_config_channel->params)));
     $db_channel = GameManager::getDbConnection($config_temp, $this->_config_channel->dbname);
     $this->_db_channel = $db_channel;
     $config_temp = new Zend_Config(array('database' => array('adapter' => 'pdo_mysql', 'params' => array('host' => $this->_config_channel->params->host, 'dbname' => "information_schema", 'username' => $this->_config_channel->params->username, 'password' => $this->_config_channel->params->password))));
     $db_channel_schema = GameManager::getDbConnection($config_temp, $this->_config_channel->dbname . ".information_schema");
     $this->_db_channel_schema = $db_channel_schema;
     return $this;
 }
コード例 #2
0
 public function init()
 {
     $this->view->start_time = microtime(true);
     $db_static = Zend_Registry::get('db_static');
     $this->view->metadata = Zend_Registry::get('metadata');
     $this->view->config = Zend_Registry::get('config');
     $this->view->self_root = Zend_Registry::get('self_root');
     $this->view->self = $this->view->self_root . $this->view->page;
     $this->view->request_uri = getenv('REQUEST_URI');
     $this->view->client = Zend_Registry::get('client');
     $this->view->controller_name = Zend_Registry::get('controller_name');
     $this->view->action = $this->getRequest()->getActionName();
     $this->view->request_id = 0;
     $this->view->uid = 0;
     $request_data = $this->getRequestData();
     // [ADD] by Puttipong Nakapat to allow bypass signature system for DEBUG purpose.
     //if($request_data["status"] != 200) {
     //	$this->sendResponse($request_data);
     //}
     // Specify name of controller that does not require login to connect.
     if (!in_array($this->view->controller_name, array('account', 'info', 'stat'))) {
         if (!isset($request_data["data"]["token"])) {
             $data = array("data" => null, "status" => 305, "status_msg" => "[BaseController] Input Wrong Format");
             $this->sendResponse($data);
         } else {
             try {
                 $uid = GameManager::getUidByToken($request_data["data"]["token"]);
                 if ($uid == 0) {
                     $data = array("data" => null, "status" => 302, "status_msg" => "[BaseController] Session Not Found");
                     $this->sendResponse($data);
                 }
                 $users = new Users();
                 $me = $users->init($uid);
                 $authorize = $me->_data["authorize"];
                 if ($me->_data['status'] == "banned") {
                     $data = array("data" => null, "status" => 601, "status_msg" => "[BaseController] Account was banned");
                     $this->sendResponse($data);
                 }
                 if (!$db_static->fetchRow("select * from db_controller where name=? and {$authorize}='yes'", $this->view->controller_name)) {
                     $data = array("data" => null, "status" => 404, "status_msg" => "[BaseController] API Not Found");
                     $this->sendResponse($data);
                 }
                 $this->view->uid = $me->_data["uid"];
                 //$this->rewriteCreatureMax($me);
                 Zend_Registry::set('me', $me);
             } catch (Exception $e) {
                 $data = array("data" => null, "status" => 500, "status_msg" => "[BaseController] Internal Server Error:" . $e);
                 $this->sendResponse($data);
             }
         }
     }
     //checking
     $this->view->request_data = $request_data;
 }
コード例 #3
0
 private function extractInfo($inResult, $inCommand, $inToken)
 {
     $db_share = Zend_Registry::get('db_share');
     $info = array();
     if ($inCommand == 'news') {
         foreach ($inResult as $row) {
             array_push($info, array('news_id' => $row['news_id'], 'author_id' => 0, 'author_name' => '', 'date' => $row['date'], 'title' => $this->view->dict[$row['codename'] . '.TITLE'], 'brief' => $this->view->dict[$row['codename'] . '.BRIEF'], 'detail' => $this->view->dict[$row['codename'] . '.DETAIL']));
         }
     } elseif ($inCommand == 'articles') {
         foreach ($inResult as $row) {
             array_push($info, array('articles_id' => $row['articles_id'], 'author_id' => 0, 'author_name' => '', 'date' => $row['date'], 'title' => $this->view->dict[$row['codename'] . '.TITLE'], 'brief' => $this->view->dict[$row['codename'] . '.BRIEF'], 'detail' => $this->view->dict[$row['codename'] . '.DETAIL']));
         }
     } elseif ($inCommand == 'campaign') {
         $uid = GameManager::getUidByToken($inToken);
         foreach ($inResult as $row) {
             $recent_signatures = array();
             if ($result_signatures = $db_share->fetchAll('SELECT * FROM signatures WHERE enable=? AND campaign_id=? ORDER BY date DESC, time DESC LIMIT 30', array('yes', $row['campaign_id']))) {
                 foreach ($result_signatures as $c) {
                     array_push($recent_signatures, array('campaign_id' => $c['campaign_id'], 'uid' => $c['uid'], 'username' => $c['username'], 'first_name' => $c['first_name'], 'last_name' => $c['last_name'], 'date' => $c['date'], 'time' => $c['time']));
                 }
             }
             $comments = array();
             if ($result_comment = $db_share->fetchAll('SELECT * FROM comments WHERE enable=? AND campaign_id=? ORDER BY date DESC, time DESC LIMIT 30', array('yes', $row['campaign_id']))) {
                 foreach ($result_comment as $c) {
                     array_push($comments, array('campaign_id' => $c['campaign_id'], 'uid' => $c['uid'], 'username' => $c['username'], 'display_name' => $c['display_name'], 'display_comment' => $c['display_comment'], 'date' => $c['date'], 'time' => $c['time']));
                 }
             }
             $timeline = array();
             if ($result_timeline = $db_share->fetchAll('SELECT * FROM timeline WHERE enable=? AND campaign_id=? ORDER BY date DESC, time DESC, id DESC LIMIT 30', array('yes', $row['campaign_id']))) {
                 foreach ($result_timeline as $c) {
                     array_push($timeline, array('campaign_id' => $c['campaign_id'], 'uid' => $c['uid'], 'username' => $c['username'], 'display_name' => $c['display_name'], 'display_content' => $this->view->dict[$c['display_content'] . '.DETAIL'], 'date' => $c['date'], 'time' => $c['time'], 'icon' => $c['icon'], 'icon_color' => $c['icon_color'], 'image' => $c['image'], 'image_url' => $c['image_url']));
                 }
             }
             $letters = array();
             $disparage_name = explode('|', $row['disparage_name']);
             $disparage_letter = explode('|', $row['disparage_letter']);
             foreach ($disparage_letter as $j => $l) {
                 if ($l != 'none') {
                     array_push($letters, array('name' => $disparage_name[$j], 'content' => $this->view->dict[$l]));
                 }
             }
             $already_support = false;
             if ($uid) {
                 $users = new Users();
                 $me = $users->init($uid);
                 $already_support = ($record = $me->_db_channel->fetchRow('SELECT id FROM signatures WHERE campaign_id=? AND uid=? LIMIT 1', array($row['campaign_id'], $uid))) ? true : false;
             }
             array_push($info, array('campaign_id' => $row['campaign_id'], 'author_id' => 0, 'author_name' => '', 'date' => $row['date'], 'title' => $this->view->dict[$row['codename'] . '.TITLE'], 'brief' => $this->view->dict[$row['codename'] . '.BRIEF'], 'detail' => $this->view->dict[$row['codename'] . '.DETAIL'], 'copied_head' => $this->view->dict[$row['codename'] . '.COPIED_HEAD'], 'copied_full' => $this->view->dict[$row['codename'] . '.COPIED_FULL'], 'target' => $row['target'], 'signatures' => $row['signatures'], 'recent_signatures' => $recent_signatures, 'comments' => $comments, 'letters' => $letters, 'timeline' => $timeline, 'already_support' => $already_support));
         }
     }
     return $info;
 }
コード例 #4
0
 public function infoAction()
 {
     $request_data = $this->view->request_data["data"];
     $token = isset($request_data['token']) ? $request_data['token'] : "";
     try {
         $uid = GameManager::getUidByToken($token);
         $me = GameManager::getUserObject($uid);
         $response = array("data" => $me->_data, "status" => ReturnStatus::SUCCESS, "status_msg" => "Success");
         parent::sendResponse($response);
     } catch (Exception $e) {
         $data = array("data" => null, "status" => ReturnStatus::INTERNAL_SERVER_ERROR, "status_msg" => "Internal Server Error:" . $e);
         parent::sendResponse($data);
     }
 }
コード例 #5
0
ファイル: TeamPvP.php プロジェクト: Skull3x/TeamPvP
 public function onInteract(PlayerInteractEvent $event)
 {
     $p = $event->getPlayer();
     $teams = array("red", "blue");
     if ($event->getBlock()->getX() === $this->yml["sign_join_x"] && $event->getBlock()->getY() === $this->yml["sign_join_y"] && $event->getBlock()->getZ() === $this->yml["sign_join_z"]) {
         if (count($this->blues) !== 5 and count($this->reds) !== 5) {
             $this->setTeam($p->getName(), $teams[array_rand($teams, 1)]);
             $s = new GameManager();
             $s->run();
         } else {
             $p->sendMessage($this->yml["teams_are_full_message"]);
         }
     }
 }
コード例 #6
0
 public static function getUserByPlayerName($playername)
 {
     $config = Zend_Registry::get("config");
     $sql = " select uid from player where playername = ? ";
     $playerData = array();
     //find user by name
     for ($i = 1; $i <= $config->total_channel; $i++) {
         $chkey = "channel{$i}";
         $config_temp = new Zend_Config(array('database' => array('adapter' => 'pdo_mysql', 'params' => array('host' => $config->db->{$chkey}->params->host, 'dbname' => $config->db->{$chkey}->params->dbname, 'username' => $config->db->{$chkey}->params->username, 'password' => $config->db->{$chkey}->params->password))));
         $db_channel = GameManager::getDbConnection($config_temp, $config->db->{$chkey}->params->dbname);
         $playerData = $db_channel->fetchRow($sql, $playername);
         if ($playerData) {
             break;
         }
     }
     if ($playerData) {
         return self::getUserObject($playerData["uid"]);
     } else {
         return null;
     }
 }
コード例 #7
0
 public static function getRegisterSetting()
 {
     $db_static = Zend_Registry::get('db_static');
     $db_users = Zend_Registry::get('db_users');
     $db_users_schema = Zend_Registry::get('db_users_schema');
     //check uid
     $user_total = $db_users_schema->fetchOne("select MAX(AUTO_INCREMENT) from TABLES where TABLE_NAME like '%user%'");
     $current_setting = GameManager::getChannel($user_total);
     if (!$current_setting) {
         //passed
         $data = array("data" => null, "status" => ReturnStatus::INTERNAL_SERVER_ERROR, "status_msg" => "Input Wrong Format [NOT FOUND AVAILABLE CHANNEL]");
         parent::sendResponse($data);
     }
     if (!($found = $db_users_schema->fetchRow("select * from TABLES where TABLE_NAME =? ", $current_setting->usertable))) {
         //passed
         $data = array("data" => null, "status" => ReturnStatus::INTERNAL_SERVER_ERROR, "status_msg" => "Server not ready for registration");
         parent::sendResponse($data);
     }
     return $current_setting;
 }