Файл: Gladiators v2.2/modules/shop/index.asp
Строк: 141
<?php
/**
* @author ByUNNAMED
* @copyright 2012
*/
ob_start();
$title='Магазин';//Титул
include('../../system/include/settings.inc');//Потключаемся к базе
include('../../system/include/function.inc');//Выводим функции
head($title,$udata2);//Верх страницы
if(isset($udata['pass']) && isset($udata2['nick'])){
switch($_GET['mod'])
{
default:
echo '<a href="?mod=shop&type=weapon">Оружия</a>';
echo '<br /><a href="?mod=shop&type=shield">Щиты</a>';
echo '<br /><a href="?mod=shop&type=golova">Защита для головы</a>';
echo '<br /><a href="?mod=shop&type=body">Защита для живота</a>';
echo '<br /><a href="?mod=shop&type=nogi">Защита для ног</a>';
echo '<br /><a href="?mod=elixir&type=elixir">Эликсиры</a>';
break;
case 'shop':
$type = mysql_real_escape_string($_GET['type']);
$at_page=6;
$page = (int)$_GET['page'];
$s=mysql_result(mysql_query("SELECT COUNT(`id`) FROM `shop` WHERE `type` = '$type'"),0);
$total = intval(($s - 1) / $at_page) + 1;
$page = (int)$page;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$from = $page * $at_page - $at_page;
$type = mysql_real_escape_string($_GET['type']);
$req = mysql_query("SELECT * FROM `shop` WHERE `type` = '$type' ORDER BY `lvl` LIMIT ".$from.",".$at_page."");
$avto = mysql_num_rows($req);
if($avto > 0)
{
while($shop = mysql_fetch_array($req))
{
echo '<a href="?mod=info&id='.$shop['id'].'">'.$shop['name'].'</a> [Уровень '.$shop['lvl'].'-30]<br />';
}
if($at_page > 0)
{
if($s > $onpage) echo '';
if ($page >= 4) $go1 = '<a href= ?mod=shop&type='.$type.'&page=1>1</a> ... ';
if ($page != $total and $page != $total-1) $outpage = ' ... <a href= ?mod=shop&type='.$type.'&page=' .$total. '>'.$total.'</a>';
if($page - 2 > 0) $page2left = ' <a href= ?mod=shop&type='.$type.'&page='. ($page - 2) .'>'. ($page - 2) .'</a> ';
if($page - 1 > 0) $page1left = '<a href= ?mod=shop&type='.$type.'&page='. ($page - 1) .'>'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href= ?mod=shop&type='.$type.'&page='. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href= ?mod=shop&type='.$type.'&page='. ($page + 1) .'&>'. ($page + 1) .'</a>';
if($s > $onpage) echo 'Страницы: ('.$go1.''.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.''.$outpage.')<br/>';
}
}else{
echo 'Нет вещей!<br />';
echo '<a href="?">Назад</a><br />';
}
break;
case 'elixir':
$type = mysql_real_escape_string($_GET['type']);
$req = mysql_query("SELECT * FROM `shop` WHERE `type` = '$type'");
$avto = mysql_num_rows($req);
if($avto > 0)
{
while($shop = mysql_fetch_array($req))
{
echo '<a href="?mod=info_el&id='.$shop['id'].'">'.$shop['name'].'</a> [Уровень '.$shop['lvl'].'-30]<br />';
}}else{
echo 'Нет вещей!<br />';
echo '<a href="?">Назад</a><br />';
}
break;
case 'info':
$id=abs(intval($_GET[id]));
$req = mysql_query("SELECT * FROM `shop` WHERE `id` = '$id'");
$shop = mysql_fetch_array($req);
if($shop['type'] == 'weapon')
{
echo $shop['name'];
echo '<br />Атака: '.$shop['p_ataka'];
if($udata2['lvl'] < $shop['lvl'])
{
echo '<br /><font color=red>Уровень: '.$shop['lvl'].'-30</font>';
}else{
echo '<br />Уровень: '.$shop['lvl'].'-30';
}
echo '<hr>';
echo '<b>Цена</b>';
if($shop['gold'] != 0)
{
echo '<br />Золото: '.$shop['gold'];
}
if($shop['tree'] != 0)
{
echo '<br />Дерево: '.$shop['tree'];
}
if($shop['iron'] != 0)
{
echo '<br />Железо: '.$shop['iron'];
}
if($shop['stones'] != 0)
{
echo '<br />Камень: '.$shop['stones'];
}
echo '<br /><b><a href="?mod=buy&id='.$shop['id'].'">Купить</a></b>';
}else{
echo $shop['name'];
echo '<br />Физ. Защита: '.$shop['p_def'];
echo '<br />Защита головы: '.$shop['p_golova'];
echo '<br />Защита живота: '.$shop['p_body'];
echo '<br />Защита ног: '.$shop['p_nogi'];
if($udata2['lvl'] < $shop['lvl'])
{
echo '<br /><font color=red>Уровень: '.$shop['lvl'].'-30</font>';
}else{
echo '<br />Уровень: '.$shop['lvl'].'-30';
}
echo '<hr>';
echo '<b>Цена</b>';
if($shop['gold'] != 0)
{
echo '<br />Золото: '.$shop['gold'];
}
if($shop['tree'] != 0)
{
echo '<br />Дерево: '.$shop['tree'];
}
if($shop['iron'] != 0)
{
echo '<br />Железо: '.$shop['iron'];
}
if($shop['stones'] != 0)
{
echo '<br />Камень: '.$shop['stones'];
}
echo '<br /><b><a href="?mod=buy&id='.$shop['id'].'">Купить</a></b>';
}
break;
case 'info_el':
$id=abs(intval($_GET[id]));
$req = mysql_query("SELECT * FROM `shop` WHERE `id` = '$id'");
$shop = mysql_fetch_array($req);
echo $shop['name'];
echo '<br />Количество: '.$shop['number'];
if($udata2['lvl'] < $shop['lvl'])
{
echo '<br /><font color=red>Уровень: '.$shop['lvl'].'-30</font>';
}else{
echo '<br />Уровень: '.$shop['lvl'].'-30';
}
echo '<hr>';
echo '<b>Цена</b>';
if($shop['gold'] != 0)
{
echo '<br />Золото: '.$shop['gold'];
}
if($shop['tree'] != 0)
{
echo '<br />Дерево: '.$shop['tree'];
}
if($shop['iron'] != 0)
{
echo '<br />Железо: '.$shop['iron'];
}
if($shop['stones'] != 0)
{
echo '<br />Камень: '.$shop['stones'];
}
echo '<br /><b><a href="?mod=buy_el&id='.$shop['id'].'">Купить</a></b>';
break;
case 'buy':
$id=abs(intval($_GET[id]));
$req = mysql_query("SELECT * FROM `shop` WHERE `id` = '$id'");
$shop = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto <= 0)
{
echo 'Таких вещей нет!';
echo '<br /><b><a href="?mod=shop">Назад</a></b>';
foot(); exit;
}
if($udata2['gold'] < $shop['gold'])
{
echo 'У вас слишком мало золота!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['tree'] < $shop['tree'])
{
echo 'У вас слишком мало дерева!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['iron'] < $shop['iron'])
{
echo 'У вас слишком мало железа!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['stones'] < $shop['stones'])
{
echo 'У вас слишком мало камня!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b>';
foot(); exit;
}
mysql_query("INSERT INTO `implements`
SET `usr` = '".$udata2['nick']."',
`name` = '".$shop['name']."',
`lat_name` = '".$shop['lat_name']."',
`p_ataka` = '".$shop['p_ataka']."',
`p_def` = '".$shop['p_def']."',
`p_golova` = '".$shop['p_golova']."',
`p_body` = '".$shop['p_body']."',
`p_nogi` = '".$shop['p_nogi']."',
`hp` = '".$shop['hp']."',
`lvl` = '".$shop['lvl']."',
`dressed` = 'not',
`type` = '".$shop['type']."',
`number` = '".$shop['number']."'");
$gold = $udata2['gold'] - $shop['gold'];
$tree = $udata2['tree'] - $shop['tree'];
$iron = $udata2['iron'] - $shop['iron'];
$stones = $udata2['stones'] - $shop['stones'];
mysql_query("UPDATE `chars` SET `gold` = '$gold', `tree` = '$tree', `iron` = '$iron', `stones` = '$stones' WHERE `nick` = '".$udata2['nick']."'");
echo 'Вы успешно купили '.$shop['name'].'<br /><b><a href="?">Назад</a></b>';
break;
case 'buy_el':
$id=abs(intval($_GET['id']));
$req = mysql_query("SELECT * FROM `shop` WHERE `id` = '$id'");
$shop = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto <= 0)
{
echo 'Таких вещей нет!';
echo '<br /><b><a href="?mod=shop">Назад</a></b>';
foot(); exit;
}
if($udata2['gold'] < $shop['gold'])
{
echo 'У вас слишком мало золота!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['tree'] < $shop['tree'])
{
echo 'У вас слишком мало дерева!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['iron'] < $shop['iron'])
{
echo 'У вас слишком мало железа!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b><br />';
foot(); exit;
}
if($udata2['stones'] < $shop['stones'])
{
echo 'У вас слишком мало камня!';
echo '<br /><b><a href="?mod=shop&type='.$shop['type'].'">Назад</a></b>';
foot(); exit;
}
$req = mysql_query("SELECT * FROM `implements` WHERE `lat_name` = '".$shop['lat_name']."' and `usr` = '".$udata2['nick']."'");
$avto = mysql_num_rows($req);
if($avto > 0)
{
$in = mysql_fetch_array($req);
$kol = $in['number'] + $shop['number'];
mysql_query("UPDATE `implements`
SET `usr` = '".$udata2['nick']."',
`name` = '".$shop['name']."',
`lat_name` = '".$shop['lat_name']."',
`p_ataka` = '".$shop['p_ataka']."',
`p_def` = '".$shop['p_def']."',
`p_golova` = '".$shop['p_golova']."',
`p_body` = '".$shop['p_body']."',
`p_nogi` = '".$shop['p_nogi']."',
`hp` = '".$shop['hp']."',
`lvl` = '".$shop['lvl']."',
`dressed` = 'not',
`type` = '".$shop['type']."',
`number` = '$kol' WHERE `lat_name` = '".$shop['lat_name']."' and `usr` = '".$udata2['nick']."'");
}else{
mysql_query("INSERT INTO `implements`
SET `usr` = '".$udata2['nick']."',
`name` = '".$shop['name']."',
`lat_name` = '".$shop['lat_name']."',
`p_ataka` = '".$shop['p_ataka']."',
`p_def` = '".$shop['p_def']."',
`p_golova` = '".$shop['p_golova']."',
`p_body` = '".$shop['p_body']."',
`p_nogi` = '".$shop['p_nogi']."',
`hp` = '".$shop['hp']."',
`lvl` = '".$shop['lvl']."',
`dressed` = 'not',
`type` = '".$shop['type']."',
`number` = '".$shop['number']."'");
}
$gold = $udata2['gold'] - $shop['gold'];
$tree = $udata2['tree'] - $shop['tree'];
$iron = $udata2['iron'] - $shop['iron'];
$stones = $udata2['stones'] - $shop['stones'];
mysql_query("UPDATE `chars` SET `gold` = '$gold', `tree` = '$tree', `iron` = '$iron', `stones` = '$stones' WHERE `nick` = '".$udata2['nick']."'");
echo 'Вы успешно купили '.$shop['name'].'<br /><b><a href="?">Назад</a></b>';
break;
}
}else{echo'Вы не ';
echo '<a href="../../index.asp">авторизированы</a> или не выбран персонаж';
}
foot();
?>