Файл: okrestnosti.php
Строк: 211
<?
define('PROTECTOR', 1);
$headmod = 'okrestnosti';//фикс. места
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
zasad();
ryd();
place_city();
place_zamok();
place_tower();
include($path.'files/core.php');
/////////место
$req = mysql_query("SELECT * FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_array($req);
/////////////////////////////////////////
$req = mysql_query("SELECT * FROM `world` WHERE `city` = '$udata[city]' and `x`='$mestouser[x]' and `y`='$mestouser[y]'");
$world = mysql_fetch_array($req);
//////////////////////////////////////////
if($_GET[mod]==go_left or $_GET[mod]==go_right or $_GET[mod]==go_up or $_GET[mod]==go_down){
$header=TRUE;
}else{
if(empty($world[name])){
$textl='Окрестности';}else{
$textl=$world[name];
}
}
include($path.'files/head.php');
include($path.'files/zag.php');
////////////////////////
$random=rand(1000,9999);
////////////////
function zasada(){
global $log,$udata,$mestouser;
$req = mysql_query("SELECT * FROM `zasada` WHERE `city` = '$udata[city]' and `x`='$mestouser[x]' and `y`='$mestouser[y]' and `usr`!='$log' LIMIT 1");
$ri=mysql_num_rows($req);
if($ri==1){
$zasada = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$zasada[usr]'");
$pk = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `pk` WHERE `usr` = '$pk[usr]'");
$avto=mysql_num_rows($req);
if($avto>="1"){
mysql_query("DELETE FROM `zasada` WHERE usr='$pk[usr]'");
}
$reqtmp = mysql_query("SELECT * FROM `tmp` WHERE `usr` = '$pk[usr]' LIMIT 1");
if (mysql_num_rows($reqtmp)>=1){
mysql_query("DELETE FROM `zasada` WHERE usr='$pk[usr]'");
}
if($zasada[tip]==1){
if(!empty($udata[clan]) and $udata[clan]!=$pk[clan]){
$ztip=true;
}
}else{
if(empty($udata[clan])){
$ztip=true;
}
}
$timeout = time() - 150;
$asd = mysql_num_rows(mysql_query("SELECT laikas, usr FROM online WHERE laikas > '$timeout' AND usr='$pk[usr]'"));
////////////////////////////
if($asd==0){
mysql_query("DELETE FROM `zasada` WHERE usr='$pk[usr]'");
}
if($udata[lvl]>=5 and $ztip==true){
$time=time();
mysql_query("INSERT INTO
`pk` SET `usr` = '$log',
`enemy` = '$pk[usr]',
`xod` = 'not',
`ltime`='$time'");
mysql_query("INSERT INTO
`pk` SET `usr` = '$pk[usr]',
`enemy` = '$log',
`napal` = '1',
`xod` = 'not',
`ltime`='$time'");
mysql_query("INSERT INTO pk_log SET usr='$log',log='Вы попали в засаду $pk[usr]!Бой начался!',kto='system'");
mysql_query("INSERT INTO pk_log SET usr='$pk[usr]',log='$log попал в вашу засаду!Бой начался!',kto='system'");
mysql_query("DELETE FROM `zasada` WHERE usr='$pk[usr]'");
echo"Вы попали в засаду <b>$pk[usr]</b>!<br/>";
echo"<a href="pk.php?">Бой</a>";
include($path.'files/down.php');exit;
}
}
}
switch($_GET[mod]){
default:
zasada();//засады
$xi=$mestouser[x]-1;
$xmi=$mestouser[x]+1;
$yi=$mestouser[y]-1;
$ymi=$mestouser[y]+1;
#################################
if($world['br']=='0'){
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `x` = '$xmi' AND `y`='$mestouser[y]' LIMIT 1");
$ri=mysql_num_rows($req);
if($ri==1){
$right = mysql_fetch_array($req);
}
}
################################
if($world['bl']=='0'){
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `x` = '$xi' AND `y`='$mestouser[y]' LIMIT 1");
$le=mysql_num_rows($req);
if($le==1){
$left = mysql_fetch_array($req);
}
}
##############################
if($world['bu']=='0'){
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `y` = '$ymi' AND `x`='$mestouser[x]' LIMIT 1");
$up=mysql_num_rows($req);
if($up==1){
$upo = mysql_fetch_array($req);
}
}
#######################################
if($world['bd']=='0'){
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' and `y` = '$yi' and `x`='$mestouser[x]' LIMIT 1");
$do=mysql_num_rows($req);
if($do==1){
$down = mysql_fetch_array($req);
}
}
$req = mysql_query("SELECT * FROM `mob` WHERE `city` = '$udata[city]' and `x`='$mestouser[x]' and `y`='$mestouser[y]' ORDER BY lvl DESC");
//////////////////////////////
echo"<div align='center'><b>$world[name]</b></div>";
echo"<div align='center'><b>Если Вы хотели попасть в другое место, но попали сюда - Вам следует перейти для начала в Город (ссылка внизу)</b></div>";
echo"<div align='center'><b><font color='red'>X</font>: $mestouser[x]; <font color='red'>Y</font>: $mestouser[y]</b></div>";
echo"<div align='center'><b><a href="okrestnosti.php?&r=$random">Ждать</a></b></div>";
$avto=mysql_num_rows($req);
if($avto>=1){
echo'<b>Монстры:</b><br/>';
While($mob = mysql_fetch_array($req))
{
if($mob['tip']=='boss'){
$color='#e94038';
}else{
$color='#5ade36';
}
if($mob[status]==on){
echo"<a href="ok.php?id=$mob[id]"><font color='$color'>$mob[name]($mob[hp] хп, $mob[lvl] ур)</font></a> [<a href="okrestnosti.php?mod=info&id=$mob[id]">Инфо</a>]<br/>";
}
elseif($mob[status]==battle){
$r = mysql_query("SELECT * FROM `tmp` WHERE `city` = '$udata[city]' AND `usr`='$mob[oponent]' LIMIT 1");
$m = mysql_fetch_array($r);
$d = time();
if(($d>=($m['ltime']+600) and $mob[hp]<=0) or $d>=($m['ltime']+600)){
mysql_query("UPDATE `mob` SET `status`='on',`hp`='$mob[hpall]', `oponent`='not' WHERE `id` = '$mob[id]'");
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$mob[oponent]' LIMIT 1");
$mu = mysql_fetch_array($req);
$nloses=$mu[loses]+1;
mysql_query("UPDATE users SET loses = '$nloses',hp='0' WHERE usr = '$mob[oponent]'");//пишем данные в плэера
mysql_query("DELETE FROM `tmp` WHERE usr='$mob[oponent]'");
mysql_query("DELETE FROM `log` WHERE usr='$mob[oponent]'");
echo"<a href="ok.php?id=$mob[id]"><font color='$color'>$mob[name]($mob[hp] хп, $mob[lvl] ур)</font></a> [<a href="okrestnosti.php?mod=info&id=$mob[id]">Инфо</a>]<br/>";
}else{
echo"<b><a href="okrestnosti.php?mod=info&id=$mob[id]"><font color='$color'>$mob[name]($mob[hp]/$mob[hpall])</font></a> против <a href="search.php?nick=$mob[oponent]&go=go">$mob[oponent]</a></b><br/>";
}
}
elseif($mob[status]==off){
$d = time();
if($d>=($mob[oponent]+$mob[time])){
mysql_query("UPDATE `mob` SET `status`='on',`hp`='$mob[hpall]', `oponent`='not' WHERE `id` = '$mob[id]'");
echo"<a href="ok.php?id=$mob[id]"> Бить</a> <a href="okrestnosti.php?mod=info&id=$mob[id]"><font color='$color'>$mob[name]($mob[hpall] хп)</font></a><br/>";
}else{
echo"";
}
}
}
}
///////////////игроки
echo'<b>Игроки:</b><br/>';
$odin=false;
$timeout=time()-150;//оффлайн
$req = mysql_query("SELECT * FROM online WHERE laikas > '$timeout' and usr!='$log'");
////////////////////////////
While($who = mysql_fetch_array($req))
{
$reqs = mysql_query("SELECT * FROM `mesto` WHERE `usr` = '$who[usr]' LIMIT 1");
$mesto = mysql_fetch_array($reqs);//место
$reqs = mysql_query("SELECT id,city,storona,hp FROM `users` WHERE `usr` = '$who[usr]' LIMIT 1");
$cit = mysql_fetch_array($reqs);//город
if($mestouser['city']==$mesto[city] && $cit[city]==$udata[city] && $mesto[x]==$mestouser['x'] && $mesto[y]==$mestouser['y']){
if($cit[storona]==$udata[storona]){echo'<font color="green">Союзник: ';}else{
echo'<font color="red">Враг: ';
}
idlog($idlog=$who[usr]); echo" <a href="ok.php?k=pk&id=$cit[id]">Бить($cit[hp] хп)</a></font><br/>";
$odin=true;
}
}
if($odin==false){
echo'Никого нет!<br/>';
}
/////////////////
echo"<b>Локации:</b><br/>";
if($world[incity]==1){echo"[город] <a href="to_gorod.php?">Город</a><br/>";}
if($world[portal]==1){echo"[портал] <a href="okrestnosti.php?mod=portal">Портал</a><br/>";}
if($le==1){echo"[влево] <a href="okrestnosti.php?mod=go_left">$left[name]</a><br/>";}
if($ri==1){echo"[вправо] <a href="okrestnosti.php?mod=go_right">$right[name]</a><br/>";}
if($do==1){echo"[вниз] <a href="okrestnosti.php?mod=go_down">$down[name]</a><br/>";}
if($up==1){echo"[вверх] <a href="okrestnosti.php?mod=go_up">$upo[name]</a><br/>";}
break;
case 'info':
$reqm = mysql_query("SELECT * FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
$mm = mysql_fetch_array($reqm);
if(empty($mm[page])){$mm[page]=7;}
$id=$_GET[id];
$req = mysql_query("SELECT * FROM `mob` WHERE `city` = '$udata[city]' and `id`='$id' and `x`='$mestouser[x]' and `y`='$mestouser[y]' LIMIT 1");
////////////////////////////
if (mysql_num_rows($req)==0){echo"Такого монстра не существует.".mysql_num_rows($req);include($path.'files/down.php');exit;}
$mob = mysql_fetch_array($req);
echo"<b>$mob[name]</b><br/>";
echo"Уровень: $mob[lvl]<br/>";
echo"Жизни: $mob[hp]/$mob[hpall]<br/>";
echo"Урон: $mob[umin]/$mob[umax]<br/>";
echo"Защита головы: $mob[pgolova]<br/>";
echo"Защита тела: $mob[pbody]<br/>";
echo"Защита ног: $mob[pnogi]<br/>";
echo"Защита от умений: $mob[pmag]<br/>";
echo"Ловкость: $mob[lovk]<br/>";
echo"Крит: $mob[krit]%<br/>";
echo"Крит-урон: $mob[ukrit]%<br/>";
echo"АНТИ-крит: $mob[antikrit]%<br/>";
echo"<a href="okrestnosti.php?">Назад</a>";
break;
case 'go_left':
$xi=$mestouser[x]-1;
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `x` = '$xi' AND `y`='$mestouser[y]' LIMIT 1");
$le=mysql_num_rows($req);
if($le==1 and $world['bl']=='0'){
mysql_query("UPDATE `mesto` SET `x`='$xi' WHERE usr = '$log'");
header("Location: okrestnosti.php?");exit;
}else{
header("Location: okrestnosti.php?");exit;
}
//////////////////////////////////////////
break;
case 'go_right':
$xmi=$mestouser[x]+1;
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `x` = '$xmi' AND `y`='$mestouser[y]' LIMIT 1");
$ri=mysql_num_rows($req);
if($ri==1 and $world['br']=='0'){
mysql_query("UPDATE `mesto` SET `x`='$xmi' WHERE usr = '$log'");
header("Location: okrestnosti.php?");exit;
}else{
header("Location: okrestnosti.php?");exit;
}
//////////////////////////////////////////
break;
case 'go_up':
$ymi=$mestouser[y]+1;
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' AND `y` = '$ymi' AND `x`='$mestouser[x]' LIMIT 1");
$up=mysql_num_rows($req);
if($up==1 and $world['bu']=='0'){
mysql_query("UPDATE `mesto` SET `y`='$ymi' WHERE usr = '$log'");
header("Location: okrestnosti.php?");exit;
}else{
header("Location: okrestnosti.php?");exit;
}
//////////////////////////////////////////
break;
case 'go_down':
$yi=$mestouser[y]-1;
$req = mysql_query("SELECT name FROM world WHERE `city` = '$udata[city]' and `y` = '$yi' and `x`='$mestouser[x]' LIMIT 1");
$do=mysql_num_rows($req);
if($do==1 and $world['bd']=='0'){
mysql_query("UPDATE `mesto` SET `y`='$yi' WHERE usr = '$log'");
header("Location: okrestnosti.php?");exit;
}else{
header("Location: okrestnosti.php?");exit;
}
//////////////////////////////////////////
break;
case 'portal':
echo'<div class="event">';
$req = mysql_query("SELECT * FROM world WHERE `city` = '$udata[city]' and `y` = '$mestouser[y]' and `x`='$mestouser[x]' and `portal`='1' LIMIT 1");
$do=mysql_num_rows($req);
if($do==1){
if($_GET[act]==city){
mysql_query("UPDATE `mesto` SET `place` = 'gorod',`city` = '0',`x` = '0',`y` = '0' WHERE `usr` = '$log'");
echo"Вы прибыли в город.<br/>";
echo"<a href="gorod.php?">Далее</a>";
echo'</div>';
include($path.'files/down.php');exit;
}elseif($_GET[act]==loc){
$req = mysql_query("SELECT * FROM world WHERE `city` = '$udata[city]' and `id` = '$_GET[id]' and `portal`='1' LIMIT 1");
$do=mysql_num_rows($req);
if($do==1){
$citys = mysql_fetch_array($req);
mysql_query("UPDATE `mesto` SET `x` = '$citys[x]',`y` = '$citys[y]' WHERE `usr` = '$log'");
echo"Вы прибыли в локацию $citys[name].<br/>";
echo"<a href="okrestnosti.php?">Далее</a>";
echo'</div>';
include($path.'files/down.php');exit;
}else{
echo"В этой локации нет портала!<br/>";
}
}
echo"<b>Город:</b><br/>";
echo"<a href="okrestnosti.php?mod=portal&act=city">Город</a><br/>";
echo"<b>Местность:</b><br/>";
$req = mysql_query("SELECT * FROM world WHERE `city` = '$udata[city]' and `portal`='1'");
//////////////////////////////
While($mob = mysql_fetch_array($req)){
echo"<a href="okrestnosti.php?mod=portal&act=loc&id=$mob[id]">$mob[name]</a><br/>";
}
echo"<a href="okrestnosti.php?">Назад</a>";
}else{
echo"В этой локации нет портала!<br/>";
}
echo'</div>';
break;
}
include($path.'files/down.php');
?>