2018-01-28 16:40:49 +00:00
< ? php
2021-02-01 16:42:52 +00:00
2021-02-01 19:20:23 +00:00
use Battles\Nick ;
2021-02-01 16:42:52 +00:00
use Battles\Template ;
use Battles\User ;
2018-01-28 16:40:49 +00:00
session_start ();
2020-09-29 22:39:06 +00:00
require_once " functions.php " ;
2021-02-01 16:42:52 +00:00
$user = $user ? ? new User ( $_SESSION [ 'uid' ]);
2020-09-28 16:03:01 +00:00
try {
db :: c () -> query ( 'LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE' );
} catch ( Exception $e ) {
echo $e -> getMessage ();
}
2019-06-21 18:43:56 +00:00
2020-08-29 23:21:22 +00:00
$do = $_GET [ 'do' ] ? ? null ;
2021-02-01 19:20:23 +00:00
if ( $do == " clear " && $user -> getAdmin () == 1 ) {
2018-11-06 01:28:10 +00:00
db :: c () -> query ( 'UPDATE `zayavka` SET `coment` = "?s" WHERE `id` = ?i' , '<em>Вырезано цензурой!</em>' , $_GET [ 'zid' ]);
2018-01-28 16:40:49 +00:00
}
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_GET [ 'del' ]) && $user -> getAdmin () == 1 ) { //удаление заявки на бой.
2018-11-06 01:28:10 +00:00
$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' ]);
2018-01-28 16:40:49 +00:00
} else {
echo 'Заявка не найдена ...' ;
}
}
2019-06-22 15:09:03 +00:00
$_SESSION [ 'view' ] = false ;
2020-09-28 15:59:12 +00:00
if ( isset ( $_REQUEST [ 'view' ])) {
$_SESSION [ 'view' ] = $_REQUEST [ 'view' ];
}
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
class Zayavka
2018-11-06 01:28:10 +00:00
{
2020-09-28 15:59:12 +00:00
/**
* @ var string
*/
private $errorMessage ;
2020-09-28 16:24:49 +00:00
private $user ;
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
function __construct ( $user_id )
2018-11-06 01:28:10 +00:00
{
2020-09-28 16:24:49 +00:00
$this -> user = $user_id ;
2018-11-06 01:28:10 +00:00
}
function fteam ( $team )
{
$team = explode ( " ; " , $team );
unset ( $team [ count ( $team ) - 1 ]);
return $team ;
}
2019-06-22 10:05:59 +00:00
/**
2019-09-24 11:55:23 +00:00
* @ param int $razdel - тип поединка ( 1 - нубы , 2 - физы , 4 - группы , 5 - х а о с )
* @ param null $level - показывать заявки только N уровня
2019-06-22 10:05:59 +00:00
* @ param null $id
2019-09-24 11:55:23 +00:00
*
2019-06-22 10:05:59 +00:00
* @ return mixed
* @ throws \Krugozor\Database\Mysql\Exception
*/
2020-09-28 15:59:12 +00:00
public function getlist ( $razdel = 4 , $level = null , $id = null )
2018-11-06 01:28:10 +00:00
{
2019-06-22 09:34:23 +00:00
$sql = db :: c () -> prepare ( 'SELECT * FROM `zayavka` WHERE `level` = ?i' , $razdel );
if ( ! is_null ( $level )) {
2019-06-22 09:35:22 +00:00
$sql .= db :: c () -> prepare ( ' AND (`t1min` <= ?i OR `t1min` = 99) AND (`t1max` >= ?i OR `t1max` = 99)' , $level , $level );
2019-06-22 09:34:23 +00:00
if ( 4 == $razdel ) {
2019-06-22 09:35:22 +00:00
$sql .= db :: c () -> prepare ( ' AND (`t2min` <= ?i OR `t2min` = 99) AND (`t2max` >= ?i OR `t2max` = 99)' , $level , $level );
2019-06-22 09:34:23 +00:00
}
}
if ( ! is_null ( $id )) {
2019-06-22 09:35:22 +00:00
$sql .= db :: c () -> prepare ( ' AND `id` = ?i' , $id );
2019-06-22 09:34:23 +00:00
}
$fict = db :: c () -> query ( $sql );
while ( $row = $fict -> fetch_assoc ()) {
2018-11-06 01:28:10 +00:00
if (( $row [ 'start' ] + 300 ) < time ()) {
2019-06-22 09:34:23 +00:00
if ( db :: c () -> query ( 'DELETE FROM `zayavka` WHERE `id` = ?i' , $row [ 'id' ])) {
2018-11-06 01:28:10 +00:00
$team1 = $this -> fteam ( $row [ 'team1' ]);
foreach ( $team1 as $k => $v ) {
2019-06-22 09:34:23 +00:00
db :: c () -> query ( 'UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i' , $v );
2018-11-06 01:28:10 +00:00
}
$team2 = $this -> fteam ( $row [ 'team2' ]);
foreach ( $z [ $zay ][ 'team2' ] as $k => $v ) {
2019-06-22 09:34:23 +00:00
db :: c () -> query ( 'UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i' , $v );
2018-11-06 01:28:10 +00:00
}
}
}
2019-09-24 11:55:23 +00:00
$zay [ $row [ 'id' ]] = [ " 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' ]];
2018-11-06 01:28:10 +00:00
}
return $zay ;
}
2020-09-28 15:59:12 +00:00
public function addteam ( $team , $r )
2018-11-06 01:28:10 +00:00
{
2019-09-24 10:38:05 +00:00
$id = $_SESSION [ 'uid' ];
$zay = $_REQUEST [ 'gocombat' ];
2019-06-22 15:43:05 +00:00
$owntravma = db :: c () -> query ( 'SELECT `id`, `type` FROM `effects` WHERE (`type` = 12 OR `type` = 13) AND `owner` = ?i' , $id ) -> fetch_assoc ();
2018-11-06 01:28:10 +00:00
$z = $this -> getlist ( $r , null , $zay );
2020-09-28 15:59:12 +00:00
if ( $owntravma [ 'type' ] == 12 && ( $z [ $zay ][ 'type' ] != 4 && $z [ $zay ][ 'type' ] != 5 )) {
$this -> errorMessage = " У В а с средняя травма, поединки с оружием слишком тяжелы для В а с ..." ;
} elseif ( $owntravma [ 'type' ] == 13 ) {
$this -> errorMessage = " У В а с тяжелая травма, Вы не сможете драться..." ;
2018-11-06 01:28:10 +00:00
}
2020-09-28 16:24:49 +00:00
if ( $this -> user -> zayavka ) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Вы находитесь в заявке " ;
}
2020-09-28 16:24:49 +00:00
if ( $this -> user -> health < $this -> user -> maxHealth * 0.33 ) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Вы слишком ослаблены для боя, восстановитесь. " ;
}
if ( ! $z || ! empty ( $this -> user_status ( $id ))) {
$this -> errorMessage = " Эта заявка не может быть принята Вами. " ;
}
if ( $z [ $zay ][ 'type' ] != 3 || $z [ $zay ][ 'type' ] != 5 ) {
if ( $team == 1 ) {
$teamz = 2 ;
} else {
$teamz = 1 ;
}
2018-11-06 01:28:10 +00:00
foreach ( $z [ $zay ][ 'team' . $teamz ] as $v ) {
2019-06-22 15:09:03 +00:00
$enemy = db :: c () -> query ( 'SELECT `klan` FROM `users` WHERE `id` = ?i' , $v ) -> fetch_assoc ();
2020-09-28 16:24:49 +00:00
if ( $this -> user -> clan == $enemy [ 'klan' ]) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Нельзя драться против сокланов! " ;
}
2018-11-06 01:28:10 +00:00
}
}
if ( $z [ $zay ][ 't' . $team . 'min' ] == 99 ) {
2019-06-22 15:43:05 +00:00
$toper = db :: c () -> query ( 'SELECT `klan` FROM `users` WHERE `id` = ?i' , $z [ $zay ][ 'team' . $team ][ 0 ]) -> fetch_assoc ();
2020-09-28 16:24:49 +00:00
if ( $this -> user -> clan != $toper [ 'klan' ]) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Эта заявка не может быть принята Вами. " ;
}
2018-11-06 01:28:10 +00:00
} else {
2020-09-28 16:24:49 +00:00
if ( $this -> user -> level > 0 && ! ( $z [ $zay ][ 't' . $team . 'min' ] <= $this -> user -> level && $z [ $zay ][ 't' . $team . 'max' ] >= $this -> user -> level )) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Эта заявка не может быть принята Вами. - " . $z [ $zay ][ 't' . $team . 'min' ];
2018-11-06 01:28:10 +00:00
}
}
if ( count ( $z [ $zay ][ 'team' . $team ]) >= $z [ $zay ][ 't' . $team . 'c' ]) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Группа уже набрана. " ;
2018-11-06 01:28:10 +00:00
}
$z [ $zay ][ 'team' . $team ][] = '' ;
2020-09-28 15:59:12 +00:00
if ( $this -> errorMessage ) {
return $this -> errorMessage ;
} else {
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 } " );
2018-11-06 01:28:10 +00:00
return " Вы приняли заявку на бой. " ;
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
public function delteam ( $id , $zay , $r )
2018-11-06 01:28:10 +00:00
{
$z = $this -> getlist ( $r , null , $zay );
if ( $z [ $zay ][ 'level' ] > 3 || $z [ $zay ][ 'level' ] == null ) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = 'Неизвестная ошибка.' ;
2018-11-06 01:28:10 +00:00
}
2019-06-22 15:09:03 +00:00
foreach ( $z [ $zay ][ 'team2' ] as $v ) {
2018-11-06 01:28:10 +00:00
if ( $v != $id ) {
$teams [] = $v ;
}
}
2020-09-28 15:59:12 +00:00
if ( $this -> errorMessage ) {
return $this -> errorMessage ;
} else {
mysql_query ( " UPDATE `users`, `zayavka` SET `users`.`zayavka` = '0', `zayavka`.`team { $team } ` = ' { $teams } ' WHERE `users`.`id` = { $id } AND `zayavka`.`id` = { $zay } ; " );
2018-11-06 01:28:10 +00:00
return " Вы отозвали запрос " ;
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
public function addzayavka ( $start , $timeout , $t1c , $t2c , $type , $t1min , $t2min , $t1max , $t2max , $coment , $level , $blood = 0 )
2018-11-06 01:28:10 +00:00
{
2020-09-28 15:59:12 +00:00
if ( ! in_array ( $level , [ 2 , 4 , 5 ])) {
$level = 4 ;
} /*2-физ, 4-группа, 5-х а о с */
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
if ( $level == 2 && $type != 1 && $type != 4 && $type != 6 ) {
$type = 1 ;
}
if ( $level == 4 && $type != 2 && $type != 4 ) {
$type = 2 ;
}
if ( $level == 5 && $type != 3 && $type != 5 ) {
$type = 3 ;
}
if ( ! in_array ( $start , [ 1 , 3 , 5 , 10 , 15 , 30 , 60 ])) {
$start = 1 ;
}
if ( ! in_array ( $timeout , [ 1 , 3 , 5 , 10 ])) {
$timeout = 1 ;
}
2020-09-28 16:24:49 +00:00
if ( $this -> user_status ( $this -> user -> id ) != 0 ) {
2020-09-28 15:59:12 +00:00
exit ();
}
2020-09-28 16:24:49 +00:00
if ( ! $this -> user -> clan && $t1min == 99 ) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Вы не состоите в клане. " ;
2018-11-06 01:28:10 +00:00
}
2020-09-28 16:24:49 +00:00
if ( $this -> user -> health < $this -> user -> maxHealth * 0.33 ) {
2020-09-28 15:59:12 +00:00
$this -> errorMessage = " Вы слишком ослаблены для боя, восстановитесь. " ;
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
if ( $this -> errorMessage ) {
return $this -> errorMessage ;
} else {
if ( $type == 3 ) {
AddChatSystem ( 'Внимание! Подана заявка на хаотический поединок ({$t1min} - {$t1max}), который начнется через {$start} минут.' );
}
$start = time () + $start * 60 ;
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
db :: c () -> query ( ' INSERT INTO `zayavka`
2019-09-24 13:27:46 +00:00
( `start` , `timeout` , `t1c` , `t2c` , `type` , `level` , `coment` , `team1` , `t1min` , `t2min` , `t1max` , `t2max` , `podan` , `blood` )
2018-11-06 01:28:10 +00:00
VALUES ( ? i , ? i , ? i , ? i , ? i , ? i , " ?s " , " ?s " , ? d , ? i , ? i , ? i , ? i , " ?s " , ? i ) ' ,
2020-09-28 16:24:49 +00:00
$start , $timeout , $t1c , $t2c , $type , $level , $coment , $this -> user -> id , $t1min , $t2min , $t1max , $t2max , date ( 'H:i' ), $blood );
db :: c () -> query ( 'UPDATE `users` SET `zayavka` = ?i WHERE `id` = ?i' , db :: c () -> getLastInsertId (), $this -> user -> id );
2020-09-28 15:59:12 +00:00
return 'Заявка подана!' ;
}
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
public function delzayavka ( $id , $zay , $r , $f = 1 )
2018-11-06 01:28:10 +00:00
{
$z = $this -> getlist ( $r , null , $zay );
2020-09-28 15:59:12 +00:00
if ( $f != 1 && $z [ $zay ][ 'level' ] > 3 ) {
return 'Неизвестная ошибка.' ;
} else {
mysql_query ( " DELETE FROM `zayavka` WHERE `id` = { $zay } AND (`team1` LIKE ' { $id } ;%' OR `team2` LIKE ' { $id } ;%') LIMIT 1 " );
2018-11-06 01:28:10 +00:00
if ( count ( $z [ $zay ][ 'team1' ]) > 0 ) {
2020-09-28 15:59:12 +00:00
foreach ( $z [ $zay ][ 'team1' ] as $k => $v ) {
2019-06-22 15:43:05 +00:00
db :: c () -> query ( 'UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i' , $v );
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
}
if ( count ( $z [ $zay ][ 'team2' ]) > 0 ) {
2020-09-28 15:59:12 +00:00
foreach ( $z [ $zay ][ 'team2' ] as $k => $v ) {
2019-06-22 15:43:05 +00:00
db :: c () -> query ( 'UPDATE `users` SET `zayavka` = 0 WHERE `id` = ?i' , $v );
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
}
return 'Вы отозвали заявку.' ;
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
public function showfiz ( $row )
2018-11-06 01:28:10 +00:00
{
2020-09-28 16:24:49 +00:00
$rr = " <input type= \" radio \" " . (( in_array ( $this -> user -> id , $row [ 'team1' ]) || in_array ( $this -> user -> id , $row [ 'team2' ]) || $row [ 'team2' ]) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" /><font class=date> { $row [ 'podan' ] } </font> " ;
2018-11-06 01:28:10 +00:00
foreach ( $row [ 'team1' ] as $k => $v ) {
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
}
if ( $row [ 'team2' ]) {
$rr .= " <i>против</i> " ;
foreach ( $row [ 'team2' ] as $k => $v ) {
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
}
}
$rr .= " тип боя: " ;
if ( $row [ 'type' ] == 4 ) {
$rr .= " <img src= \" i/fighttype4.gif \" width= \" 20 \" height= \" 20 \" title= \" Кулачный бой \" /> " ;
} elseif ( $row [ 'type' ] == 6 ) {
$rr .= " <img src= \" i/fighttype6.gif \" width= \" 20 \" height= \" 20 \" title= \" Кровавый бой \" /> " ;
} elseif ( $row [ 'type' ] == 1 ) {
$rr .= " <img src= \" i/fighttype1.gif \" width= \" 20 \" height= \" 20 \" title= \" Физический бой \" /> " ;
}
$rr .= " (таймаут { $row [ 'timeout' ] } мин.) <br /> " ;
return $rr ;
}
2020-09-28 15:59:12 +00:00
public function showgroup ( $row )
2018-11-06 01:28:10 +00:00
{
if ( $row [ 't1min' ] == 99 ) {
$range1 = " <i>клан</i> " ;
} else {
$range1 = " { $row [ 't1min' ] } - { $row [ 't1max' ] } " ;
}
if ( $row [ 't2min' ] == 99 ) {
$range2 = " <i>клан</i> " ;
} else {
$range2 = " { $row [ 't2min' ] } - { $row [ 't2max' ] } " ;
}
2020-09-28 16:24:49 +00:00
$rr = " <input type= \" radio \" " . (( in_array ( $this -> user -> id , $row [ 'team1' ]) || in_array ( $this -> user -> id , $row [ 'team2' ])) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" ><span class=date> { $row [ 'podan' ] } </span> <b> { $row [ 't1c' ] } </b>( { $range1 } ) ( " ;
2018-11-06 01:28:10 +00:00
foreach ( $row [ 'team1' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
}
$rr .= " ) <i>против</i> <b> { $row [ 't2c' ] } </b>( { $range2 } )( " ;
foreach ( $row [ 'team2' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
}
if ( count ( $row [ 'team2' ]) == 0 ) {
$rr .= " <i>группа не набрана</i> " ;
}
if ( $row [ 'blood' ] && $row [ 'type' ] == 5 ) {
$rr .= " <img src= \" i/fighttype6.gif \" width= \" 20 \" height= \" 20 \" /> " ;
}
2020-09-28 16:24:49 +00:00
$a = db :: c () -> query ( 'SELECT `admin` FROM `users` WHERE `id` = ?i' , $this -> user -> id ) -> fetch_assoc ();
2018-11-06 01:28:10 +00:00
$rr .= " ) тип боя: " ;
if ( $row [ 'blood' ] && $row [ 'type' ] == 4 ) {
$rr .= " <img src= \" i/fighttype4.gif \" width= \" 20 \" height= \" 20 \" title= \" кулачный бой \" /><img src= \" i/fighttype6.gif \" width= \" 20 \" height= \" 20 \" title= \" Кровавый поединок \" /> " ;
} elseif ( $row [ 'blood' ] && $row [ 'type' ] == 2 ) {
$rr .= " <img src= \" i/fighttype6.gif \" width= \" 20 \" height= \" 20 \" title= \" Кровавый поединок \" /> " ;
} elseif ( $row [ 'type' ] == 2 ) {
$rr .= " <img src= \" i/fighttype2.gif \" width= \" 20 \" height= \" 20 \" title= \" групповой бой \" /> " ;
} elseif ( $row [ 'type' ] == 4 ) {
$rr .= " <img src= \" i/fighttype4.gif \" width= \" 20 \" height= \" 20 \" title= \" кулачный групповой бой \" /> " ;
}
$rr .= " (таймаут { $row [ 'timeout' ] } мин.) <span style='color: gray;'><i>бой начнется через " . round (( $row [ 'start' ] - time ()) / 60 , 1 ) . " мин. " . (( $row [ 'coment' ]) ? " ( " . $row [ 'coment' ] . " ) " : " " ) . " </i></span> " ;
2019-09-24 09:49:05 +00:00
if ( $a [ 'admin' ] === 1 ) {
2018-11-06 01:28:10 +00:00
$rr .= " <a href='?zid= { $row [ 'id' ] } &do=clear'><small>Удалить комментарий</small></a><br /> " ;
} else {
$rr .= " <br /> " ;
}
return $rr ;
}
2020-09-28 15:59:12 +00:00
public function showhaos ( $row )
2018-11-06 01:28:10 +00:00
{
global $user ;
2020-09-28 16:24:49 +00:00
$rr = " <input type= \" radio \" " . (( in_array ( $this -> user -> id , $row [ 'team1' ]) || in_array ( $this -> user -> id , $row [ 'team2' ])) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" /><font class= \" date \" > { $row [ 'podan' ] } </font> ( " ;
2018-11-06 01:28:10 +00:00
if ( $row [ 'bots' ] == '7' ) {
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10962 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10964 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10965 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
} elseif ( $row [ 'bots' ] == '8' || $row [ 'bots' ] == '13' ) {
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10124 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10125 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( 10126 ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
$rr .= " , " ;
}
foreach ( $row [ 'team1' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2018-11-06 01:28:10 +00:00
}
if ( count ( $row [ 'team1' ]) == 0 && $row [ 'bots' ] == 0 ) {
$rr .= " <i>группа не набрана</i> " ;
}
$rr .= " ) ( { $row [ 't1min' ] } - { $row [ 't1max' ] } ) тип боя: " ;
if ( $row [ 'blood' ] && $row [ 'type' ] == 5 ) {
$rr .= " <img src= \" i/fighttype5.gif \" style= \" width: 20px; height: 20px; \" title= \" Кулачный бой \" /><img src= \" i/fighttype6.gif \" style= \" width: 20px; height: 20px; \" title= \" Кровавый поединок \" /> " ;
} elseif ( $row [ 'blood' ] && $row [ 'type' ] == 3 ) {
$rr .= " <img src= \" i/fighttype6.gif \" style= \" width: 20px; height: 20px; \" title= \" Кровавый поединок \" /> " ;
} elseif ( $row [ 'type' ] == 3 ) {
$rr .= " <img src= \" i/fighttype3.gif \" style= \" width: 20px; height: 20px; \" title= \" Групповой бой \" /> " ;
} elseif ( $row [ 'type' ] == 5 ) {
$rr .= " <img src= \" i/fighttype5.gif \" style= \" width: 20px; height: 20px; \" title= \" Кулачный групповой бой \" /> " ;
}
$rr .= " (таймаут { $row [ 'timeout' ] } мин.) <span style='color: gray;'><i >бой начнется через " . round (( $row [ 'start' ] - time ()) / 60 , 1 ) . " мин. " . (( $row [ 'coment' ]) ? " ( " . $row [ 'coment' ] . " ) " : " " ) . " </i></span> " ;
2020-09-28 16:24:49 +00:00
if ( $this -> user -> admin == 1 ) {
$rr .= " <small><a href='?zid= { $row [ 'id' ] } &do=clear'>Удалить комментарий</a> | <a href= \ '?level=haos&zid= { $row [ 'id' ] } &del=true \ '>Удалить заявку</a></small><br /> " ;
2018-11-06 01:28:10 +00:00
} else {
$rr .= " <br /> " ;
}
return $rr ;
}
2020-09-28 15:59:12 +00:00
public function user_status ( $id )
2018-11-06 01:28:10 +00:00
{
$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 ;
}
}
2020-09-28 15:59:12 +00:00
public function battlestart ( $id , $zay , $r )
2018-11-06 01:28:10 +00:00
{
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 ) {
2019-09-24 11:55:23 +00:00
$bots_raw = [ 7 => [ 10962 , 10964 , 10965 ], 8 => [ 10124 , 10125 , 10126 ], 13 => [ 10124 , 10125 , 10126 ]];
2018-11-06 01:28:10 +00:00
$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_ ) {
2020-10-30 00:33:02 +00:00
//Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().
2018-11-06 01:28:10 +00:00
#addchp('<font color=red>Внимание!</font> Ваш бой не может начаться по причине <b>Группа не набрана</b>.', '{[]}' . nick::id($v)->short() . '{[]}');
2020-09-30 12:01:33 +00:00
exit ( 'Bitch' );
2018-11-06 01:28:10 +00:00
}
}
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_ ) {
2019-06-22 15:43:05 +00:00
$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 ();
2018-11-06 01:28:10 +00:00
} else {
2019-06-22 15:43:05 +00:00
$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 ();
2018-11-06 01:28:10 +00:00
}
2019-09-24 11:55:23 +00:00
$cost [] = [ $z [ 'team1' ][ $i ], $gamer [ 0 ]];
2018-11-06 01:28:10 +00:00
}
$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 ;
}
}
}
2020-09-28 15:59:12 +00:00
while ( ! empty ( $cost )) {
2018-11-06 01:28:10 +00:00
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 ];
}
}
}
2019-09-24 11:55:23 +00:00
$teams = [];
2018-11-06 01:28:10 +00:00
foreach ( $z [ 'team1' ] as $k => $v ) {
foreach ( $z [ 'team2' ] as $kk => $vv ) {
2019-09-24 11:55:23 +00:00
$teams [ $v ][ $vv ] = [ 0 , 0 , time ()];
2018-11-06 01:28:10 +00:00
}
}
foreach ( $z [ 'team2' ] as $k => $v ) {
foreach ( $z [ 'team1' ] as $kk => $vv ) {
2019-09-24 11:55:23 +00:00
$teams [ $v ][ $vv ] = [ 0 , 0 , time ()];
2018-11-06 01:28:10 +00:00
}
}
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 ) {
2020-10-30 00:33:02 +00:00
//Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[2]
2018-11-06 01:28:10 +00:00
#addchp('<font color=red>Внимание!</font> Ваш бой не может начаться по причине "Группа не набрана".', '{[]}' . nick::id($v)->short() . '{[]}');
return null ;
}
header ( " Location: zayavka.php " );
2020-09-30 12:01:33 +00:00
exit ;
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
if ( ! in_array ( $z [ 'timeout' ], [ 3 , 4 , 5 , 7 , 10 ])) {
$z [ 'timeout' ] = 3 ;
}
2018-11-06 01:28:10 +00:00
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 = " <b> " ;
foreach ( $z [ 'team1' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2020-10-30 00:33:02 +00:00
//Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[3]
2018-11-06 01:28:10 +00:00
#addchp('<font color=red>Внимание!</font> Ваш бой начался!<br />\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . nick::id($v)->short() . '{[]}');
}
$rr .= " </b> и <b> " ;
foreach ( $z [ 'team2' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
2020-08-27 12:17:02 +00:00
$rr .= Nick :: id ( $v ) -> full ( 1 );
2020-10-30 00:33:02 +00:00
//Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[4]
2018-11-06 01:28:10 +00:00
#addchp('<font color=red>Внимание!</font> Ваш бой начался!<br />\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . nick::id($v)->short() . '{[]}');
}
$rr .= " </b> " ;
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу.<BR> " );
foreach ( $z [ 'team1' ] as $k => $v ) {
if ( $v < _BOTSEPARATOR_ ) {
2019-06-22 15:09:03 +00:00
db :: c () -> query ( 'UPDATE `users` SET `battle` = ?i, `zayavka` = 0 WHERE `id` = ?i' , $id , $v );
2018-11-06 01:28:10 +00:00
} else {
2019-06-22 15:09:03 +00:00
db :: c () -> query ( 'UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i' , $id , $v );
2018-11-06 01:28:10 +00:00
}
}
foreach ( $z [ 'team2' ] as $k => $v ) {
if ( $v < _BOTSEPARATOR_ ) {
2019-06-22 15:09:03 +00:00
db :: c () -> query ( 'UPDATE `users` SET `battle` = ?i, `zayavka` = 0 WHERE `id` = ?i' , $id , $v );
2018-11-06 01:28:10 +00:00
} else {
2019-06-22 15:09:03 +00:00
db :: c () -> query ( 'UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i' , $id , $v );
2018-11-06 01:28:10 +00:00
}
}
if ( $bot ) {
2019-06-22 15:09:03 +00:00
db :: c () -> query ( 'UPDATE `bots` SET `battle` = ?i WHERE `id` = ?i' , $id , $bot [ 'id' ]);
2018-11-06 01:28:10 +00:00
}
}
2020-09-28 16:24:49 +00:00
if ( $this -> user -> zayavka == $zay ) {
2020-09-30 12:01:33 +00:00
exit ( " <script>location.href='fbattle.php';</script> " );
2018-11-06 01:28:10 +00:00
}
}
2018-01-28 16:40:49 +00:00
}
2020-09-28 15:59:12 +00:00
$zay = new Zayavka ;
2019-06-21 18:56:59 +00:00
if ( ! empty ( $_POST [ 'open' ])) {
2021-02-01 16:42:52 +00:00
$f = fopen ( " /tmp/zayavka/ " . $user -> getId () . " .txt " , " w+ " );
2018-11-06 01:28:10 +00:00
fputs ( $f , time ());
fclose ( $f );
2018-01-28 16:40:49 +00:00
}
2021-02-01 16:42:52 +00:00
Template :: header ( 'zayavka' );
2018-01-28 16:40:49 +00:00
?>
2018-11-06 01:28:10 +00:00
< style >
. m {
background : #99CCCC;
text - align : center ;
}
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
. s {
background : #BBDDDD;
text - align : center ;
}
</ style >
< TABLE width = 100 % cellspacing = 1 cellpadding = 1 >
2019-06-22 16:01:21 +00:00
< TR >
< TD colspan = 5 >
2020-09-28 15:59:12 +00:00
< ? php if ( ! empty ( $level )) {
echo Nick :: id ( $user ) -> battle ();
} ?>
2019-06-22 16:01:21 +00:00
</ TD >
< TD colspan = 4 align = right >
< INPUT TYPE = button value = " Вернуться " onclick = " location.href='main.php?top=<?= mt_rand() ?>'; " >
</ TD >
</ TR >
< TR >
< TD class = m width = 40 >& nbsp ; < B > Бои :</ B ></ TD >
2019-09-24 10:26:08 +00:00
< TD class = s >< A HREF = " ?fiz " > Физические </ A ></ TD >
< TD class = s >< A HREF = " ?group " > Групповые </ A ></ TD >
< TD class = s >< A HREF = " ?haos " > Хаотические </ A ></ TD >
< TD class = s >< A HREF = " ?current " > Текущие </ A >
2019-06-22 16:01:21 +00:00
</ TD >
</ TR >
2018-11-06 01:28:10 +00:00
</ TABLE >
2019-09-24 11:06:55 +00:00
< TABLE class = " allzeroes " >
2018-11-06 01:28:10 +00:00
< TR >
2019-09-24 11:06:55 +00:00
< TD >
2018-11-06 01:28:10 +00:00
< ? php
2019-09-24 10:26:08 +00:00
$get = urldecode ( filter_input ( INPUT_SERVER , 'QUERY_STRING' ));
2021-02-01 19:20:23 +00:00
if ( $user -> getRoom () != 1 && $get != 'current' ) {
2020-09-28 15:59:12 +00:00
exit ( 'В этой комнате невозможно подавать заявки!' );
}
if ( ! $get ) {
echo '<p style="text-align: center; font-weight: bold; margin-top: 16px;">Выберите раздел</p>' ;
}
2018-11-06 01:28:10 +00:00
2019-09-24 10:26:08 +00:00
if ( $get == 'fiz' ) {
2019-09-24 11:06:55 +00:00
echo " <b style='color: #f80000;'> " ;
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'open' ])) {
2018-11-06 01:28:10 +00:00
if ( $_POST [ 'k' ] == 6 ) {
$blood = 1 ;
} else {
$blood = 0 ;
}
2021-02-01 16:42:52 +00:00
echo $zay -> addzayavka ( 0 , $_POST [ 'timeout' ], 1 , 1 , $_POST [ 'k' ], $user -> getLevel (), 1 , $user -> getLevel (), 21 , '' , 2 , $blood );
2020-09-30 12:01:33 +00:00
exit ( " <script>document.location='zayavka.php?fiz';</script> " );
2018-11-06 01:28:10 +00:00
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'back' ])) {
2021-02-01 16:42:52 +00:00
unlink ( " /tmp/zayavka/ " . $user -> getId () . " .txt " );
2021-02-01 19:20:23 +00:00
echo $zay -> delzayavka ( $user -> getId (), $user -> getZayavka (), 2 , 0 );
2018-11-06 01:28:10 +00:00
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'back2' ])) {
2021-02-01 19:20:23 +00:00
$z = $zay -> getlist ( 2 , null , $user -> getZayavka ());
2021-02-01 16:42:52 +00:00
AddChatSystem ( 'Внимание!' . Nick :: id ( $user -> getId ()) -> short () . ' отозвал заявку.' );
2021-02-01 19:20:23 +00:00
echo $zay -> delteam ( $user -> getId (), $user -> getZayavka (), 2 );
2018-11-06 01:28:10 +00:00
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'cansel' ])) {
2021-02-01 19:20:23 +00:00
$z = $zay -> getlist ( 2 , null , $user -> getZayavka ());
echo $zay -> delteam ( $z [ $user -> getZayavka ()][ 'team2' ][ 0 ], $user -> getZayavka (), 2 );
2021-02-01 16:42:52 +00:00
AddChatSystem ( 'Внимание!' . Nick :: id ( $user -> getId ()) -> short () . ' отказался от поединка.' );
2018-11-06 01:28:10 +00:00
}
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'confirm2' ]) && empty ( $user -> getZayavka ())) {
2018-11-06 01:28:10 +00:00
$z = $zay -> getlist ( 2 , null , $_REQUEST [ 'gocombat' ]);
2019-06-22 15:43:05 +00:00
$toper = db :: c () -> query ( 'SELECT `klan` FROM `users` WHERE `id` = ?i' , $z [ $_REQUEST [ 'gocombat' ]][ 'team1' ][ 0 ]) -> fetch_assoc ();
2021-02-01 16:42:52 +00:00
if ( $user -> getClan () != $toper [ 'klan' ] || ! $user -> getClan ()) {
AddChatSystem ( 'Внимание!' . Nick :: id ( $user -> getId ()) -> short () . ' принял заявку, нужно принять вызов или отказать.' );
2018-11-06 01:28:10 +00:00
}
2019-09-24 10:38:05 +00:00
echo $zay -> addteam ( 2 , 2 );
2018-11-06 01:28:10 +00:00
echo " </b></font><BR>Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'> " ;
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'gofi' ])) {
2021-02-01 19:20:23 +00:00
$zay -> battlestart ( $user -> getId (), $user -> getZayavka (), 2 );
2018-11-06 01:28:10 +00:00
}
2019-09-24 11:06:55 +00:00
echo " </b> " ;
2018-11-06 01:28:10 +00:00
echo '<table cellspacing=0 cellpadding=0><tr><td>' ;
2021-02-01 16:42:52 +00:00
if ( $zay -> user_status ( $user -> getId ()) == 0 ) { ?>
2019-09-24 11:55:23 +00:00
< FIELDSET >
< LEGEND >< B > Подать заявку на бой </ B ></ LEGEND >
Таймаут
< SELECT NAME = timeout >
2019-09-24 13:27:46 +00:00
< OPTION value = 1 selected > 1 мин .
< OPTION value = 3 > 3 мин .
2019-09-24 11:55:23 +00:00
< OPTION value = 5 > 5 мин .
< OPTION value = 10 > 10 мин .
</ SELECT >
Тип боя
< SELECT NAME = k >
< OPTION value = 1 > с оружием
< OPTION value = 4 > кулачный
< OPTION value = 6 > кровавый
</ SELECT >
< INPUT TYPE = submit name = open value = " Подать заявку " >
</ FIELDSET >
< ? php }
2021-02-01 19:20:23 +00:00
$z = $zay -> getlist ( 2 , null , $user -> getZayavka ());
2021-02-01 16:42:52 +00:00
if ( $zay -> user_status ( $user -> getId ()) == 1 ) {
2021-02-01 19:20:23 +00:00
if ( count ( $z [ $user -> getZayavka ()][ 'team2' ]) > 0 ) {
echo " <B><font color=red>Внимание! " . Nick :: id ( $z [ $user -> getZayavka ()][ 'team2' ][ 0 ]) -> full ( 1 ) . " принял заявку на бой, нужно отказать или принять вызов.</font></b> <input type=submit value='Битва!' name=gofi> <input type=submit value='Отказать' name=cansel> " ;
2018-11-06 01:28:10 +00:00
} else {
2021-02-01 19:20:23 +00:00
if ( $z [ $user -> getZayavka ()][ 'level' ] == 2 ) {
2018-11-06 01:28:10 +00:00
echo " Заявка на бой подана, ожидаем противника. <input type=submit name=back value='Отозвать заявку'> " ;
2021-02-01 16:42:52 +00:00
$Path = " /tmp/zayavka/ " . $user -> getId () . " .txt " ;
2018-11-06 01:28:10 +00:00
$f = fopen ( $Path , " r " );
$timeFigth = fread ( $f , filesize ( $Path ));
fclose ( $f );
2021-02-01 16:42:52 +00:00
if ( $timeFigth < time () && ( $user -> getLevel () <= 14 )) {
2021-02-01 19:20:23 +00:00
if ( $get == 'trainstart' && $user -> getHealth () > $user -> getMaxHealth () * 0.33 && ( $user -> getLevel () <= 7 || $user -> getAdmin () == 1 )) {
2020-09-28 16:24:49 +00:00
unlink ( " /tmp/zayavka/ " . $user -> id . " .txt " );
2021-02-01 19:20:23 +00:00
$zay -> delzayavka ( $user -> id , $user -> getZayavka (), 2 , 0 );
2018-11-06 01:28:10 +00:00
2021-02-01 19:20:23 +00:00
mysql_query ( " INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) values (' " . $user -> getLogin () . " (Клон 1)',' " . $user -> getId () . " ','',' " . $user -> getMaxHealth () . " '); " );
2018-11-06 01:28:10 +00:00
$bot = mysql_insert_id ();
2019-09-24 11:55:23 +00:00
$teams = [];
2018-11-06 01:28:10 +00:00
2020-09-28 16:24:49 +00:00
$teams [ $user -> id ][ $bot ] = [ 0 , 0 , time ()];
$teams [ $bot ][ $user -> id ] = [ 0 , 0 , time ()];
2018-11-06 01:28:10 +00:00
mysql_query ( " INSERT INTO `battle`
2018-01-28 16:40:49 +00:00
( `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `clone`
)
VALUES
2020-09-28 16:24:49 +00:00
( '" . serialize($teams) . "' , '3' , '1' , '0' , '" . $user->id . "' , '" . $bot . "' , '" . time() . "' , '" . time() . "' , 1
2018-01-28 16:40:49 +00:00
) " );
2018-11-06 01:28:10 +00:00
$id = mysql_insert_id ();
mysql_query ( " UPDATE `bots` SET `battle` = { $id } WHERE `id` = { $bot } LIMIT 1 " );
2020-09-28 16:24:49 +00:00
$rr = " <b> " . Nick :: id ( $user -> id ) -> full ( 1 ) . " </b> и <b> " . Nick :: id ( $bot ) -> full ( 1 ) . " </b> " ;
2018-11-06 01:28:10 +00:00
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
2020-09-28 16:24:49 +00:00
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $user -> id } ; " );
2020-09-30 12:01:33 +00:00
exit ( " <script>location.href='fbattle.php';</script> " );
2018-11-06 01:28:10 +00:00
}
2020-09-28 16:24:49 +00:00
$Path = " /tmp/zayavka/ " . $user -> id . " .txt " ;
2018-11-06 01:28:10 +00:00
$f = fopen ( $Path , " r " );
$timeFigth = fread ( $f , filesize ( $Path ));
fclose ( $f );
2021-02-01 19:20:23 +00:00
if ( $user -> getAdmin () == 1 ) {
2019-09-24 10:26:08 +00:00
echo " или <input type=button onclick= \" location.href='zayavka.php?trainstart'; \" value= \" Начать тренировочный бой \" > " ;
2018-11-06 01:28:10 +00:00
}
}
}
}
}
2021-02-01 19:20:23 +00:00
if ( $zay -> user_status ( $user -> id ) == 2 && $z [ $user -> getZayavka ()][ 'level' ] == 2 ) {
2020-09-28 15:59:12 +00:00
echo " Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'> " ;
2018-11-06 01:28:10 +00:00
}
2021-02-01 16:42:52 +00:00
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user -> getLevel () . '" ' . (( $_SESSION [ 'view' ] != null ) ? " checked " : " " ) . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (( $_SESSION [ 'view' ] == null ) ? " checked " : " " ) . '></td><td>все</td></tr></table></FIELDSET>' ;
2018-11-06 01:28:10 +00:00
echo '<tr><td><INPUT TYPE=hidden name=level value=fiz><INPUT TYPE=submit value="Принять вызов" NAME=confirm2><BR>' ;
2020-09-28 15:59:12 +00:00
if ( $z = $zay -> getlist ( 2 , $_SESSION [ 'view' ])) {
2018-11-06 01:28:10 +00:00
foreach ( $z as $k => $v ) {
echo $zay -> showfiz ( $v );
}
2020-09-28 15:59:12 +00:00
}
2018-11-06 01:28:10 +00:00
echo '<INPUT TYPE=submit value="Принять вызов" NAME=confirm2></TD></TR></TABLE>' ;
}
2019-09-24 10:26:08 +00:00
if ( $get == 'group' ) {
2019-09-24 11:55:23 +00:00
2020-09-28 16:24:49 +00:00
if ( $zay -> user_status ( $user -> id ) != 0 ) {
2021-02-01 19:20:23 +00:00
$z = $zay -> getlist ( 4 , null , $user -> getZayavka ());
if ( $z [ $user -> getZayavka ()][ 'level' ] == 4 ) {
$battleStartTime = round (( $z [ $user -> getZayavka ()][ 'start' ] - time ()) / 60 , 1 );
2019-09-24 12:36:26 +00:00
echo " <div><b>Ожидаем начала группового боя...</b><br>Бой начнется через: $battleStartTime мин.</div> " ;
2018-11-06 01:28:10 +00:00
}
2019-09-24 12:36:26 +00:00
} else { ?>
< TABLE >
< TR >
< TD >
2019-09-24 15:47:17 +00:00
< H3 > Подать заявку на поединок </ H3 >
2020-09-28 15:59:12 +00:00
< select NAME = startime >
< option selected disabled > Начало боя </ option >
< option value = 60 > через 1 минуту </ option >
< option value = 180 > через 3 минуты </ option >
< option value = 300 > через 5 минут </ option >
< option value = 600 > через 10 минут </ option >
2019-09-24 15:47:17 +00:00
</ select >
< select NAME = timeout >
< option selected disabled > Таймаут </ option >
< option value = 1 > 1 мин .</ option >
< option value = 3 selected > 3 мин .</ option >
< option value = 5 > 5 мин .</ option >
< option value = 10 > 10 мин .</ option >
</ select >
2019-09-24 12:36:26 +00:00
< BR >< BR >
2020-09-28 15:59:12 +00:00
Ваша команда < INPUT TYPE = text NAME = nlogin1 size = 3 maxlength = 2
placeholder = " Количество союзников " > бойцов < BR >
2019-09-24 12:36:26 +00:00
Уровни союзников & nbsp ; & nbsp ; < SELECT NAME = levellogin1 >
< option value = 0 > любой
< option value = 1 > только моего и ниже
< option value = 2 > только ниже моего уровня
< option value = 3 > только моего уровня
< option value = 4 > не старше меня более чем на уровень
< option value = 5 > не младше меня более чем на уровень
< option value = 6 > мой уровень +/- 1
< option value = 99 > мой клан
</ SELECT >
< BR >< BR >
Противники & nbsp ; & nbsp ; < INPUT TYPE = text NAME = nlogin2 size = 3 maxlength = 2 > бойцов < BR >
Уровни противников < SELECT NAME = levellogin2 >
< option value = 0 > любой
< option value = 1 > только моего и ниже
< option value = 2 > только ниже моего уровня
< option value = 3 > только моего уровня
< option value = 4 > не старше меня более чем на уровень
< option value = 5 > не младше меня более чем на уровень
< option value = 6 > мой уровень +/- 1
< option value = 99 > только клан
</ SELECT >
< p >< INPUT TYPE = checkbox NAME = k > Кулачный бой </ p >
< INPUT TYPE = checkbox NAME = travma > Бой без правил ( < span class = dsc > проигравшая сторона получает инвалидность </ span > ) < BR >
Комментарий к бою < INPUT TYPE = text NAME = cmt maxlength = 40 size = 40 >
</ TD >
</ TR >
< TR >
< TD align = center >
< INPUT TYPE = submit value = " Начнем месилово! :) " name = open >
</ TD >
</ TR >
</ TABLE >
</ TD >
< TD align = right valign = top >
< INPUT TYPE = submit value = " Вернуться " >
</ TD >
</ TR >
</ TABLE >
< INPUT TYPE = hidden name = level value = group >
< ? php }
2018-01-28 16:40:49 +00:00
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'goconfirm' ]) && empty ( $user -> getZayavka ())) {
2019-09-24 12:36:26 +00:00
echo '<TABLE width=100%><TR><TD>' ;
$z = $zay -> getlist ( 4 , null , $_POST [ 'gocombat' ]);
echo " <B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round (( $z [ $_POST [ 'gocombat' ]][ 'start' ] - time ()) / 60 , 1 ) . " мин. " ;
echo ' </ TD >< TD align = right >< INPUT TYPE = submit value = " Вернуться " ></ TD ></ TR ></ TABLE >< H3 > Н а чьей стороне будете сражаться ? </ H3 >
2018-01-28 16:40:49 +00:00
< TABLE align = center cellspacing = 4 cellpadding = 1 >< TR >< TD bgcolor = 99 CCCC >< B > Группа 1 :</ B >< BR >
2018-11-06 01:28:10 +00:00
Максимальное кол - во : ' . $z[$_POST[' gocombat ']][' t1c '] . ' < BR >
Ограничения по уровню : ' . ($z[$_POST[' gocombat ']][' t1min '] == 99 ? ' клан ' : $z[$_POST[' gocombat ']][' t1min '] . " - " . $z[$_POST[' gocombat ']][' t1max ']) . '
2018-01-28 16:40:49 +00:00
</ TD >< TD bgcolor = 99 CCCC >< B > Группа 2 :</ B >< BR >
2018-11-06 01:28:10 +00:00
Максимальное кол - во : ' . $z[$_POST[' gocombat ']][' t2c '] . ' < BR >
Ограничения по уровню : ' . ($z[$_POST[' gocombat ']][' t2min '] == 99 ? ' клан ' : $z[$_POST[' gocombat ']][' t2min '] . " - " . $z[$_POST[' gocombat ']][' t2max ']) . '
2018-01-28 16:40:49 +00:00
</ TD ></ TR >< TR >
< TD align = center > ' ;
2019-09-24 12:36:26 +00:00
foreach ( $z [ $_POST [ 'gocombat' ]][ 'team1' ] as $k => $v ) {
2020-09-28 15:59:12 +00:00
if ( $k != 0 ) {
$rr .= " <BR> " ;
}
2020-08-27 12:17:02 +00:00
echo Nick :: id ( $v ) -> full ( 1 );
2019-09-24 12:36:26 +00:00
}
echo '</TD><TD align=center>' ;
foreach ( $z [ $_POST [ 'gocombat' ]][ 'team2' ] as $k => $v ) {
2020-09-28 15:59:12 +00:00
if ( $k != 0 ) {
$rr .= " <BR> " ;
}
2020-08-27 12:17:02 +00:00
echo Nick :: id ( $v ) -> full ( 1 );
2019-09-24 12:36:26 +00:00
}
echo '</TD></TR><TR>' ;
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
if ( $z [ $_POST [ 'gocombat' ]][ 'team1' ][ 0 ] != 1000 && $z [ $_POST [ 'gocombat' ]][ 'team1' ][ 0 ] != 1001 ) {
2019-09-24 12:36:26 +00:00
echo '<TD align=center><INPUT TYPE=submit name=confirm1 value="Я за этих!"></TD>' ;
2020-09-28 15:59:12 +00:00
} else {
echo '<TD align=center>Силы Х а о с а </TD>' ;
}
2018-11-06 01:28:10 +00:00
2019-09-24 12:36:26 +00:00
echo '<TD align=center><INPUT TYPE=submit name=confirm2 value="Я за этих!"></TD></TR></TABLE><INPUT TYPE=hidden name=gocombat value="' . $_POST [ 'gocombat' ] . '"><INPUT TYPE=hidden name=level value=group>' ;
2020-09-30 12:01:33 +00:00
exit ;
2019-09-24 12:36:26 +00:00
}
2018-11-06 01:28:10 +00:00
2019-09-24 12:36:26 +00:00
echo " <b style='color: #f80000;'> " ;
2018-11-06 01:28:10 +00:00
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'confirm1' ]) && ! empty ( $_POST [ 'gocombat' ]) && empty ( $user -> getZayavka ())) {
2019-09-24 12:36:26 +00:00
echo $zay -> addteam ( 1 , 4 );
}
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'confirm2' ]) && $_POST [ 'gocombat' ] && empty ( $user -> getZayavka ())) {
2019-09-24 12:36:26 +00:00
echo $zay -> addteam ( 2 , 4 );
}
2018-11-06 01:28:10 +00:00
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'open' ]) && empty ( $user -> getZayavka ())) {
2019-09-24 12:36:26 +00:00
switch ( $_POST [ 'levellogin1' ]) {
2020-09-28 15:59:12 +00:00
default :
2019-09-24 12:36:26 +00:00
case 0 : //любой
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2019-09-24 12:36:26 +00:00
$max1 = 21 ;
break ;
case 1 : //только моего и ниже
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2021-02-01 16:42:52 +00:00
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 2 : //только ниже моего уровня
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2021-02-01 16:42:52 +00:00
$max1 = $user -> getLevel () - 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 3 : //только моего уровня
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel ();
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 4 : //не старше меня более чем на уровень
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel ();
$max1 = $user -> getLevel () + 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 5 : //не младше меня более чем на уровень
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel () - 1 ;
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 6 : //мой уровень +/- 1
2021-02-01 19:20:23 +00:00
$min1 = $user -> getLevel () - 1 ;
$max1 = $user -> getLevel () + 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 99 : // кланы
$min1 = 99 ;
$max1 = 99 ;
break ;
}
switch ( $_POST [ 'levellogin2' ]) {
2020-09-28 15:59:12 +00:00
default :
2019-09-24 12:36:26 +00:00
case 0 : //любой
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2019-09-24 12:36:26 +00:00
$max1 = 21 ;
break ;
case 1 : //только моего и ниже
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2021-02-01 16:42:52 +00:00
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 2 : //только ниже моего уровня
2019-09-24 13:27:46 +00:00
$min1 = 0 ;
2021-02-01 16:42:52 +00:00
$max1 = $user -> getLevel () - 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 3 : //только моего уровня
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel ();
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 4 : //не старше меня более чем на уровень
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel ();
$max1 = $user -> getLevel () + 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 5 : //не младше меня более чем на уровень
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel () - 1 ;
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 6 : //мой уровень +/- 1
2021-02-01 19:20:23 +00:00
$min1 = $user -> getLevel () - 1 ;
$max1 = $user -> getLevel () + 1 ;
2019-09-24 12:36:26 +00:00
break ;
case 99 : // кланы
$min1 = 99 ;
$max1 = 99 ;
break ;
}
2020-09-28 15:59:12 +00:00
if ( $min1 < 0 ) {
$min1 = 0 ;
}
if ( $max1 < 0 ) {
$max1 = 0 ;
}
2019-09-24 12:36:26 +00:00
if ( $_POST [ 'k' ]) {
$_POST [ 'k' ] = 4 ;
} else {
$_POST [ 'k' ] = 2 ;
}
if ( $_POST [ 'travma' ]) {
$blood = 1 ;
} else {
$blood = 0 ;
}
2020-09-28 15:59:12 +00:00
echo $zay -> addzayavka ( $_POST [ 'startime' ] / 60 , $_POST [ 'timeout' ], $_POST [ 'nlogin1' ], $_POST [ 'nlogin2' ], $_POST [ 'k' ], $min1 , $min2 , $max1 , $max2 , $_POST [ 'cmt' ], 4 , $blood );
2019-09-24 12:36:26 +00:00
}
2020-09-28 15:59:12 +00:00
2019-09-24 12:36:26 +00:00
echo " </b><INPUT TYPE=hidden name=level value=group> " ;
2018-11-06 01:28:10 +00:00
2021-02-01 16:42:52 +00:00
echo '</TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user -> getLevel () . '" ' . (( $_SESSION [ 'view' ] != null ) ? " checked " : " " ) . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (( $_SESSION [ 'view' ] == null ) ? " checked " : " " ) . '></td><td>все</td></tr></table></FIELDSET>' ;
2019-09-24 12:36:26 +00:00
echo '<tr><td width=85%>' ;
echo '<BR><INPUT TYPE=submit value="Принять участие" NAME=goconfirm><BR>' ;
2018-11-06 01:28:10 +00:00
2020-09-28 15:59:12 +00:00
if ( $z = $zay -> getlist ( 4 , $_SESSION [ 'view' ])) {
2019-09-24 12:36:26 +00:00
foreach ( $z as $k => $v ) {
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 );
}
2020-09-28 15:59:12 +00:00
}
2019-09-24 12:36:26 +00:00
echo '<INPUT TYPE=submit value="Принять участие" NAME=goconfirm></td></tr></table>' ;
}
2018-11-06 01:28:10 +00:00
2019-09-24 12:36:26 +00:00
if ( $get == 'haos' ) {
2021-02-01 19:20:23 +00:00
if ( ! empty ( $_POST [ 'open' ]) && empty ( $user -> getZayavka ())) {
2019-09-24 12:36:26 +00:00
switch ( $_POST [ 'levellogin1' ]) {
2020-09-28 15:59:12 +00:00
default :
2019-09-24 12:36:26 +00:00
case 0 :
$min1 = 1 ;
$max1 = 21 ;
break ;
case 3 :
2021-02-01 16:42:52 +00:00
$min1 = $user -> getLevel ();
$max1 = $user -> getLevel ();
2019-09-24 12:36:26 +00:00
break ;
case 6 :
2021-02-01 16:42:52 +00:00
$min1 = ( int ) $user -> getLevel () - 1 ;
$max1 = ( int ) $user -> getLevel () + 1 ;
2019-09-24 12:36:26 +00:00
break ;
}
2018-11-06 01:28:10 +00:00
2019-09-24 12:36:26 +00:00
$blood = 0 ;
if ( $_POST [ 'travma' ]) {
$blood = 1 ;
}
2019-09-24 13:27:46 +00:00
echo $zay -> addzayavka ( $_POST [ 'startime2' ] / 60 , $_POST [ 'timeout' ], 99 , 99 , $_POST [ 'k' ], $min1 , $min1 , $max1 , $max1 , $_POST [ 'cmt' ], 5 , $blood );
2019-09-24 12:36:26 +00:00
}
if ( ! empty ( $_POST [ 'confirm2' ])) {
2020-06-23 09:24:37 +00:00
echo " <span class='success'> " . $zay -> addteam ( 1 , 5 ) . " </span> " ;
2019-09-24 12:36:26 +00:00
}
echo '<table cellspacing=0 cellpadding=0><tr><td>' ;
2020-09-28 16:24:49 +00:00
if ( $zay -> user_status ( $user -> id ) == 0 ) {
2019-09-24 12:36:26 +00:00
echo 'Хаотичный бой - разновидность группового, где группы формируются автоматически. Бой не начнется, если собралось меньше 4-х человек. <DIV id="dv2" style="display:"><A href="#" onclick="dv1.style.display=\'\'; dv2.style.display=\'none\'; return false">Подать заявку на хаотичный бой</A></DIV><DIV id="dv1" style="display: none"><FIELDSET><LEGEND><B>Подать заявку на хаотичный бой</B> </LEGEND>Начало боя через <SELECT NAME=startime2><option value=180>3 минуты</option><option value=300 selected>5 минут</option><option value=600>10 минут</option><option value=900>15 минут</option><option value=1800>30 минут</option><option value=2700>45 минут</option><option value=3600>1 час</option></SELECT> Таймаут <SELECT NAME=timeout><OPTION value=3 SELECTED>3 мин.<OPTION value=5>5 мин.<OPTION value=10>10 мин.</SELECT><BR>Уровни бойцов <SELECT NAME=levellogin1><option value=0>любой<option value=3>только моего уровня<option value=6 selected>мой уровень +/- 1</SELECT><BR><BR>Тип боя <SELECT NAME=k><OPTION value=3>с оружием<OPTION value=5>кулачный</SELECT><BR><INPUT TYPE=checkbox NAME=travma> Бой без правил (<font class=dsc>проигравшая сторона получает инвалидность</font>)<BR><INPUT TYPE=submit name=open value="Подать заявку"> <BR>Комментарий к бою <INPUT TYPE=text NAME=cmt maxlength=40 size=40></FIELDSET><BR></DIV>' ;
}
2020-09-28 16:24:49 +00:00
if ( $zay -> user_status ( $user -> id )) {
2021-02-01 19:20:23 +00:00
$z = $zay -> getlist ( 5 , null , $user -> getZayavka ());
if ( $z [ $user -> getZayavka ()][ 'level' ] == 5 ) {
echo " <B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round (( $z [ $user -> getZayavka ()][ 'start' ] - time ()) / 60 , 1 ) . " мин. " ;
2020-09-28 15:59:12 +00:00
}
2019-09-24 12:36:26 +00:00
}
2021-02-01 16:42:52 +00:00
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить"><BR><FIELDSET style="width:150px;"><LEGEND>Показывать заявки</LEGEND><table cellspacing=0 cellpadding=0 ><tr><td width=1%><input type=radio name=view value="' . $user -> getLevel () . '" ' . (( $_SESSION [ 'view' ] != null ) ? " checked " : " " ) . '></td><td>моего уровня</td></tr><tr><td><input type=radio name=view value="" ' . (( $_SESSION [ 'view' ] == null ) ? " checked " : " " ) . '></td><td>все</td></tr></table></FIELDSET>' ;
2019-09-24 12:36:26 +00:00
echo '<tr><td width=85%><INPUT TYPE=hidden name=level value=haos><INPUT TYPE=submit value="Принять участие" NAME=confirm2><BR>' ;
2020-09-28 15:59:12 +00:00
if ( $z = $zay -> getlist ( 5 , $_SESSION [ 'view' ])) {
2019-09-24 12:36:26 +00:00
foreach ( $z as $k => $v ) {
if (( $z [ $k ][ 'start' ] - time ()) < 0 ) {
$zay -> battlestart ( " CHAOS " , $k , 5 );
2018-11-06 01:28:10 +00:00
}
2019-09-24 12:36:26 +00:00
echo $zay -> showhaos ( $v );
}
2020-09-28 15:59:12 +00:00
}
2019-09-24 12:36:26 +00:00
echo '<INPUT TYPE=submit value="Принять участие" NAME=confirm2></TD></TR></TABLE>' ;
}
2018-11-06 01:28:10 +00:00
2019-09-24 12:36:26 +00:00
if ( $get == 'current' ) {
$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 );
2020-09-28 15:59:12 +00:00
if ( empty ( $data -> getNumRows ())) {
echo 'Надо же! Ни одного поединка!' ;
}
else {
while ( $row = $data -> fetch_assoc ()) {
echo " <span class=date> { $row [ 'date' ] } </span> " ;
$z = explode ( " ; " , $row [ 't1' ]);
foreach ( $z as $k => $v ) {
if ( $k > 0 ) {
echo " , " ;
}
Nick :: id ( $v ) -> full ();
2018-11-06 01:28:10 +00:00
}
2020-09-28 15:59:12 +00:00
echo " против " ;
$z = explode ( " ; " , $row [ 't2' ]);
foreach ( $z as $k => $v ) {
if ( $k > 0 ) {
echo " , " ;
}
Nick :: id ( $v ) -> full ();
2019-09-24 12:36:26 +00:00
}
2020-09-28 15:59:12 +00:00
echo " <img src='i/fighttype { $row [ 'type' ] } .gif'> <a href='logs.php?log= { $row [ 'id' ] } ' target=_blank>»»</a><br /> " ;
2019-09-24 12:36:26 +00:00
}
}
}
2020-09-30 19:12:34 +00:00
db :: c () -> query ( 'UNLOCK TABLES' );