need to sometimes commit :-)
This commit is contained in:
@ -18,7 +18,7 @@ class db
|
||||
private $database = "db351634_avionpoeme";
|
||||
public $connect;
|
||||
public $result;
|
||||
|
||||
// avion
|
||||
public $uid;
|
||||
public $message;
|
||||
public $expeMail;
|
||||
@ -39,6 +39,11 @@ class db
|
||||
public $deliveryTime;
|
||||
public $deliveryTZ;
|
||||
public $deliveryTimeServer;
|
||||
public $deliveryMethod;
|
||||
// peripeties
|
||||
public $idPeripetie;
|
||||
public $datePeripetie;
|
||||
public $effetPeripetie;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@ -104,28 +109,32 @@ class db
|
||||
$query .= $this->protect($this->color) . "', ";
|
||||
$query .= "FROM_UNIXTIME(" . $this->protect($this->deliveryTime) . "), '";
|
||||
$query .= $this->protect($this->deliveryTZ) . "', ";
|
||||
$query .= "FROM_UNIXTIME(" . $this->protect($this->deliveryTimeServer) . ")";
|
||||
$query .= "FROM_UNIXTIME(" . $this->protect($this->deliveryTimeServer) . "), '";
|
||||
$query .= $this->protect($this->deliveryMethod) . "'";
|
||||
$query .= ")";
|
||||
print_r($this);
|
||||
//print_r($this);
|
||||
$this->query($query);
|
||||
echo "{'uid':'" . $this->connect->insert_id . "'}";
|
||||
$this->uid = $this->connect->insert_id;
|
||||
echo "{'uid':'" . $this->uid . "'}";
|
||||
|
||||
//newPeripetie($uid);
|
||||
}
|
||||
|
||||
function getCurrentPlanes()
|
||||
{
|
||||
$query = "SELECT idAvion as uid, UNIX_TIMESTAMP(deliveryTime) as deliveryTime, deliveryTZ, destLat, destLon, destName, UNIX_TIMESTAMP(startTime) as startTime, startTZ, startLon, startLat, startName, color FROM avionpoeme WHERE deliveryTimeServer>NOW() AND public='1'";
|
||||
$query = "SELECT idAvion as uid, UNIX_TIMESTAMP(deliveryTime) as deliveryTime, deliveryTZ, destLat, destLon, destName, UNIX_TIMESTAMP(startTime) as startTime, startTZ, startLon, startLat, startName, color FROM avionpoeme WHERE deliveryTimeServer>NOW()";
|
||||
$this->query($query);
|
||||
$planes = $this->result->fetch_all(MYSQLI_ASSOC);
|
||||
print json_encode($planes);
|
||||
return planes;
|
||||
return $planes;
|
||||
}
|
||||
|
||||
function getAnthology($page=0)
|
||||
{
|
||||
$query = "SELECT COUNT(*) as count FROM avionpoeme WHERE public='1'";
|
||||
$query = "SELECT COUNT(*) as count FROM avionpoeme WHERE deliveryTimeServer<NOW() AND public='1'";
|
||||
$this->query($query);
|
||||
$result = $this->result->fetch_assoc();
|
||||
$n_pages = round($result["count"] / RESULTS_BY_PAGE + 1, 0, PHP_ROUND_HALF_DOWN);
|
||||
$n_pages = floor(($result["count"] / RESULTS_BY_PAGE))+1;
|
||||
if ($page <= 0) //renvoie le nombre de ligne d'anthologie
|
||||
{
|
||||
print '{"nAnthology":"' . $result["count"] . '","nPages":"' . $n_pages .'"}';
|
||||
@ -133,7 +142,7 @@ class db
|
||||
}else //renvoie les lignes d'anthologie
|
||||
{
|
||||
if ($page > $n_pages) $page=$n_pages;
|
||||
$query = "SELECT deliveryTime, deliveryTZ, destName, startTime, startTZ, startName, message FROM avionpoeme WHERE public='1' LIMIT " . ($page-1)*RESULTS_BY_PAGE . "," . RESULTS_BY_PAGE . " ORDER BY startTime ASC";
|
||||
$query = "SELECT UNIX_TIMESTAMP(startTime) as startTime, startTZ, startName, message, UNIX_TIMESTAMP(deliveryTime) as deliveryTime , deliveryTZ, destName FROM avionpoeme WHERE deliveryTimeServer<NOW() AND public='1' ORDER BY startTime ASC LIMIT " . ($page-1)*RESULTS_BY_PAGE . "," . RESULTS_BY_PAGE;
|
||||
$this->query($query);
|
||||
$planes = $this->result->fetch_all(MYSQLI_ASSOC);
|
||||
print json_encode($planes, JSON_FORCE_OBJECT);
|
||||
@ -141,6 +150,44 @@ class db
|
||||
}
|
||||
}
|
||||
|
||||
function savePeripetie()
|
||||
{
|
||||
global $db;
|
||||
$query = "INSERT INTO avionPeripetie VALUES ('0','";
|
||||
$query .= $this->protect($this->uid) . ",'";
|
||||
$query .= $this->protect($this->idPeripetie) . "', '";
|
||||
$query .= $this->protect($this->datePeripetie) . "', '";
|
||||
$query .= $this->protect($this->effetPeripetie) . "', '";
|
||||
$query .= $this->protect($this->expeMail) . "', '";
|
||||
$query .= $this->protect($this->destMail) . "')";
|
||||
echo $query;
|
||||
//$this->query($query);
|
||||
}
|
||||
|
||||
function newPeripetie()
|
||||
{
|
||||
global $db;
|
||||
mt_getrandmax ( );
|
||||
$query = "SELECT COUNT(*) as count FROM peripeties";
|
||||
$this->query($query);
|
||||
$result = $this->result->fetch_assoc();
|
||||
$db->idPeripetie = round(mt_rand(1,$result["count"]));
|
||||
$query = "SELECT * FROM peripeties WHERE idPeripetie='" . $db->idPeripetie . "'";
|
||||
$query = "SELECT COUNT(*) as count FROM peripeties";
|
||||
$this->query($query);
|
||||
$result = $this->result->fetch_assoc();
|
||||
//calcul de la probabilité de la péripétie
|
||||
|
||||
|
||||
//ajustement de l'effet
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->savePeripetie();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user