2018-01-28 16:40:49 +00:00
< ? php
session_start ();
2020-09-30 12:58:44 +00:00
if ( empty ( $_SESSION [ 'uid' ])) {
2020-09-29 22:39:06 +00:00
header ( " Location: index.php " );
}
require_once " functions.php " ;
2020-09-30 12:01:33 +00:00
if ( $user -> room != 31 ) {
2020-09-29 22:39:06 +00:00
header ( " Location: main.php " );
2020-09-30 12:01:33 +00:00
exit ;
2020-09-29 22:39:06 +00:00
}
if ( $user [ 'in_tower' ] == 1 ) {
header ( 'Location: towerin.php' );
2020-09-30 12:01:33 +00:00
exit ;
2020-09-29 22:39:06 +00:00
}
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
class predbannik_bs
{
public $userid = 0 ;
public $turnir_id = 0 ;
public $turnir_info = 0 ;
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
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 ];
}
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
function get_turnir ()
{
$data = mysql_fetch_array ( mysql_query ( " SELECT * FROM `deztow_turnir` WHERE `active` = TRUE " ));
$this -> turnir_id = $data [ 0 ];
return $data ;
}
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
function get_stavka ()
{
$data = mysql_fetch_array ( mysql_query ( " SELECT `kredit` FROM `deztow_stavka` WHERE `owner` = ' " . $this -> userid [ 'id' ] . " ' LIMIT 1 " ));
return $data [ 0 ];
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
}
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
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 " );
}
}
2018-01-28 16:40:49 +00:00
2020-09-29 22:39:06 +00:00
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 " );
}
2018-01-28 16:40:49 +00:00
}
2020-09-29 22:39:06 +00:00
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 ;
}
2018-01-28 16:40:49 +00:00
}
$bania = new predbannik_bs ;
$haos = mysql_fetch_array ( mysql_query ( " SELECT `id` FROM `effects` WHERE `owner` = ' { $user [ 'id' ] } ' AND `type` = '4' LIMIT 1 " ));
2020-09-29 22:39:06 +00:00
if ( $_POST [ 'docoin' ]) {
if ( ! isset ( $haos [ 'id' ])) {
$bania -> set_stavka ( $_POST [ 'coin' ]);
} else {
echo " <font color=red><b>Хаосникам запрещено участвовать в турнире!</b></font> " ;
}
2018-01-28 16:40:49 +00:00
}
2020-09-29 22:39:06 +00:00
if ( $_POST [ 'upcoin' ]) {
if ( ! isset ( $haos [ 'id' ])) {
$bania -> up_stavka ( $_POST [ 'coin' ]);
} else {
echo " <font color=red><b>Хаосникам запрещено участвовать в турнире!</b></font> " ;
}
2018-01-28 16:40:49 +00:00
}
2020-09-29 22:39:06 +00:00
if ( $_GET [ 'st' ] == 'startmegaturnirnow' ) {
$bania -> start_turnir ();
2018-01-28 16:40:49 +00:00
}
$tr = $bania -> get_turnir ();
$bania -> get_fond ();
?>
< html >
< head >
2020-09-29 22:39:06 +00:00
< 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 " />
2018-01-28 16:40:49 +00:00
</ head >
< body leftmargin = 5 topmargin = 5 marginwidth = 5 marginheight = 5 bgcolor = #e2e0e0>
2020-09-29 22:39:06 +00:00
< table border = 0 width = 100 % cellspacing = " 0 " cellpadding = " 0 " >
2018-01-28 16:40:49 +00:00
< td align = right >
2020-09-29 22:39:06 +00:00
< form action = " city.php " method = " GET " >
< input type = " button " value = " Профили характеристик " style = " background-color:#A9AFC0 "
onclick = " window.open('towerstamp.php', 'help', 'height=300,width=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes') " />
< input type = " button " value = " Обновить " onclick = " location.href='tower.php'; " />
< input type = " button " value = " Подсказка " style = " background-color:#A9AFC0 "
onclick = " window.open('help/tower.html', 'help', 'height=300,width=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes') " />
< input type = " submit " onclick = " location.href('city.php?strah=1'); " value = " Вернуться " name = " strah " />
</ form >
2018-01-28 16:40:49 +00:00
</ td >
2020-09-29 22:39:06 +00:00
</ table >
< form method = " POST " >
< ? if ( $tr [ 'id' ] == 0 ) { ?>
< h3 > Башня смерти .</ h3 >
< center >< h4 > Внимание ! Персонаж с травмой , с молчанкой или с силой нейтралитета не сможет зайти в БС !</ h4 >
</ center >
< center >< h4 > Внимание ! Принять участие могут уровни от 4 и старше !</ h4 ></ center >
< h4 > Прием заявок на следующий турнир </ h4 >< br />
Начало турнира : < span class = " date " >< ? echo date ( " d.m.y H:i " , $bania -> turnirstart ); ?> </span><br/>
Призовой фонд на текущий момент : < b >< ? echo $bania -> turnir_info [ 0 ]; ?> </b> кр.<br/>
В с е г о подано заявок : < b >< ? echo $bania -> turnir_info [ 1 ]; ?> </b><br/>
<!--< ? if ( $bania -> arts == 1 ) {
echo " <font style= \" color: Blue; \" ><b>Артовая Башня смерти!</b></font><br /> " ;
} ?> -->
< h4 > Подать заявку </ h4 >
< ? if ( $bania -> get_stavka ()) {
echo " Вы уже поставили <b><font style= \" color: Red; \" > " . round ( $bania -> get_stavka (), 2 ) . " кр.</b></font> хотите увеличить ставку? У вас в наличии <b> " . round ( $user [ 'money' ], 2 ) . " кр.</b><br /> " ; ?>
< input type = " text " name = " coin " value = " 1.00 " size = " 8 " /> < input type = " submit " value = " увеличить ставку "
name = " upcoin " />< br />
< ?
} else {
echo " Разрешены ставки от <strong>3</strong> до <strong>30</strong> кр.<br /> " ;
echo " Ваша ставка (минимальная ставка <b>3.00 кр.</B> у вас в наличии <b> " . round ( $user [ 'money' ], 2 ) . " кр.</b>)<br /> " ;
?>
< input type = " text " name = " coin " value = " 3.00 " size = " 8 " /> < input type = " submit " value = " Подать заявку "
name = " docoin " />< br />
< ? } ?>
Чем выше ваша ставка , тем больше шансов принять участие в турнире . Подробнее о башне смерти читайте в разделе " Подсказка " .
< ?
} else {
$ls = mysql_fetch_array ( mysql_query ( " SELECT COUNT(`id`) FROM `users` WHERE `in_tower` = 1 " ));
$lss = mysql_query ( " SELECT `id` FROM `users` WHERE `in_tower` = 1 " );
$i = 0 ;
while ( $in = mysql_fetch_array ( $lss )) {
$i ++ ;
if ( $i > 1 ) {
$lors .= " , " ;
}
$lors .= Nick :: id ( $in [ 0 ]) -> full ( 1 );
$lors .= ltrim ( " , " , $lors );
}
if ( $lors == '' ) {
$lors = 'Никого' ;
}
?>
< h4 > Турнир начался .</ h4 >
Призовой фонд : < b >< ? echo $tr [ 'coin' ]; ?> кр.</b><br/>
< ? echo $tr [ 'log' ]; ?> <br/>
В с е г о живых участников на данный момент : < b >< ? echo $ls [ 0 ]; ?> </b> (<? echo $lors; ?>)
< br />
< ? } ?>
< ? $row = mysql_query ( " SELECT * FROM `deztow_turnir` WHERE `active` = FALSE ORDER BY `id` DESC LIMIT 10 " ); ?>
< p >& nbsp ; < h4 > Победители 10 - ти предыдущих турниров </ h4 >
< ol >
< ?
while ( $data = mysql_fetch_array ( $row )) {
?>
< li > Победитель : < ? echo $data [ 'winnerlog' ]; ?> Начало турнира <font
class = " date " >< ? echo date ( " d.m.y H:i " , $data [ 'start_time' ]); ?> </font>, продолжительность :
< font class = " date " >< ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ); ?>
ч . < ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 - floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ) * 60 ); ?>
мин .</ font > , приз : < b >< ? echo $data [ 'coin' ]; ?> кр.</b> <a
href = " /towerlog.php?id=<? echo $data['id'] ; ?> " target = " _blank " > История турнира »» </ a >< br /></ li >
< ? } ?>
</ ol >
< ?
$data = mysql_fetch_array ( mysql_query ( " SELECT * FROM `deztow_turnir` ORDER BY `coin` DESC LIMIT 1 " ));
?>
< h4 > Максимальный выигрыш </ h4 >
Победитель : < ? echo $data [ 'winnerlog' ]; ?> Начало турнира <font
class = " date " >< ? echo date ( " d.m.y H:i " , $data [ 'start_time' ]); ?> </font>, продолжительность : <font
class = " date " >< ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ); ?>
ч . < ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 - floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ) * 60 ); ?>
мин .</ font > , приз : < b >< ? echo $data [ 'coin' ]; ?> кр.</b> <a href="/towerlog.php?id=<? echo $data['id']; ?>"
target = " _blank " > История турнира »» </ a >< br />
< ?
$data = mysql_fetch_array ( mysql_query ( " SELECT * FROM `deztow_turnir` ORDER BY (`endtime`-`start_time`) DESC LIMIT 1 " ));
?>
< h4 > Самый продолжительный турнир </ h4 >
Победитель : < ? echo $data [ 'winnerlog' ]; ?> Начало турнира <font
class = " date " >< ? echo date ( " d.m.y H:i " , $data [ 'start_time' ]); ?> </font>, продолжительность : <font
class = " date " >< ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ); ?>
ч . < ? echo floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 - floor (( $data [ 'endtime' ] - $data [ 'start_time' ]) / 60 / 60 ) * 60 ); ?>
мин .</ font > , приз : < b >< ? echo $data [ 'coin' ]; ?> кр.</b> <a href="/towerlog.php?id=<? echo $data['id']; ?>"
target = " _blank " > История турнира »» </ a >< br />
2018-01-28 16:40:49 +00:00
</ body >
</ html >