room != 31) { header("Location: main.php"); exit; } if ($user['in_tower'] == 1) { header('Location: towerin.php'); exit; } class predbannik_bs { public $userid = 0; public $turnir_id = 0; public $turnir_info = 0; function __construct() { global $user; $this->userid = $user; $this->turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1")); $this->arts = $this->turnirstart[1]; $this->turnirstart = $this->turnirstart[0]; } function get_turnir() { $data = mysql_fetch_array(mysql_query("SELECT * FROM `deztow_turnir` WHERE `active` = TRUE")); $this->turnir_id = $data[0]; return $data; } function get_stavka() { $data = mysql_fetch_array(mysql_query("SELECT `kredit` FROM `deztow_stavka` WHERE `owner` = '" . $this->userid['id'] . "' LIMIT 1")); return $data[0]; } function set_stavka($kredit) { if (($kredit >= 3 && $kredit <= 30) && $this->userid['level'] > 3 && $this->userid['money'] >= $kredit) { $this->userid['money'] -= $kredit; mysql_query("INSERT `deztow_stavka` (`owner`, `kredit`, `time`) VALUES ('" . $this->userid['id'] . "', '" . (float)$kredit . "', '" . time() . "')"); mysql_query("UPDATE `users` SET `money` = '" . $this->userid['money'] . "' WHERE `id` = '" . $this->userid['id'] . "' LIMIT 1"); } } function up_stavka($kredit) { $all_stavka = mysql_fetch_array(mysql_query("SELECT `kredit` FROM `deztow_stavka` WHERE `owner` = '{$this->userid['id']}' LIMIT 1")); if ($all_stavka) { $all_stavka = $all_stavka['kredit']; } if (($all_stavka + $kredit <= 30) && $this->userid['level'] > 3 && $this->userid['money'] >= $kredit) { $this->userid['money'] -= $kredit; mysql_query("UPDATE `deztow_stavka` SET `kredit` = (`kredit`+'" . (float)$kredit . "') WHERE `owner` = '" . $this->userid['id'] . "' LIMIT 1"); mysql_query("UPDATE `users` SET `money` = '" . $this->userid['money'] . "' WHERE `id` = '" . $this->userid['id'] . "' LIMIT 1"); } } function get_fond() { $data = mysql_fetch_array(mysql_query("SELECT SUM(`kredit`)*0.7, COUNT(`kredit`) FROM `deztow_stavka`")); $this->turnir_info = [round($data[0], 2), $data[1]]; return $this->turnir_info; } } $bania = new predbannik_bs; $haos = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `owner` = '{$user['id']}' AND `type` = '4' LIMIT 1")); if ($_POST['docoin']) { if (!isset($haos['id'])) { $bania->set_stavka($_POST['coin']); } else { echo "Хаосникам запрещено участвовать в турнире!"; } } if ($_POST['upcoin']) { if (!isset($haos['id'])) { $bania->up_stavka($_POST['coin']); } else { echo "Хаосникам запрещено участвовать в турнире!"; } } if ($_GET['st'] == 'startmegaturnirnow') { $bania->start_turnir(); } $tr = $bania->get_turnir(); $bania->get_fond(); \Battles\Template::header('Башня смерти') ?>