<?php
if(!$conn->query('INSERT INTO`t2_conectati`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`de`="'.$de.'"'))
$conn->query('UPDATE`t2_conectati`SET`data`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
require'f_simbol.php';
echo$div[4].'<img src="'.$domenii_statice[1].'triburile2/screen.png" alt="" />Salut '.simbol($de).nume($de).'!'.$div[5];
$chs=$conn->query('SELECT COUNT(*)FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
if(!$chs[0])
{
echo$div[7].'Nu ești inscris în acest joc.<br />Ca sa poți juca, trebuie să te inscrii.'.$div[0].$div[1].'<a href="/triburile2/tip/1">Inscriete în triburi</a>'.$div[0];
require'f_jos.php';
}
function updated($de)
{
global$conn;
$dor=$conn->query('SELECT COUNT(*)FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
if($dor[0])
{
$bo=$conn->query('SELECT`lvlmag`,`lvllmn`,`lvlarg`,`lvlptr`,`updaterl`,`lmn`,`arg`,`ptr`,`updatera`,`updaterp`FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
$mag=$conn->query('SELECT`cant`FROM`t2_magazie`WHERE`lvl`="'.$bo[0].'"')->fetch_row();
$lmn=$conn->query('SELECT`cant`FROM`t2_lemn`WHERE`lvl`="'.$bo[1].'"')->fetch_row();
$arg=$conn->query('SELECT`cant`FROM`t2_argila`WHERE`lvl`="'.$bo[2].'"')->fetch_row();
$ptr=$conn->query('SELECT`cant`FROM`t2_piatra`WHERE`lvl`="'.$bo[3].'"')->fetch_row();
if($bo[5]<$mag[0])
{
$totallmn=round((($_SERVER['REQUEST_TIME']-$bo[4])/60)*($lmn[0]/60),0);
if($totallmn>5)
{
$totallmn=$totallmn+$bo[5];
if($totallmn>$mag[0])
$conn->query('UPDATE`t2_membrii`SET`lmn`="'.$mag[0].'",`updaterl`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
else
$conn->query('UPDATE`t2_membrii`SET`lmn`="'.$totallmn.'",`updaterl`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
}
}
if($bo[6]<$mag[0])
{
$totalarg=round((($_SERVER['REQUEST_TIME']-$bo[8])/60)*($arg[0]/60),0);
if($totalarg>5)
{
$totalarg=$totalarg+$bo[6];
if($totalarg>$mag[0])
$conn->query('UPDATE`t2_membrii`SET`arg`="'.$mag[0].'",`updatera`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
else
$conn->query('UPDATE`t2_membrii`SET`arg`="'.$totalarg.'",`updatera`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
}
}
if($bo[7]<$mag[0])
{
$totalptr=round((($_SERVER['REQUEST_TIME']-$bo[9])/ 60)*($ptr[0]/60),0);
if($totalptr>5)
{
$totalptr=$totalptr+$bo[7];
if($totalptr>$mag[0])
$conn->query('UPDATE`t2_membrii`SET`ptr`="'.$mag[0].'",`updaterp`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
else
$conn->query('UPDATE`t2_membrii`SET`ptr`="'.$totalptr.'",`updaterp`="'.$_SERVER['REQUEST_TIME'].'"WHERE`de`="'.$de.'"');
}
}
}
}
updated($de);
function delarmata($de)
{
global$conn;
$ite=$conn->query('SELECT COUNT(*)FROM`t2_armata`WHERE`de`="'.$de.'"')->fetch_row();
if($ite[0])
{
$items=$conn->query('SELECT`tip`,`nr`,`data`,`timp`,`id`FROM`t2_armata`WHERE`de`="'.$de.'"ORDER BY`id`ASC LIMIT 100');
while($item=$items->fetch_row())
{
if(($item[2]+$item[3])<$_SERVER['REQUEST_TIME'])
{
$nr=$conn->query('SELECT`de`,`lanc`,`lpsp`,`lptp`,`spio`,`cvus`,`cvgr`FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
if($conn->query('UPDATE`t2_membrii`SET`'.['','lanc','lpsp','lptp','spio','cvus','cvgr'][$item[0]].'`="'.($nr[$item[0]]+$item[1]).'"WHERE`de`="'.$de.'"'))
$conn->query('DELETE FROM`t2_armata`WHERE`id`="'.$item[4].'"');
}
}
}
}
delarmata($de);
function delatacuri($de)
{
global$conn;
$idsat=$conn->query('SELECT`id`,`sat`FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
$ite=$conn->query('SELECT COUNT(*)FROM`t2_ajutor`WHERE`la`="'.$idsat[0].'"')->fetch_row();
if($ite[0])
{
$items=$conn->query('SELECT`id`,`de`,`lpsp`,`lptp`,`lanc`,`cvus`,`cvgr`,`spio`,`data`,`timp`,`tip`FROM`t2_ajutor`WHERE`la`="'.$idsat[0].'"ORDER BY`id`ASC LIMIT 100');
while($item=$items->fetch_row())
{
if(($item[8]+$item[9])<$_SERVER['REQUEST_TIME'])
{
$pctard=0;
$pctteg=0;
if($item[10]=='atac')
{
$ard=$conn->query('SELECT`lvlarm`,`lvlcal`,`lvlzid`,`lvlfer`FROM`t2_membrii`WHERE`de`="'.$de.'"')->fetch_row();
$teg=$conn->query('SELECT`lvlarm`,`lvlcal`,`lvlfer`FROM`t2_membrii`WHERE`de`="'.$item[1].'"')->fetch_row();
$pctard=$ard[0]+$ard[1]+$ard[2]+$ard[3]+$item[2]+$item[3]+$item[4]+$item[5]+$item[6]+$item[7];
$pctteg=$teg[0]+$teg[1]+$teg[2]+$item[2]+$item[3]+$item[4]+$item[5]+$item[6]+$item[7];
if($pctard>$pctteg)
{
$conn->query('UPDATE`t2_membrii`SET`lanc`="0",`lpsp`="0",`lptp`="0",`spio`="0",`cvus`="0",`cvgr`="0",`lvlzid`="0"WHERE`id`="'.$idsat[0].'"');
$conn->query('INSERT INTO`t2_rapoarte`SET`la`="'.$de.'",`subiect`="'.$idsat[1].' nu te-a invins!",`text`="'.$idsat[1].' nu a reusit sa te invinga dar ti-ai pierdut toata armata și zidul ti-a fost distrus!",`data`="'.$_SERVER['REQUEST_TIME'].'"');
$conn->query('DELETE FROM`t2_ajutor`WHERE`id`="'.$item[0].'"');
}
else
{
require'f_sterg.php';
sterge_t2($de,0);
$conn->query('DELETE FROM`t2_ajutor`WHERE`id`="'.$item[0].'"');
}
}
else
{
$conn->query('INSERT INTO`t2_rapoarte`SET`la`="'.$de.'",`subiect`="'.$idsat[1].' a ajuns",`text`="Ti-au sosit ajutoarele de la '.$idsat[1].'!",`data`="'.$_SERVER['REQUEST_TIME'].'"');
$conn->query('UPDATE`t2_membrii`SET`lanc`=lanc+'.$item[4].',`lpsp`=lpsp+'.$item[2].',`lptp`=lptp+'.$item[3].',`spio`=spio+'.$item[7].',`cvus`=cvus+'.$item[5].',`cvgr`=cvgr+'.$item[6].' WHERE`id`="'.$idsat[0].'"');
$conn->query('DELETE FROM`t2_ajutor`WHERE`id`="'.$item[0].'"');
}
}
}
}
}
delatacuri($de);
function delproces($de)
{
global$conn;
$ite=$conn->query('SELECT COUNT(*)FROM`t2_procese`WHERE`de`="'.$de.'"')->fetch_row();
if($ite[0])
{
$items=$conn->query('SELECT`tip`,`lvl`,`data`,`timp`,`id`FROM`t2_procese`WHERE`de`="'.$de.'"ORDER BY`id`ASC LIMIT 1');
while($item=$items->fetch_row())
{
if(($item[2]+$item[3])<$_SERVER['REQUEST_TIME'])
{
$info=$conn->query('SELECT`lvl`,`pop`,`cant`FROM'.['','`t2_cladire_principala`','`t2_lemn`','`t2_argila`','`t2_piatra`','`t2_zid`','`t2_ferma`','`t2_ascunzatoare`','`t2_cazermata`','`t2_grajd`','`t2_fierarie`','`t2_magazie`'][$item[0]].'WHERE`lvl`="'.$item[1].'"')->fetch_row();
if($conn->query('UPDATE`t2_membrii`SET'.['','`lvlprin`','`lvllmn`','`lvlarg`','`lvlptr`','`lvlzid`','`lvlfrm`','`lvlasc`','`lvlarm`','`lvlcal`','`lvlfer`','`lvlmag`'][$item[0]].'="'.$item[1].'"WHERE`de`="'.$de.'"'))
$conn->query('DELETE FROM`t2_procese`WHERE`id`="'.$item[4].'"');
}
}
}
}
delproces($de);