Example #1
0
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '');
     while (true) {
         if (is_null($this->getHttp()->getPost('password'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Password obligatoire";
             break;
         }
         if ($this->getHttp()->getPost('password') != Conf::common()['server']['passwordAdmin']) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Mauvais password";
             break;
         }
         BaseStore::reset();
         JsonServer::getIntance()->setPartie(PartieBusiness::GetById(JsonServer::getIntance()->getPartie()->getId()));
         JsonServer::getIntance()->getPartie()->warm();
         CacheCarte::reset();
         break;
     }
     $this->output(json_encode($ret));
 }
Example #2
0
/**
 * Démarre le serveur
 */
function start()
{
    foreach (PartieBusiness::partiesActives() as $partie) {
        /** @var Partie $partie */
        popen(SCRIPT_TO_LAUNCH . '=' . $partie->getId() . ' >> ' . Conf::common()['path']['serverLogs'] . '/' . $partie->getId() . '.log 2>&1 &', 'r');
    }
}
Example #3
0
 /**
  *
  * Refait la connexion à la DB
  * @return void
  */
 public function reconnectDb()
 {
     DbHandler::connect(Conf::common()['DB']['HOST'], Conf::common()['DB']['DB'], Conf::common()['DB']['USER'], Conf::common()['DB']['PASS']);
 }
Example #4
0
#!/usr/bin/php
<?php 
namespace fr\gilman\nj;

use fr\gilman\nj\common\bb\DbHandler;
use fr\gilman\nj\common\bb\store\PartieStore;
use fr\gilman\nj\server\Conf;
use fr\gilman\nj\server\JsonServer;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
require dirname(__FILE__) . '/vendor/autoload.php';
require_once dirname(__FILE__) . '/models/Conf.php';
Conf::initCommon(dirname(__FILE__) . '/common.ini');
require_once Conf::common()['path']['commonClasses'] . '/inc.php';
DbHandler::connect(Conf::common()['DB']['HOST'], Conf::common()['DB']['DB'], Conf::common()['DB']['USER'], Conf::common()['DB']['PASS']);
$options = getopt('', array("idPartie:"));
if (!isset($options['idPartie'])) {
    echo "Paramètre idPartie obligatoire\n";
    exit;
}
$jsonServer = JsonServer::getIntance();
$jsonServer->setPartie(PartieStore::getById($options['idPartie']));
$jsonServer->getPartie()->warm();
$server = IoServer::factory(new HttpServer($jsonServer), $jsonServer->getPartie()->getPort());
$server->run();