HB/pages/validation_soldat.php

162 lines
6.6 KiB
PHP
Raw Normal View History

2007-10-27 10:00:00 +00:00
<?php
session_start();
if (isset($_POST['cons_soldat1']) || isset($_POST['cons_soldat2']) || isset($_POST['cons_soldat3']) || isset($_POST['cons_soldat4']) || isset($_POST['cons_sniper']) || isset($_POST['cons_spartan']) || isset($_POST['cons_medecin']) || isset($_POST['cons_ingenieur']) || isset($_POST['cons_soldat_lourd'])) {
$id=$_SESSION['id'];
$galaxy=$_SESSION['galaxy'];
$ss=$_SESSION['ss'];
$pos=$_SESSION['pos'];
require_once('bdd.php');
require('../connectBDD.php');
$sa=0;
if (isset($_POST['cons_soldat1'])) $sa = floor($_POST['cons_soldat1']);
if (isset($_POST['cons_soldat2'])) $sa = floor($_POST['cons_soldat2']);
if (isset($_POST['cons_soldat3'])) $sa = floor($_POST['cons_soldat3']);
if (isset($_POST['cons_soldat4'])) $sa = floor($_POST['cons_soldat4']);
if (isset($_POST['cons_sniper'])) $sa = floor($_POST['cons_sniper']);
if (isset($_POST['cons_spartan'])) $sa = floor($_POST['cons_spartan']);
if (isset($_POST['cons_medecin'])) $sa = floor($_POST['cons_medecin']);
if (isset($_POST['cons_ingenieur'])) $sa = floor($_POST['cons_ingenieur']);
if (isset($_POST['cons_soldat_lourd'])) $sa = floor($_POST['cons_soldat_lourd']);
if ($sa < 0) $sa=0;
if (isset($_POST['cons_soldat1']) && $sa > 0) {
if ($metal - ($sa*80) >= 0) {
if ($cristal - ($sa*45) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(60/pow(1.25,($caserne-1)));
2007-10-27 10:00:00 +00:00
$unit = 1;
$metal -= ($sa*80);
$cristal -= ($sa*45);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'") or die ("erreur sql ".mysql_error());
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_soldat2']) && $sa > 0) {
if ($metal - ($sa*110) >= 0) {
if ($cristal - ($sa*90) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(240/pow(1.25,($caserne-2)));
2007-10-27 10:00:00 +00:00
$unit = 2;
$metal -= ($sa*110);
$cristal -= ($sa*90);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_soldat3']) && $sa > 0) {
if ($metal - ($sa*150) >= 0) {
if ($cristal - ($sa*105) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(240/pow(1.25,($caserne-3)));
2007-10-27 10:00:00 +00:00
$unit = 3;
$metal -= ($sa*150);
$cristal -= ($sa*105);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_soldat4']) && $sa > 0) {
if ($metal - ($sa*220) >= 0) {
if ($cristal - ($sa*150) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(720/pow(1.25,($caserne-5)));
2007-10-27 10:00:00 +00:00
$unit = 4;
$metal -= ($sa*220);
$cristal -= ($sa*150);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_sniper']) && $sa > 0) {
if ($metal - ($sa*180) >= 0) {
if ($cristal - ($sa*100) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(300/pow(1.25,($caserne-3)));
2007-10-27 10:00:00 +00:00
$unit = 5;
$metal -= ($sa*180);
$cristal -= ($sa*100);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_spartan']) && $sa > 0) {
if ($metal - ($sa*25000) >= 0) {
if ($cristal - ($sa*10000) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(29700/pow(1.25,($caserne-10)));
2007-10-27 10:00:00 +00:00
$unit = 6;
$metal -= ($sa*25000);
$cristal -= ($sa*10000);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_medecin']) && $sa > 0) {
if ($metal - ($sa*100) >= 0) {
if ($cristal - ($sa*100) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(90/pow(1.25,($caserne-2)));
2007-10-27 10:00:00 +00:00
$unit = 7;
$metal -= ($sa*100);
$cristal -= ($sa*100);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_ingenieur']) && $sa > 0) {
if ($metal - ($sa*90) >= 0) {
if ($cristal - ($sa*105) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(90/pow(1.25,($caserne-2)));
2007-10-27 10:00:00 +00:00
$unit = 8;
$metal -= ($sa*90);
$cristal -= ($sa*105);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
elseif (isset($_POST['cons_soldat_lourd']) && $sa > 0) {
if ($metal - ($sa*300) >= 0) {
if ($cristal - ($sa*250) >= 0) {
2007-11-04 11:00:00 +00:00
$temps_caserne = time() + $sa*ceil(900/pow(1.25,($caserne-5)));
2007-10-27 10:00:00 +00:00
$unit = 9;
$metal -= ($sa*300);
$cristal -= ($sa*250);
mysql_query("UPDATE planete SET cas_contruct_nb='$sa', cas_contruct='$unit', cas_contruct_time='$temps_caserne', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND position='$pos' AND ss='$ss'");
header("Location: caserne.php");
}
else echo "Pas assez de cristal !";
}
else echo "Pas assez de m<>tal !";
}
else header("Location: caserne.php");
mysql_close();
}