Файл: accmarket.net/zerg/shpil.php
Строк: 93
<?php
define('_ON_CMS', 1);
require_once '../includes/start.php';
require_once '../includes/function.php';
require_once '../includes/header.php';
$pl=$_GET['p'];
$q = mysql_query("SELECT * FROM `planet` WHERE `id`='".check(mysql_real_escape_string($pl))."'");
$f = mysql_fetch_array($q);
$s = mysql_query("SELECT * FROM `building` WHERE `planet_id`='".check(mysql_real_escape_string($f['id']))."'");
$b = mysql_fetch_array($s);
if($game==0 OR $level==0 OR $rasa!=3 OR $f['uid']!=$use_id OR $b['b11']==0 OR $ban!=0){
header('Location: ../index.php');
}
echo '<div class="top"><a href="../game/planet.php?act=pl&p='.$f['id'].'">Планета '.$f['name'].'</a> | Шпиль</div>';
switch ($act) {
default:
echo '<div class="conts">';
if($lvl_hero>=16)echo '<img src="../images/zerg.png" alt="image" /> <a href="?act=un&u=8&p='.$f['id'].'">Владыки</a><br/>';
if($lvl_hero>=17)echo '<img src="../images/zerg.png" alt="image" /> <a href="?act=un&u=9&p='.$f['id'].'">Муталиски</a><br/>';
if($lvl_hero>=17)echo '<img src="../images/zerg.png" alt="image" /> <a href="?act=un&u=10&p='.$f['id'].'">Губители</a><br/>';
if($lvl_hero>=17)echo '<img src="../images/zerg.png" alt="image" /> <a href="?act=un&u=11&p='.$f['id'].'">Хозяины стаи</a><br/>';
if($lvl_hero>=18)echo '<img src="../images/zerg.png" alt="image" /> <a href="?act=un&u=12&p='.$f['id'].'">Левиафаны</a>';
echo '</div>';
break;
case 'un':
$un=$_GET['u'];
$q = mysql_query("SELECT * FROM `units_info` WHERE `unit`='".check(mysql_real_escape_string($un))."' AND `rasa`='".$rasa."'");
$u = mysql_fetch_array($q);
if($lvl_hero>=$u['lvl_hero'] AND $u['lvl_hero']!='' AND $u['unit']>=8 AND $u['unit']<=12){
echo '<div class="cont">'.rasa($rasa).' '.$u['name'].'</div><div class="conts">';
if(!$_POST)
{
echo 'Стоимость 1 юнита:<br/>
<img src="../images/min.gif" alt="image" /> '.$u['min'].' минералов<br/>
<img src="../images/metall.gif" alt="image" /> '.$u['metall'].' металлов<br/>
<img src="../images/gas.gif" alt="image" /> '.$u['gas'].' газа Веспен<br/>
<img src="../images/water.png" alt="image" /> '.$u['water'].' воды<br/>
<img src="../images/peo.gif" alt="" /> '.$u['peo'].' населения<br/>
<form action="" method="POST">
Кол-во обучаемых: <br />
<input type="text" value="" name="number" />
<input type="submit" name="submit" value="Обучить"/></form>';
}
else
{
$number2 = check(trim($_POST['number']));
$error = false;
if (empty($number2))
$error = $error . 'Не введено число юнитов<br/>';
elseif (preg_match('/[^d_]+/',$number2))
$error = $error . 'Недопустимые символы<br />';
if (empty($error))
{
$gas1=$number2*$u['gas'];
$min1=$number2*$u['min'];
$metall1=$number2*$u['metall'];
$water1=$number2*$u['water'];
$peo1=$number2*$u['peo'];
$timerab=$realtime+($number2*$u['time']);
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `rabota` WHERE `typerab`=8 AND `planet`='".$f['id']."' AND `type`='".$u['unit']."';"), 0);
if($count!=0){echo 'Юниты данного типа уже обучаются!<br/>';}else{
if($gas>=$gas1 AND $min>=$min1 AND $metall>=$metall1 AND $water>=$water1 AND $f['peo']>=$peo1){
mysql_query("INSERT INTO `rabota` SET
`uid`='".$use_id."',
`planet`='".$f['id']."',
`name_planet`='".$f['name']."',
`rasa`='".$rasa."',
`typerab`=8,
`type`='".$u['unit']."',
`number`='" . check(mysql_real_escape_string($number2)) . "',
`time`=$timerab;");
mysql_query("UPDATE `users` SET
`metall`=metall-$metall1,
`gas`=gas-$gas1,
`min`=min-$min1,
`water`=water-$water1 WHERE `id` = '".$use_id."';");
mysql_query("UPDATE `planet` SET
`peo`=peo-$peo1 WHERE `id` = '".$f['id']."';");
echo ''.rasa($rasa).' Начато обучение '.$u['name'].' ['.$number2.']!<br/>
Использовано:<br/>
<img src="../images/min.gif" alt="image" /> '.$min1.' минералов<br/>
<img src="../images/metall.gif" alt="image" /> '.$metall1.' металлов<br/>
<img src="../images/gas.gif" alt="image" /> '.$gas1.' газа Веспен<br/>
<img src="../images/water.png" alt="image" /> '.$water1.' воды<br/>
<img src="../images/peo.gif" alt="" /> '.$peo1.' населения<br/>
<img src="../images/time.gif" alt="image" /> Работа будет завершена '.dates($timerab).'<br/>';
} else {
echo 'Не хватает ресурсов! Нужно:<br/>
<img src="../images/min.gif" alt="image" /> '.$min1.' минералов<br/>
<img src="../images/metall.gif" alt="image" /> '.$metall1.' металлов<br/>
<img src="../images/gas.gif" alt="image" /> '.$gas1.' газа Веспен<br/>
<img src="../images/water.png" alt="image" /> '.$water1.' воды<br/>
<img src="../images/peo.gif" alt="" /> '.$peo1.' населения<br/>';
}}}else{
echo ''.$error.'';
}}
echo '<a href="shpil.php?p='.$f['id'].'"><<Назад</a></div>';
}
break;
}
div('<a href="../">В игру</a>','conts');
require_once '../includes/footer.php';
?>