<?php

$datetime = $row[date];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetime, $thetime);
$time = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftemps = time() - $time;
$difheure = round($diftemps / 3600,1);
// fer
$datetimefer2 = $row[fer_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimefer2, $thetime);
$timefer2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsfer2 = time() - $timefer2;
$diftempsfer3 = $timefer2 - $time;
// exfer
$datetimeexfer2 = $row[exfer_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeexfer2, $thetime);
$timeexfer2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsexfer2 = time() - $timeexfer2;
$diftempsexfer3 = $timeexfer2 - $time;
// or
$datetimeor2 = $row[or_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeor2, $thetime);
$timeor2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsor2 = time() - $timeor2;
$diftempsor3 = $timeor2 - $time;
// exor
$datetimeexor2 = $row[exor_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeexor2, $thetime);
$timeexor2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsexor2 = time() - $timeexor2;
$diftempsexor3 = $timeexor2 - $time;
// ada
$datetimeada2 = $row[ada_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeada2, $thetime);
$timeada2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsada2 = time() - $timeada2;
$diftempsada3 = $timeada2 - $time;

//ura
$datetimeura2 = $row[ura_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeura2, $thetime);
$timeura2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);

$diftempsura2 = time() - $timeura2;
$diftempsura3 = $timeura2 - $time;

//central
$datetimecentral2 = $row[central_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimecentral2, $thetime);
$timecentral2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempscentral2 = time() - $timecentral2;
$diftempscentral3 = $timecentral2 - $time;

//fission
$datetimefission2 = $row[fission_destruction];

ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimefission2, $thetime);
$timefission2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempsfission2 = time() - $timefission2;
$diftempsfission3 = $timefission2 - $time;

//labo
$datetimelabo2 = $row[labo_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimelabo2, $thetime);
$timelabo2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempslabo2 = time() - $timelabo2;
$diftempslabo3 = $timelabo2 - $time;

//robo
$datetimerobo2 = $row[robo_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimerobo2, $thetime);
$timerobo2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempsrobo2 = time() - $timerobo2;
$diftempsrobo3 = $timerobo2 - $time;

//siege
$datetimesiege2 = $row[siege_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimesiege2, $thetime);
$timesiege2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempssiege2 = time() - $timesiege2;
$diftempssiege3 = $timesiege2 - $time;

//chantier
$datetimechantier2 = $row[chantier_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimechantier2, $thetime);
$timechantier2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempschantier2 = time() - $timechantier2;
$diftempschantier3 = $timechantier2 - $time;

//hangarfer
$datetimehangarfer2 = $row[hangarfer_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimehangarfer2, $thetime);
$timehangarfer2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempshangarfer2 = time() - $timehangarfer2;
$diftempshangarfer3 = $timehangarfer2 - $time;

//hangaror
$datetimehangaror2 = $row[hangaror_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimehangaror2, $thetime);
$timehangaror2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempshangaror2 = time() - $timehangaror2;
$diftempshangaror3 = $timehangaror2 - $time;

//hangarada
$datetimehangarada2 = $row[hangarada_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimehangarada2, $thetime);
$timehangarada2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempshangarada2 = time() - $timehangarada2;
$diftempshangarada3 = $timehangarada2 - $time;

//hangarura
$datetimehangarura2 = $row[hangarura_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimehangarura2, $thetime);
$timehangarura2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempshangarura2 = time() - $timehangarura2;
$diftempshangarura3 = $timehangarura2 - $time;

//silo
$datetimesilo2 = $row[silo_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimesilo2, $thetime);
$timesilo2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempssilo2 = time() - $timesilo2;
$diftempssilo3 = $timesilo2 - $time;

// defense
$datetimedefense2 = $row[defense_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimedefense2, $thetime);
$timedefense2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempsdefense2 = time() - $timedefense2;
$diftempsdefense3 = $timedefense2 - $time;

// mili
$datetimemili2 = $row[mili_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimemili2, $thetime);
$timemili2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempsmili2 = time() - $timemili2;
$diftempsmili3 = $timemili2 - $time;

//terri
$datetimeterri2 = $row[terri_destruction];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimeterri2, $thetime);
$timeterri2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempsterri2 = time() - $timeterri2;
$diftempsterri3 = $timeterri2 - $time;



// fer
if ($timefer2 > 0 && $diftempsfer2 > 0){
$New_fer_lvl = $row[fer_lvl] - 1;
if ($row[fer_lvl] =="0") {
$Depense_fer_ressource = 60 / 3 ;
$Depense_or_ressource = 15 / 3 ;
}
else {
$Depense_fer_ressource = round((60 / 3  * ( bcpow( 1.45, ($row[fer_lvl]),3))),0);
$Depense_or_ressource = round((15 / 3  * ( bcpow( 1.45, ($row[fer_lvl])))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $New_fer_ressource + $New_or_ressource + $row2[pts_bats];


$New_fer_energie = round((30 * (bcpow(1.18, $row[fer_lvl],3)) + $row[fer_energie]),0);

$sql = "UPDATE matgraph_users SET fer_lvl=$New_fer_lvl, fer_energie = $New_fer_energie, fer_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// or
if ($timeor2 > 0 && $diftempsor2 > 0){
$New_or_lvl = $row[or_lvl] - 1;
if ($row[or_lvl] =="0") {
$Depense_fer_ressource = 50 / 3 ;
$Depense_or_ressource = 25 / 3 ;
}
else {
$Depense_fer_ressource = round((50 / 3  * ( bcpow( 1.5, ($row[or_lvl]),3))),0);
$Depense_or_ressource = round((25 / 3  * ( bcpow( 1.5, ($row[or_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $row2[pts_bats];

$New_or_energie = round((30 * (bcpow(1.18, $row[or_lvl],3)) + $row[or_energie]),0);

$sql = "UPDATE matgraph_users SET or_lvl=$New_or_lvl, or_energie = $New_or_energie, or_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// ada
if ($timeada2 > 0 && $diftempsada2 > 0){
$New_ada_lvl = $row[ada_lvl] - 1;
if ($row[ada_lvl] =="0") {
$Depense_fer_ressource = 500 / 3 ;
$Depense_or_ressource = 160 / 3 ;
}
else {
$Depense_fer_ressource = round((500 / 3  * ( bcpow( 1.45, ($row[ada_lvl]),3))),0);
$Depense_or_ressource = round((160 / 3  * ( bcpow( 1.45, ($row[ada_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $row2[pts_bats];

$New_ada_energie = round((30 * (bcpow(1.18, $row[ada_lvl],3)) + $row[ada_energie]),0);

$sql = "UPDATE matgraph_users SET ada_lvl=$New_ada_lvl, ada_energie = $New_ada_energie, ada_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// ura
if ($timeura2 > 0 && $diftempsura2 > 0){
$New_ura_lvl = $row[ura_lvl] - 1;
if ($row[ura_lvl] =="0") {
$Depense_fer_ressource = 500 / 3 ;
$Depense_or_ressource = 300 / 3 ;
$Depense_ada_ressource = 100 / 3 ;
}
else {
$Depense_fer_ressource = round((500 / 3  * ( bcpow( 1.4, ($row[ura_lvl]),3))),0);
$Depense_or_ressource = round((300 / 3  * ( bcpow( 1.4, ($row[ura_lvl]),3))),0);
$Depense_ada_ressource = round((100 / 3  * ( bcpow( 1.4, ($row[ura_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];

$New_ura_energie = round((30 * (bcpow(1.18, $row[ura_lvl],3)) + $row[ura_energie]),0);

$sql = "UPDATE matgraph_users SET ura_lvl=$New_ura_lvl, ura_energie = $New_ura_energie, ura_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}


// exfer
if ($timeexfer2 > 0 && $diftempsexfer2 > 0){
$New_exfer_lvl = $row[exfer_lvl] - 1;
if ($row[exfer_lvl] =="0") {
$Depense_fer_ressource = 35000 / 3 ;
$Depense_or_ressource = 15000 / 3 ;
$Depense_ada_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((30000 / 3  * ( bcpow( 1.2, ($row[exfer_lvl]),3))),0);
$Depense_or_ressource = round((20000 / 3  * ( bcpow( 1.2, ($row[exfer_lvl])))),0);
$Depense_ada_ressource = round((1000 / 3  * ( bcpow( 1.2, ($row[exfer_lvl])))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];

$New_exfer_energie = round((30 * (bcpow(1.18, $row[exfer_lvl],3)) + $row[exfer_energie]),0);

$sql = "UPDATE matgraph_users SET exfer_lvl=$New_exfer_lvl, exfer_energie = $New_exfer_energie, exfer_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// exor
if ($timeexor2 > 0 && $diftempsexor2 > 0){
$New_exor_lvl = $row[exor_lvl] - 1;
if ($row[exor_lvl] =="0") {
$Depense_fer_ressource = 35000 / 3 ;
$Depense_or_ressource = 15000 / 3 ;
$Depense_ada_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((30000 / 3  * ( bcpow( 1.2, ($row[exor_lvl]),3))),0);
$Depense_or_ressource = round((20000 / 3  * ( bcpow( 1.2, ($row[exor_lvl])))),0);
$Depense_ada_ressource = round((1000 / 3  * ( bcpow( 1.2, ($row[exor_lvl])))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];

$New_exor_energie = round((30 * (bcpow(1.18, $row[exor_lvl],3)) + $row[exor_energie]),0);

$sql = "UPDATE matgraph_users SET exor_lvl=$New_exor_lvl, exor_energie = $New_exor_energie, exor_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// labo
if ($timelabo2 > 0 && $diftempslabo2 > 0){
$New_labo_lvl = $row[labo_lvl] - 1;
if ($row[labo_lvl] =="0") {
$Depense_fer_ressource = 200 / 3 ;
$Depense_or_ressource = 400 / 3 ;
$Depense_ada_ressource = 200 / 3 ;
}
else {
$Depense_fer_ressource = round((200 / 3  * ( bcpow( 1.75, ($row[labo_lvl]),3))),0);
$Depense_or_ressource = round((400 / 3  * ( bcpow( 1.75, ($row[labo_lvl]),3))),0);
$Depense_ada_ressource = round((200 / 3  * ( bcpow( 1.75, ($row[labo_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET labo_lvl=$New_labo_lvl, labo_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// robo
if ($timerobo2 > 0 && $diftempsrobo2 > 0){
$New_robo_lvl = $row[robo_lvl] - 1;
if ($row[robo_lvl] =="0") {
$Depense_fer_ressource = 35000 / 3 ;
$Depense_or_ressource = 15000 / 3 ;
$Depense_ada_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((30000 / 3  * ( bcpow( 1.2, ($row[robo_lvl]),3))),0);
$Depense_or_ressource = round((20000 / 3  * ( bcpow( 1.2, ($row[robo_lvl])))),0);
$Depense_ada_ressource = round((1000 / 3  * ( bcpow( 1.2, ($row[robo_lvl])))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET robo_lvl=$New_robo_lvl, robo_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// siege
if ($timesiege2 > 0 && $diftempssiege2 > 0){
$New_siege_lvl = $row[siege_lvl] - 1;
if ($row[siege_lvl] =="0") {
$Depense_fer_ressource = 900000 / 3 ;
$Depense_or_ressource = 900000 / 3 ;
$Depense_ada_ressource = 500000 / 3 ;
$Depense_ura_ressource = 10000 / 3 ;
}
else {
$Depense_fer_ressource = round((450000 / 3  * ( bcpow( 2, ($row[siege_lvl]),3))),0);
$Depense_or_ressource = round((450000 / 3  * ( bcpow( 2, ($row[siege_lvl]),3))),0);
$Depense_ada_ressource = round((250000 / 3  * ( bcpow( 2, ($row[siege_lvl]),3))),0);
$Depense_ura_ressource = round((5000 / 3  * ( bcpow( 2, ($row[siege_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$New_ura_ressource = ($row[ura_ressource] + $Depense_ura_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $Depense_ura_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET siege_lvl=$New_siege_lvl, siege_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource, ura_ressource=$New_ura_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// chantier
if ($timechantier2 > 0 && $diftempschantier2 > 0){
$New_chantier_lvl = $row[chantier_lvl] - 1;
if ($row[chantier_lvl] =="0") {
$Depense_fer_ressource = 100 / 3 ;
$Depense_or_ressource = 200 / 3 ;
$Depense_ada_ressource = 100 / 3 ;
}
else {
$Depense_fer_ressource = round((100 / 3  * ( bcpow( 1.9, ($row[chantier_lvl]),3))),0);
$Depense_or_ressource = round((200 / 3  * ( bcpow( 1.9, ($row[chantier_lvl]),3))),0);
$Depense_ada_ressource = round((100 / 3  * ( bcpow( 1.9, ($row[chantier_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET chantier_lvl=$New_chantier_lvl, chantier_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// hangarfer
if ($timehangarfer2 > 0 && $diftempshangarfer2 > 0){
$New_hangarfer_lvl = $row[hangarfer_lvl] - 1;
if ($row[hangarfer_lvl] =="0") {
$Depense_fer_ressource = 2000 / 3 ;
}
else {
$Depense_fer_ressource = round((1000 / 3  * ( bcpow( 2, ($row[hangarfer_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET hangarfer_lvl=$New_hangarfer_lvl, hangarfer_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// hangaror
if ($timehangaror2 > 0 && $diftempshangaror2 > 0){
$New_hangaror_lvl = $row[hangaror_lvl] - 1;
if ($row[hangaror_lvl] =="0") {
$Depense_fer_ressource = 2000 / 3 ;
$Depense_or_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((1000 / 3  * ( bcpow( 2, ($row[hangaror_lvl]),3))),0);
$Depense_or_ressource = round((500 / 3  * ( bcpow( 2, ($row[hangaror_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET hangaror_lvl=$New_hangaror_lvl, hangaror_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// hangarada
if ($timehangarada2 > 0 && $diftempshangarada2 > 0){
$New_hangarada_lvl = $row[hangarada_lvl] - 1;
if ($row[hangarada_lvl] =="0") {
$Depense_fer_ressource = 2000 / 3 ;
$Depense_or_ressource = 2000 / 3 ;
}
else {
$Depense_fer_ressource = round((1000 / 3  * ( bcpow( 2, ($row[hangarada_lvl]),3))),0);
$Depense_or_ressource = round((1000 / 3  * ( bcpow( 2, ($row[hangarada_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET hangarada_lvl=$New_hangarada_lvl, hangarada_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// hangarura
if ($timehangarura2 > 0 && $diftempshangarura2 > 0){
$New_hangarura_lvl = $row[hangarura_lvl] - 1;
if ($row[hangarura_lvl] =="0") {
$Depense_fer_ressource = 2000 / 3 ;
$Depense_or_ressource = 1000 / 3 ;
$Depense_ada_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((1000 / 3  * ( bcpow( 2, ($row[hangarura_lvl]),3))),0);
$Depense_or_ressource = round((500 / 3  * ( bcpow( 2, ($row[hangarura_lvl]),3))),0);
$Depense_ada_ressource = round((500 / 3  * ( bcpow( 2, ($row[hangarura_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET hangarura_lvl=$New_hangarura_lvl, hangarura_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// silo
if ($timesilo2 > 0 && $diftempssilo2 > 0){
$New_silo_lvl = $row[silo_lvl] - 1;
if ($row[silo_lvl] =="0") {
$Depense_fer_ressource = 20000 / 3 ;
$Depense_or_ressource = 20000 / 3 ;
$Depense_ada_ressource = 1000 / 3 ;
}
else {
$Depense_fer_ressource = round((20000 / 3  * ( bcpow( 1.9, ($row[silo_lvl]),3))),0);
$Depense_or_ressource = round((20000 / 3  * ( bcpow( 1.9, ($row[silo_lvl]),3))),0);
$Depense_ada_ressource = round((1000 / 3  * ( bcpow( 1.9, ($row[silo_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET silo_lvl=$New_silo_lvl, silo_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// defense
if ($timedefense2 > 0 && $diftempsdefense2 > 0){
$New_defense_lvl = $row[defense_lvl] - 1;
if ($row[defense_lvl] =="0") {
$Depense_fer_ressource = 75 / 3 ;
$Depense_or_ressource = 150 / 3 ;
$Depense_ada_ressource = 75 / 3 ;
}
else {
$Depense_fer_ressource = round((75 / 3  * ( bcpow( 1.9, ($row[defense_lvl]),3))),0);
$Depense_or_ressource = round((150 / 3  * ( bcpow( 1.9, ($row[defense_lvl]),3))),0);
$Depense_ada_ressource = round((75 / 3  * ( bcpow( 1.9, ($row[defense_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_ada_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $Depense_ada_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET defense_lvl=$New_defense_lvl, defense_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}

// mili
if ($timemili2 > 0 && $diftempsmili2 > 0){
$New_mili_lvl = $row[mili_lvl] - 1;
if ($row[mili_lvl] =="0") {
$Depense_fer_ressource = 500 / 3 ;
$Depense_or_ressource = 500 / 3 ;
}
else {
$Depense_fer_ressource = round((250 / 3  * ( bcpow( 2, ($row[mili_lvl]),3))),0);
$Depense_or_ressource = round((250 / 3  * ( bcpow( 2, ($row[mili_lvl]),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] + $Depense_or_ressource) ;
$new_pts_bats= $Depense_fer_ressource + $Depense_or_ressource + $row2[pts_bats];
$sql = "UPDATE matgraph_users SET mili_lvl=$New_mili_lvl, mili_destruction = \"0000-00-00 00:00:00\", fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET pts_bats=$new_pts_bats WHERE id='$dataid[id]' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
}
?>