Файл: reyds.php
Строк: 129
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
if($udata['admin']<6)
{
header('location: index.php');exit;
}
$textl='Рейды';
include($path.'files/core.php');
if($udata['lvl']<20)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Режим доступен с 20 уровня!'
");
header('location: game.php');exit;
}
$mobs=mysql_query("SELECT * FROM `craft` WHERE `usr`='".$udata['id']."'");
$rows=mysql_num_rows($mobs);
if($rows!=0)
{
header('location: work.php');exit;
}
$mobs1=mysql_query("SELECT * FROM `arena_usr` WHERE `usr`='".$udata['id']."'");
$rows1=mysql_num_rows($mobs1);
if($rows1!=0)
{
header('location: arena.php');exit;
}
$mobs2=mysql_query("SELECT * FROM `avan_usr` WHERE `usr`='".$udata['id']."'");
$rows2=mysql_num_rows($mobs2);
if($rows2!=0)
{
header('location: avan.php');exit;
}
$mobs3=mysql_query("SELECT * FROM `battle` WHERE `usr`='".$udata['id']."'");
$rows3=mysql_num_rows($mobs3);
if($rows3!=0)
{
header('location: battle.php');exit;
}
$mobs4=mysql_query("SELECT * FROM `ohota` WHERE `usr`='".$udata['id']."'");
$rows4=mysql_num_rows($mobs4);
if($rows4!=0)
{
header('location: b_oh.php');exit;
}
$mobs5=mysql_query("SELECT * FROM `okrest` WHERE `usr`='".$udata['id']."'");
$rows5=mysql_num_rows($mobs5);
if($rows5!=0)
{
header('location: b_okr.php');exit;
}
$mobs6=mysql_query("SELECT * FROM `str_usr` WHERE `usr`='".$udata['id']."'");
$rows6=mysql_num_rows($mobs6);
if($rows6!=0)
{
header('location: b_str.php');exit;
}
$mobs7=mysql_query("SELECT * FROM `terr_usr` WHERE `usr`='".$udata['id']."'");
$rows7=mysql_num_rows($mobs7);
if($rows7!=0)
{
header('location: terr_b.php');exit;
}
////
$_GET[id]=intval($_GET['id']);
$reyd=htmlspecialchars(trim($_GET['reyd']));
////
if(isset($_GET['create']))
{
$id=mysql_real_escape_string($_GET['create']);
$cre = mysql_num_rows(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$id."' AND `auth`='yes' "));
if($cre==0){header('location: ?reyd=create&ers1');exit;}
$cret = mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$id."' AND `auth`='yes' "));
if($udata['lvl']<$cret['lvl']){header('location: ?reyd=create&ers2');exit;}
$ure = mysql_num_rows(mysql_query("SELECT * FROM `reyd_groups` WHERE `usr`='".$udata['id']."' "));
if($ure!=0){header('Location: reyds.php?');exit;}
$time_user=time();
mysql_query("INSERT INTO `reyd_groups` SET
`id_reyd` = '".$cre['id']."',
`id_lider` = '".$udata['id']."',
`usr` = '".$udata['id']."',
`tip` = 'lider',
`start` = 'no',
`time` = '".time()."',
`groupon` = 'yes',
`battle` = 'no',
`life`='yes',
`max_pers` = '1' ");
//$rmob=mysql_fetch_array(mysql_query("SELECT * FROM `reyd_mob` WHERE `id_reyd`='".$cr['id']."' ORDER BY `top` DESC"));
// порядок выхода мобов. Оставить или убрать потом с Лехой решим :D
// ТУТ запрос на создание монстров из таблицы reyd_mob !!! НЕ ЗАБЫТЬ ДОБАВИТЬ ПОСЛЕ ПОДГОТОВКИ БОЕВОЙ СИСТЕМЫ!!!
header('Location: reyds.php?reyd=group');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<div class="v3 bts brs bls b p v12">Навигация</div><div class="v4 bts brs bls bbs p">
<img src=img/main/i26.png class="menu"> <a href=game.php>главная</a> / <a href=prikl.php>приключения</a> / <a href=reyds.php>рейды</a>
</div>';
echo '<div class="v8">';
///// Список рейдов
switch($reyd){
default:
echo '<div class="v3 bts brs bls b p v12">Список рейдов</div><div class=bbs>';
$reyds1 = mysql_query("SELECT * FROM `reyd` WHERE `auth`='yes' ");
while($reyds = mysql_fetch_array($reyds1)){
echo"<a href='reyds.php?reyd=opis&id=$reyds[id]'><div class='v2s brs bls p'><img width='24' height='24' src=$reyds[img]> $reyds[name_reyd] ($reyds[lvl]уровень)</div></a>";}
echo '</div></div><div class="v8"><div class="v3 bts brs bls b p v12">Группы</div>';
echo"<a href='reyds.php?reyd=allgroups'><div class='v2s bts brs bls bbs p'><img src=img/main/i25.png > Поиск банд</div></a></div>";
$time_reyd = mysql_num_rows(mysql_query("SELECT * FROM `reyd_time` WHERE `usr`='".$udata['usr']."' "));
$time_r = mysql_query("SELECT * FROM `reyd_time` WHERE `usr`='".$udata['usr']."' ");
if($time_reyd==0){echo"<div class='v8'><div class='v3 bts brs bls b p v12'>Пройдены:</div><div class='v2 bts brs bls bbs p'>";
while($tir = mysql_fetch_array($time_r)){$re = mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$tir['id_reyd']."' "));
echo"$re[name_reyd] еще $tir[time]</br>";}}else{echo"";}
echo"</div>";
break;
///// Описание рейда, поиск/создание группы
case'opis':
$rreyd = mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$_GET['id']."' AND `auth`='yes' "));
if($rreyd==0){
echo"<div class='v2 brs bls p'>";
echo"Рейд закрыт или не существует!";}
else{
echo"<div class='v3 bts bbs brs bls b p v12'><center>$rreyd[name_reyd]</center></div>";
echo"<div class='v2 brs bls p'>";
echo"<center><img src='$rreyd[img]'></center></br>";
echo"Описание: $rreyd[opis]";
if($udata['lvl']>=$rreyd['lvl']){echo"</div>
<a href='reyds.php?create=".$rreyd['id']."'><div class='v2s brs bts bls bbs p'><img src=img/main/i25.png > Создать банду</div></a>";}
else{echo"<br><b><font color=red>Требуется $rreyd[lvl] уровень!</font></b>";}
}
echo"</div>";
break;
///// Создание группы
case'create':
echo"<div class='v3 bts bbs brs bls b p v12'><center>Создание группы</center></div>";
//// Лог ошибок..////
if(isset($_GET['err1']))
{
echo"<div class='v2 p bts bbs bls brs'>Данного рейда не существует!</div>";
include('files/down.php');exit;
}
elseif($_GET['err2'])
{
echo"<div class='v2 p bts bbs bls brs'>Вашего уровня недостаточно для данного рейда!</div>";
include('files/down.php');exit;
}
////
$ure = mysql_num_rows(mysql_query("SELECT * FROM `reyd_groups` WHERE `usr`='".$udata['id']."' "));
if($ure!=0){
echo"<div class='v2 p bts bbs bls brs'>Вы уже состоите в группе.</div>";
}
else
{
echo"<div class='v2'>";
echo"<center><img src='$cre[img]'></center>";
echo" Создать группу на <b>$cre[name_reyd]</b>?";
echo"
<a href='reyds.php?reyd=create&create=yes&id=$cre[id]'><div class='v2s brs bts bls bbda p'><img src=img/main/i25.png > Да</a></div>
<a href='reyds.php?reyd=opis&id=$cre[id]'><div class='v2s brs bls bbda p'><img src=img/main/i25.png > Нет</a></div>";
}
break;
///// Группа/управление группой/чат/группы
case'group':
$myg = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `usr`='".$udata['id']."' ")); // Группа
$myr = mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$myg['id_reyd']."' ")); // Рейд
$lig = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `tip`='lider' AND `id_lider`='".$myg['id_lider']."' ")); // Лидер группы
$ligr = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`='".$lig['usr']."' "));
$myli = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `usr`='".$udata['id']."' "));
$usgr = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' ")); // Массив списка людей в группе
$tre = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_time` WHERE `usr` = '".$udata['id']."' AND `id_reyd`='".$myg['id_reyd']."' AND `time`>'".time()."' "));
if($myg){
$usg = mysql_result(mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' AND `groupon`='yes' "),0);
$usk = mysql_result(mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' "),0);
}
mysql_query("UPDATE `reyd_battle` SET `time`='".(time())."' WHERE `id_lider`='".$myg['id_lider']."' ");
echo"<div class='v2'>";
if($myg==0){echo"Вы не состоите в банде!";}else{
if($_GET['nowin']=='yes'){echo"Вы проиграли! Рейд не пройден!</br>";}
if($_GET['life']=='yes'){echo"Жизни восстановлены!</br>";}
if($_GET['life']=='no'){echo"Недостаточно монет!</br>";}
if($_GET['exit']=='pod'){
if($_GET['g']=='yes'){
if($udata['usr']==$lig['usr'] && $usk>1){echo"В группе $usk человек! Сначала передайте лидерство!";}
elseif($usk==1){
mysql_query("DELETE FROM `reyd_log` WHERE `id_lider`='".$myg['id_lider']."' ");
mysql_query("DELETE FROM `reyd_chat` WHERE `id_lider`='".$myg['id_lider']."' ");
mysql_query("DELETE FROM `reyd_battle` WHERE `id_lider`='".$myg['id_lider']."' ");
mysql_query("DELETE FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' ");
echo"Вы покинули группу!</br>";}
else{mysql_query("DELETE FROM `reyd_groups` WHERE `usr`='".$udata['id']."' ");echo"Вы покинули группу!</br>";}
}
else{
echo"Вы действительно хотите покинуть группу?</br><a href='reyds.php?reyd=group&exit=pod&g=yes'>Да</a>
</br><a href='reyds.php?reyd=group'>Нет</a>";}
}else{
if($_GET['nowin']=='yes'){
//$rmob=mysql_fetch_array(mysql_query("SELECT * FROM `reyd_mob` WHERE `id_reyd`='".$myg['id_reyd']."' ORDER BY `top` DESC"))or die (mysql_error()); // порядок выхода мобов
///// Тут должен быть запрос на пересоздание монстров в случае поражения группы! НЕ ЗАБЫТЬ ДОБАВИТЬ!!!
mysql_query("UPDATE `reyd_groups` SET `start`='no' WHERE `id_lider`='".$myg['id_lider']."' ") or die (mysql_error());
echo"<div class='v2'><a href='reyds.php?reyd=dead&act=life'>Восстоновить здоровье</a></div>";
}
if($tre==0 && $myg['tip']=='lider'){
//$rmob=mysql_fetch_array(mysql_query("SELECT * FROM `reyd_mob` WHERE `id_reyd`='".$myg['id_reyd']."' ORDER BY `top` DESC"))or die (mysql_error()); // порядок выхода мобов
///// Тут должен быть запрос на пересоздание монстров в случае поражения группы! НЕ ЗАБЫТЬ ДОБАВИТЬ!!!
mysql_query("UPDATE `reyd_groups` SET `start`='no' WHERE `id_lider`='".$myg['id_lider']."' ") or die (mysql_error());
}
////////////
if(time()>$tre['time']){mysql_query("DELETE FROM `reyd_time` WHERE `usr`='".$udata['usr']."' AND `id_reyd`='".$myg['id_reyd']."' ") or die (mysql_error());}
if($_GET['ug']=='yes'){if($myg['tip']=='lider'){$pl = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' AND `usr`='".$_GET['pl']."' "))or die(mysql_error());if($_GET['pl']!=''){if($pl==0){echo"Ошибка!</br>";}else{$upl = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`='".$pl['usr']."' "));if($pl['usr']==$udata['usr']){echo"Ошибка</br>";}else{mysql_query("UPDATE `reyd_groups` SET `tip`='lider' WHERE `usr`='".$upl['usr']."' ")or die(mysql_error());mysql_query("UPDATE `reyd_groups` SET `id_lider`='".$upl['id']."' WHERE `id_lider`='".$myg['id_lider']."' ")or die(mysql_error());mysql_query("UPDATE `reyd_groups` SET `tip`='user' WHERE `usr`='".$myg['usr']."' ")or die(mysql_error());echo"Вы передали лидера $_GET[pl] </br>";}}}}else{echo"Вы не лидер группы</br>";}}
if($_GET['kik']=='yes'){if($_GET['ki']=='yes'){$kk = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' AND `usr`='".$_GET['kk']."' "));if($_GET['kk']!=''){echo"";}if($kk==0){echo"Ошибка!</br>";}else{if($kk['usr']==$udata['usr']){echo"Ошибка!</br>";}else{mysql_query("DELETE FROM `reyd_groups` WHERE `usr`='".$kk['usr']."' ")or die(mysql_error());echo"Успешно!</br>";}}}else{echo"Ошибка!</br>";}}
if($myg['start']=='yes'){echo"Рейд окончен! </font></br>";
}
if($udata['hp']>0){mysql_query("UPDATE `reyd_groups` SET `life`='yes' WHERE `usr`='".$udata['usr']."' ")or die(mysql_error());}
if($lig['life']=='yes' && $lig['battle']=='yes' && $lig['groupon']=='yes' && $tre==0 ){header('Location: b_reyd.php');}
if($tre!=0){echo"Рейд закрыт до - ".time($tsu['time'])."</br>";}
echo"Группа на $myr[name_reyd]</br>";
echo"Лидер группы: <a href='/info.php?id=$ligr[id]'>$ligr[usr]</a></br>";
if($myg['tip']!='lider'){echo"Ожидаем начала боя!</br>";}else{echo"<a href='b_reyd.php?go=battle'>Начать бой</a></br>";}
echo"Состав группы($usk/$myr[max_pers]):</br>";
$myg = mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$myg['id_lider']."' ");
while($vgr = mysql_fetch_array($myg))
{
$usvgr = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`='".$vgr['usr']."' "));
echo"<a href='/info.php?id=$usvgr[id]'>$usvgr[usr]</a></br>";
if($myli['tip']=='lider'){echo"<a href='reyds.php?reyd=group&kik=yes&ki=yes&kk=$usvgr[usr]'><font color=red>Выгнать</font></a>
| <a href='reyds.php?reyd=group&ug=yes&pl=$usvgr[usr]'><font color=gold>Передать лидера</font></a></br>";}
}
echo"</br><a href='reyds.php?reyd=group&exit=pod'><b>Покинуть банду</b></a>";
}
}
////////////
break;
case'allgroups':
echo"<div class='v2'>";
$rey=mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$_POST['id_reyd']."' "));
$kolg = mysql_result(mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id`='".$rey['id_reyd']."' AND `start`='no' "),0);
$kl=$rey['max_pers']<$kolg;
$group=mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id`='".$_POST['id_reyd']."' AND `max_pers`='$kl' AND `start`='no' "));
echo"Поиск группы<br/><form action='reyds.php?reyd=allgroups' method='post'><select name="id_reyd">";
$rrr=mysql_query("SELECT * FROM `reyd` ");
while($rrr1=mysql_fetch_array($rrr)){echo"<option value='$rrr1[id]'>$rrr1[name_reyd] ($rrr1[lvl]уровень)</option>";}
echo"</select><br/><input class='text large' type='submit' value='Искать'/></form>";
if($_POST['id_reyd']==""){echo"";}
else{
$num = 10;
$page = $_GET['page'];
$result = mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id_reyd`='".$_POST['id_reyd']."' AND `start`='no' ");
$posts = mysql_result($result, 0);$total = intval(($posts - 1) / $num) + 1;$page = intval($page);
echo"Список групп:</br>";
if(empty($page) or $page < 0) $page = 1;if($page > $total) $page = $total;$start = $page * $num - $num;
$qi = mysql_query("SELECT * FROM `reyd_groups` WHERE `id_reyd`='".$_POST['id_reyd']."' AND `tip`='lider' AND `start`='no' LIMIT $start, $num ");
$query = mysql_query("SELECT * FROM `reyd_groups` WHERE `id_reyd`='".$_POST['id_reyd']."' AND `tip`='lider' AND `start`='no' ORDER BY `max_pers` DESC");
if (mysql_affected_rows()==0){echo "Пусто!";echo"<a href='reyds.php?'>Рейды</a>";}
else{while($sc=mysql_fetch_array($qi) ){
$vgsl = mysql_result(mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id_lider`='".$sc['id_lider']."' "),0);
$reydd=mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$_POST['id_reyd']."' "));
echo"<a href='reyds.php?reyd=vgroup&id=$sc[id]'> <b>$reydd[name_reyd]</b> - Лидер:$sc[usr] $vgsl/$rey[max_pers]</a></br>";}
if ($page != 1) $pervpage = '<a href="reyds.php?reyd=allgroups&page=1" title="«"><span><span>«</span></span></a> ';
if ($page != $total) $nextpage = ' <a href="reyds.php?reyd=allgroups&page='.$total.'">'. » .'</a>';
if($page - 2 > 0) $page2left = '<a href="reyds.php?reyd=allgroups&page='. ($page - 2) .'">'. ($page - 2) .'</a>';
if($page - 1 > 0) $page1left = '<a href="reyds.php?reyd=allgroups&page='. ($page -1) .'">'. ($page - 1) .'</a> ';
if($page + 2 <= $total) $page2right = ' <a href="reyds.php?reyd=allgroups&page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' <a href="reyds.php?reyd=allgroups&page='. ($page + 1) .'">'. ($page + 1) .'</a>';
$aa= "<span title='Page $page'>$page</span> ";
echo $pervpage.$page2left.$page1left.'<b>' .$aa. '</b>'.$page1right.$page2right.$nextpage;
echo"<br/><a href='reyds.php?'>Рейды</a>";
echo"</div>";}
}
echo"</div></div>";
break;
case'vgroup':
echo"<div class='v2'>";
$lig = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id`='".$_GET['id']."' "));
if($lig==0){echo"Не выбранна банда";}
else{
$rey = mysql_fetch_array(mysql_query("SELECT * FROM `reyd` WHERE `id`='".$lig['id_reyd']."' "));
$li = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `tip`='lider' AND `id_lider`='".$lig['id_lider']."' "));
$liu = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`='".$li['usr']."' "));
$use = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$lig['id_lider']."' "));
$uses = mysql_query("SELECT * FROM `reyd_groups` WHERE `id_lider`='".$lig['id_lider']."' ");
$kolu = mysql_result(mysql_query("SELECT COUNT(*) FROM `reyd_groups` WHERE `id_lider`='".$lig['id_lider']."' "),0);
if($rey['max_pers']==$kkkkol){echo"Слишком много человек!";}else{
echo"Рейд на $rey[name_reyd]</br>";
echo"Лидер: <a href='/info.php?id=$liu[id]'>$liu[usr]</a></br>";
echo"Состав($kolu/$rey[max_pers]):</br>";
while($usee = mysql_fetch_array($uses)){
$use1 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr` = '".$usee['usr']."' "));
echo"<a href='/info.php?id=$use1[id]'>$use1[usr]</a></br>";}
echo"<a href='/reyds.php?reyd=vgroupu&id=$li[id]'>Присоеденится у группе</a>";
}
}
echo"</div>";
break;
case'vgroupu':
echo"<div class='v2'>";
$mygr = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `usr`='".$udata['usr']."' "));
$lig = mysql_fetch_array(mysql_query("SELECT * FROM `reyd_groups` WHERE `id`='".$_GET['id']."' "));
if($mygr){header('Location: reyds.php?reyd=group');exit;}
if($lig==0){echo"Такой группы нет!";}
else{
echo"Вступить в группу?<br>";
echo"<a href='reyds.php?reyd=vgroupu&id=$lig[id]&aut=yes'>Да</a></br>";
echo"<a href='reyds.php?'>Нет</a></li>";
if($_GET['aut']=='yes'){
$max_pers=$lig['max_pers']+1;
$time_user=time();
mysql_query("INSERT INTO `reyd_groups` SET `id_reyd` = '".$lig['id_reyd']."',`id_lider` = '".$lig['id_lider']."',`usr` = '".$udata['usr']."',`tip` = 'user',`time` = '".time()."',`groupon` = 'yes',`battle` = 'no', `life`='yes',`max_pers` = '".$max_pers."' ") or die (mysql_error());
header('Location: reyds.php?reyd=group');exit;
}
}
echo"</div>";
break;
}
echo '</div>';
//
include('files/down.php');
//
?>