Файл: public_html/loc.php
Строк: 103
<?php
$title = 'Локация';
require_once ('system/function.php');
require_once ('system/header.php');
if(!$user['id'])
{
header('Location: /');
exit();
}
$xi=$user[x]-1;
$xmi=$user[x]+1;
$yi=$user[y]-1;
$ymi=$user[y]+1;
if($loc['nr']=='0'){
$req = mysql_query("SELECT * FROM `locations` WHERE `x` = '$xmi' AND `y`='$user[y]' LIMIT 1");
$ri=mysql_num_rows($req);
if($ri==1){
$rirad=mysql_fetch_array($req);
}
}
if($loc['nl']=='0'){
$req = mysql_query("SELECT * FROM `locations` WHERE `x` = '$xi' AND `y`='$user[y]' LIMIT 1");
$le=mysql_num_rows($req);
if($le==1){
$lerad=mysql_fetch_array($req);
}
}
if($loc['nu']=='0'){
$req = mysql_query("SELECT * FROM `locations` WHERE `y` = '$ymi' AND `x`='$user[x]' LIMIT 1");
$up=mysql_num_rows($req);
if($up==1){
$uprad=mysql_fetch_array($req);
}
}
if($loc['nd']=='0'){
$req = mysql_query("SELECT * FROM `locations` WHERE `y` = '$yi' and `x`='$user[x]' LIMIT 1");
$do=mysql_num_rows($req);
if($do==1){
$dorad=mysql_fetch_array($req);
}
}
switch($_GET[mod]){
default:
echo "<center>$loc[name]<br/><b>$user[x]</b>:<b>$user[y]</b></center>";
if($_GET[error]=='energy'){echo "<div class='info'>Не хватает энергии!</div>";}
echo "<center>";
if($up==1){echo "<a href='?mod=up'><img src='/images/move/up.png'></a>";}
if($le==1){echo "<a href='?mod=left'><img src='/images/move/left.png'></a>";}
if($ri==1){echo "<a href='?mod=right'><img src='/images/move/right.png'></a>";}
if($do==1){echo "<a href='?mod=down'><img src='/images/move/down.png'></a>";}
echo "</center><img src='/images/move/eye.png' width=16px> <a href='?mod=osmotr'>Осмотреться</a><br/>";
break;
case 'osmotr':
$mutantcount = mysql_result(mysql_query("SELECT COUNT(*) FROM mutants WHERE x='$user[x]' and y='$user[y]' and `status`='life'"),0);
echo "<b>Мутанты</b>: ($mutantcount)<br/>";
$req = mysql_query("SELECT * FROM `mutants` WHERE `x` = '$user[x]' and `y`='$user[y]' and `status`='life'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mutant = mysql_fetch_array($req)){
echo"<img src='images/target.png'> <a href="pve.php?id=$mutant[id]">$mutant[name]</a><br/>";
}
}else{
echo"Нет мутантов...<br/>";
}
break;
case 'up':
if($up==1){
$radiat=$user[radiation]+$uprad[radiation];
$menergy=$user[energy]-10;
if($menergy<0){header('Location: loc.php?error=energy');}else{
$py=$user[y]+1;
mysql_query("UPDATE `users` SET `y` = '$py', `energy` = '$menergy', `radiation` = '$radiat' WHERE `login` = '$user[login]'");
header('Location: loc.php');}
}
break;
case 'down':
if($do==1){
$radiat=$user[radiation]+$dorad[radiation];
$menergy=$user[energy]-10;
if($menergy<0){header('Location: loc.php?error=energy');}else{
$my=$user[y]-1;
mysql_query("UPDATE `users` SET `y` = '$my', `energy` = '$menergy', `radiation` = '$radiat' WHERE `login` = '$user[login]'");
header('Location: loc.php');}
}
break;
case 'left':
if($le==1){
$radiat=$user[radiation]+$lerad[radiation];
$menergy=$user[energy]-10;
if($menergy<0){header('Location: loc.php?error=energy');}else{
$mx=$user[x]-1;
mysql_query("UPDATE `users` SET `x` = '$mx', `energy` = '$menergy', `radiation` = '$radiat' WHERE `login` = '$user[login]'");
header('Location: loc.php');}
}
break;
case 'right':
if($ri==1){
$radiat=$user[radiation]+$rirad[radiation];
$menergy=$user[energy]-10;
if($menergy<0){header('Location: loc.php?error=energy');}else{
$px=$user[x]+1;
mysql_query("UPDATE `users` SET `x` = '$px', `energy` = '$menergy', `radiation` = '$radiat' WHERE `login` = '$user[login]'");
header('Location: loc.php');}
}
break;
}
require_once ('system/footer.php');
?>