コード例 #1
0
ファイル: JsonCarte.php プロジェクト: eleparquier/nj_server
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '');
     while (true) {
         if (is_null($this->getHttp()->getPost('idCentre')) || is_null($this->getHttp()->getPost('largeur')) || is_null($this->getHttp()->getPost('hauteur'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Données manquantes";
             break;
         }
         $token = null;
         if (!is_null($this->getHttp()->getCookie('token'))) {
             $token = $this->getHttp()->getCookie('token');
         } elseif ($this->getHttp()->getGet('token')) {
             $token = $this->getHttp()->getGet('token');
         } elseif ($this->getHttp()->getPost('token')) {
             $token = $this->getHttp()->getPost('token');
         }
         if (is_null($token)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Pas de token de session";
             break;
         }
         $session = SessionStore::getByToken($token);
         $carte = new Carte($session->getPartie(), HexaStore::getById($this->getHttp()->getPost('idCentre')), $session->getJoueur(), $this->getHttp()->getPost('largeur'), $this->getHttp()->getPost('hauteur'));
         $this->output($carte->getJson());
         break;
     }
 }
コード例 #2
0
 /**
  * Met les Sessions de la collection dans le SessionStore
  * Vérifie si le Session était déjà storé, dans ce cas, remplace le Session concerné par celui du SessionStore
  */
 public function store()
 {
     $replaces = array();
     foreach ($this as $offset => $session) {
         /** @var Session $session */
         if (SessionStore::exists($session->getId())) {
             $replaces[$offset] = $session;
         } else {
             SessionStore::store($session);
         }
     }
     unset($offset);
     foreach ($replaces as $offset => $session) {
         $this->offsetSet($offset, SessionStore::getById($session->getId()));
     }
 }
コード例 #3
0
 /**
  * Renvoie la session définie par le cookie (HTTP seulement)
  * @return Session
  */
 public static function getCookieSession()
 {
     if (!isset($_COOKIE['token'])) {
         return null;
     }
     if (!is_null(SessionStore::getSessionCourante())) {
         return SessionStore::getSessionCourante();
     }
     $req = "SELECT * FROM session WHERE token = '" . addslashes($_COOKIE['token']) . "';";
     $ret = DbHandler::objFromQuery($req, 'Session');
     if (is_null($ret)) {
         return null;
     }
     /** @var Session $ret */
     $ret->setTimeSession(time());
     $ret->save();
     SessionStore::setSessionCourante($ret);
     return $ret;
 }
コード例 #4
0
ファイル: EditUnite.php プロジェクト: eleparquier/nj_server
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '', 'debug' => '');
     while (true) {
         if (is_null($this->getHttp()->getGet('idUnite'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Données manquantes (idUnite)";
             break;
         }
         $idUnite = $this->getHttp()->getGet('idUnite');
         $token = null;
         if (!is_null($this->getHttp()->getCookie('token'))) {
             $token = $this->getHttp()->getCookie('token');
         } elseif ($this->getHttp()->getGet('token')) {
             $token = $this->getHttp()->getGet('token');
         } elseif ($this->getHttp()->getPost('token')) {
             $token = $this->getHttp()->getPost('token');
         }
         if (is_null($token)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Pas de token de session";
             break;
         }
         $session = SessionStore::getByToken($token);
         $unite = UniteStore::getById($idUnite);
         if (is_null($unite)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Unite inconnue";
             break;
         }
         if ($unite->getQg()->getIdJoueur() != $session->getIdJoueur()) {
             $ret['error'] = 3;
             $ret['errorMsg'] = "Unite inconnue";
             break;
         }
         $nlleUnite = UniteBusiness::getById($idUnite);
         $unite->setIdQgTransfert($nlleUnite->getIdQgTransfert());
         $unite->resetJson();
         CacheCarte::$infosVisibles = array();
         break;
     }
     $this->output('rienDuTout(' . json_encode($ret) . ');');
 }