Прикручиваем шаблон. Хороним идиотские ошибки. Исправляем дичь.

This commit is contained in:
Igor Barkov (iwork) 2020-09-30 16:45:10 +03:00
parent 0917f9d07f
commit cb47ba0542
4 changed files with 822 additions and 898 deletions

View File

@ -1,430 +1,370 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
include "functions.php";
$wait_msg="Ждем готовности всей группы...";
//rooms
$ch_rooms=array
(
include "functions.php";
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
$wait_msg = "Ждем готовности всей группы...";
//rooms
$ch_rooms = [
// 0 - empty
"1"=>"Ворота (1)",
"2"=>"Двор (2)",
"3"=>"Внешний корридор (3)",
"4"=>"Спуск в подвал (4)",
"5"=>"Подвал (5)",//босс Душа
"6"=>"Люк на Западную стену (6)",
"7"=>"Западная стена (7)",
"8"=>"Галерея Страха (8)",
"9"=>"Западная башня (9)",
"10"=>"Галерея Смерти (10)",//босс Зомби
"11"=>"Проход к Северной стене (11)",
"12"=>"Галерея Тьмы (12)",
"13"=>"Северная стена (13)",
"14"=>"Галерея Бликов (14)",
"15"=>"Внутренний корридор (15)",//босс Повелитель
"16"=>"Гостевая (16)",
"17"=>"Руины Северной башни (17)",
"18"=>"Поминальная комната (18)",
"19"=>"Галерея Порталов (19)",
"20"=>"Зал Посвященных (20)",//босс Хромой Билли
"21"=>"Старая лестница (21)",
"22"=>"Трофейная (22)",
"23"=>"Костяной зал (23)",
"24"=>"Склеп (24)",
"25"=>"Лабиринт (25)",//босс Мародер
"26"=>"Тронный зал (26)",
"27"=>"Тайный корридор (27)",
"28"=>"Комната прислуги (28)",
"29"=>"Королевские покои (29)",
"30"=>"Переход (30)"//босс Грохобот
);
//bots
"1" => "Ворота (1)",
"2" => "Двор (2)",
"3" => "Внешний корридор (3)",
"4" => "Спуск в подвал (4)",
"5" => "Подвал (5)",//босс Душа
"6" => "Люк на Западную стену (6)",
"7" => "Западная стена (7)",
"8" => "Галерея Страха (8)",
"9" => "Западная башня (9)",
"10" => "Галерея Смерти (10)",//босс Зомби
"11" => "Проход к Северной стене (11)",
"12" => "Галерея Тьмы (12)",
"13" => "Северная стена (13)",
"14" => "Галерея Бликов (14)",
"15" => "Внутренний корридор (15)",//босс Повелитель
"16" => "Гостевая (16)",
"17" => "Руины Северной башни (17)",
"18" => "Поминальная комната (18)",
"19" => "Галерея Порталов (19)",
"20" => "Зал Посвященных (20)",//босс Хромой Билли
"21" => "Старая лестница (21)",
"22" => "Трофейная (22)",
"23" => "Костяной зал (23)",
"24" => "Склеп (24)",
"25" => "Лабиринт (25)",//босс Мародер
"26" => "Тронный зал (26)",
"27" => "Тайный корридор (27)",
"28" => "Комната прислуги (28)",
"29" => "Королевские покои (29)",
"30" => "Переход (30)"//босс Грохобот
];
//bots
$ch_bots=array();
//1 - упырь
//2 - падший
//3 - душа
$db=mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_var` WHERE `group`='".$in_haos['group']."' limit 1; "));
if(!$db['bots'])
{
$bot_low=array
(
$ch_bots = [];
//1 - упырь
//2 - падший
//3 - душа
$db = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_var` WHERE `group`='" . $in_haos['group'] . "' limit 1; "));
if (!$db['bots']) {
$bot_low = [
// 0 - empty
"1"=>"Упырь",
"2"=>"Посланник смерти",
"3"=>"Падший",
"4"=>"Отморозок",
"5"=>"Проклятие глубин"
);
for($i=1;$i<=30;$i++)
{
$ch_get_bot=rand(1,5);
$ch_bots[$i]=array("0"=>$bot_low[$ch_get_bot]);
}
$ch_bots[5]=array("0"=>"Душа");
$ch_bots[10]=array("0"=>"Зомби");
$ch_bots[15]=array("0"=>"Повелитель");
$ch_bots[20]=array("0"=>"Хромой Билли");
$ch_bots[25]=array("0"=>"Мародер");
$ch_bots[30]=array("0"=>"Грохобот");
$dbb=serialize($ch_bots);
mysql_query("UPDATE `cit_haos_var` SET bots='".$dbb."' WHERE `group`='".$in_haos['group']."'; ");
"1" => "Упырь",
"2" => "Посланник смерти",
"3" => "Падший",
"4" => "Отморозок",
"5" => "Проклятие глубин"
];
for ($i = 1; $i <= 30; $i++) {
$ch_get_bot = rand(1, 5);
$ch_bots[$i] = ["0" => $bot_low[$ch_get_bot]];
}
else
{
$ch_bots=unserialize($db['bots']);
$ch_bots[5] = ["0" => "Душа"];
$ch_bots[10] = ["0" => "Зомби"];
$ch_bots[15] = ["0" => "Повелитель"];
$ch_bots[20] = ["0" => "Хромой Билли"];
$ch_bots[25] = ["0" => "Мародер"];
$ch_bots[30] = ["0" => "Грохобот"];
$dbb = serialize($ch_bots);
mysql_query("UPDATE `cit_haos_var` SET bots='" . $dbb . "' WHERE `group`='" . $in_haos['group'] . "'; ");
} else {
$ch_bots = unserialize($db['bots']);
}
// комната - опыт == доблесть
$ch_priz = [
"5" => [100, 1],
"10" => [200, 2],
"15" => [300, 3],
"20" => [400, 4],
"25" => [500, 5],
"30" => [600, 10]
];
// комната - кирка == уник_7 == цветок == уник_8
$ch_drop = [
"25" => [10, 60, 95, 100],
"30" => [3, 6, 7, 8],
];
$priz_low =
["727"];
$priz_med =
["775", "776", "777", "778"];
$priz_flow =
["14"];
$priz_high =
["803", "804", "805", "806"];
/*$ch_bots[1]=array
(
"0"=>"Младший страж глубин",
"1"=>"Младший страж глубин",
"2"=>"Босс глубин"
);
$ch_bots[2]=array
(
"0"=>"Младший страж глубин",
"1"=>"Босс глубин"
);*/
if ($user->room != 601) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
if ($in_haos['status'] == 4) {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '600',`online`.`room` = '600' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
mysql_query("UPDATE `cit_haos_status` SET room='0',bot='0',group='0' WHERE id = '{$user['id']}'; ");
header('location: c_haos.php');
}
if (!$ch_rooms[$in_haos['room']]) {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '600',`online`.`room` = '600' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
if ($in_haos['status'] == 2) {
mysql_query("UPDATE `cit_haos_status` SET room='0',status='5',bot='0' WHERE id = '{$user['id']}'; ");
addchp('Вы пробились до двери на 2 уровень подземелий Цитадели Хаоса. Только опытный воин и храбрый страж сможет пройти через нее (10 уровень, страж 2 уровня)', '{[]}' . Nick::id($user['id'])->short() . '{[]}');
}
mysql_query("UPDATE `cit_haos_var` SET bots='',players='' WHERE group='" . $in_haos['group'] . "'; ");
header('location: c_haos.php');
}
Template::header('c_haos_in');
?>
<script>
function refreshPeriodic() {
location.href = 'c_haos_in.php';//reload()
timerID = setTimeout("refreshPeriodic()", 30000);
}
// комната - опыт == доблесть
$ch_priz=array
(
"5" => array (100,1),
"10" => array (200,2),
"15" => array (300,3),
"20" => array (400,4),
"25" => array (500,5),
"30" => array (600,10)
);
// комната - кирка == уник_7 == цветок == уник_8
$ch_drop=array
(
"25" => array (10,60,95,100),
"30" => array (3,6,7,8),
);
$priz_low=
array("727");
$priz_med=
array("775","776","777","778");
$priz_flow=
array("14");
$priz_high=
array("803","804","805","806");
/*$ch_bots[1]=array
(
"0"=>"Младший страж глубин",
"1"=>"Младший страж глубин",
"2"=>"Босс глубин"
);
$ch_bots[2]=array
(
"0"=>"Младший страж глубин",
"1"=>"Босс глубин"
);*/
timerID = setTimeout("refreshPeriodic()", 30000);
</script>
if ($user->room != 601) { header("Location: main.php"); exit; }
if ($user->battle) { header('location: fbattle.php'); exit; }
if ($in_haos['status'] == 4)
{
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '600',`online`.`room` = '600' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
mysql_query("UPDATE `cit_haos_status` SET room='0',bot='0',group='0' WHERE id = '{$user['id']}'; ");
header('location: c_haos.php');
}
if (!$ch_rooms[$in_haos['room']])
{
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '600',`online`.`room` = '600' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
if ($in_haos['status'] == 2)
{
mysql_query("UPDATE `cit_haos_status` SET room='0',status='5',bot='0' WHERE id = '{$user['id']}'; ");
addchp ('Вы пробились до двери на 2 уровень подземелий Цитадели Хаоса. Только опытный воин и храбрый страж сможет пройти через нее (10 уровень, страж 2 уровня)','{[]}'.Nick::id($user['id'])->short().'{[]}');
<TABLE border=0 width=340 cellspacing="0" cellpadding="0" align=left>
<tr>
<td><h3>Цитадель Хаоса: <?= $ch_rooms[$in_haos['room']] ?><br/>
<br/></td>
</tr>
<?php
//attack
if ($_POST['go_attack']) {
if ($in_haos['status'] == 2) {
$bot_name = $ch_bots[$in_haos['room']][$in_haos['bot']];
switch ($bot_name) {
case "Упырь":
$bot_id = 2897;
$bot_count = rand(10, 30);
break;
case "Падший":
$bot_id = 2903;
$bot_count = rand(3, 9);
break;
case "Посланник смерти":
$bot_id = 2896;
$bot_count = 2;
break;
case "Отморозок":
$bot_id = 2893;
$bot_count = 3;
break;
case "Проклятие глубин":
$bot_id = 2892;
$bot_count = rand(1, 5);
break;
case "Душа":
$bot_id = 2895;
$bot_count = 1;
break;
case "Зомби":
$bot_id = 2901;
$bot_count = 5;
break;
case "Повелитель":
$bot_id = 2902;
$bot_count = 1;
break;
case "Хромой Билли":
$bot_id = 2898;
$bot_count = 1;
break;
case "Мародер":
$bot_id = 2899;
$bot_count = 1;
break;
case "Грохобот":
$bot_id = 2900;
$bot_count = 1;
break;
}
mysql_query("UPDATE `cit_haos_var` SET bots='',players='' WHERE group='".$in_haos['group']."'; ");
header('location: c_haos.php');
}
?>
<HTML><HEAD>
<!-- JS -->
<script>
function refreshPeriodic()
{
location.href='c_haos_in.php';//reload()
timerID=setTimeout("refreshPeriodic()",30000);
}
timerID=setTimeout("refreshPeriodic()",30000);
</script>
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
</HEAD>
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=#d4d4d4>
<TABLE border=0 width=340 cellspacing="0" cellpadding="0" align=left>
<tr><td><h3>Цитадель Хаоса: <?= $ch_rooms[$in_haos['room']]?><br />
<br /></td></tr>
<!--tr><td><FORM action="city.php" method=GET><INPUT TYPE="submit" value="Вернуться в Город" name="bps"></FORM></td></tr-->
<?php
//attack
if($_POST['go_attack'])
{
if($in_haos['status'] == 2)
{
$bot_name=$ch_bots[$in_haos['room']][$in_haos['bot']];
switch ($bot_name)
{
case "Упырь":
//$bot_hp=200;
$bot_id=2897;
$bot_count=rand(10,30);
break;
case "Падший":
//$bot_hp=300;
$bot_id=2903;
$bot_count=rand(3,9);
break;
case "Посланник смерти":
//$bot_hp=700;
$bot_id=2896;
$bot_count=2;
break;
case "Отморозок":
//$bot_hp=500;
$bot_id=2893;
$bot_count=3;
break;
case "Проклятие глубин":
//$bot_hp=1000;
$bot_id=2892;
$bot_count=rand(1,5);
break;
case "Душа":
//$bot_hp=1000;
$bot_id=2895;
$bot_count=1;
break;
case "Зомби":
//$bot_hp=1000;
$bot_id=2901;
$bot_count=5;
break;
case "Повелитель":
//$bot_hp=2000;
$bot_id=2902;
$bot_count=1;
break;
case "Хромой Билли":
//$bot_hp=3000;
$bot_id=2898;
$bot_count=1;
break;
case "Мародер":
//$bot_hp=5000;
$bot_id=2899;
$bot_count=1;
break;
case "Грохобот":
//$bot_hp=10000;
$bot_id=2900;
$bot_count=1;
break;
}
$b_pers=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp=$b_pers['maxhp'];
$bots=array();
$group_raw=mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}' AND status='2';");
while ($gr = mysql_fetch_array($group_raw))
{
addchp ('<font color=red>Внимание!</font> '.$bot_name.' напал на Вашу группу!','{[]}'.Nick::id($gr['id'])->short().'{[]}');
$b_pers = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp = $b_pers['maxhp'];
$bots = [];
$group_raw = mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}' AND status='2';");
while ($gr = mysql_fetch_array($group_raw)) {
addchp('<font color=red>Внимание!</font> ' . $bot_name . ' напал на Вашу группу!', '{[]}' . Nick::id($gr['id'])->short() . '{[]}');
}
for($bot_c=0;$bot_c<$bot_count;$bot_c++)
{
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '".$bot_name."%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('".$bot_name." ".($nb[0]+1)."','".$bot_id."','','".$bot_hp."');");
$bot = mysql_insert_id();
$bots[]=$bot;
}
// командный вход
$group_fight=array();
$group_raw=mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}' AND status='2';");
while ($gr = mysql_fetch_array($group_raw))
$group_fight[]=$gr['id'];
{
$teams = array();
foreach($bots as $b)
foreach($group_fight as $gf)
{
$teams[$gf][$b] = array(0,0,time());
$teams[$b][$gf] = array(0,0,time());
for ($bot_c = 0; $bot_c < $bot_count; $bot_c++) {
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '" . $bot_name . "%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('" . $bot_name . " " . ($nb[0] + 1) . "','" . $bot_id . "','','" . $bot_hp . "');");
$bot = mysql_insert_id();
$bots[] = $bot;
}
// командный вход
$group_fight = [];
$group_raw = mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}' AND status='2';");
while ($gr = mysql_fetch_array($group_raw)) {
$group_fight[] = $gr['id'];
}
$teams = [];
foreach ($bots as $b) {
foreach ($group_fight as $gf) {
$teams[$gf][$b] = [0, 0, time()];
$teams[$b][$gf] = [0, 0, time()];
mysql_query("UPDATE `cit_haos_status` SET `status` = '3' WHERE `id` ='{$gf}'; ");
}
}
mysql_query("INSERT INTO `battle`
mysql_query("INSERT INTO `battle`
(
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`
)
VALUES
(
NULL,'','".serialize($teams)."','3','1','0','".implode(";", $group_fight)."','".implode(";", $bots)."','".time()."','".time()."'
NULL,'','" . serialize($teams) . "','3','1','0','" . implode(";", $group_fight) . "','" . implode(";", $bots) . "','" . time() . "','" . time() . "'
)");
$id = mysql_insert_id();
$id = mysql_insert_id();
// апдейтим бота
foreach($bots as $b) mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$b} LIMIT 1;");
// создаем лог
//$rr = "<b>".nick3($user['id'])."</b> и <b>".nick3($bot)."</b>";
//addlog($id,"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." сошлись в поединке. <BR>");
// апдейтим бота
foreach ($bots as $b) {
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$b} LIMIT 1;");
}
foreach($group_fight as $gf) mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$gf};");
//}
exit("<script>location.href='fbattle.php';</script>");
foreach ($group_fight as $gf) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$gf};");
}
exit("<script>location.href='fbattle.php';</script>");
}
}
}
$group_num=mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}';"));
$group_ready=mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_status` WHERE (`room` = '{$in_haos['room']}' AND `group` = '{$in_haos['group']}');"));
$cit_haos_t=mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'cit_haos_time' LIMIT 1;"));
$tm=time();
if($in_haos['status'] == 2)
{if(($tm>($cit_haos_t['value']+960))||($tm<($cit_haos_t['value']-600)))//def 960
{
$flag_ref=1;
foreach($ch_bots[$in_haos['room']] as $bot_id=>$bot_name)
if($bot_id>=$in_haos['bot'])
{
echo '<tr><td><FORM action="c_haos_in.php" method=POST>';
if($bot_id==$in_haos['bot']) echo'<strong>'.$bot_name.'</strong>'; else echo($bot_name);
if($bot_id==$in_haos['bot']) echo' - <INPUT TYPE="submit" value="Напасть" name="go_attack">';
echo ' </FORM></td></tr>';
$flag_ref=0;
}
if (!array_key_exists($in_haos['bot'],$ch_bots[$in_haos['room']]))
{
echo($wait_msg);
//проверяем есть ли приз
if(array_key_exists($in_haos['room'],$ch_priz))
$group_num = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}';"));
$group_ready = mysql_num_rows(mysql_query("SELECT * FROM `cit_haos_status` WHERE (`room` = '{$in_haos['room']}' AND `group` = '{$in_haos['group']}');"));
$cit_haos_t = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'cit_haos_time' LIMIT 1;"));
$tm = time();
if ($in_haos['status'] == 2) {
if (($tm > ($cit_haos_t['value'] + 960)) || ($tm < ($cit_haos_t['value'] - 600)))//def 960
{
$priz_exp=$ch_priz[$in_haos['room']][0];
$priz_dobl=$ch_priz[$in_haos['room']][1];
}
else
{
$priz_exp=0;
$priz_dobl=0;
}
if(array_key_exists($in_haos['room'],$ch_drop))
{
$got_drop=rand(0,400);//100 - norm, 400 - 25%
}
else
{
$got_drop=-1;
}
//выбираем приз
if($in_haos['room']<30)
{
if($got_drop>=0 && $got_drop<$ch_drop[$in_haos['room']][0])
{
$rand_k = array_rand($priz_low, 1);
$p_id=$priz_low[$rand_k];
$p_shop="shop";
}
elseif($got_drop>=$ch_drop[$in_haos['room']][0] && $got_drop<$ch_drop[$in_haos['room']][1])
{
$rand_k = array_rand($priz_med, 1);
$p_id=$priz_med[$rand_k];
$p_shop="shop";
}
elseif($got_drop>=$ch_drop[$in_haos['room']][1] && $got_drop<$ch_drop[$in_haos['room']][2])
{
$rand_k = array_rand($priz_flow, 1);
$p_id=$priz_flow[$rand_k];
$p_shop="fshop";
}
elseif($got_drop>=$ch_drop[$in_haos['room']][2] && $got_drop<=$ch_drop[$in_haos['room']][3])
{
$rand_k = array_rand($priz_high, 1);
$p_id=$priz_high[$rand_k];
$p_shop="shop";
}
}
elseif($in_haos['room']==30)
{
if($got_drop<=200)//400max/4=>50%
{
$priz_low=
array("808","809");
$flag_ref = 1;
foreach ($ch_bots[$in_haos['room']] as $bot_id => $bot_name)
if ($bot_id >= $in_haos['bot']) {
echo '<tr><td><FORM action="c_haos_in.php" method=POST>';
if ($bot_id == $in_haos['bot']) echo '<strong>' . $bot_name . '</strong>'; else echo($bot_name);
if ($bot_id == $in_haos['bot']) echo ' - <INPUT TYPE="submit" value="Напасть" name="go_attack">';
echo ' </FORM></td></tr>';
$flag_ref = 0;
}
if (!array_key_exists($in_haos['bot'], $ch_bots[$in_haos['room']])) {
echo($wait_msg);
//проверяем есть ли приз
if (array_key_exists($in_haos['room'], $ch_priz)) {
$priz_exp = $ch_priz[$in_haos['room']][0];
$priz_dobl = $ch_priz[$in_haos['room']][1];
} else {
$priz_exp = 0;
$priz_dobl = 0;
}
if (array_key_exists($in_haos['room'], $ch_drop)) {
$got_drop = rand(0, 400);//100 - norm, 400 - 25%
} else {
$got_drop = -1;
}
//выбираем приз
if ($in_haos['room'] < 30) {
if ($got_drop >= 0 && $got_drop < $ch_drop[$in_haos['room']][0]) {
$rand_k = array_rand($priz_low, 1);
$p_id = $priz_low[$rand_k];
$p_shop = "shop";
} elseif ($got_drop >= $ch_drop[$in_haos['room']][0] && $got_drop < $ch_drop[$in_haos['room']][1]) {
$rand_k = array_rand($priz_med, 1);
$p_id = $priz_med[$rand_k];
$p_shop = "shop";
} elseif ($got_drop >= $ch_drop[$in_haos['room']][1] && $got_drop < $ch_drop[$in_haos['room']][2]) {
$rand_k = array_rand($priz_flow, 1);
$p_id = $priz_flow[$rand_k];
$p_shop = "fshop";
} elseif ($got_drop >= $ch_drop[$in_haos['room']][2] && $got_drop <= $ch_drop[$in_haos['room']][3]) {
$rand_k = array_rand($priz_high, 1);
$p_id = $priz_high[$rand_k];
$p_shop = "shop";
}
} elseif ($in_haos['room'] == 30) {
if ($got_drop <= 200)//400max/4=>50%
{
$priz_low =
["808", "809"];
$rand_k = array_rand($priz_low, 1);
$p_id=$priz_low[$rand_k];
$p_shop="shop";
}
$rand_k = array_rand($priz_low, 1);
$p_id = $priz_low[$rand_k];
$p_shop = "shop";
}
}
}
//выбираем получателя
$all_get=array();
$gr_raw=mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}';");
while($g_id=mysql_fetch_array($gr_raw))
$all_get[]=$g_id['id'];
$l_id=rand(0,count($all_get)-1);
//$all_get[$l_id];
//if($priz_exp>0) addchp ('CH get priz - '.$all_get[$l_id],'{[]}'.nick7 (1258).'{[]}');
//даем призы
if($p_id>0)
{
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `{$p_shop}` WHERE `id` = '{$p_id}' LIMIT 1;"));
mysql_query("INSERT INTO `inventory`
//выбираем получателя
$all_get = [];
$gr_raw = mysql_query("SELECT * FROM `cit_haos_status` WHERE `group` = '{$in_haos['group']}';");
while ($g_id = mysql_fetch_array($gr_raw)) {
$all_get[] = $g_id['id'];
}
$l_id = rand(0, count($all_get) - 1);
//даем призы
if ($p_id > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `{$p_shop}` WHERE `id` = '{$p_id}' LIMIT 1;"));
mysql_query("INSERT INTO `inventory`
(`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,
`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,
`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`gmp`,`gmeshok`,`encicl`,`artefact`,`duration`,`present`
)
VALUES
('{$dress['id']}','{$all_get[$l_id]}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}',
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','{$dur}','Мусорщик'
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','{$dur}','Мусорщик'
) ;");
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','$all_get[$l_id]','\"".$user['login']."\" получил в ЦХ предмет: \"".$dress['name']."\" ".$dresscount."id:(".$dressid.") [0/".$dress['maxdur']."]',1,'".time()."');");
addchp ('За убийство босса Цитадели Хаоса вы получили '.$dress['name'],'{[]}'.Nick::id($all_get[$l_id])->short().'{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','$all_get[$l_id]','\"" . $user['login'] . "\" получил в ЦХ предмет: \"" . $dress['name'] . "\" " . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "]',1,'" . time() . "');");
addchp('За убийство босса Цитадели Хаоса вы получили ' . $dress['name'], '{[]}' . Nick::id($all_get[$l_id])->short() . '{[]}');
}
if ($priz_exp > 0) {
GiveExp($all_get[$l_id], $priz_exp);
addchp('За убийство босса Цитадели Хаоса вы получили ' . $priz_exp . ' опыта', '{[]}' . Nick::id($all_get[$l_id])->short() . '{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$cur_user['id']}','\"" . $all_get[$l_id] . "\" получил в ЦХ \"" . $priz_exp . "\" опыта',1,'" . time() . "');");
}
if ($priz_dobl > 0) {
mysql_query("UPDATE users SET `doblest`=`doblest`+'" . $priz_dobl . "' WHERE `id` = '" . $all_get[$l_id] . "';");
addchp('За убийство босса Цитадели Хаоса вы получили ' . $priz_dobl . ' доблести', '{[]}' . Nick::id($all_get[$l_id])->short() . '{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$cur_user['id']}','\"" . $all_get[$l_id] . "\" получил в ЦХ \"" . $priz_dobl . "\" доблести',1,'" . time() . "');");
}
mysql_query("UPDATE `cit_haos_status` SET `room` = `room`+1,`bot`=0 WHERE `group` = '{$in_haos['group']}'; ");
if (!headers_sent()) {
header('location: c_haos_in.php');
}
}
if ($flag_ref == 0 && !headers_sent()) {
header('location: c_haos_in.php');
}
} else {
echo "<TR><TD>Ждем готовности группы... Приготовьтесь!</TR></TD>";
echo '<tr><td><FORM action="c_haos_in.php" method=POST><INPUT TYPE="submit" value="Обновить" name="refresh">';
echo ' </FORM></td></tr>';
}
if($priz_exp>0)
{
GiveExp($all_get[$l_id],$priz_exp);
addchp ('За убийство босса Цитадели Хаоса вы получили '.$priz_exp.' опыта','{[]}'.Nick::id($all_get[$l_id])->short().'{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$cur_user['id']}','\"".$all_get[$l_id]."\" получил в ЦХ \"".$priz_exp."\" опыта',1,'".time()."');");
}
if($priz_dobl>0)
{
mysql_query("UPDATE users SET `doblest`=`doblest`+'".$priz_dobl."' WHERE `id` = '".$all_get[$l_id]."';");
addchp ('За убийство босса Цитадели Хаоса вы получили '.$priz_dobl.' доблести','{[]}'.Nick::id($all_get[$l_id])->short().'{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$cur_user['id']}','\"".$all_get[$l_id]."\" получил в ЦХ \"".$priz_dobl."\" доблести',1,'".time()."');");
}
mysql_query("UPDATE `cit_haos_status` SET `room` = `room`+1,`bot`=0 WHERE `group` = '{$in_haos['group']}'; ");
if (!headers_sent()) header('location: c_haos_in.php');
}
if($flag_ref==0 && !headers_sent()) header('location: c_haos_in.php');
}
else
{
echo("<TR><TD>Ждем готовности группы... Приготовьтесь!</TR></TD>");
echo '<tr><td><FORM action="c_haos_in.php" method=POST><INPUT TYPE="submit" value="Обновить" name="refresh">';
echo ' </FORM></td></tr>';
}
}
?>
?>
</table>
<?php
echo('<div align=right><img width="260" src="i/zitadel/'.($in_haos['room']+1).'.jpg" /></div>');
<?php
echo '<div align=right><img width="260" src="i/zitadel/' . ($in_haos['room'] + 1) . '.jpg" /></div>';
?>
</BODY>
</HTML>

View File

@ -1,251 +1,236 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
$in_park = mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));
if (!$in_park) {
mysql_query("INSERT INTO cit_park(id) values('{$user['id']}');");
$in_park = mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$user['id']." AND (type=13 OR type=12 OR type=14) limit 1;"));
}
if(!$in_park)
{
mysql_query("INSERT INTO cit_park(id) values('{$user['id']}');");
$in_park=mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
}
include "functions.php";
include "functions.php";
if ($user->room != 602) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
if ($user->room != 602) { header("Location: main.php"); exit; }
if ($user->battle) { header('location: fbattle.php'); exit; }
//комнаты парка
//комнаты парка
$ch_rooms=array
(
$ch_rooms = [
// 0 - empty
"1"=>"Площадь (1)",
"2"=>"Аллея Геры (2)",
"3"=>"Фонтан Снов (3)",
"4"=>"Лабиринт Фавна (4)",
"5"=>"Поляна Сказок (5)",//босс Душа
"6"=>"Переулок Зеленый (6)",
"7"=>"Дубрава (7)",
"8"=>"Старая Роща (8)",
"9"=>"Лукоморье (9)",
"10"=>"Золотая Роща (10)",//босс Зомби
"11"=>"Вечная Осень (11)",
"12"=>"Заливные Луга (12)",
"13"=>"Терра Нова (13)",
"14"=>"Гора Райдинг (14)",
"15"=>"Пасифик-Риф (15)"//босс Повелитель
);
"1" => "Площадь (1)",
"2" => "Аллея Геры (2)",
"3" => "Фонтан Снов (3)",
"4" => "Лабиринт Фавна (4)",
"5" => "Поляна Сказок (5)",//босс Душа
"6" => "Переулок Зеленый (6)",
"7" => "Дубрава (7)",
"8" => "Старая Роща (8)",
"9" => "Лукоморье (9)",
"10" => "Золотая Роща (10)",//босс Зомби
"11" => "Вечная Осень (11)",
"12" => "Заливные Луга (12)",
"13" => "Терра Нова (13)",
"14" => "Гора Райдинг (14)",
"15" => "Пасифик-Риф (15)"//босс Повелитель
];
// выдаем ботов
// выдаем ботов
$ch_bots=array();
$bot_low=array
("4150","4152","4153","4154","4155","4156");
$bot_high=array
("4157","4158","4159");
if($in_park['bots']=='')
{
for($i=1;$i<=15;$i++)
{
$rand_num=rand(3,7);
$rand_bot='';
for($j=1;$j<=$rand_num;$j++)
{
$rand_bot.=$bot_low[array_rand($bot_low,1)];
$rand_bot.=';';
}
if($i%5==0)
$rand_bot.=$bot_high[array_rand($bot_high,1)];
$rand_bot.=';';
$ch_bots[$i]=$rand_bot;
$ch_bots = [];
$bot_low = ["4150", "4152", "4153", "4154", "4155", "4156"];
$bot_high = ["4157", "4158", "4159"];
if ($in_park['bots'] == '') {
for ($i = 1; $i <= 15; $i++) {
$rand_num = rand(3, 7);
$rand_bot = '';
for ($j = 1; $j <= $rand_num; $j++) {
$rand_bot .= $bot_low[array_rand($bot_low, 1)];
$rand_bot .= ';';
}
$dbb=serialize($ch_bots);
mysql_query("UPDATE `cit_park` SET bots='{$dbb}' WHERE `id`='{$user['id']}'; ");
if ($i % 5 == 0)
$rand_bot .= $bot_high[array_rand($bot_high, 1)];
$rand_bot .= ';';
$ch_bots[$i] = $rand_bot;
}
else
{
$ch_bots=unserialize($in_park['bots']);
$dbb = serialize($ch_bots);
mysql_query("UPDATE `cit_park` SET bots='{$dbb}' WHERE `id`='{$user['id']}'; ");
} else {
$ch_bots = unserialize($in_park['bots']);
}
// начинаем расчет действий
if ($_POST['start_raid']) {
mysql_query("UPDATE `cit_park` SET `counter`=`counter`+1, `room`=`room`+1 WHERE `id`='{$user['id']}';");
$in_park = mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
}
//старт боя - началоа
if ($_POST['attack']) {
$bots_raw = explode(";", $ch_bots[$in_park['room']]);
$bots = [];
foreach ($bots_raw as $bot_id)
if ($bot_id > 0) {
$b_pers = mysql_fetch_array(mysql_query("SELECT `login`,`maxhp` FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp = $b_pers['maxhp'];
$bot_name = $b_pers['login'];
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '" . $bot_name . "%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('" . $bot_name . " " . ($nb[0] + 1) . "','" . $bot_id . "','','" . $bot_hp . "');");
$bots[] = mysql_insert_id();
}
$teams = [];
foreach ($bots as $b) {
$teams[$user['id']][$b] = [0, 0, time()];
$teams[$b][$user['id']] = [0, 0, time()];
}
// начинаем расчет действий
if($_POST['start_raid'])
{
mysql_query("UPDATE `cit_park` SET `counter`=`counter`+1, `room`=`room`+1 WHERE `id`='{$user['id']}';");
$in_park=mysql_fetch_array(mysql_query("SELECT * FROM `cit_park` WHERE `id` = '{$user['id']}' LIMIT 1;"));
}
//старт боя - началоа
if($_POST['attack'])
{
$bots_raw=explode(";",$ch_bots[$in_park['room']]);
$bots=array();
foreach($bots_raw as $bot_id)
if($bot_id>0)
{
$b_pers=mysql_fetch_array(mysql_query("SELECT `login`,`maxhp` FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp=$b_pers['maxhp'];
$bot_name=$b_pers['login'];
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '".$bot_name."%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('".$bot_name." ".($nb[0]+1)."','".$bot_id."','','".$bot_hp."');");
$bots[]=mysql_insert_id();
}
$teams = array();
foreach($bots as $b)
{
$teams[$user['id']][$b] = array(0,0,time());
$teams[$b][$user['id']] = array(0,0,time());
}
mysql_query("INSERT INTO `battle`
mysql_query("INSERT INTO `battle`
(
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`
)
VALUES
(
NULL,'','".serialize($teams)."','3','1','0','".$user['id']."','".implode(";", $bots)."','".time()."','".time()."'
NULL,'','" . serialize($teams) . "','3','1','0','" . $user['id'] . "','" . implode(";", $bots) . "','" . time() . "','" . time() . "'
)");
$id = mysql_insert_id();
foreach($bots as $b) mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$b} LIMIT 1;");
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']};");
$id = mysql_insert_id();
foreach ($bots as $b) mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$b} LIMIT 1;");
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']};");
addchp ('<font color=red>Внимание!</font> Вы вступили в бой c бандитами!','{[]}'.Nick::id($user['id'])->short().'{[]}');
addchp('<font color=red>Внимание!</font> Вы вступили в бой c бандитами!', '{[]}' . Nick::id($user['id'])->short() . '{[]}');
exit("<script>location.href='fbattle.php';</script>");
}
exit("<script>location.href='fbattle.php';</script>");
}
//старт боя - конец
//старт боя - конец
?>
<HTML><HEAD>
?>
<HTML>
<HEAD>
<!-- JS -->
<script>
function refreshPeriodic()
{
location.href='c_park.php';//reload()
timerID=setTimeout("refreshPeriodic()",30000);
}
timerID=setTimeout("refreshPeriodic()",30000);
</script>
function refreshPeriodic() {
location.href = 'c_park.php';//reload()
timerID = setTimeout("refreshPeriodic()", 30000);
}
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
timerID = setTimeout("refreshPeriodic()", 30000);
</script>
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
</HEAD>
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=#d4d4d4>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>
<tr><td><h3>Городской Парк</td></tr>
<?php
if($in_park['room']==0 || $in_park['room']>=15)
{
echo('<tr><td>Вы стоите на парковой площади</strong></td></tr>');
echo("<tr><td>За сегодня Вы посетили парк <b>".$in_park['counter']."/3</b> раз.</td></tr>");
if($in_park['room']==15)
{
echo("<tr><td>Вы вышли из парка с чувством глубокого удовлетворения...</td></tr>");
//раздача гаек
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '856' LIMIT 1;"));
$gadget_num=mt_rand(1,8);
for($i=0;$i<$gadget_num;$i++)
{
mysql_query("INSERT INTO `inventory`
<tr>
<td><h3>Городской Парк</td>
</tr>
<?php
if ($in_park['room'] == 0 || $in_park['room'] >= 15) {
echo('<tr><td>Вы стоите на парковой площади</strong></td></tr>');
echo("<tr><td>За сегодня Вы посетили парк <b>" . $in_park['counter'] . "/3</b> раз.</td></tr>");
if ($in_park['room'] == 15) {
echo("<tr><td>Вы вышли из парка с чувством глубокого удовлетворения...</td></tr>");
//раздача гаек
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '856' LIMIT 1;"));
$gadget_num = mt_rand(1, 8);
for ($i = 0; $i < $gadget_num; $i++) {
mysql_query("INSERT INTO `inventory`
(`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,
`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,
`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`gmp`,`gmeshok`,`encicl`,`artefact`,`duration`
)
VALUES
('{$dress['id']}','{$user[id]}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}',
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
) ;");
}
//раздача страничек
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '867' LIMIT 1;"));
$gadget_num=mt_rand(1,5);
for($i=0;$i<$gadget_num;$i++)
{
mysql_query("INSERT INTO `inventory`
//раздача страничек
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '867' LIMIT 1;"));
$gadget_num = mt_rand(1, 5);
for ($i = 0; $i < $gadget_num; $i++) {
mysql_query("INSERT INTO `inventory`
(`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,
`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,
`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`gmp`,`gmeshok`,`encicl`,`artefact`,`duration`
)
VALUES
('{$dress['id']}','{$user[id]}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}',
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
) ;");
}
//раздача ингридиентов
$ing_list=array("859","860","861","862","863","864","865");
$ing_id=$ing_list[array_rand($ing_list)];
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '{$ing_id}' LIMIT 1;"));
$gadget_num=mt_rand(1,3);
for($i=0;$i<$gadget_num;$i++)
{
mysql_query("INSERT INTO `inventory`
$ing_list = ["859", "860", "861", "862", "863", "864", "865"];
$ing_id = $ing_list[array_rand($ing_list)];
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `shop` WHERE `id` = '{$ing_id}' LIMIT 1;"));
$gadget_num = mt_rand(1, 3);
for ($i = 0; $i < $gadget_num; $i++) {
mysql_query("INSERT INTO `inventory`
(`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,
`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,
`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`gmp`,`gmeshok`,`encicl`,`artefact`,`duration`
)
VALUES
('{$dress['id']}','{$user[id]}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}',
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','".(($dress['goden'])?($dress['goden']*24*60*60+time()):"")."','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['gmp']}','{$dress['gmeshok']}','{$dress['encicl']}','{$dress['artefact']}','0'
) ;");
}
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','\"".$user['login']."\" Подобрал в Парке гайки ( \"".$gadget_num."\" ".$dresscount."id:(".$dressid.") [0/".$dress['maxdur']."]',1,'".time()."');");
addchp ('В Парке Вы подобрали гайки ('.$gadget_num.' шт.)','{[]}'.Nick::id($user['id'])->short().'{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','\"" . $user['login'] . "\" Подобрал в Парке гайки ( \"" . $gadget_num . "\" " . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "]',1,'" . time() . "');");
addchp('В Парке Вы подобрали гайки (' . $gadget_num . ' шт.)', '{[]}' . Nick::id($user['id'])->short() . '{[]}');
//денежный приз
$priz=mt_rand(1,10);
$priz = mt_rand(1, 10);
mysql_query("UPDATE users set money=money+{$priz} where id='{$user['id']}';");
addchp ('После посещения Парка Вы обогатились на '.$priz.' кр. ','{[]}'.Nick::id($user['id'])->short().'{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$user['id']}','\"".$user['login']."\" нашел в Парке ".$priz." кр. ',1,'".time()."');");
addchp('После посещения Парка Вы обогатились на ' . $priz . ' кр. ', '{[]}' . Nick::id($user['id'])->short() . '{[]}');
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`)
VALUES ('','0','{$user['id']}','\"" . $user['login'] . "\" нашел в Парке " . $priz . " кр. ',1,'" . time() . "');");
//переход
mysql_query("UPDATE `cit_park` SET `room`=0,`bots`='',`time`='".time()."' WHERE `id` ='{$user['id']}'; ");
}
if($in_park['counter']>=3)
echo('<tr><td>По какому-то странному совпадению Вам не хочется идти в парк. Может, подождать до завтра? </td></tr>');
elseif(($in_park['time']+3600)>time())
{/**/
$tm=time();
$t_wait=round(((3600-$tm+$in_park['time'])/60),1);
echo('<tr><td>Вы совсем недавно вернулись из парка, бесполезно идти туда снова. <br/>(Осталось ждать: <strong>'.$t_wait.'</strong> мин.)</td></tr>');
mysql_query("UPDATE `cit_park` SET `room`=0,`bots`='',`time`='" . time() . "' WHERE `id` ='{$user['id']}'; ");
}
else
echo('<tr><td><FORM action="c_park.php" method=POST><INPUT TYPE="submit" value="Прогуляться" name="start_raid"><br></FORM></td></tr>');
echo '<tr><td><FORM action="city.php" method=GET><INPUT TYPE="submit" value="Вернуться в Город" name="ps"></FORM></td></tr>';
}
else
{
echo('<tr><td>Вы видите табличку с названием улицы: <strong>'.$ch_rooms[$in_park['room']].'</strong></td></tr>');
echo('<tr><td>В парке пустынно и темно, только какие-то подозрительные личности шныряют по своим делам.</td></tr>');
echo('<tr><td>Вы видите несколько бандитов. Они замышляют зловещие преступления в городе!</td></tr>');
echo('<tr><td><FORM action="c_park.php" method=POST><INPUT TYPE="submit" value="Напасть" name="attack"><br></FORM></td></tr>');
}
if ($in_park['counter'] >= 3)
echo('<tr><td>По какому-то странному совпадению Вам не хочется идти в парк. Может, подождать до завтра? </td></tr>');
elseif (($in_park['time'] + 3600) > time()) {/**/
$tm = time();
$t_wait = round(((3600 - $tm + $in_park['time']) / 60), 1);
echo('<tr><td>Вы совсем недавно вернулись из парка, бесполезно идти туда снова. <br/>(Осталось ждать: <strong>' . $t_wait . '</strong> мин.)</td></tr>');
} else
echo('<tr><td><FORM action="c_park.php" method=POST><INPUT TYPE="submit" value="Прогуляться" name="start_raid"><br></FORM></td></tr>');
echo '<tr><td><FORM action="city.php" method=GET><INPUT TYPE="submit" value="Вернуться в Город" name="ps"></FORM></td></tr>';
} else {
echo('<tr><td>Вы видите табличку с названием улицы: <strong>' . $ch_rooms[$in_park['room']] . '</strong></td></tr>');
echo('<tr><td>В парке пустынно и темно, только какие-то подозрительные личности шныряют по своим делам.</td></tr>');
echo('<tr><td>Вы видите несколько бандитов. Они замышляют зловещие преступления в городе!</td></tr>');
echo('<tr><td><FORM action="c_park.php" method=POST><INPUT TYPE="submit" value="Напасть" name="attack"><br></FORM></td></tr>');
}
?>
?>
</table>
<div align=right><img width="260" src="i/park/<?php echo($in_park['room']+1); ?>.jpg" /></div>
<?php
<div align=right><img width="260" src="i/park/<?php echo($in_park['room'] + 1); ?>.jpg"/></div>
<?php
?>
</BODY>

View File

@ -1,332 +1,333 @@
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
include "config.php";
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " AND (type=13 OR type=12 OR type=14) limit 1;"));
$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$user['klan']}' LIMIT 1;"));
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$user['id']." AND (type=13 OR type=12 OR type=14) limit 1;"));
$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$user['klan']}' LIMIT 1;"));
include "functions.php";
if ($user->room != 45) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
include "functions.php";
if ($user->room != 45) { header("Location: main.php"); exit; }
if ($user->battle) { header('location: fbattle.php'); exit; }
$cc_date = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var`='cc_time' LIMIT 1;"));
$ccd = $cc_date['value'];
$cc_date=mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var`='cc_time' LIMIT 1;"));
$ccd=$cc_date['value'];
if ($_POST['admin_start']) {
$tm = time();
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
exit("<script>location.href='clan_castle.php';</script>");
}
if ($_POST['admin_start1']) {
$tm = time() - 900;
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
exit("<script>location.href='clan_castle.php';</script>");
}
if($_POST['admin_start'])
{
$tm=time();
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
exit("<script>location.href='clan_castle.php';</script>");
}
if($_POST['admin_start1'])
{
$tm=time()-900;
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
exit("<script>location.href='clan_castle.php';</script>");
}
if ($_POST['add_zay']) {
mysql_query("INSERT INTO `clan_castle` VALUES ('{$user['id']}','{$user['klan']}');");
exit("<script>location.href='clan_castle.php';</script>");
}
if($_POST['add_zay'])
{
mysql_query("INSERT INTO `clan_castle` VALUES ('{$user['id']}','{$user['klan']}');");
exit("<script>location.href='clan_castle.php';</script>");
}
?>
<HTML><HEAD>
?>
<HTML>
<HEAD>
<!-- JS -->
<script>
function refreshPeriodic()
{
location.href='clan_castle.php';
timerID=setTimeout("refreshPeriodic()",30000);
}
timerID=setTimeout("refreshPeriodic()",30000);
</script>
function refreshPeriodic() {
location.href = 'clan_castle.php';
timerID = setTimeout("refreshPeriodic()", 30000);
}
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
timerID = setTimeout("refreshPeriodic()", 30000);
</script>
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
</HEAD>
<body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5 bgcolor=#d4d4d4>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>
<tr><td><h3>Замок Мэра</td></tr>
<tr><td><FORM action="city.php" method=GET><INPUT TYPE="submit" value="Вернуться в Город" name="bps"></FORM></td></tr>
<tr><td>Добро пожаловать в Замок доброго и справедливого Мэра!
Если Вы заинтерисованы в обладании правами на Замок, либо считаете что обладаете достаточными способностями для исполнения
обязанностей Мэра, приглашаем Вас и Ваших единомышлеников поселиться в Замке! <br/> <br/>
Внимание! Администрация не несет ответственности за возможные конфликты на основе спора о правах обладания Замком,
целость и сохранность Ваших личных вещей, здоровье и жизни посетителей!<br/>
<?php
$own=mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
if($own['value']>0) $tmp_k=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$own['value']}' LIMIT 1;"));
echo('<br />Над Замком развевается флаг ');
if($tmp_k['name'])
echo('<strong>клана <img title="'.$tmp_k['name'].'" src="i/clan/'.$tmp_k['name'].'.gif">'.$tmp_k['name'].'</strong><br />');
else
echo('<strong>сил Хаоса</strong><br />');
<tr>
<td><h3>Замок Мэра</td>
</tr>
<tr>
<td>
<FORM action="city.php" method=GET><INPUT TYPE="submit" value="Вернуться в Город" name="bps"></FORM>
</td>
</tr>
<tr>
<td>Добро пожаловать в Замок доброго и справедливого Мэра!
Если Вы заинтерисованы в обладании правами на Замок, либо считаете что обладаете достаточными способностями
для исполнения
обязанностей Мэра, приглашаем Вас и Ваших единомышлеников поселиться в Замке! <br/> <br/>
Внимание! Администрация не несет ответственности за возможные конфликты на основе спора о правах обладания
Замком,
целость и сохранность Ваших личных вещей, здоровье и жизни посетителей!<br/>
<?php
$own = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
if ($own['value'] > 0) $tmp_k = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$own['value']}' LIMIT 1;"));
echo('<br />Над Замком развевается флаг ');
if ($tmp_k['name'])
echo('<strong>клана <img title="' . $tmp_k['name'] . '" src="i/clan/' . $tmp_k['name'] . '.gif">' . $tmp_k['name'] . '</strong><br />');
else
echo('<strong>сил Хаоса</strong><br />');
if($user['align']==2.99) echo('<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: запустить" name="admin_start"><br></FORM>');
if($user['align']==2.99) echo('<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: старт боя" name="admin_start1"><br></FORM>');
if($ccd>=time())
{
echo("Следующая битва: ".(date("j.m",$ccd))." в ".(date("H:i",$ccd)));
if ($user['align'] == 2.99) echo('<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: запустить" name="admin_start"><br></FORM>');
if ($user['align'] == 2.99) echo('<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: старт боя" name="admin_start1"><br></FORM>');
if ($ccd >= time()) {
echo("Следующая битва: " . (date("j.m", $ccd)) . " в " . (date("H:i", $ccd)));
}
elseif($ccd<time() && ($ccd+900)>=time())
{
$zays=array();
echo("Заявили права на Замок Мэра:");
echo('<TABLE border=0 width=100% cellspacing="0" cellpadding="0" align=left>');
$all_c=mysql_query("SELECT * FROM `clan_castle`;");
while ($a_zay=mysql_fetch_array($all_c))
{
$zays[]=$a_zay['clan'];
$tmp_k=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$a_zay['clan']}' LIMIT 1;"));
echo '<tr><td><strong>Клан <img title="'.$tmp_k['name'].'" src="i/clan/'.$tmp_k['name'].'.gif">'.$tmp_k['name'].'</strong></td></tr>';
}
if(empty($zays))
echo '<tr><td><strong>Ждем смелых ...</strong></td></tr>';
echo('</TABLE>');
echo("<br/>Прием заявок до: <strong>".(date("H:i",$ccd+900))."</strong>");
} elseif ($ccd < time() && ($ccd + 900) >= time()) {
$zays = [];
echo("Заявили права на Замок Мэра:");
echo('<TABLE border=0 width=100% cellspacing="0" cellpadding="0" align=left>');
$all_c = mysql_query("SELECT * FROM `clan_castle`;");
while ($a_zay = mysql_fetch_array($all_c)) {
$zays[] = $a_zay['clan'];
$tmp_k = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$a_zay['clan']}' LIMIT 1;"));
echo '<tr><td><strong>Клан <img title="' . $tmp_k['name'] . '" src="i/clan/' . $tmp_k['name'] . '.gif">' . $tmp_k['name'] . '</strong></td></tr>';
}
if (empty($zays))
echo '<tr><td><strong>Ждем смелых ...</strong></td></tr>';
echo('</TABLE>');
echo("<br/>Прием заявок до: <strong>" . (date("H:i", $ccd + 900)) . "</strong>");
$own=mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
$own = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
if ($klan['glava']==$user['id'] && !in_array($user['klan'],$zays) && $user['klan']!=$own['value'])
{
echo("<br />Прием заявок от глав кланов:");
echo '<tr><td><FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Заявиться" name="add_zay"></FORM></td></tr>';
}
if ($klan['glava'] == $user['id'] && !in_array($user['klan'], $zays) && $user['klan'] != $own['value']) {
echo("<br />Прием заявок от глав кланов:");
echo '<tr><td><FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Заявиться" name="add_zay"></FORM></td></tr>';
}
}
elseif(($ccd+900)<time() && ($ccd+90+900)>=time())
{
$zays=array();
$all_zay=mysql_query("SELECT * FROM `clan_castle`;");
while ($a_zay=mysql_fetch_array($all_zay))
{
$cur_c=mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `klan`='{$a_zay['clan']}' AND `room`='45';"));
for($cc=0;$cc<$cur_c;$cc++)
$zays[]=$a_zay['clan'];
}
$own=mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
shuffle($zays);
$lucky=$zays[array_rand($zays)];
} elseif (($ccd + 900) < time() && ($ccd + 90 + 900) >= time()) {
$zays = [];
$all_zay = mysql_query("SELECT * FROM `clan_castle`;");
while ($a_zay = mysql_fetch_array($all_zay)) {
$cur_c = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `klan`='{$a_zay['clan']}' AND `room`='45';"));
for ($cc = 0; $cc < $cur_c; $cc++)
$zays[] = $a_zay['clan'];
}
$own = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
shuffle($zays);
$lucky = $zays[array_rand($zays)];
// if($lucky>0 && $lucky!=$own['vlaue']);
mysql_query("UPDATE `variables` SET `value`='{$lucky}' WHERE `var`='castle_att';");
$tmp_k=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$lucky}' LIMIT 1;"));
mysql_query("UPDATE `variables` SET `value`='{$lucky}' WHERE `var`='castle_att';");
$tmp_k = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$lucky}' LIMIT 1;"));
if($own['value']>0)
$tmp_o=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$own['value']}' LIMIT 1;"));
if ($own['value'] > 0)
$tmp_o = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$own['value']}' LIMIT 1;"));
if($tmp_k) echo('Внимание!<img title="'.$tmp_k['name'].'" src="i/clan/'.$tmp_k['name'].'.gif"><strong>'.$tmp_k['name'].'</strong> собираются штурмовать замок');
if($tmp_k && $own['value']>0) echo('<img title="'.$tmp_o['name'].'" src="i/clan/'.$tmp_o['name'].'.gif"><strong>'.$tmp_o['name'].'</strong>!');
if($tmp_k && !$own['value']>0) echo('!');
}
elseif(($ccd+90+900)<=time())
{
$att=mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_att' LIMIT 1;"));
$own=mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
if ($tmp_k) echo('Внимание!<img title="' . $tmp_k['name'] . '" src="i/clan/' . $tmp_k['name'] . '.gif"><strong>' . $tmp_k['name'] . '</strong> собираются штурмовать замок');
if ($tmp_k && $own['value'] > 0) echo('<img title="' . $tmp_o['name'] . '" src="i/clan/' . $tmp_o['name'] . '.gif"><strong>' . $tmp_o['name'] . '</strong>!');
if ($tmp_k && !$own['value'] > 0) echo('!');
} elseif (($ccd + 90 + 900) <= time()) {
$att = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_att' LIMIT 1;"));
$own = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1;"));
$at_t=array();
$ow_t=array();
$at_t = [];
$ow_t = [];
if($att['value']>0)
{
$att_r=mysql_query("SELECT `id` FROM `users` WHERE `klan`='{$att['value']}' AND `room`='45';");
while($a=mysql_fetch_array($att_r))
{
$at_on = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = '{$a['id']}' LIMIT 1;"));
if($at_on[0])
$at_t[]=$a['id'];
}
if ($att['value'] > 0) {
$att_r = mysql_query("SELECT `id` FROM `users` WHERE `klan`='{$att['value']}' AND `room`='45';");
while ($a = mysql_fetch_array($att_r)) {
$at_on = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= " . (time() - 60) . " AND `id` = '{$a['id']}' LIMIT 1;"));
if ($at_on[0])
$at_t[] = $a['id'];
}
}
if($own['value']>0)
{
$def_r=mysql_query("SELECT `id` FROM `users` WHERE `klan`='{$own['value']}' AND `room`='45';");
while($o=mysql_fetch_array($def_r))
{
$df_on = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = '{$o['id']}' LIMIT 1;"));
if($df_on[0])
$ow_t[]=$o['id'];
}
}
if(empty($at_t))
{
echo("Смелых так и не нашлось...<br/>");
}
elseif(empty($ow_t) && ($own['value']>0))
{
echo("Хозяева слили замок без боя...<br/>");
$cc_own=mysql_fetch_array(mysql_query("SELECT `value` FROM variables WHERE var='castle_owner' LIMIT 1;"));
$cc_k=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$cc_own['value']}' LIMIT 1;"));
$cc_att=mysql_fetch_array(mysql_query("SELECT `value` FROM variables WHERE var='castle_att' LIMIT 1;"));
$cc_a=mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$cc_att['value']}' LIMIT 1;"));
{AddChatSystem('<font color=red><strong>Клан <img title="'.$cc_a['name'].'" src="i/clan/'.$cc_a['name'].'.gif">'.$cc_a['name'].'</strong> без боя забрал у <strong>клана <img title="'.$cc_k['name'].'" src="i/clan/'.$cc_k['name'].'.gif">'.$cc_k['name'].'</strong> Замок Мэра</font>');}
$c_prev=mysql_fetch_array(mysql_query("SELECT `glava`,`align` FROM `clans` WHERE `id`='{$own['value']}' LIMIT 1;"));
mysql_query("UPDATE `users` SET `align`='{$c_prev['align']}',`abil`='' WHERE `id`='{$c_prev['glava']}';");
mysql_query("UPDATE `variables` SET `value`='{$att['value']}' WHERE `var`='castle_owner';");
mysql_query("UPDATE `variables` SET `value`='0' WHERE `var`='castle_att';");
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
$c_lead=mysql_fetch_array(mysql_query("SELECT `glava` FROM `clans` WHERE `id`='{$att['value']}' LIMIT 1;"));
$abil=array();
for($i=0;$i<10;$i++) $abil[$i]=9;
mysql_query("UPDATE `users` SET `align`='7.97',`abil`='".serialize($abil)."' WHERE `id`='{$c_lead['glava']}';");
mysql_query("DELETE FROM `clan_castle`");
}
elseif($own['value']==0)
{
//побоище против ботов
//ставим ботов
$bots_raw=array
("2897","2897","2897","2897","2897","2897","2897","2897","2897","2897","4150","4150","4156","4156","4156","4156",
"2895","2895","4158","4158","4158","4158","4158","2900");
$bots=array();
foreach($bots_raw as $bot_id)
if($bot_id>0)
{
$b_pers=mysql_fetch_array(mysql_query("SELECT `login`,`maxhp` FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp=$b_pers['maxhp'];
$bot_name=$b_pers['login'];
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '".$bot_name."%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('".$bot_name." ".($nb[0]+1)."','".$bot_id."','','".$bot_hp."');");
$bots[]=mysql_insert_id();
}
//отаке!
$teams = array();
foreach($at_t as $b)
foreach($bots as $gf)
{
$teams[$gf][$b] = array(0,0,time());
$teams[$b][$gf] = array(0,0,time());
}
mysql_query("INSERT INTO `battle`
if ($own['value'] > 0) {
$def_r = mysql_query("SELECT `id` FROM `users` WHERE `klan`='{$own['value']}' AND `room`='45';");
while ($o = mysql_fetch_array($def_r)) {
$df_on = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= " . (time() - 60) . " AND `id` = '{$o['id']}' LIMIT 1;"));
if ($df_on[0])
$ow_t[] = $o['id'];
}
}
if (empty($at_t)) {
echo("Смелых так и не нашлось...<br/>");
} elseif (empty($ow_t) && ($own['value'] > 0)) {
echo("Хозяева слили замок без боя...<br/>");
$cc_own = mysql_fetch_array(mysql_query("SELECT `value` FROM variables WHERE var='castle_owner' LIMIT 1;"));
$cc_k = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$cc_own['value']}' LIMIT 1;"));
$cc_att = mysql_fetch_array(mysql_query("SELECT `value` FROM variables WHERE var='castle_att' LIMIT 1;"));
$cc_a = mysql_fetch_array(mysql_query("SELECT `name` FROM `clans` WHERE `id` = '{$cc_att['value']}' LIMIT 1;"));
{
AddChatSystem('<font color=red><strong>Клан <img title="' . $cc_a['name'] . '" src="i/clan/' . $cc_a['name'] . '.gif">' . $cc_a['name'] . '</strong> без боя забрал у <strong>клана <img title="' . $cc_k['name'] . '" src="i/clan/' . $cc_k['name'] . '.gif">' . $cc_k['name'] . '</strong> Замок Мэра</font>');
}
$c_prev = mysql_fetch_array(mysql_query("SELECT `glava`,`align` FROM `clans` WHERE `id`='{$own['value']}' LIMIT 1;"));
mysql_query("UPDATE `users` SET `align`='{$c_prev['align']}',`abil`='' WHERE `id`='{$c_prev['glava']}';");
mysql_query("UPDATE `variables` SET `value`='{$att['value']}' WHERE `var`='castle_owner';");
mysql_query("UPDATE `variables` SET `value`='0' WHERE `var`='castle_att';");
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
$c_lead = mysql_fetch_array(mysql_query("SELECT `glava` FROM `clans` WHERE `id`='{$att['value']}' LIMIT 1;"));
$abil = [];
for ($i = 0; $i < 10; $i++) $abil[$i] = 9;
mysql_query("UPDATE `users` SET `align`='7.97',`abil`='" . serialize($abil) . "' WHERE `id`='{$c_lead['glava']}';");
mysql_query("DELETE FROM `clan_castle`");
} elseif ($own['value'] == 0) {
//побоище против ботов
//ставим ботов
$bots_raw = ["2897", "2897", "2897", "2897", "2897", "2897", "2897", "2897", "2897", "2897", "4150", "4150", "4156", "4156", "4156", "4156",
"2895", "2895", "4158", "4158", "4158", "4158", "4158", "2900"];
$bots = [];
foreach ($bots_raw as $bot_id)
if ($bot_id > 0) {
$b_pers = mysql_fetch_array(mysql_query("SELECT `login`,`maxhp` FROM users WHERE id='{$bot_id}' LIMIT 1;"));
$bot_hp = $b_pers['maxhp'];
$bot_name = $b_pers['login'];
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '" . $bot_name . "%';"));
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('" . $bot_name . " " . ($nb[0] + 1) . "','" . $bot_id . "','','" . $bot_hp . "');");
$bots[] = mysql_insert_id();
}
//отаке!
$teams = [];
foreach ($at_t as $b)
foreach ($bots as $gf) {
$teams[$gf][$b] = [0, 0, time()];
$teams[$b][$gf] = [0, 0, time()];
}
mysql_query("INSERT INTO `battle`
(
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`,`blood`
)
VALUES
(
NULL,'','".serialize($teams)."','3','1','0','".implode(";",$at_t)."','".implode(";",$bots)."','".time()."','".time()."','0'
NULL,'','" . serialize($teams) . "','3','1','0','" . implode(";", $at_t) . "','" . implode(";", $bots) . "','" . time() . "','" . time() . "','0'
)");
$id = mysql_insert_id();
// создаем лог
$rr = "<b>";
$id = mysql_insert_id();
// создаем лог
$rr = "<b>";
foreach( $at_t as $k=>$v ) {
if ($k!=0) { $rr.=", "; $rrc.=", "; }
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp ('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.Nick::id($v)->short().'{[]}');
}
$rr .= "</b> и <b>"; $rrc .= "</b> и <b>";
foreach( $bots as $k=>$v ) {
if ($k!=0) { $rr.=", "; $rrc.=", ";}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
}
$rr .= "</b>";
addch ("<a href=logs.php?log=".$id." target=_blank>Поединок</a> между <B>".$rrc."</B> начался. ",$user->room);
mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}','Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>');");
foreach ($at_t as $k => $v) {
if ($k != 0) {
$rr .= ", ";
$rrc .= ", ";
}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . Nick::id($v)->short() . '{[]}');
}
$rr .= "</b> и <b>";
$rrc .= "</b> и <b>";
foreach ($bots as $k => $v) {
if ($k != 0) {
$rr .= ", ";
$rrc .= ", ";
}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
}
$rr .= "</b>";
addch("<a href=logs.php?log=" . $id . " target=_blank>Поединок</a> между <B>" . $rrc . "</B> начался. ", $user->room);
mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}','Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <BR>');");
addlog($id,"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
$add_time=time();
// всех в БОЙ!!!
foreach($at_t as $k=>$v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
foreach($bots as $k=>$v) {
mysql_query("UPDATE `bots` SET `battle` ={$id} WHERE `id`= {$v}");
}
mysql_query("DELETE FROM `clan_castle`");
}
elseif(!empty($at_t) && !empty($ow_t))
{
//побоище
addlog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <BR>");
$add_time = time();
// всех в БОЙ!!!
foreach ($at_t as $k => $v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
foreach ($bots as $k => $v) {
mysql_query("UPDATE `bots` SET `battle` ={$id} WHERE `id`= {$v}");
}
mysql_query("DELETE FROM `clan_castle`");
} elseif (!empty($at_t) && !empty($ow_t)) {
//побоище
$teams = array();
foreach($at_t as $b)
foreach($ow_t as $gf)
{
$teams[$gf][$b] = array(0,0,time());
$teams[$b][$gf] = array(0,0,time());
}
$teams = [];
foreach ($at_t as $b)
foreach ($ow_t as $gf) {
$teams[$gf][$b] = [0, 0, time()];
$teams[$b][$gf] = [0, 0, time()];
}
mysql_query("INSERT INTO `battle`
mysql_query("INSERT INTO `battle`
(
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`,`blood`
)
VALUES
(
NULL,'','".serialize($teams)."','3','1','0','".implode(";",$at_t)."','".implode(";",$ow_t)."','".time()."','".time()."','0'
NULL,'','" . serialize($teams) . "','3','1','0','" . implode(";", $at_t) . "','" . implode(";", $ow_t) . "','" . time() . "','" . time() . "','0'
)");
$id = mysql_insert_id();
// создаем лог
$rr = "<b>";
$id = mysql_insert_id();
// создаем лог
$rr = "<b>";
foreach( $at_t as $k=>$v ) {
if ($k!=0) { $rr.=", "; $rrc.=", "; }
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp ('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.Nick::id($v)->short().'{[]}');
}
$rr .= "</b> и <b>"; $rrc .= "</b> и <b>";
foreach( $ow_t as $k=>$v ) {
if ($k!=0) { $rr.=", "; $rrc.=", ";}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp ('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.Nick::id($v)->short().'{[]}');
}
$rr .= "</b>";
addch ("<a href=logs.php?log=".$id." target=_blank>Поединок</a> между <B>".$rrc."</B> начался. ",$user->room);
mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}','Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>');");
foreach ($at_t as $k => $v) {
if ($k != 0) {
$rr .= ", ";
$rrc .= ", ";
}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . Nick::id($v)->short() . '{[]}');
}
$rr .= "</b> и <b>";
$rrc .= "</b> и <b>";
foreach ($ow_t as $k => $v) {
if ($k != 0) {
$rr .= ", ";
$rrc .= ", ";
}
$rr .= Nick::id($v)->full(1);
$rrc .= Nick::id($v)->short();
addchp('<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . Nick::id($v)->short() . '{[]}');
}
$rr .= "</b>";
addch("<a href=logs.php?log=" . $id . " target=_blank>Поединок</a> между <B>" . $rrc . "</B> начался. ", $user->room);
mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}','Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <BR>');");
addlog($id,"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
$add_time=time();
// всех в БОЙ!!!
foreach($at_t as $k=>$v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
foreach($ow_t as $k=>$v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
addlog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <BR>");
$add_time = time();
// всех в БОЙ!!!
foreach ($at_t as $k => $v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
foreach ($ow_t as $k => $v) {
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$v}");
}
mysql_query("DELETE FROM `clan_castle`");
}
$tm = time() + 23 * 60 * 60;
mysql_query("UPDATE `variables` SET `value`='0' WHERE `var`='castle_att';");
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
mysql_query("DELETE FROM `clan_castle`");
}
$tm=time()+23*60*60;
mysql_query("UPDATE `variables` SET `value`='0' WHERE `var`='castle_att';");
mysql_query("UPDATE `variables` SET `value`='{$tm}' WHERE `var`='cc_time';");
mysql_query("DELETE FROM `clan_castle`");
}
?>
</td></tr>
}
?>
</td>
</tr>
</table>
<div align=right><img width="260" src="i/zamok/4.jpg" /></div>
<div align=right><img width="260" src="i/zamok/4.jpg"/></div>
</BODY>
</HTML>

View File

@ -5,9 +5,7 @@
header("Location: index.php");
exit;
}
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
include "functions.php";
include "functions.php";
if ($user->room != 53) { header("Location: main.php"); exit; }
if ($user->battle) { header('location: fbattle.php'); exit; }