<?php
if(!defined('INDEX')) { header('Location: ../'); exit; }
$page = 'accueil';
$titre = 'Accueil';

//Affichage de l'alliance du joueur
$bdd->connexion();
$alli = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = '".$queryUser['id_alliance']."';");

//On regarde si le joueur a une flotte en vue
$radar = array();
$nbPlan = count($queryPlanetes);
$detect = $queryUser['detection']*1800;
for($i = 0; $i < $nbPlan; $i++){
	$end_galaxie = $queryPlanetes[$i]['galaxie'];
	$end_ss = $queryPlanetes[$i]['ss'];
	$end_position = $queryPlanetes[$i]['position'];
	$radar[] = array($bdd->query("SELECT F.mission, F.start_galaxie, F.start_ss, F.start_position, F.start_time, F.end_time, F.start_time + F.end_time - ".time()." AS arrive_time, P.nom_planete, U.pseudo FROM $table_flottes F INNER JOIN $table_planete P ON P.galaxie = F.start_galaxie AND P.ss = F.start_ss AND P.position = F.start_position INNER JOIN $table_user U ON U.id = P.id_user WHERE F.effectue != '1' AND F.end_galaxie = '$end_galaxie' AND F.end_ss = '$end_ss' AND F.end_position = '$end_position' AND F.id_user != $id_user AND F.start_time + F.end_time - ".time()." <= $detect;"), array($queryPlanetes[$i]['nom_planete'], $queryPlanetes[$i]['galaxie'], $queryPlanetes[$i]['ss'], $queryPlanetes[$i]['position']));
}

$bdd->deconnexion();

//Affichage des informations sur la planète
$diametre = separerNombres($planete->cases * 92);
$Classpoints = separerNombres($queryUser['points']);

$template->assign('mail', $queryMail);
$template->assign('radar',$radar);
$template->assign('diametre',$diametre);
$template->assign('points',$Classpoints);
$template->assign('alliance', $alli);
?>