game/pages/flotte_detail.php

60 lines
2.7 KiB
PHP

<?php
session_start();
$id=$_SESSION['id'];
$galaxy=$_SESSION['galaxy'];
$ss=$_SESSION['ss'];
$pos=$_SESSION['pos'];
$_SESSION['dernPage'] = 'flotte.php';
include_once('common.php');
require('../template.php');
$template = new Template('../templates/'.$templates);
require('../connectBDD.php');
/* Page Flotte
*
*/
$template->set_filenames(array('flotte' => 'flotte3.tpl'));
if (!isset($_GET['ref']) || !is_numeric($_GET['ref'])) {
header('Location: flotte.php');
exit;
}
else $ref = $_GET['ref'];
$req = mysql_query("SELECT * FROM flottes WHERE `id_user` = '$id' AND `id` = '$ref'");
if (mysql_num_rows($req) != 1) {
header('Location: flotte.php');
exit;
}
else {
$resultat = mysql_fetch_array($req);
if (isset($_GET['act']) && $_GET['act'] == 'ret') {
//Calcul du temps passé depuis le lancement de la flotte
$tpsDD = time()-$resultat['start_time'];
if ($resultat['end_time'] < $tpsDD) {
$tpsDD = $resultat['end_time'] - ($tpsDD - $resultat['end_time']);
}
mysql_query("UPDATE `flottes` SET `mission` = '6', `end_time` = '$tpsDD' WHERE `id_user` = '$id' AND `id` = '$ref';");
}
$template->assign_vars(array('NOM' => $resultat['nom'], 'MISSION' => txtmission($resultat['mission']), 'NOMBRE' => $resultat['nb_vais'], 'DATEDEP' => dateFR(date('/D d M Y/Hi/',$resultat['start_time'])), 'DATEARR' => dateFR(date('/D d M Y/Hi/',$resultat['start_time']+$resultat['end_time'])), 'DATERET' => dateFR(date('/D d M Y/Hi/',$resultat['start_time']+$resultat['end_time']*2)), 'LIEUDEP' => $resultat['start_galaxie'].':'.$resultat['start_ss'].':'.$resultat['start_position'], 'LIEUARR' => $resultat['end_galaxie'].':'.$resultat['end_ss'].':'.$resultat['end_position'], 'RETOUR' => '<form method="post" action="flotte_detail.php?ref='.$ref.'&act=ret"><input type="submit" value="Forcer le retour" /></form>'));
}
/* FIN Page Flotte
*
*/
$result = mysql_query("SELECT * FROM version ORDER BY temps DESC");
$data = mysql_fetch_array($result);
$version = $data['version'];
mysql_close();
$template->set_filenames(array('base' => 'base.tpl'));
$template->assign_vars(array('PUB' => $PUB, 'VERSION' => $version, 'RES_IMAGE' => $RES_IMAGE, 'NOM_METAL' => strtolower($NOM_METAL), 'NOM_CRISTAL' => strtolower($NOM_CRISTAL), 'NOM_HYDROGENE' => strtolower($NOM_HYDROGENE), 'NOM_ENERGIE' => strtolower($NOM_ENERGIE), 'RES_METAL' => $RES_METAL, 'RES_CRISTAL' => $RES_CRISTAL, 'RES_HYDROGENE' => $RES_HYDROGENE, 'RES_ENERGIE' => $RES_ENERGIE));
for ($i=0 ; $i<count($Aplan_value) ; $i++) {
$template->assign_block_vars('planetes',array('RES_VALUE' => $Aplan_value[$i], 'RES_MORE' => $Aplan_more[$i], 'RES_IMG' => $Aplan_img[$i], 'RES_NOM' => $Aplan_nom[$i], 'RES_REF' => $Aplan_ref[$i]));
}
$template->assign_var_from_handle('CONTENU', 'flotte');
$template->pparse('base');
?>