HB/pages/chantier_terrestre_validation.php

94 lines
2.6 KiB
PHP
Raw Normal View History

2007-11-13 11:00:00 +00:00
<?php
session_start();
$id=$_SESSION['id'];
$galaxy=$_SESSION['galaxy'];
$ss=$_SESSION['ss'];
$pos=$_SESSION['pos'];
$race=$_SESSION['race'];
require_once('bdd.php');
require_once('noms.php');
require('../connectBDD.php');
if ($_POST['type'] == 'e' && $labo >= 1 && !ereg('e,', implode(',',$fileVai).',')) {
$temps_s = '';
$veh = 'e';
}
else {
// Annulation de la production en cha<68>ne si elle existe
//if (ereg('e,', implode(',',$fileVai).',')) { header('Location: annul_bat.php?bat=e&go='.$_POST['type']); exit; }
if (!isset($_POST['sa'])) exit;
else $sa = abs(floor($_POST['sa']));
if ($_POST['type'] == 9) {
$metal -= ($sa*500);
$cristal -= ($sa*200);
$temps_s = $sa*ceil(480/pow(1.25,($chantier_terrestre-1)));
$veh = 9;
}
elseif ($_POST['type'] == 10) {
$metal -= ($sa*4000);
$cristal -= ($sa*2000);
$temps_s = $sa*ceil(1560/pow(1.25,($chantier_terrestre-3)));
$veh = 10;
}
elseif ($_POST['type'] == 11) {
$metal -= ($sa*4500);
$cristal -= ($sa*800);
$hydrogene -= ($sa*600);
$temps_s = $sa*ceil(1800/pow(1.25,($chantier_terrestre-4)));
$veh = 11;
}
elseif ($_POST['type'] == 12) {
$metal -= ($sa*12000);
$cristal -= ($sa*10000);
$hydrogene -= ($sa*1000);
$temps_s = $sa*ceil(6720/pow(1.25,($chantier_terrestre-4)));
$veh = 12;
}
elseif ($_POST['type'] == 13) {
$metal -= ($sa*15000);
$cristal -= ($sa*9500);
$hydrogene -= ($sa*1500);
$temps_s = $sa*ceil(12960/pow(1.25,($chantier_terrestre-8)));
$veh = 13;
}
}
if (isset($veh) && $veh != '' && (!empty($nomvaisn[$veh-1]) || $veh == 'e' || (isset($_GET['act']) && $_GET['act'] == 'e'))) {
if ($metal >= 0 && $cristal >= 0 && $hydrogene >= 0) {
for ($c=0 ; $c < $sa ; $c++){
$fileVai = explode(' ',implode(' ',$fileVai).' '.$veh);
}
$veh = implode(' ',$fileVai);
if (count($fileTemps_s) == 0 || count($fileTemps_s) == 1) {
$temps_ss = time();
for ($c=0 ; $c < $sa ; $c++){
$temps_ss .= ' '.$temps_s;
}
$temps_s = $temps_ss;
}
else {
$temps_ss = implode(' ',$fileTemps_s);
for ($c=0 ; $c < $sa ; $c++){
$temps_ss .= ' '.$temps_s;
}
$temps_s = $temps_ss;
}
mysql_query("UPDATE planete SET metal='$metal', cristal='$cristal', temps_spatial='$temps_s', unit_s='$veh' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'") or die ("erreur sql ".mysql_error());
}
else {
if ($veh >= 9 ) header('Location: chantier_terrestre.php?err=3');
else header('Location: chantier_terrestre.php?err=3');
mysql_close();
exit;
}
}
mysql_close();
$veh = $fileVai[0];
if ($veh >= 9 ) header('Location: defense.php');
else header('Location: chantier_terrestre.php');
?>