<?php
$sql = "SELECT date FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetime = mysql_result($req,0);

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);
// techenergie
$sql = "SELECT techenergie_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechenergie2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechenergie2, $thetime);
$timetechenergie2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechenergie2 = time() - $timetechenergie2;

// techlaser
$sql = "SELECT techlaser_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechlaser2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechlaser2, $thetime);
$timetechlaser2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechlaser2 = time() - $timetechlaser2;

// techions
$sql = "SELECT techions_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechions2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechions2, $thetime);
$timetechions2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechions2 = time() - $timetechions2;

// techplasma
$sql = "SELECT techplasma_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechplasma2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechplasma2, $thetime);
$timetechplasma2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechplasma2 = time() - $timetechplasma2;

// techordi
$sql = "SELECT techordi_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechordi2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechordi2, $thetime);
$timetechordi2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechordi2 = time() - $timetechordi2;

// techcombustion
$sql = "SELECT techcombustion_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechcombustion2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechcombustion2, $thetime);
$timetechcombustion2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechcombustion2 = time() - $timetechcombustion2;

// techAsgaards
$sql = "SELECT techAsgaards_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechAsgaards2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechAsgaards2, $thetime);
$timetechAsgaards2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechAsgaards2 = time() - $timetechAsgaards2;

// techhyperespace
$sql = "SELECT techhyperespace_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechhyperespace2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechhyperespace2, $thetime);
$timetechhyperespace2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechhyperespace2 = time() - $timetechhyperespace2;

// techespio1
$sql = "SELECT techespio1_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechespio12 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechespio12, $thetime);
$timetechespio12 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechespio12 = time() - $timetechespio12;

// techespio2
$sql = "SELECT techespio2_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechespio22 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechespio22, $thetime);
$timetechespio22 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechespio22 = time() - $timetechespio22;

// techArmement
$sql = "SELECT techArmement_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechArmement2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechArmement2, $thetime);
$timetechArmement2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechArmement2 = time() - $timetechArmement2;

// techBouclier
$sql = "SELECT techBouclier_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechBouclier2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechBouclier2, $thetime);
$timetechBouclier2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechBouclier2 = time() - $timetechBouclier2;

// techcoque
$sql = "SELECT techcoque_evolution FROM matgraph_users WHERE id='$dataid[id]' ";
$req = db_mysql_Query($sql);
$datetimetechcoque2 = mysql_result($req,0);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $datetimetechcoque2, $thetime);
$timetechcoque2 = mktime($thetime[4],$thetime[5],$thetime[6],$thetime[2],$thetime[3],$thetime[1]);
$diftempstechcoque2 = time() - $timetechcoque2;



$sql = "SELECT pts,techenergie_lvl,techenergie_evolution,techlaser_lvl,techlaser_evolution,techions_lvl,techions_evolution,techplasma_lvl,techplasma_evolution,techordi_lvl,techordi_evolution,techcombustion_lvl,techcombustion_evolution,techAsgaards_lvl,techAsgaards_evolution,techhyperespace_lvl,techhyperespace_evolution,techespio1_lvl,techespio1_evolution,techespio2_lvl,techespio2_evolution,techArmement_lvl,techArmement_evolution,techBouclier_lvl,techBouclier_evolution,techcoque_lvl,techcoque_evolution,robo_lvl,labo_lvl,labo_evolution,fer_energie,or_energie,ada_energie,ura_energie,exfer_energie,exor_energie,central_energie FROM matgraph_users WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 

// techenergie
if ($timetechenergie2 > 0 && $diftempstechenergie2 > 0){
$New_techenergie_lvl = $row[techenergie_lvl] + 1 ;
if ($row[techenergie_lvl] == "0") {
$Depense_techenergie_or = "800";
$Depense_techenergie_ada = "400";
}
else {
$Depense_techenergie_or = round((800 * ( bcpow( 2, ($row[techenergie_lvl] + 1),3))),0);
$Depense_techenergie_ada = round((400 * ( bcpow( 2, ($row[techenergie_lvl] + 1),3))),0);
}
$new_pts= $Depense_techenergie_or + $Depense_techenergie_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techenergie_lvl=$New_techenergie_lvl, techenergie_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techlaser
if ($timetechlaser2 > 0 && $diftempstechlaser2 > 0){
$New_techlaser_lvl = $row[techlaser_lvl] + 1 ;
if ($row[techlaser_lvl] == "0") {
$Depense_techlaser_fer = "200";
$Depense_techlaser_or = "100";
}
else {
$Depense_techlaser_fer = round((200 * ( bcpow( 2, ($row[techlaser_lvl] + 1),3))),0);
$Depense_techlaser_or = round((100 * ( bcpow( 2, ($row[techlaser_lvl] + 1),3))),0);
}
$new_pts= $Depense_techlaser_fer + $Depense_techlaser_or + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techlaser_lvl=$New_techlaser_lvl, techlaser_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techions
if ($timetechions2 > 0 && $diftempstechions2 > 0){
$New_techions_lvl = $row[techions_lvl] + 1 ;
if ($row[techions_lvl] == "0") {
$Depense_techions_fer = "1000";
$Depense_techions_or = "300";
$Depense_techions_ada = "100";
}
else {
$Depense_techions_fer = round((1000 * ( bcpow( 2, ($row[techions_lvl] + 1),3))),0);
$Depense_techions_or = round((300 * ( bcpow( 2, ($row[techions_lvl] + 1),3))),0);
$Depense_techions_ada = round((100 * ( bcpow( 2, ($row[techions_lvl] + 1),3))),0);
}
$new_pts= $Depense_techions_fer + $Depense_techions_or + $Depense_techions_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techions_lvl=$New_techions_lvl, techions_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techplasma
if ($timetechplasma2 > 0 && $diftempstechplasma2 > 0){
$New_techplasma_lvl = $row[techplasma_lvl] + 1 ;
if ($row[techplasma_lvl] == "0") {
$Depense_techplasma_fer = "2000";
$Depense_techplasma_or = "4000";
$Depense_techplasma_ada = "1000";
}
else {
$Depense_techplasma_fer = round((2000 * ( bcpow( 2, ($row[techplasma_lvl] + 1),3))),0);
$Depense_techplasma_or = round((4000 * ( bcpow( 2, ($row[techplasma_lvl] + 1),3))),0);
$Depense_techplasma_ada = round((1000 * ( bcpow( 2, ($row[techplasma_lvl] + 1),3))),0);
}
$new_pts= $Depense_techplasma_fer + $Depense_techplasma_or + $Depense_techplasma_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techplasma_lvl=$New_techplasma_lvl, techplasma_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techordi
if ($timetechordi2 > 0 && $diftempstechordi2 > 0){
$New_techordi_lvl = $row[techordi_lvl] + 1 ;
if ($row[techordi_lvl] == "0") {
$Depense_techordi_or = "400";
$Depense_techordi_ada = "600";
}
else {
$Depense_techordi_or = round((400 * ( bcpow( 2, ($row[techordi_lvl] + 1),3))),0);
$Depense_techordi_ada = round((600 * ( bcpow( 2, ($row[techordi_lvl] + 1),3))),0);
}
$new_pts= $Depense_techordi_or + $Depense_techordi_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techordi_lvl=$New_techordi_lvl, techordi_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techcombustion
if ($timetechcombustion2 > 0 && $diftempstechcombustion2 > 0){
$New_techcombustion_lvl = $row[techcombustion_lvl] + 1 ;
if ($row[techcombustion_lvl] == "0") {
$Depense_techcombustion_fer = "400";
$Depense_techcombustion_ada = "600";
}
else {
$Depense_techcombustion_fer = round((400 * ( bcpow( 2, ($row[techcombustion_lvl] + 1),3))),0);
$Depense_techcombustion_ada = round((600 * ( bcpow( 2, ($row[techcombustion_lvl] + 1),3))),0);
}
$new_pts= $Depense_techcombustion_fer + $Depense_techcombustion_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techcombustion_lvl=$New_techcombustion_lvl, techcombustion_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techAsgaards
if ($timetechAsgaards2 > 0 && $diftempstechAsgaards2 > 0){
$New_techAsgaards_lvl = $row[techAsgaards_lvl] + 1 ;
if ($row[techAsgaards_lvl] == "0") {
$Depense_techAsgaards_fer = "2000";
$Depense_techAsgaards_or = "4000";
$Depense_techAsgaards_ada = "600";
}
else {
$Depense_techAsgaards_fer = round((2000 * ( bcpow( 2, ($row[techAsgaards_lvl] + 1),3))),0);
$Depense_techAsgaards_or = round((4000 * ( bcpow( 2, ($row[techAsgaards_lvl] + 1),3))),0);
$Depense_techAsgaards_ada = round((600 * ( bcpow( 2, ($row[techAsgaards_lvl] + 1),3))),0);
}
$new_pts= $Depense_techAsgaards_fer + $Depense_techAsgaards_or + $Depense_techAsgaards_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techAsgaards_lvl=$New_techAsgaards_lvl, techAsgaards_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techhyperespace
if ($timetechhyperespace2 > 0 && $diftempstechhyperespace2 > 0){
$New_techhyperespace_lvl = $row[techhyperespace_lvl] + 1 ;
if ($row[techhyperespace_lvl] == "0") {
$Depense_techhyperespace_or = "4000";
$Depense_techhyperespace_ada = "2000";
}
else {
$Depense_techhyperespace_or = round((4000 * ( bcpow( 2, ($row[techhyperespace_lvl] + 1),3))),0);
$Depense_techhyperespace_ada = round((2000 * ( bcpow( 2, ($row[techhyperespace_lvl] + 1),3))),0);
}
$new_pts= $Depense_techhyperespace_or + $Depense_techhyperespace_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techhyperespace_lvl=$New_techhyperespace_lvl, techhyperespace_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techespio1
if ($timetechespio12 > 0 && $diftempstechespio12 > 0){
$New_techespio1_lvl = $row[techespio1_lvl] + 1 ;
if ($row[techespio1_lvl] == "0") {
$Depense_techespio1_fer = "200";
$Depense_techespio1_or = "1000";
$Depense_techespio1_ada = "200";
}
else {
$Depense_techespio1_fer = round((200 * ( bcpow( 2, ($row[techespio1_lvl] + 1),3))),0);
$Depense_techespio1_or = round((1000 * ( bcpow( 2, ($row[techespio1_lvl] + 1),3))),0);
$Depense_techespio1_ada = round((200 * ( bcpow( 2, ($row[techespio1_lvl] + 1),3))),0);
}
$new_pts= $Depense_techespio1_fer + $Depense_techespio1_or + $Depense_techespio1_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techespio1_lvl=$New_techespio1_lvl, techespio1_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techespio2
if ($timetechespio22 > 0 && $diftempstechespio22 > 0){
$New_techespio2_lvl = $row[techespio2_lvl] + 1 ;
if ($row[techespio2_lvl] == "0") {
$Depense_techespio2_fer = "200";
$Depense_techespio2_or = "2000";
$Depense_techespio2_ada = "500";
}
else {
$Depense_techespio2_fer = round((200 * ( bcpow( 2, ($row[techespio1_lvl] + 1),3))),0);
$Depense_techespio2_or = round((2000 * ( bcpow( 2, ($row[techespio2_lvl] + 1),3))),0);
$Depense_techespio2_ada = round((500 * ( bcpow( 2, ($row[techespio2_lvl] + 1),3))),0);
}
$new_pts= $Depense_techespio2_fer + $Depense_techespio2_or + $Depense_techespio2_ada + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techespio2_lvl=$New_techespio2_lvl, techespio2_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techArmement
if ($timetechArmement2 > 0 && $diftempstechArmement2 > 0){
$New_techArmement_lvl = $row[techArmement_lvl] + 1 ;
if ($row[techArmement_lvl] == "0") {
$Depense_techArmement_fer = "800";
$Depense_techArmement_or = "200";
}
else {
$Depense_techArmement_fer = round((800 * ( bcpow( 2, ($row[techArmement_lvl] + 1),3))),0);
$Depense_techArmement_or = round((200 * ( bcpow( 2, ($row[techArmement_lvl] + 1),3))),0);
}
$new_pts= $Depense_techArmement_fer + $Depense_techArmement_or + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techArmement_lvl=$New_techArmement_lvl, techArmement_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techBouclier
if ($timetechBouclier2 > 0 && $diftempstechBouclier2 > 0){
$New_techBouclier_lvl = $row[techBouclier_lvl] + 1 ;
if ($row[techBouclier_lvl] == "0") {
$Depense_techBouclier_fer = "200";
$Depense_techBouclier_or = "600";
}
else {
$Depense_techBouclier_fer = round((200 * ( bcpow( 2, ($row[techBouclier_lvl] + 1),3))),0);
$Depense_techBouclier_or = round((600 * ( bcpow( 2, ($row[techBouclier_lvl] + 1),3))),0);
}
$new_pts= $Depense_techBouclier_fer + $Depense_techBouclier_or + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techBouclier_lvl=$New_techBouclier_lvl, techBouclier_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

// techcoque
if ($timetechcoque2 > 0 && $diftempstechcoque2 > 0){
$New_techcoque_lvl = $row[techcoque_lvl] + 1 ;
if ($row[techcoque_lvl] == "0") {
$Depense_techcoque_fer = "800";
}
else {
$Depense_techcoque_fer = round((1000 * ( bcpow( 2, ($row[techcoque_lvl] + 1),3))),0);
}
$new_pts= $Depense_techcoque_fer + $row[pts];
$sql = "UPDATE matgraph_users SET pts=$new_pts, techcoque_lvl=$New_techcoque_lvl, techcoque_evolution = \"0000-00-00 00:00:00\" WHERE id='$dataid[id]' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
}

?>