View file sdark.mobi/hiking/abode-dragons/index.php

File size: 15.88Kb
<?
require_once'../../core/system.php';
echo only_reg();
echo ban();
echo blok();
$header='Обитель Драконов';
require_once'../../core/head.php';
mysql_query("DELETE FROM `hik_otk` WHERE `time`<='".$time."'");
mysql_query("DELETE FROM `hik_gift` WHERE `time`<='".$time."'");
mysql_query("DELETE FROM `hiking` WHERE `time`<='".$time."' and `status`='1'");

mysql_query("UPDATE `user` set `mesto` = 'Поход', `battle` = '0' where `id` = '".$user['id']."'");
if($user['level'] < 80){
header('location: /'); 
$_SESSION['err'] = 'Доступно только с 80 уровня';
}
/* $req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."') and `status`='1'");
$avto = mysql_num_rows($req);
if($avto>0){
header('location: /'); 
$_SESSION['err'] = 'Недоступно';
} */


echo"<img src='/images/abode-dragons.jpg' width='100%'>";

$req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."') and `name`='6'");
$hik = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){

$avo = mysql_num_rows(mysql_query("SELECT id FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='6'")); 
if($avo > 0) {
$_SESSION['err'] = "Поход уже пройден!";
header('Location: /');
exit;
}

echo"<hr>
<div class='head grey center'>
Драконы эволюционировали, пройти сквозь них будет очень сложно!  </div>";

echo"<hr><div class='head'><a class='mini-fight center' href='search'><img src='/images/icon/stat/sila.png'> Найти команду</a></div>";

if(isset($_GET['honors'])){
	
?>

<hr>
<div class='d-grey center grey'>
Награда за убийство босса: <font color='CDCDCD'> <img src='/images/icon/gold.png'>3</font></br>
<?
	if($user['plem']=='ogn')	$plem='0';
	if($user['plem']=='mol')	$plem='1';
	
if($user['clan']>0)	echo"Рейтинг клана: <font color='CDCDCD'> <img src='/images/icon/rating_".$plem.".png'>70</font>";

?>
</br>
<img src="/images/chests/2.png" width="25px" height="25px"> Ларец Чародея
</div>

<?
}

echo"<hr>
<div class='d-grey center'>
Умения: <img src='/images/icon/level.png'><font color='CDCDCD'>7+</font></br>
Параметры: <font color='CDCDCD'>10000+</font></br>
Команда: <font color='CDCDCD'>до 4 чел.</font></div>";

if(!isset($_GET['honors'])){
	echo"<hr>
	<div class='foot'>
	<a class='inpc-ar center' href='?honors'>Посмотреть награды</br></a>
	</div>";
	} else {
echo"<hr>
<div class='foot'>
<a class='inpc-ar center' href='?'>Скрыть награды</br></a>
</div>";
}
echo'<hr>
<div class="mli">
<div class="empty"></div>
<div class="grey center mli"> После прохождения, пойти снова  в поход можно через 24 часа.
</div>
<div class="empty"></div>
</div>';
} else {

if($hik['fight']==1 && $hik['status']<1 && !isset($_GET['exit'])){
$_SESSION['message'] = 'Бой начался!';
header("Location: fight");
exit();
}

$otk = mysql_num_rows(mysql_query("SELECT id FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='6'")); 

if($hik['status']==0 && $otk==0){	
if($user['id']==$hik['lider']){echo"<hr>
<div class='head grey center'>
Когда команда будет готова, Вы можете начинать бой!  </div>";}


if($hik['lider']==$user['id']){
	echo "<hr><div class='foot'><a class='mini-fight' href='fight'><img src='/images/icon/stat/sila.png'> Начать бой</a></div>";
}
} else { 
echo"<hr>
<div class='head grey center'>
Поход успешно завершен, награды выданы! </div>";

?>

<hr>
<div class='d-grey center grey'>
Вы получили: <font color='CDCDCD'> <img src='/images/icon/gold.png'>3</font>

<?
	if($user['plem']=='ogn')	$plem='0';
	if($user['plem']=='mol')	$plem='1';
	
if($user['clan']>0)	echo"</br>Рейтинг: <font color='CDCDCD'> <img src='/images/icon/rating_".$plem.".png'>70</font>

</br>
<img src='/images/chests/2.png' width='25px' height='25px'> Ларец Чародея";

?>

</div>

<?	 

}
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
$kol = mysql_result(mysql_query("SELECT COUNT(id)  FROM `chat` where `msg` = '".$msg."' and `id_user` = '".$user['id']."'"),0);
if($kol > 0) $err =  'Сообщение повторяет предыдущее!';

$lelfi = $_SERVER['REQUEST_TIME'] - 60;
$elfilox = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat` WHERE `msg`  = '".$msg."' and `id_user` = '".$user['id']."' and `time`>".$lelfi.""),0);
if($elfilox > 0 ) {
$err = 'Сообщение повторяет предыдущее!';
header('Location: ? ');
}

if(strlen($msg) < 1 or strlen($msg) > 400 and $user['prava']!='5') $err =  'Длина сообщения должна быть от 1 до 400 символов';
if($user['level'] < 5) $err =  'Писать в чате можно только с 5 уровня!';
if(!isset($err)) {
$f=$_SERVER['REQUEST_TIME']+43200;
mysql_query("INSERT INTO `chat` SET `id_user` = '".$user['id']."', `msg` = '".$msg."', `timer` = '".$f."', `time` = '".$_SERVER['REQUEST_TIME']."', `hiking`='".$hik['id']."'");
header('Location: ?');

exit();
}else{
header('Location: ?');
$_SESSION['err'] = $err;
// Вывод ошибки 
exit();
} 
}else{
header('Location: ?');
$_SESSION['err'] = 'Введите текст';
exit();
}
break;
default:

if(isset($_GET['del'])){
if($user['prava']<2){
$_SESSION['error'] = 'Ошибка!';
header("Location: ?");exit;}
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");}


$k_post = mysql_result(mysql_query("SELECT COUNT(id)  FROM `chat`  WHERE `hiking`='".$hik['id']."'"),0);
$k_page = k_page($k_post,5);
$page = page($k_page);
$start = 5*$page-5;
echo '<hr>
<table class="foot" width="100%" border="0" cellpadding="3px" cellspacing="0" style="padding-top: 5px;">
<tbody>
<tr>
<td class="center" width="40%">
<a class="fight" href="?"><img src="/images/icon/reload.png">
Обновить</a></td>

<td class="center" width="40%">
<a class="fight" href="/moduls/smiles"><img src="/images/icon/smiley.png">
Смайлики</a></td></tr></tbody>
</table><hr>';

$req = mysql_query("SELECT * from `ban` where `id_us` = '".$user['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$ban = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto == 0){
if(isset($_GET['id'])) {
$ank = mysql_fetch_array(mysql_query("SELECT nick FROM `user` WHERE `id` = '".abs(intval($_GET['id']))."' LIMIT 1"));
echo '<div class="head"><div class="empty"></div><form  method="post" action="?act=post">
<input class="text-area" value="'.$ank['nick'].', " name="msg" /></textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить"></span>
</form></div>';
} else {
echo'<div class="head"><div class="empty"></div><form  method="post" action="?act=post">
<textarea rows="3" class="text-area" name="msg"></textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить"></span>
</form></div>';
}
echo '<hr>';
}
$q = mysql_query("SELECT * FROM `chat`  WHERE `hiking`='".$hik['id']."' ORDER BY `id` DESC LIMIT ".$start.", 5");
while($post = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT id,font,prava,nick FROM `user` WHERE `id` = ".$post['id_user']." LIMIT 1"));
$req = mysql_query("SELECT id from `ban` where `id_us` = '".$ank['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$avto = mysql_num_rows($req);
if($avto > 0){
echo'<div class="player">';
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/"><font color="'.$ank['font'].'">'.$ank['nick'].'</font></a>';  
if($ank['nick']!="".$user['nick'].""){
	echo '<a href="?comm='.$ank['id'].'&page=end"> (+)</a>';
	}
echo '<span class="mit">'.vremja($post['time']).'</span>';
if ($user['prava'] >= 4){
	echo'</br>'.smiles($post['msg']).' <font color="#FE2E2E">[BANED]</font>';
	}
if ($user['prava'] >= 2){
	echo' <a href="?del&id_msg='.$post['id'].'">[X]</a>';
}
echo'</br><font color="'.$color.'"> </font>';
?>
</div><hr></div>
<?
} else {
if($ank['prava']=="5"){
	$status="<font color='ffc22b'>[A]</font>"; $color="#F7990D";}
if($ank['prava']=="4"){
	$status="<font color='ffc22b'>[a]</font>"; $color="EBC621";}
if($ank['prava']=="3"){
	$status="<font color='ffc22b'>[M]</font>";
}
if($ank['prava']=="2"){
	$status="<font color='ffc22b'>[m]</font>";
}

?>
<div class="d-grey">
<?
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/"><font color="'.$ank['font'].'">'.$ank['nick'].'</font></a>';
if($ank['prava']>"1"){
echo' '.$status.'';
}
if($ank['nick']!="".$user['nick'].""){
echo'  <a href="?id='.$ank['id'].'">(+)</a>';
}
echo '<span class="mit">'.vremja($post['time']).'</span>';
if ($user['prava'] >= 2){
echo" <a href='?del&id_msg=".$post['id']."'>[X]</a>";
}
if ( preg_match('/'.$user['nick'].'/i', $post['msg']) )
{
	$to = ["".$user['nick']."," =>'<font color="#EBCA46">'.$user['nick'].', </font>'];
	$post['msg'] = strtr($post['msg'], $to);
}

if ($ank['prava'] >= 4){
echo'</br><font color="'.$color.'">'.smiles(antimat($post['msg'])).'</font></font> ';
} else {
echo'</br>'.smiles(antimat($post['msg'])).' ';
}

?>

</div><hr>

<?

}
}

?>

</div></div>

<?

if ($k_page>1){
str('?',$k_page,$page); // Вывод страниц
echo'<hr>';
}
}
if(isset($_GET['close'])){
	
if($user['id']!=$hik['lider']){
$_SESSION['err'] = "Ошибка";
header('Location: /');
exit();
}
mysql_query("UPDATE `hiking` SET  `open`='1' WHERE `id`='".$hik['id']."'");
$_SESSION['message']='Команда закрыта!';
header('Location: ?');
}

if(isset($_GET['open'])){
	
if($user['id']!=$hik['lider']){
$_SESSION['err'] = "Ошибка";
header('Location: /');
exit();
}
mysql_query("UPDATE `hiking` SET  `open`='' WHERE `id`='".$hik['id']."'");
$_SESSION['message']='Команда открыта!';
header('Location: ?');
}


if(isset($_GET['exclude'])){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['exclude'])."'"));

if($user['id']!=$hik['lider']){
$_SESSION['err'] = "Ошибка";
header('Location: /');
exit();
}

if($ank['id']==$hik['usr1']){
	mysql_query("UPDATE `hiking` SET `usr1` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
}
elseif($ank['id']==$hik['usr2']){
	mysql_query("UPDATE `hiking` SET `usr2` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
}
elseif($ank['id']==$hik['usr3']){
	mysql_query("UPDATE `hiking` SET `usr3` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
} else {
header('location: /'); 
$_SESSION['err'] = 'Игрок не находится в команде!';
exit;
}
$texst = "".$user['nick']." исключил вас из команды";
$timer = time()+1296000;
$req = mysql_query("SELECT * FROM `users_konts` WHERE `id_user`='".$ank['id']."' and `id_kont` = '2'");
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("INSERT INTO `users_konts` SET `id_user` = '".$ank['id']."', `id_kont` = '2', `time` = '".$time."', `timer` = '".$timer."', `new_msg` = '1'");
}else{mysql_query("UPDATE `users_konts` SET  `time` = '".$time."', `timer` = '".$timer."', `new_msg` = '1'  WHERE`id_user` = '".$ank['id']."' and `id_kont` = '2'");
}

	mysql_query("UPDATE `user` set `team`='0' where `id` = '".$ank['id']."'");
mysql_query("INSERT INTO `mail` SET `id_user` = '2', `id_kont` = '".$ank['id']."', `time` = '".$time."', `timer` = '".$timer."', `read` = '1', `msg` = '".$texst."'");
$_SESSION['message']='Вы исключили игрока '.$ank['nick'].'';
header('Location: ?');
}

if(isset($_GET['transfer'])){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['transfer'])."'"));

if($user['id']!=$hik['lider']){
$_SESSION['err'] = "Ошибка";
header('Location: /');
exit();
}

if($ank['id']==$hik['usr1']){
	mysql_query("UPDATE `hiking` SET `usr1` = '".$user['id']."', `lider`='".$ank['id']."' WHERE `id`='".$hik['id']."'");
}
elseif($ank['id']==$hik['usr2']){
	mysql_query("UPDATE `hiking` SET `usr2` = '".$user['id']."', `lider`='".$ank['id']."' WHERE `id`='".$hik['id']."'");
}
elseif($ank['id']==$hik['usr3']){
	mysql_query("UPDATE `hiking` SET `usr3` = '".$user['id']."', `lider`='".$ank['id']."' WHERE `id`='".$hik['id']."'");
} else {
header('location: /'); 
$_SESSION['err'] = 'Игрок не находится в команде!';
exit;
}

$_SESSION['message']='Вы передали команду '.$ank['nick'].'';
header('Location: ?');
}

if(isset($_GET['exit'])){

if($user['id']==$hik['usr1']){
	mysql_query("UPDATE `hiking` SET `usr1` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
	mysql_query("UPDATE `user` set `team`='0' where `id` = '".$user['id']."'");

}
elseif($user['id']==$hik['usr2']){
	mysql_query("UPDATE `hiking` SET `usr2` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
	mysql_query("UPDATE `user` set `team`='0' where `id` = '".$user['id']."'");
}
elseif($user['id']==$hik['lider']){

if(!empty($hik['usr1'])){
	mysql_query("UPDATE `hiking` SET `lider` = '".$hik['usr1']."', `usr1` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
}
elseif(!empty($hik['usr2'])){
	mysql_query("UPDATE `hiking` SET `lider` = '".$hik['usr2']."', `usr2` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
}
elseif(!empty($hik['usr3'])){
	mysql_query("UPDATE `hiking` SET `lider` = '".$hik['usr3']."', `usr3` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
} else {

mysql_query("DELETE FROM `hiking` WHERE `id`='".$hik['id']."'");

}

	mysql_query("UPDATE `user` set `team`='0' where `id` = '".$user['id']."'");
}
elseif($user['id']==$hik['usr3']){
	mysql_query("UPDATE `hiking` SET `usr3` = '', `kol`=`kol`-'1' WHERE `id`='".$hik['id']."'");
	mysql_query("UPDATE `user` set `team`='0' where `id` = '".$user['id']."'");
} else {
header('location: /'); 
$_SESSION['err'] = 'Игрок не находится в команде!';
exit;
}

$_SESSION['message']='Вы покинули команду!';
header('Location: /');
}


echo"<div class='head center'><div class='empty2'></div>Состав команды (".$hik['kol']."/4) </div>";


$q = mysql_query("SELECT * FROM `user` WHERE (`id`='".$hik['lider']."' || `id`=".$hik['usr1']." || `id`=".$hik['usr2']." || `id`=".$hik['usr3'].") LIMIT 4");
echo "<div class='head'><div class='empty'></div>";
while($post = mysql_fetch_array($q)) {
if($post['prava']=="5"){$status="<font color='ffc22b'>[A]</font>";$color="#F7990D";}
if($post['prava']=="4"){$status="<font color='ffc22b'>[a]</font>";$color="EBC621";}
if($post['prava']=="3"){$status="<font color='ffc22b'>[M]</font>";}
if($post['prava']=="2"){$status="<font color='ffc22b'>[m]</font>";}
echo '<a href="/user/'.$post['id'].'/">';
echo"<div class='empty2'></div>";
echo online($post['id']);
echo' <font color="'.$post['font'].'">'.$post['nick'].'</font>';
if($post['prava']>"1"){echo" $status";}echo'</a>, <img src="/images/icon/level.png">'.$post['level'].', ';
if($hik['lider']==$post['id']){echo' <img src="/images/icon/rating_'.$hik['imp'].'.png">, ';}echo'('.$post['mesto'].')';
if($hik['lider']!=$post['id'] && $hik['lider']==$user['id']){echo' <a href="?exclude='.$post['id'].'">исключить</a> | <a href="?transfer='.$post['id'].'">передать команду</a>';}echo'<div class="empty2"></div>';
}
echo '</div>';


if($user['id']==$hik['lider']){
echo '<hr>
<table class="foot" width="100%" border="0" cellpadding="3px" cellspacing="0" style="padding-top: 5px;">
<tbody>
<tr>
<td class="center" width="40%">
<a class="inpc-ar" href="search"> Поиск игроков</a></td>';

if($hik['open']==0){
	echo'<td class="center" width="40%">
<a class="inpc-ar" href="?close"> Закрыть команду</a></td></tr></tbody>
</table>';
} else {
	echo'<td class="center" width="40%">
<a class="inpc-ar" href="?open"> Открыть команду</a></td></tr></tbody>
</table>';}
}

echo'<hr><div class="head center"><a class="fight" href="?exit"> Покинуть команду</a></div>';

}

require_once'../../core/foot.php';
?>