query('LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE'); if ((input::check('do') == "clear") AND $user['admin'] == 1) { db::c()->query('UPDATE `zayavka` SET `coment` = "?s" WHERE `id` = ?i', 'Вырезано цензурой!', $_GET['zid']); } if (!empty($_GET['del']) && $user['admin'] == 1) { //удаление заявки на бой. $zayavka = db::c()->query('SELECT `id` FROM `zayavka` WHERE `id` = ?i', $_GET['zid'])->fetch_assoc(); if (isset($zayavka['id'])) { db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = ?i', $zayavka['id']); db::c()->query('DELETE FROM `zayavka` WHERE `id` = ?i', $zayavka['id']); } else { echo 'Заявка не найдена ...'; } } $_SESSION['view'] = false; if (isset($_REQUEST['view'])) $_SESSION['view'] = $_REQUEST['view']; class zayavka { var $mysql; function __construct() { global $mysql; $this->mysql = $mysql; } function fteam($team) { $team = explode(";", $team); unset($team[count($team) - 1]); return $team; } /** * @param int $razdel - тип поединка (1-нубы,2-физы,4-группы,5-хаос) * @param null $level - показывать заявки только N уровня * @param null $id * @return mixed * @throws \Krugozor\Database\Mysql\Exception */ function getlist($razdel = 1, $level = null, $id = null) { $sql = db::c()->prepare('SELECT * FROM `zayavka` WHERE `level` = ?i', $razdel); if (!is_null($level)) { $sql .= db::c()->prepare(' AND (`t1min` <= ?i OR `t1min` = 99) AND (`t1max` >= ?i OR `t1max` = 99)', $level, $level); if (4 == $razdel) { $sql .= db::c()->prepare(' AND (`t2min` <= ?i OR `t2min` = 99) AND (`t2max` >= ?i OR `t2max` = 99)', $level, $level); } } if (!is_null($id)) { $sql .= db::c()->prepare(' AND `id` = ?i', $id); } $fict = db::c()->query($sql); while ($row = $fict->fetch_assoc()) { if (($row['start'] + 300) < time()) { if (db::c()->query('DELETE FROM `zayavka` WHERE `id` = ?i', $row['id'])) { $team1 = $this->fteam($row['team1']); foreach ($team1 as $k => $v) { db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v); } $team2 = $this->fteam($row['team2']); foreach ($z[$zay]['team2'] as $k => $v) { db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v); } } } $zay[$row['id']] = array("team1" => $this->fteam($row['team1']), "team2" => $this->fteam($row['team2']), "coment" => $row['coment'], "type" => $row['type'], "timeout" => $row['timeout'], "start" => $row['start'], "t1min" => $row['t1min'], "t1max" => $row['t1max'], "t2min" => $row['t2min'], "t2max" => $row['t2max'], "t1c" => $row['t1c'], "t2c" => $row['t2c'], "podan" => $row['podan'], "id" => $row['id'], "level" => $row['level'], "blood" => $row['blood'], "bots" => $row['bots']); } return $zay; } function addteam($team, $id, $zay, $r) { global $user; $owntravma = db::c()->query('SELECT `id`, `type` FROM `effects` WHERE (`type` = 12 OR `type` = 13) AND `owner` = ?i', $id)->fetch_assoc(); $z = $this->getlist($r, null, $zay); if ($owntravma) { switch ($owntravma['type']) { case ($owntravma['type'] == 12 && ($z[$zay]['type'] != 4 && $z[$zay]['type'] != 5)): return "У Вас средняя травма, поединки с оружием слишком тяжелы для Вас..."; break; case 13: return "У Вас тяжелая травма, Вы не сможете драться..."; break; } } if (!empty($user['zayavka'])) return "Вы находитесь в заявке"; if ($user['hp'] < $user['maxhp'] * 0.33) return "Вы слишком ослаблены для боя, восстановитесь."; if (!$z) return "Эта заявка не может быть принята Вами."; if ($this->user_status($id) != 0) return "Эта заявка не может быть принята Вами."; if ($z[$zay]['type'] != 3 OR $z[$zay]['type'] != 5) { if ($team == 1) $teamz = 2; else $teamz = 1; foreach ($z[$zay]['team' . $teamz] as $v) { $enemy = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $v)->fetch_assoc(); if ($user['klan'] == $enemy['klan']) return "Нельзя драться против сокланов!"; } } if ($z[$zay]['t' . $team . 'min'] == 99) { $toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$zay]['team' . $team][0])->fetch_assoc(); if ($user['klan'] != $toper['klan']) return "Эта заявка не может быть принята Вами."; } else { if ($user['level'] > 0 && !($z[$zay]['t' . $team . 'min'] <= $user['level'] && $z[$zay]['t' . $team . 'max'] >= $user['level'])) { return "Эта заявка не может быть принята Вами. - " . $z[$zay]['t' . $team . 'min']; } } if (count($z[$zay]['team' . $team]) >= $z[$zay]['t' . $team . 'c']) { return "Группа уже набрана."; } $z[$zay]['team' . $team][] = ''; if (mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = {$zay}, `zayavka`.`team{$team}` = '" . implode(";", $z[$zay]['team' . $team]) . "" . $id . ";' WHERE `users`.`id` = {$id} AND `users`.`zayavka` = 0 AND `zayavka`.`id` = {$zay}")) { return "Вы приняли заявку на бой."; } else return 'addteam(): database error!'; } function delteam($id, $zay, $r) { $z = $this->getlist($r, null, $zay); if ($z[$zay]['level'] > 3 || $z[$zay]['level'] == null) { return "Ай-ай-ай!"; } foreach ($z[$zay]['team2'] as $v) { if ($v != $id) { $teams[] = $v; } } if (mysql_query("UPDATE `users`, `zayavka` SET `users`.`zayavka` = '0', `zayavka`.`team{$team}` = '{$teams}' WHERE `users`.`id` = {$id} AND `zayavka`.`id` = {$zay};")) { return "Вы отозвали запрос"; } else return 'delteam(): database error!'; } function addzayavka($start, $timeout, $t1c, $t2c, $type, $t1min, $t2min, $t1max, $t2max, $coment, $creator, $level, $stavka, $blood = 0) { global $user; if (!in_array($level, [1, 2, 4, 5])) { $level = 1; } else return "Ошибка!"; if ($level == 1 AND $type != 1 AND $type != 4) $type = 1; if ($level == 2 AND $type != 1 AND $type != 4 AND $type != 6) $type = 1; if ($level == 4 AND $type != 2 AND $type != 4) $type = 2; if ($level == 5 AND $type != 3 AND $type != 5) $type = 3; // Level 3? Что это? Где это? if (!in_array($start, [3, 5, 10, 15, 30, 45, 60])) $start = 10; if (!in_array($timeout, [3, 4, 5, 7, 10])) $timeout = 3; if ($this->user_status($creator) != 0) { exit(); } $owntravma = db::c()->query('SELECT `type` FROM `effects` WHERE `owner` = ?i AND (`type` = 12 OR `type` = 13)', $creator)->fetch_assoc(); if ($owntravma) { switch ($owntravma['type']) { case ($owntravma['type'] == 12 && ($type != 4 && $type != 5)): return "У Вас средняя травма, поединки с оружием слишком тяжелы для Вас..."; break; case 13: return "У Вас тяжелая травма, Вы не сможети драться..."; break; } } if (!$user['klan'] && $t1min == 99) { return "Вы не состоите в клане."; } if ($user['hp'] < $user['maxhp'] * 0.33) { return "Вы слишком ослаблены для боя, восстановитесь."; } if ($type == 3) { AddChatSystem('Внимание! Подана заявка на хаотический поединок ({$t1min} - {$t1max}), который начнется через {$start} минут.'); } $start = time() + $start * 60; $stavka = round($stavka, 2); db::c()->query('INSERT INTO `zayavka` (`start`, `timeout`, `t1c`, `t2c`, `type`, `level`, `coment`, `team1`, `stavka`, `t1min`, `t2min`, `t1max`, `t2max`,`podan`,`blood`) VALUES (?i,?i,?i,?i,?i,?i,"?s","?s",?d,?i,?i,?i,?i,"?s",?i)', $start, $timeout, $t1c, $t2c, $type, $level, $coment, $creator, $stavka, $t1min, $t2min, $t1max, $t2max, date('H:i'), $blood); db::c()->query('UPDATE `users` SET `zayavka` = ?i WHERE `id` = ?i', db::c()->getLastInsertId(), $creator); return null; } function delzayavka($id, $zay, $r, $f = 1) { $z = $this->getlist($r, null, $zay); if ($f != 1) { if ($z[$zay]['level'] > 3) { return 'Ай-ай-ай!'; } } if (mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1")) { if (count($z[$zay]['team1']) > 0) { foreach ($z[$zay]['team1'] as $k => $v) db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v); } if (count($z[$zay]['team2']) > 0) { foreach ($z[$zay]['team2'] as $k => $v) db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i', $v); } return 'Вы отозвали заявку.'; } else return 'delzayavka(): database error!'; } function showfiz($row) { global $user; $rr = "{$row['podan']} "; foreach ($row['team1'] as $k => $v) { $rr .= nick::id($v)->full(1); } if ($row['team2']) { $rr .= " против "; foreach ($row['team2'] as $k => $v) { $rr .= nick::id($v)->full(1); } } $rr .= "  тип боя: "; if ($row['type'] == 4) { $rr .= " "; } elseif ($row['type'] == 6) { $rr .= " "; } elseif ($row['type'] == 1) { $rr .= " "; } $rr .= " (таймаут {$row['timeout']} мин.)
"; return $rr; } function showgroup($row) { if ($row['t1min'] == 99) { $range1 = "клан"; } else { $range1 = "{$row['t1min']}-{$row['t1max']}"; } if ($row['t2min'] == 99) { $range2 = "клан"; } else { $range2 = "{$row['t2min']}-{$row['t2max']}"; } $rr = "{$row['podan']} {$row['t1c']}({$range1}) ("; foreach ($row['team1'] as $k => $v) { if ($k != 0) { $rr .= ", "; } $rr .= nick::id($v)->full(1); } $rr .= ") против {$row['t2c']}({$range2})("; foreach ($row['team2'] as $k => $v) { if ($k != 0) { $rr .= ", "; } $rr .= nick::id($v)->full(1); } if (count($row['team2']) == 0) { $rr .= "группа не набрана"; } if ($row['blood'] && $row['type'] == 5) { $rr .= ""; } $a = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $user['id'])->fetch_assoc(); $rr .= ")  тип боя: "; if ($row['blood'] && $row['type'] == 4) { $rr .= ""; } elseif ($row['blood'] && $row['type'] == 2) { $rr .= ""; } elseif ($row['type'] == 2) { $rr .= ""; } elseif ($row['type'] == 4) { $rr .= ""; } $rr .= "(таймаут {$row['timeout']} мин.) бой начнется через " . round(($row['start'] - time()) / 60, 1) . " мин. " . (($row['coment']) ? "(" . $row['coment'] . ")" : "") . ""; if (($a['align'] > 1.4 && $a['align'] < 2) || $a['admin'] == 1) { $rr .= "Удалить комментарий
"; } else { $rr .= "
"; } return $rr; } function showhaos($row) { global $user; $rr = "{$row['podan']} ("; if ($row['bots'] == '7') { $rr .= nick::id(10962)->full(1); $rr .= ", "; $rr .= nick::id(10964)->full(1); $rr .= ", "; $rr .= nick::id(10965)->full(1); $rr .= ", "; } elseif ($row['bots'] == '8' || $row['bots'] == '13') { $rr .= nick::id(10124)->full(1); $rr .= ", "; $rr .= nick::id(10125)->full(1); $rr .= ", "; $rr .= nick::id(10126)->full(1); $rr .= ", "; } foreach ($row['team1'] as $k => $v) { if ($k != 0) { $rr .= ", "; } $rr .= nick::id($v)->full(1); } if (count($row['team1']) == 0 && $row['bots'] == 0) { $rr .= "группа не набрана"; } $rr .= ") ({$row['t1min']}-{$row['t1max']})   тип боя: "; if ($row['blood'] && $row['type'] == 5) { $rr .= ""; } elseif ($row['blood'] && $row['type'] == 3) { $rr .= ""; } elseif ($row['type'] == 3) { $rr .= ""; } elseif ($row['type'] == 5) { $rr .= ""; } $rr .= "(таймаут {$row['timeout']} мин.) бой начнется через " . round(($row['start'] - time()) / 60, 1) . " мин. " . (($row['coment']) ? "(" . $row['coment'] . ")" : "") . ""; if ($user['admin'] == 1) { $rsr = ' | Удалить заявку'; } else { $rsr = ''; } if (($user['align'] > 1.4 && $user['align'] < 2) || $user['admin'] == 1) { $rr .= "Удалить коммнтарий$rsr
"; } else { $rr .= "
"; } return $rr; } function user_status($id) { $r = db::c()->query('SELECT `team1`,`team2` FROM `zayavka`, `users` WHERE `users`.`id` = ?i AND `zayavka`.`id` = `users`.`zayavka`', $id)->fetch_assoc(); $t1 = $this->fteam($r['team1']); $t2 = $this->fteam($r['team2']); if (in_array($id, $t1)) { return 1; } elseif (in_array($id, $t2)) { return 2; } else { return 0; } } function battlestart($id, $zay, $r) { global $user; $z = $this->getlist($r, null, $zay); if ($id == 'CHAOS') { $id = $z[$zay]['team1'][0]; } $this->delzayavka($id, $zay, $r); $z = $z[$zay]; $count_users = count($z['team1']); $bot = 0; if ($z['bots'] > 0 && $count_users > 0) { $bots_raw = array(7 => array(10962, 10964, 10965), 8 => array(10124, 10125, 10126), 13 => array(10124, 10125, 10126)); $i = 0; while ($i <= count($bots_raw[$z['bots']])) { $bot_id = $bots_raw[$z['bots']][$i]; $bot = createbot($bot_id, ''); $z['team1'][] = $bot['id']; $i++; $count_users++; } } if ($z['type'] == 4 || $z['type'] == 5) { foreach ($z['team1'] as $k => $v) { undressall($v); } foreach ($z['team2'] as $k => $v) { undressall($v); } } if ($z['level'] == 2) { $btfl = fopen('' . $z['team1'][0] . '.btl', 'a'); fwrite($btfl, '{[=' . $z['team2'][0] . '=]}'); fclose($btfl); $btfl = fopen('' . $z['team2'][0] . '.btl', 'a'); fwrite($btfl, '{[=' . $z['team1'][0] . '=]}'); fclose($btfl); } if ($z['type'] == 3 || $z['type'] == 5) { if ($count_users < 4) { db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = ?i', $zay); foreach ($z['team1'] as $k => $v) { if ($v < _BOTSEPARATOR_) { //TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem(). #addchp('Внимание! Ваш бой не может начаться по причине Группа не набрана.', '{[]}' . nick::id($v)->short() . '{[]}'); die('Bitch'); } } db::c()->query('UPDATE `variables` SET `value` = ?i WHERE `var` = "?s"', $count_users, 'haos_match'); db::c()->query('DELETE FROM `zayavka` WHERE `id` = ?i', $zay); header("Location: zayavka.php"); } $all = count($z['team1']) - 1; $power1 = 0; $power2 = 0; // А ЭТО ещё что за хренотень?! О_о for ($i = 0; $i <= $all; $i++) { if ($z['team1'][$i] < _BOTSEPARATOR_) { $gamer = db::c()->query('SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = ?i', $z['team1'][$i])->fetch_assoc(); } else { $bt = db::c()->query('SELECT `prototype` FROM `bots` WHERE `id` = ?i', $z['team1'][$i])->fetch_assoc(); $gamer = db::c()->query('SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = ?i', $bt['prototype'])->fetch_assoc(); } $cost[] = array($z['team1'][$i], $gamer[0]); } $z['team1'] = null; $z['team2'] = null; $flag = true; while ($flag) { $flag = false; for ($ii = 0; $ii <= $all - 1; $ii++) { if ($cost[$ii][1] < $cost[$ii + 1][1]) { $ctr = $cost[$ii + 1]; $cost[$ii + 1] = $cost[$ii]; $cost[$ii] = $ctr; $flag = true; } } } while (count($cost) > 0) { if ($power1 <= $power2) { $tmp = array_shift($cost); $power1 += $tmp[1]; $z['team1'][] = $tmp[0]; } else { $tmp = array_shift($cost); $power2 += $tmp[1]; $z['team2'][] = $tmp[0]; } } } $teams = array(); foreach ($z['team1'] as $k => $v) { foreach ($z['team2'] as $kk => $vv) { $teams[$v][$vv] = array(0, 0, time()); } } foreach ($z['team2'] as $k => $v) { foreach ($z['team1'] as $kk => $vv) { $teams[$v][$vv] = array(0, 0, time()); } } if (count($z['team2']) == 0) { db::c()->query('UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = ?i', $zay); db::c()->query('DELETE FROM `zayavka` WHERE `id` = ?i', $zay); foreach ($z['team1'] as $k => $v) { //TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[2] #addchp('Внимание! Ваш бой не может начаться по причине "Группа не набрана".', '{[]}' . nick::id($v)->short() . '{[]}'); return null; } header("Location: zayavka.php"); die(); } if (!in_array($z['timeout'], [3, 4, 5, 7, 10])) $z['timeout'] = 3; if (count($teams) > 1) { if ($z['type'] == 1 || $z['type'] == 4) { $rs = ', `fiz`'; $rss = ', 1'; } else { $rs = ''; $rss = ''; } db::c()->query(' INSERT INTO `battle` (`coment`, `teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, ?f, `bots`) VALUES ("?s","?s",?i,?i,?i,"?s","?s",?i,?i,?i,?i)', 'blood' . $rs, $z['coment'], serialize($teams), $z['timeout'], $z['type'], 0, implode(';', $z['team1']), implode(';', $z['team2']), time(), time(), $z['blood'], $rss, $z['bots']); $id = db::c()->getLastInsertId(); $rr = ""; foreach ($z['team1'] as $k => $v) { if ($k != 0) { $rr .= ", "; } $rr .= nick::id($v)->full(1); //TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[3] #addchp('Внимание! Ваш бой начался!
\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . nick::id($v)->short() . '{[]}'); } $rr .= "
и "; foreach ($z['team2'] as $k => $v) { if ($k != 0) { $rr .= ", "; } $rr .= nick::id($v)->full(1); //TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[4] #addchp('Внимание! Ваш бой начался!
\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . nick::id($v)->short() . '{[]}'); } $rr .= "
"; addlog($id, "Часы показывали " . date("Y.m.d H.i") . ", когда " . $rr . " бросили вызов друг другу.
"); foreach ($z['team1'] as $k => $v) { if ($v < _BOTSEPARATOR_) { db::c()->query('UPDATE `users` SET `battle` = ?i, `zayavka` = 0 WHERE `id` = ?i', $id, $v); } else { db::c()->query('UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i', $id, $v); } } foreach ($z['team2'] as $k => $v) { if ($v < _BOTSEPARATOR_) { db::c()->query('UPDATE `users` SET `battle` = ?i, `zayavka` = 0 WHERE `id` = ?i', $id, $v); } else { db::c()->query('UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i', $id, $v); } } if ($bot) { db::c()->query('UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i', $id, $bot['id']); } } if ($user['zayavka'] == $zay) { die(""); } } } $zay = new zayavka; header("Cache-Control: no-cache"); if (!empty($_POST['open'])) { $f = fopen("/tmp/zayavka/" . $user['id'] . ".txt", "w+"); fputs($f, time()); fclose($f); } ?> );">
 Бои: Новичков Физические Договорные Групповые Хаотические Текущие


В этой комнате невозможно подавать заявки
"; // die(); // } if (!$level && !$tklogs && !$logs) { echo "


Выберите раздел
"; } if ($level == 'begin') { if ($user['level'] > 0) { die("


Вы уже выросли из ползунков ;)
"); } //FIXME: Всем функциям прописать return и отказаться от лишних строк. echo ""; if ($_POST['open']) { echo $zay->addzayavka(0, $_POST['timeout'], 1, 1, $_POST['k'], $user['level'], 1, $user['level'], 21, '', $user['id'], 1, 0); die(""); } if ($_POST['back']) { unlink("/tmp/zayavka/" . $user['id'] . ".txt"); echo $zay->delzayavka($user['id'], $user['zayavka'], 1, 0); } if ($_POST['back2']) { $z = $zay->getlist(1, null, $user['zayavka']); AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' отозвал заявку.'); echo $zay->delteam($user['id'], $user['zayavka'], 1); } if ($_POST['cansel']) { $z = $zay->getlist(1, null, $user['zayavka']); echo $zay->delteam($z[$user['zayavka']]['team2'][0], $user['zayavka'], 1); AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' отказался от поединка.'); } if ($_POST['confirm2']) { $z = $zay->getlist(1, null, $_REQUEST['gocombat']); AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' принял заявку, нужно принять вызов или отказать.'); echo $zay->addteam(2, $user['id'], $_REQUEST['gocombat'], 1); die(""); } if ($_POST['gofi']) { $zay->battlestart($user['id'], $user['zayavka'], 1); } echo ""; echo '
'; $z = $zay->getlist(1, null, $user['zayavka']); if ($zay->user_status($user['id']) == 0) { //if ($z[$user['zayavka']]['level'] == 1) { echo '
Подать заявку на бой Таймаут Тип боя  
'; }; } if ($zay->user_status($user['id']) == 1) { if (count($z[$user['zayavka']]['team2']) > 0) { echo "Внимание! " . nick::id($z[$user['zayavka']]['team2'][0])->full(1) . " принял заявку на бой, нужно отказать или принять вызов. "; } else { if ($z[$user['zayavka']]['level'] == 1) echo "Заявка на бой подана, ожидаем противника. "; $Path = "/tmp/zayavka/" . $user['id'] . ".txt"; $f = fopen($Path, "r"); $timeFigth = fread($f, filesize($Path)); fclose($f); if ($user['level'] == 0) { if ($_GET['trainstart'] == 1 && $user['hp'] > $user['maxhp'] * 0.33 && $user['level'] <= 7) { unlink("/tmp/zayavka/" . $user['id'] . ".txt"); $zay->delzayavka($user['id'], $user['zayavka'], 1, 0); db::c()->query('INSERT INTO `bots` (`name`,`prototype`,`hp`) VALUES ("?s",?i,?i)', $user['login'] . ' (Клон 1)', $user['id'], $user['maxhp']); $bot = db::c()->getLastInsertId(); $teams = array(); $teams[$user['id']][$bot] = array(0, 0, time()); $teams[$bot][$user['id']] = array(0, 0, time()); db::c()->query('INSERT INTO `battle` (`teams`,`timeout`, `type`, `t1`, `t2`, `to1`, `to2`, `clone`) VALUES ("?s", 3, 1, "?s", "?s", ?i, ?i, 1)', serialize($teams), $user['id'], $bot, time(), time()); $id = db::c()->getLastInsertId(); $log_message = 'Часы показывали ' . date("Y.m.d H.i") . ', когда ' . $rr . ' бросили вызов друг другу.
'; db::c()->query('INSERT INTO `logs` (`id`, `log`) VALUES (?i,"?s")', $id, $log_message); db::c()->query('UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i', $id, $bot); $rr = "" . nick::id($user['id'])->full(1) . " и " . nick::id($bot)->full(1) . ""; addlog($id, "Часы показывали " . date("Y.m.d H.i") . ", когда " . $rr . " бросили вызов друг другу.
"); db::c()->query('UPDATE users SET `battle` = ?i, `zayavka`= 0 WHERE `id`= ?i', $id, $user['id']); die(""); ///======================================================================================= } else { echo $user['level']; } if ($user['level'] == 0) { echo " или "; } } } } if ($zay->user_status($user['id']) == 2) { if ($z[$user['zayavka']]['level'] == 1) echo "Ожидаем подтверждения боя. "; } echo '
'; echo '

'; if ($z = $zay->getlist(1)) foreach ($z as $k => $v) { echo $zay->showfiz($v); } echo '
'; } if ($level == 'fiz') { if ($user['level'] == 0) { die("


Физические бои доступны с 1 уровня.
"); } echo ""; if (!empty($_POST['open'])) { if ($_POST['k'] == 6) { $blood = 1; } else { $blood = 0; } echo $zay->addzayavka(0, $_POST['timeout'], 1, 1, $_POST['k'], $user['level'], 1, $user['level'], 21, '', $user['id'], 2, 0, $blood); die(""); } if (!empty($_POST['back'])) { unlink("/tmp/zayavka/" . $user['id'] . ".txt"); echo $zay->delzayavka($user['id'], $user['zayavka'], 2, 0); } if (!empty($_POST['back2'])) { $z = $zay->getlist(2, null, $user['zayavka']); AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' отозвал заявку.'); echo $zay->delteam($user['id'], $user['zayavka'], 2); } if (!empty($_POST['cansel'])) { $z = $zay->getlist(2, null, $user['zayavka']); echo $zay->delteam($z[$user['zayavka']]['team2'][0], $user['zayavka'], 2); AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' отказался от поединка.'); } if (!empty($_POST['confirm2']) AND empty($user['zayavka'])) { $z = $zay->getlist(2, null, $_REQUEST['gocombat']); $toper = db::c()->query('SELECT `klan` FROM `users` WHERE `id` = ?i', $z[$_REQUEST['gocombat']]['team1'][0])->fetch_assoc(); if ($user['klan'] != $toper['klan'] || $user['klan'] == '') { AddChatSystem('Внимание!' . nick::id($user['id'])->short() . ' принял заявку, нужно принять вызов или отказать.'); } echo $zay->addteam(2, $user['id'], $_REQUEST['gocombat'], 2); echo "
Ожидаем подтверждения боя. "; } if (!empty($_POST['gofi'])) { $zay->battlestart($user['id'], $user['zayavka'], 2); } echo ""; echo '
'; if ($zay->user_status($user['id']) == 0) { echo '
Подать заявку на бой Таймаут Тип боя  
'; } $z = $zay->getlist(2, null, $user['zayavka']); if ($zay->user_status($user['id']) == 1) { if (count($z[$user['zayavka']]['team2']) > 0) { echo "Внимание! " . nick::id($z[$user['zayavka']]['team2'][0])->full(1) . " принял заявку на бой, нужно отказать или принять вызов. "; } else { if ($z[$user['zayavka']]['level'] == 2) { echo "Заявка на бой подана, ожидаем противника. "; $Path = "/tmp/zayavka/" . $user['id'] . ".txt"; $f = fopen($Path, "r"); $timeFigth = fread($f, filesize($Path)); fclose($f); if ($timeFigth < time() && ($user['level'] <= 14)) { if ($_GET['trainstart'] == 1 && $user['hp'] > $user['maxhp'] * 0.33 && ($user['level'] <= 7 || $user['align'] == 2.99)) { unlink("/tmp/zayavka/" . $user['id'] . ".txt"); $zay->delzayavka($user['id'], $user['zayavka'], 2, 0); mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) values ('" . $user['login'] . " (Клон 1)','" . $user['id'] . "','','" . $user['maxhp'] . "');"); $bot = mysql_insert_id(); $teams = array(); $teams[$user['id']][$bot] = array(0, 0, time()); $teams[$bot][$user['id']] = array(0, 0, time()); mysql_query("INSERT INTO `battle` (`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`, `clone` ) VALUES ('" . serialize($teams) . "','3','1','0','" . $user['id'] . "','" . $bot . "','" . time() . "','" . time() . "', 1 )"); $id = mysql_insert_id(); mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$bot} LIMIT 1"); $rr = "" . nick::id($user['id'])->full(1) . " и " . nick::id($bot)->full(1) . ""; addlog($id, "Часы показывали " . date("Y.m.d H.i") . ", когда " . $rr . " бросили вызов друг другу.
"); mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']};"); die(""); } $Path = "/tmp/zayavka/" . $user['id'] . ".txt"; $f = fopen($Path, "r"); $timeFigth = fread($f, filesize($Path)); fclose($f); if ($user['level'] < 7 || $user['align'] == 2.99) { echo " или "; } } } } } if ($zay->user_status($user['id']) == 2) { if ($z[$user['zayavka']]['level'] == 2) echo "Ожидаем подтверждения боя. "; } echo '

Показывать заявки
моего уровня
все
'; echo '
'; if ($z = $zay->getlist(2, $_SESSION['view'])) foreach ($z as $k => $v) { echo $zay->showfiz($v); } echo ''; } if ($level == 'group') { if ($user['level'] < 2) { die("


Групповые бои доступны с 2 уровня.
"); } if (!empty($_POST['open1']) AND empty($user['zayavka'])) { // room 101 - противостояние сил echo '

Подать заявку на групповой бой

Начало боя через     Таймаут

Ваша команда бойцов
'; if ($user['room'] != 101) echo 'Уровни союзников   '; else echo ''; echo '

Противники    бойцов
'; if ($user['room'] != 101) echo 'Уровни противников '; else echo ''; echo '
'; if ($user['room'] != 101) echo ' Кулачный бой
Бой без правил (проигравшая сторона получает инвалидность)
'; if ($user['room'] == 101) echo '

Деньги    кр.
Опыт    единиц
'; echo 'Комментарий к бою
'; die(); } if (!empty($_POST['goconfirm']) AND empty($user['zayavka'])) { echo '
'; $z = $zay->getlist(4, null, $_POST['gocombat']); echo "Ожидаем начала группового боя...
Бой начнется через: " . round(($z[$_POST['gocombat']]['start'] - time()) / 60, 1) . " мин."; echo '

На чьей стороне будете сражаться?

'; $vs_test = mysql_fetch_array(mysql_query("SELECT * FROM zayavka where id='{$z[$_POST['gocombat']]['id']}' limit 1 ")); if ($user['room'] != 101) { if ($vs_test['versus'] == 0) { $raid_t = mysql_fetch_array(mysql_query("SELECT * FROM variables WHERE var='raid_on_status' limit 1;")); if ($z[$_POST['gocombat']]['team1'][0] != 1000 && $z[$_POST['gocombat']]['team1'][0] != 1001) echo ''; else echo ''; } else echo ''; } else { if (($user['align'] == 6) || ($user['align'] == 2.1) || ($user['align'] == 2.99) || (($user['align'] > 7) && ($user['align'] < 8)) || ($user['align'] == 2)) { echo ''; }; if (($user['align'] == 2.1) || ($user['align'] == 6)) { echo ''; }; }; if ($user['room'] != 101) { if ($vs_test['versus'] == 0) { echo ''; } else echo ''; } else { if (($user['align'] == 2.2) || ($user['align'] == 3)) { echo ''; }; if (($user['align'] == 3) || ($user['align'] == 2.2) || ($user['align'] == 2.99) || (($user['align'] > 7) && ($user['align'] < 8)) || ($user['align'] == 2)) { echo ''; }; }; echo '
Группа 1:
Максимальное кол-во: ' . $z[$_POST['gocombat']]['t1c'] . '
Ограничения по уровню: ' . ($z[$_POST['gocombat']]['t1min'] == 99 ? 'клан' : $z[$_POST['gocombat']]['t1min'] . " - " . $z[$_POST['gocombat']]['t1max']) . '
Группа 2:
Максимальное кол-во: ' . $z[$_POST['gocombat']]['t2c'] . '
Ограничения по уровню: ' . ($z[$_POST['gocombat']]['t2min'] == 99 ? 'клан' : $z[$_POST['gocombat']]['t2min'] . " - " . $z[$_POST['gocombat']]['t2max']) . '
'; foreach ($z[$_POST['gocombat']]['team1'] as $k => $v) { if ($k != 0) $rr .= "
"; echo nick::id($v)->full(1); } echo '
'; foreach ($z[$_POST['gocombat']]['team2'] as $k => $v) { if ($k != 0) $rr .= "
"; echo nick::id($v)->full(1); } echo '
Силы ХаосаВойдите в комнату "Противостояние", чтобы принять эту заявку!
'; die(); } echo ""; if (($_POST['confirm1']) && $_POST['gocombat'] && !$user['zayavka']) { echo $zay->addteam(1, $user['id'], $_REQUEST['gocombat'], 4); } if (($_POST['confirm2']) && $_POST['gocombat'] && !$user['zayavka']) { echo $zay->addteam(2, $user['id'], $_REQUEST['gocombat'], 4); } if ($_POST['open'] && !$user['zayavka']) { //print_r($_REQUEST); switch ($_POST['levellogin1']) { case 0 : //любой $min1 = 2; $max1 = 21; break; case 1 : //только моего и ниже $min1 = 2; $max1 = $user['level']; break; case 2 : //только ниже моего уровня $min1 = 2; $max1 = $user['level'] - 1; break; case 3 : //только моего уровня $min1 = $user['level']; $max1 = $user['level']; break; case 4 : //не старше меня более чем на уровень $min1 = $user['level']; $max1 = $user['level'] + 1; break; case 5 : //не младше меня более чем на уровень $min1 = $user['level'] - 1; $max1 = $user['level']; break; case 6 : //мой уровень +/- 1 $min1 = (int)$user['level'] - 1; $max1 = (int)$user['level'] + 1; break; case 99 : // кланы $min1 = 99; $max1 = 99; break; } switch ($_POST['levellogin2']) { case 0 : //любой $min1 = 2; $max1 = 21; break; case 1 : //только моего и ниже $min1 = 2; $max1 = $user['level']; break; case 2 : //только ниже моего уровня $min1 = 2; $max1 = $user['level'] - 1; break; case 3 : //только моего уровня $min1 = $user['level']; $max1 = $user['level']; break; case 4 : //не старше меня более чем на уровень $min1 = $user['level']; $max1 = $user['level'] + 1; break; case 5 : //не младше меня более чем на уровень $min1 = $user['level'] - 1; $max1 = $user['level']; break; case 6 : //мой уровень +/- 1 $min1 = (int)$user['level'] - 1; $max1 = (int)$user['level'] + 1; break; case 99 : // кланы $min1 = 99; $max1 = 99; break; } if ($_POST['k']) { $_POST['k'] = 4; } else { $_POST['k'] = 2; } if ($_POST['travma']) { $blood = 1; } else { $blood = 0; } if ($_POST['nlogin1'] == 1 && $_POST['nlogin2'] == 1) { echo "Не надо превращать групповой бой в физический поединок"; } else { echo $zay->addzayavka($_POST['startime'] / 60, $_POST['timeout'], $_POST['nlogin1'], $_POST['nlogin2'], $_POST['k'], $min1, $min2, $max1, $max2, $_POST['cmt'], $user['id'], 4, 0, $blood); } } ///////////////////////////////// echo ""; echo '
'; if ($zay->user_status($user['id']) == 0) if (($user['room'] == 101) && ($user['align'] != 2.2) && ($user['align'] != 2.1)) { echo "
Свет и Тьма не снизойдут к вашей просьбе начать новый бой
"; } else { echo ''; } if ($zay->user_status($user['id']) != 0) { $z = $zay->getlist(4, null, $user['zayavka']); if ($z[$user['zayavka']]['level'] == 4) { echo "Ожидаем начала группового боя...
Бой начнется через: " . round(($z[$user['zayavka']]['start'] - time()) / 60, 1) . " мин."; } } echo '

Показывать заявки
моего уровня
все
'; echo ''; echo '

'; if ($z = $zay->getlist(4, $_SESSION['view'])) foreach ($z as $k => $v) { $ok = 0; if ($user['room'] == 101) { $vs_test = mysql_fetch_array(mysql_query("SELECT * FROM zayavka where id='{$z[$k]['id']}' limit 1 ")); if ($vs_test['versus'] == 1) $ok = 1; else $ok = 0; } else $ok = 0; if (($ok == 0 && $user['room'] != 101) || ($ok == 1 && $user['room'] == 101)) { if ((($z[$k]['start'] - time()) < 0) || (($z[$k]['t1c'] == count($z[$k]['team1'])) && ($z[$k]['t2c'] == count($z[$k]['team2'])))) { $zay->battlestart("CHAOS", $k, 4); } echo $zay->showgroup($v); } } echo ''; } if ($level == 'haos') { if ($user['level'] < 2) { die("


Хаотичные бои доступны с 2 уровня.
"); } if (!empty($_POST['open']) AND empty($user['zayavka'])) { switch ($_POST['levellogin1']) { case 0 : $min1 = 1; $max1 = 21; break; case 3 : $min1 = $user['level']; $max1 = $user['level']; break; case 6 : $min1 = (int)$user['level'] - 1; $max1 = (int)$user['level'] + 1; break; } //$_POST['k'] = 3; $blood = 0; if ($_POST['travma']) { $blood = 1; } echo $zay->addzayavka($_POST['startime2'] / 60, $_POST['timeout'], 99, 99, $_POST['k'], $min1, $min1, $max1, $max1, $_POST['cmt'], $user['id'], 5, 0, $blood); } if (!empty($_POST['confirm2'])) { echo "" . $zay->addteam(1, $user['id'], $_REQUEST['gocombat'], 5) . ""; } echo '
'; if ($zay->user_status($user['id']) == 0) { echo 'Хаотичный бой - разновидность группового, где группы формируются автоматически. Бой не начнется, если собралось меньше 4-х человек. '; } if ($zay->user_status($user['id']) != 0) { $z = $zay->getlist(5, null, $user['zayavka']); if ($z[$user['zayavka']]['level'] == 5) echo "Ожидаем начала группового боя...
Бой начнется через: " . round(($z[$user['zayavka']]['start'] - time()) / 60, 1) . " мин."; } echo '

Показывать заявки
моего уровня
все
'; echo '
'; if ($z = $zay->getlist(5, $_SESSION['view'])) foreach ($z as $k => $v) { if (($z[$k]['start'] - time()) < 0) { $zay->battlestart("CHAOS", $k, 5); } echo $zay->showhaos($v); } echo ''; //print_r($_POST); } if (!is_null($tklogs)) { $t1 = floor(time() - 900); $data = db::c()->query('SELECT * FROM `battle` WHERE `win` = 3 AND `to1` > ?i AND `to2` > ?i ORDER BY `id` ASC', $t1, $t1); while ($row = $data->fetch_assoc()) { echo "{$row['date']}"; $z = explode(";", $row['t1']); foreach ($z as $k => $v) { if ($k > 0) { echo ","; } nick::id($v)->full(); } echo " против "; $z = explode(";", $row['t2']); foreach ($z as $k => $v) { if ($k > 0) { echo ","; } nick::id($v)->full(); } echo " »»
"; } } db::c()->query('UNLOCK TABLES'); ?>