<?
$accel = 25200;
function cp_location_two($count){
$result = $count+=1;
return $result*10000000000000000; // Цисло умножаемое на колличество уже имеющихся короблей и выступает как цена
}

if(isset($_GET['product'])){
if(is_numeric($_GET['product'])){
$get_inf = floor($_GET['product']);
if($get_inf>=1){
$inf_alm = mysql_fetch_assoc(mysql_querll('SELECT * FROM `kolhoz_loc_rubies` WHERE `id`="'.$get_inf.'"'));
if($inf_alm['id_user'] == $ku['id']){
if($inf_alm['product']!=1){
if($ku['rubies']>=20000000){
mysql_querll('UPDATE `kolhoz_user` SET `rubies`="'.($ku['rubies']-20000000).'" WHERE `id`="'.$ku['id'].'"');
mysql_querll('UPDATE `kolhoz_loc_rubies` SET `product`="1", `start_time`="'.$time.'", `end_time`="'.($time+86400).'" WHERE `id`="'.$get_inf.'"');
header('location:?elysium&location_two'); 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_querll('SELECT * FROM `kolhoz_loc_rubies` 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_querll('UPDATE `kolhoz_user` SET `euro`="'.($ku['euro']-20).'" WHERE `id`="'.$ku['id'].'"');
mysql_querll('UPDATE `kolhoz_loc_rubies` SET `acceleration`="1" WHERE `id`="'.$get_inf.'"');
header('location:?elysium&location_two'); 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_querll('SELECT * FROM `kolhoz_loc_rubies` 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_querll('UPDATE `kolhoz_user` SET `rubies`="'.($ku['rubies']+300000000000000).'", `rating`="'.($ku['rating']+$rat_mc).'" WHERE `id`="'.$ku['id'].'"');
mysql_querll('UPDATE `kolhoz_loc_rubies` 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="images/icons/experience.png" alt="o"> Опыт +'.$rat_mc.'<br> <img width="16" height="16" src="images/icons/ruby.png" alt="o"> Рубины +300000000000000';
header('location:?elysium&location_two'); exit;
}}}}}

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

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

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

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

//=================================================
while($sql_array = mysql_fetch_assoc($sql)){
echo '<li style="color:#447744;">'."\n";
echo '<img width="48" height="48" src="images/admm/anakin_starfighter.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="images/admm/1launch.png" alt="o"/> <a href="?elysium&location_two&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="images/admm/recycling_recycle_recyclin-128.png" alt="o"/> <a href="?elysium&location_two&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="images/admm/807000-beacon-light-red.png" alt="o"/> <a href="?elysium&location_two&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="images/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="images/icons/cart.png" alt="o"/> <a href="?elysium&location_two&new_spaceship">Вызвать корабль</a> за <img width="16" height="16" src="images/icons/ruby.png" alt="o"/> <span class="title">'.rating(cp_location_two($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;
?>