Файл: pets.php
Строк: 266
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$textl='Питомцы';
include($path.'files/core.php');
if(isset($_GET['act']))
{
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' and `status`='1'");
$num=mysql_num_rows($tr);
if($num==0)
{
mysql_query("UPDATE `pit` SET `status`='1' WHERE `id`='".$_GET['id']."' and `usr`='".$udata['id']."'");
}
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['ot']))
{
mysql_query("UPDATE `pit` SET `status`='0' WHERE `id`='".$_GET['id']."' and `usr`='".$udata['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['sk']))
{
$trs=mysql_query("SELECT * FROM `nav_pit` WHERE `id`=".$_GET['sk']."");
$num=mysql_num_rows($trs);
if($num!=0)
{
$ts=mysql_fetch_array($trs);
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$_GET['pit']."' and `usr`='".$udata['id']."'");
$t=mysql_fetch_array($tr);
if($t['skill']!=0)
{
$trsz=mysql_query("SELECT * FROM `mag_pit` WHERE `pit`=".$t['id']." and `mag`='".$ts['id']."'");
$numz=mysql_num_rows($trsz);
if($numz==0)
{
if($t['tip']==$ts['tip'] or $t['tip']==4 or $ts['tip']==0)
{
if($udata['money']>=$ts['cena'])
{
$mon=$udata['money']-$ts['cena'];
mysql_query("UPDATE `users` SET `money`='".$mon."' WHERE `id`='".$udata['id']."'");
}
else
{
header('location: ?');exit;
}
$skill=$t['skill']-1;
mysql_query("UPDATE `pit` SET `skill`='".$skill."' WHERE `id`='".$t['id']."'");
mysql_query("INSERT INTO `mag_pit` SET
`id`='',
`pit`='".$t['id']."',
`usr`='".$udata['id']."',
`mag`='".$ts['id']."',
`name`='".$ts['name']."',
`img`='".$ts['img']."',
`lvl`='1',
`opis`='".$ts['opis']."',
`shans`='".$ts['shans']."',
`bonus`='".$ts['bonus']."',
`sila`='".$ts['sila']."'
");
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Ваш питомец успешно выучил навык ".$ts['name']."'
");
}
}
}
}
header('location: ?');exit;
}
if(isset($_GET['up']))
{
$trs=mysql_query("SELECT * FROM `mag_pit` WHERE `id`='".$_GET['up']."'");
$ts=mysql_fetch_array($trs);
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$ts['pit']."' and `usr`='".$udata['id']."'");
$t=mysql_num_rows($tr);
if($t!=0)
{
$tz=mysql_fetch_array($tr);
if($tz['skill_up']>0)
{
$skill=mysql_fetch_array(mysql_query("SELECT * FROM `nav_pit` WHERE `id`='".$ts['mag']."'"));
if($ts['lvl']<$skill['max_lvl'])
{
if(isset($_GET['sh']))
{
if($ts['shans']>0)
{
$sh=$ts['shans']+2;
$lvl=$ts['lvl']+1;
mysql_query("UPDATE `mag_pit` SET `shans`='".$sh."', `lvl`='".$lvl."' WHERE `id`='".$ts['id']."'");
$skill=$tz['skill_up']-1;
mysql_query("UPDATE `pit` SET `skill_up`='".$skill."' WHERE `id`='".$tz['id']."'");
}
}
if(isset($_GET['bon']))
{
if($ts['bonus']>0)
{
$sh=$ts['bonus']+3;
$lvl=$ts['lvl']+1;
mysql_query("UPDATE `mag_pit` SET `bonus`='".$sh."', `lvl`='".$lvl."' WHERE `id`='".$ts['id']."'");
$skill=$tz['skill_up']-1;
mysql_query("UPDATE `pit` SET `skill_up`='".$skill."' WHERE `id`='".$tz['id']."'");
}
}
if(isset($_GET['sila']))
{
if($ts['sila']>0)
{
$sh=$ts['sila']+25;
$lvl=$ts['lvl']+1;
mysql_query("UPDATE `mag_pit` SET `sila`='".$sh."', `lvl`='".$lvl."' WHERE `id`='".$ts['id']."'");
$skill=$tz['skill_up']-1;
mysql_query("UPDATE `pit` SET `skill_up`='".$skill."' WHERE `id`='".$tz['id']."'");
}
}
}
}
}
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if(isset($_GET['sn']))
{
$mobs=mysql_query("SELECT * FROM `item` WHERE `id`='".mysql_real_escape_string($_GET['id'])."' and `status`='on' and `usr`='".$udata['id']."'");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
header('location: ?');exit;
}
else
{
$sfer=mysql_fetch_array($mobs);
if($sfer['tip']=='pet1' or $sfer['tip']=='pet2'){
mysql_query("UPDATE `item` SET `status`='off', `pet`='0' WHERE `id`='".$sfer['id']."'");
}
header('location: ?info='.$sfer['pet'].'');exit;
}
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>Питомцы
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
if(isset($_GET['info']))
{
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$_GET['info']."' and `usr`='".$udata['id']."'");
$t=mysql_fetch_array($tr);
echo'<img src=img/pit/'.$t['tip'].'/'.$t['img'].'.jpg width=45% alt='.$t['name'].' title='.$t['name'].'><br>
<img src=img/main/p21.png> Тип: ';
if($t['tip']==1)
{
echo'<font color=#ffff00>Тяжеловес</font>';
}
elseif($t['tip']==2)
{
echo'<font color=#ffff00>Ловкач</font>';
}
elseif($t['tip']==3)
{
echo'<font color=#ffff00>Паразит</font>';
}
elseif($t['tip']==4)
{
echo'<font color=#ffff00>Уникальный</font>';
}
if($t['lvl']<=10)
{
$sp=10;
}
elseif($t['lvl']>=11 and $t['lvl']<=20)
{
$sp=9;
}
elseif($t['lvl']>20 and $t['lvl']<=30)
{
$sp=8;
}
elseif($t['lvl']>30 and $t['lvl']<=40)
{
$sp=7;
}
elseif($t['lvl']>40)
{
$sp=6;
}
echo'<br>
<img src=img/main/p21.png> Атака: <font color=#cccccc><img src=img/main/e12.png> '.$sp.'сек.</font><br>';
if($t['status']==0)
{
echo'<img src=img/main/p21.png> Активность: <font color=#ff0000>неактивен</font><br>
<img src=img/main/p21.png> <a href=?id='.$t['id'].'&act>Призвать</a><br>
';
}
if($t['status']==1)
{
echo'<img src=img/main/p21.png> Активность: <font color=#00cc00>активен</font><br>
<img src=img/main/p21.png> <a href=?id='.$t['id'].'&ot>Отозвать</a><br>
';
}
echo'<img src=img/main/p21.png> Очки навыков: <img src=img/main/e28.png><font color=#00cc00>'.$t['skill'].'</font><br>';
echo'<img src=img/main/p21.png> Очки прокачки навыков: <img src=img/main/e30.png><font color=#00cc00>'.$t['skill_up'].'</font><br>';
echo'<img src=img/main/p21.png> Уровень: <img src=img/main/p10.png>'.$t['lvl'].'<br>';
$expl=$t['lvl']+1;
$ex=mysql_fetch_array(mysql_query("SELECT * FROM `lvl_pit` WHERE `lvl`='".$expl."'"));
echo'<img src=img/main/p21.png> Опыт уровня: <img src=img/main/p10.png>'.$t['exp'].'/'.$ex['exp'].'<br>';
echo'<img src=img/main/p21.png> <a href=?skills='.$t['id'].'>Навыки</a><br>';
echo'<img src=img/main/p21.png> <a href=?amyna='.$t['id'].'>Амуниция</a><br>';
echo'</div>';
echo '<div class="v8"><div class="line m bbs bts brs bls b p v12">Базовые Параметры</div><div class="bat bts brs bls bbs p t3">';
echo'<img src=img/main/p3.png> <font color=#999999>Живучесть</font>: <font color=#00ff00>'.$t['hp1'].'</font> (Жизнь: '.$t['hp'].')<br>';
echo'<img src=img/main/p1.png> <font color=#999999>Сила</font>: <font color=#00ff00>'.$t['sila1'].'</font> (Урон: '.$t['sila'].')<br>';
echo'<img src=img/main/p2.png> <font color=#999999>Броня</font>: <font color=#00ff00>'.$t['arm1'].'</font> (Защита: '.$t['arm'].')<br>';
echo'</div>';
$tr=mysql_query("SELECT * FROM `mag_pit` WHERE `pit`='".$t['id']."'");
$num=mysql_num_rows($tr);
if($num!=0)
{
echo '<div class="v8"><div class="line bbs m bts brs bls b p v12">Навыки</div><div class="bat bts brs bls bbs p t1">';
$trs=mysql_query("SELECT * FROM `mag_pit` WHERE `pit`='".$t['id']."' ORDER BY `id`");
while($ts=mysql_fetch_array($trs))
{
echo'<a href=?mag_info='.$ts['id'].'>
<img src=img/pit/skill/'.$ts['img'].'.png alt='.$ts['name'].' title='.$ts['name'].'></a>
';
}
}
}
elseif(isset($_GET['amyna']))
{
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$_GET['amyna']."' and `usr`='".$udata['id']."'");
$t=mysql_fetch_array($tr);
echo '<table width=100%><tr>';
$mobs=mysql_query("SELECT * FROM `item` WHERE `tip`='pet1' and `status`='on' and `usr`='".$udata['id']."' and `pet`='".$t['id']."'");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
echo '<td width=36px><img src=img/arm/empty.jpg></td>
<td>Пусто<br><font color=#999999>Броня</font></td>
';
}
else
{
$avto=mysql_fetch_array($mobs);
echo '<td width=36px><img src=img/arm/pet1/'.$avto['img'].'.jpg></td>';
$kac='p28';
echo '<td><img src=img/main/'.$kac.'.png> <a href=info_arm.php?id='.$avto['id'].'>'.$avto['name'].'</a><img src=img/main/p10.png>'.$avto['lvl'].'';
echo'<br>
<a href=?sn&id='.$avto['id'].'><font color=#ff0000>снять</font></a>
</td>';
}
echo '</tr><tr>';
$mobs=mysql_query("SELECT * FROM `item` WHERE `tip`='pet2' and `status`='on' and `usr`='".$udata['id']."' and `pet`='".$t['id']."'");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
echo '<td width=36px><img src=img/arm/empty.jpg></td>
<td>Пусто<br><font color=#999999>Боевые когти</font></td>
';
}
else
{
$avto=mysql_fetch_array($mobs);
echo '<td width=36px><img src=img/arm/pet2/'.$avto['img'].'.jpg></td>';
$kac='p28';
echo '<td><img src=img/main/'.$kac.'.png> <a href=info_arm.php?id='.$avto['id'].'>'.$avto['name'].'</a><img src=img/main/p10.png>'.$avto['lvl'].'';
echo'<br>
<a href=?sn&id='.$avto['id'].'><font color=#ff0000>снять</font></a>
</td>';
}
echo '</tr>
</table>';
}
elseif(isset($_GET['skills']))
{
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$_GET['skills']."' and `usr`='".$udata['id']."'");
$t=mysql_fetch_array($tr);
echo'<img src=img/main/p21.png> Очки навыков: <img src=img/main/e28.png><font color=#00cc00>'.$t['skill'].'</font><br>';
if($t['tip']!=4)
{
$trs=mysql_query("SELECT * FROM `nav_pit` WHERE `tip`='".$t['tip']."' ORDER BY `id`");
}
else
{
$trs=mysql_query("SELECT * FROM `nav_pit` ORDER BY `id`");
}
while($ts=mysql_fetch_array($trs))
{
echo'<table>
<tr>
<td><img src=img/pit/skill/'.$ts['img'].'.png alt='.$ts['name'].' title='.$ts['name'].'></td>
<td><img src=img/main/p21.png> <font color=#00ffff>'.$ts['name'].'</font><br>
<img src=img/main/e28.png> <font color=#ff9900><i>'.$ts['opis'].'</i></font><br>
<img src=img/main/p21.png> <a href=?sk='.$ts['id'].'&pit='.$t['id'].'>Купить</a> за <img src=img/main/p5.png>'.$ts['cena'].'
</td>
</tr>
</table>
';
}
}
elseif($_GET['mag_info'])
{
$trs=mysql_query("SELECT * FROM `mag_pit` WHERE `id`='".$_GET['mag_info']."'");
$ts=mysql_fetch_array($trs);
$skill=mysql_fetch_array(mysql_query("SELECT * FROM `nav_pit` WHERE `id`='".$ts['mag']."'"));
$tr=mysql_query("SELECT * FROM `pit` WHERE `id`='".$ts['pit']."' and `usr`='".$udata['id']."'");
$t=mysql_num_rows($tr);
if($t!=0)
{
$tz=mysql_fetch_array($tr);
echo'<img src=img/main/p21.png> Очки прокачки навыков: <img src=img/main/e30.png><font color=#00cc00>'.$tz['skill_up'].'</font><br>';
echo'<table>
<tr>
<td><img src=img/pit/skill/'.$ts['img'].'.png alt='.$ts['name'].' title='.$ts['name'].'></td>
<td><img src=img/main/p21.png> <font color=#00ffff>'.$ts['name'].'</font><br>
<img src=img/main/e28.png> <font color=#ffff00><i>'.$ts['opis'].'</i></font><br>
<img src=img/main/p21.png> Уровень Навыка: <font color=#00ffff>'.$ts['lvl'].'/'.$skill['max_lvl'].'</font><br>';
if($ts['shans']>0)
{
echo'<img src=img/main/p21.png> Шанс активации: <font color=#00ffff>'.$ts['shans'].'%</font>';
if($tz['skill_up']>0)
{
echo' <a href=?up='.$ts['id'].'&sh>[+2%]</a>';
}
echo'<br>';
}
if($ts['bonus']>0)
{
echo'<img src=img/main/p21.png> Бонус: +<font color=#00ffff>'.$ts['bonus'].'%</font>';
if($tz['skill_up']>0)
{
echo' <a href=?up='.$ts['id'].'&bon>[+3%]</a>';
}
echo'<br>';
}
if($ts['sila']>0)
{
echo'<img src=img/main/p21.png> Сила атаки: <font color=#00ffff>'.$ts['sila'].'</font>';
if($tz['skill_up']>0)
{
echo' <a href=?up='.$ts['id'].'&sila>[+25]</a>';
}
echo'<br>';
}
echo'</td>
</tr>
</table>';
}
}
else
{
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' ORDER BY `id`");
while($t=mysql_fetch_array($tr))
{
echo'<a href=?info='.$t['id'].'>
<img src=img/pit/'.$t['tip'].'/'.$t['img'].'.jpg width=32% alt='.$t['name'].' title='.$t['name'].'></a>
';
}
}
echo '</div></div>';
include('files/down.php');
?>