<?
$accel = 25200;
function cp_location_four($count){
$result = $count+=1;
return $result*1200;
}

if(isset($_GET['product'])){
if(is_numeric($_GET['product'])){
$get_inf = floor($_GET['product']);
if($get_inf>=1){
$inf_alm = mysql_fetch_assoc(mysql_query('SELECT * FROM `kolhoz_loc_euro` WHERE `id`="'.$get_inf.'"'));
if($inf_alm['id_user'] == $ku['id']){
if($inf_alm['product']!=1){
if($ku['rubies']>=20000000){
mysql_query('UPDATE `kolhoz_user` SET `rubies`="'.($ku['rubies']-20000000).'" WHERE `id`="'.$ku['id'].'"');
mysql_query('UPDATE `kolhoz_loc_euro` SET `product`="1", `start_time`="'.$time.'", `end_time`="'.($time+86400).'" WHERE `id`="'.$get_inf.'"');
header('location:?elysium&location_four'); exit;
} else {err_game('У вас не хватает рубинов.');}
}}}}}

elseif(isset($_GET['acceleration'])){
if(is_numeric($_GET['acceleration'])){
$get_inf = floor($_GET['acceleration']);
if($get_inf>=1){
$inf_alm = mysql_fetch_assoc(mysql_query('SELECT * FROM `kolhoz_loc_euro` WHERE `id`="'.$get_inf.'"'));
if($inf_alm['id_user'] == $ku['id']){
if(($inf_alm['product']==1)&&(($inf_alm['end_time']-($inf_alm['acceleration']*$accel))>$time)&&($inf_alm['acceleration']!=1)&&(($inf_alm['start_time']+480)<$time)){
if($ku['euro']>=20){
mysql_query('UPDATE `kolhoz_user` SET `euro`="'.($ku['euro']-20).'" WHERE `id`="'.$ku['id'].'"');
mysql_query('UPDATE `kolhoz_loc_euro` SET `acceleration`="1" WHERE `id`="'.$get_inf.'"');
header('location:?elysium&location_four'); exit;
} else {err_game('У вас не хватает евро, требуется 20.');}
}}}}}

elseif(isset($_GET['extraction'])){
if(is_numeric($_GET['extraction'])){
$get_inf = floor($_GET['extraction']);
if($get_inf>=1){
$inf_alm = mysql_fetch_assoc(mysql_query('SELECT * FROM `kolhoz_loc_euro` WHERE `id`="'.$get_inf.'"'));
if($inf_alm['id_user'] == $ku['id']){
if(($inf_alm['product']==1)&&(($inf_alm['end_time']-($inf_alm['acceleration']*$accel))<=$time)){
$rat_mc = 1000000000000;
mysql_query('UPDATE `kolhoz_user` SET `euro`="'.($ku['euro']+40).'", `rating`="'.($ku['rating']+$rat_mc).'" WHERE `id`="'.$ku['id'].'"');
mysql_query('UPDATE `kolhoz_loc_euro` SET `product`="0", `acceleration`="0", `start_time`="0", `end_time`="0", `results`="'.($inf_alm['results']+1).'" WHERE `id`="'.$get_inf.'"');
update_mc($rat_mc);
$_SESSION['msg_ns'] = '<img width="16" height="16" src="img/icons/experience.png" alt="o"> Опыт +'.$rat_mc.'<br> <img width="16" height="16" src="img/euro.png" alt="o"> Евро +40';
header('location:?elysium&location_four'); exit;
}}}}}

elseif(isset($_GET['new_spaceship'])){
$kolish = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_loc_euro` WHERE `id_user`="'.$ku['id'].'"'), 0);
if($kolish<5){
$kolish_dd = cp_location_four($kolish);
if($ku['euro']>=$kolish_dd){
mysql_query('UPDATE `kolhoz_user` SET `euro`="'.($ku['euro']-$kolish_dd).'" WHERE `id`="'.$ku['id'].'"');
mysql_query('INSERT INTO `kolhoz_loc_euro` SET `id_user`="'.$ku['id'].'"');
header('location:?elysium&location_four'); exit;
} else {err_game('У вас не хватает евро.');}
}}
//===========================

echo '<div class="event"><h1><a href="?elysium">Элизиум</a> / <a href="?elysium&location_four&rand='.rand(10000,99999).'">Планета Евро</a></h1></div>'."\n";
echo '<div class="content"><div class="block">'."\n";

$sql = mysql_query('SELECT * FROM `kolhoz_loc_euro` WHERE `id_user`="'.$ku['id'].'" ORDER BY `id`');
$sql_sum_strok = mysql_affected_rows();

if($sql_sum_strok<1){
mysql_query('INSERT INTO `kolhoz_loc_euro` SET `id_user`="'.$ku['id'].'"');
header('location:?elysium&location_four'); exit;
}

//=================================================
while($sql_array = mysql_fetch_assoc($sql)){
echo '<li style="color:#447744;">'."\n";
echo '<img width="48" height="48" src="img/admm/alienblaster.png" alt="o" class="portrait"/>'."\n";
echo '<div><span class="title">'.($sql_array['product']!=1?'Пилотируемая станция</span>':''.(($sql_array['end_time']-($sql_array['acceleration']*$accel))>$time?'Идёт добыча ресурсов</span> <span class="small">(Завершение через '.time_left(($sql_array['end_time']-($sql_array['acceleration']*$accel))-$time).')</span>':'Готов к разгрузке</span>').'').'</div>'."\n";
echo '<div>'."\n";

if($sql_array['product']!=1){
echo '<img width="16" height="16" src="img/admm/1launch.png" alt="o"/> <a href="?elysium&location_four&product='.$sql_array['id'].'">Произвести запуск корабля</a>'."\n";
}

elseif(($sql_array['product']==1)&&(($sql_array['end_time']-($sql_array['acceleration']*$accel))>$time)){
if($sql_array['acceleration']!=1){
if(($sql_array['start_time']+480)<$time){
echo '<img width="16" height="16" src="img/admm/recycling_recycle_recyclin-128.png" alt="o"/> <a href="?elysium&location_four&acceleration='.$sql_array['id'].'">Увеличить скорость</a>'."\n";
} else {echo 'Увеличить скорость через '.time_left(($sql_array['start_time']+480)-$time)."\n";}
} else {echo 'Скорость была увеличена!'."\n";}
}

elseif(($sql_array['product']==1)&&(($sql_array['end_time']-($sql_array['acceleration']*$accel))<=$time)){
echo '<img width="16" height="16" src="img/admm/807000-beacon-light-red.png" alt="o"/> <a href="?elysium&location_four&extraction='.$sql_array['id'].'">Разгрузить корабль</a>'."\n";
}

echo '</div>'."\n";
echo '<div style="clear:both"></div>'."\n";
echo '</li>'."\n";
}
//=================================================

if($sql_sum_strok<5){
echo '<li>'."\n";
echo '<img width="48" height="48" src="img/admm/Space_Art.png" alt="o" class="portrait"/>'."\n";
echo '<div><span class="title">Новый корабль</span></div>'."\n";
echo '<div>'."\n";
echo '<img width="16" height="16" src="img/icons/cart.png" alt="o"/> <a href="?elysium&location_four&new_spaceship">Вызвать корабль</a> за <img width="16" height="16" src="img/euro.png" alt="o"/> <span class="title">'.razdelen(cp_location_four($sql_sum_strok)).' евро</span>'."\n";
echo '</div>'."\n";
echo '<div style="clear:both"></div>'."\n";
echo '</li>'."\n";
}

echo '<li><span class="title">Внимание!</span> Все вопросы по элизиуму обсуждать на форуме.</li>'."\n";

echo '</div></div>'."\n";
include_once('inc/foot.php');
exit;
?>