2018-01-28 16:40:49 +00:00
< ? php
session_start ();
2018-11-06 01:28:10 +00:00
if ( ! isset ( $_SESSION [ 'uid' ])) {
header ( " Location: index.php " );
}
2018-01-28 16:40:49 +00:00
include ( " config.php " );
include ( " functions.php " );
2018-11-06 01:28:10 +00:00
if ( $user [ 'battle' ] != 0 ) {
header ( 'Location: fbattle.php' );
die ();
}
2019-06-21 18:43:56 +00:00
2019-06-21 18:46:27 +00:00
$level = filter_input ( INPUT_GET , 'level' );
2019-06-21 18:55:25 +00:00
$logs = filter_input ( INPUT_GET , 'logs' );
$tklogs = filter_input ( INPUT_GET , 'tklogs' );
2019-06-21 18:43:56 +00:00
2019-06-21 18:45:17 +00:00
db :: c () -> query ( 'LOCK TABLES `bots` WRITE, `battle` WRITE, `logs` WRITE, `users` WRITE, `inventory` WRITE, `zayavka` WRITE, `effects` WRITE, `online` WRITE, `clans` WRITE' );
2018-01-28 16:40:49 +00:00
2019-06-21 17:48:47 +00:00
if (( input :: check ( 'do' ) == " clear " ) AND $user [ 'admin' ] == 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
}
2019-06-21 17:35:40 +00:00
if ( ! empty ( $_GET [ 'del' ]) && $user [ 'admin' ] == 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 'Заявка не найдена ...' ;
}
}
2018-11-06 01:28:10 +00:00
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 ;
}
function getlist ( $razdel = 1 , $level = null , $id = null )
{
/*
* if ( $level AND $razdel == 4 AND $id ) :
* SELECT * FROM `zayavka` WHERE
* ( `t1min` <= { $level } OR `t1min` = 99 ) AND
* ( `t1max` >= { $level } OR `t1max` = 99 ) AND
* ( `t2min` <= { $level } OR `t2min` = 99 ) AND
* ( `t2max` >= { $level } OR `t2max` = 99 ) AND
* `level` = { $razdel } AND
* `id` = { $id }
*
* if ( $level AND $razdel != 4 AND $id ) :
* SELECT * FROM `zayavka` WHERE
* ( `t1min` <= { $level } OR `t1min` = 99 ) AND
* ( `t1max` >= { $level } OR `t1max` = 99 ) AND
* `level` = { $razdel } AND
* `id` = { $id }
*
* if ( $level AND $razdel != 4 AND ! $id ) :
* SELECT * FROM `zayavka` WHERE
* ( `t1min` <= { $level } OR `t1min` = 99 ) AND
* ( `t1max` >= { $level } OR `t1max` = 99 ) AND
* `level` = { $razdel }
*
* Пидорасы !
*/
$fict = mysql_query ( " SELECT * FROM `zayavka` WHERE " . (( $level != null ) ? " ((`t1min` <= ' { $level } ' OR `t1min` = '99') AND (`t1max` >= ' { $level } ' OR `t1max` = '99') " . (( $razdel == 4 ) ? " AND (`t2min` <= ' { $level } ' OR `t2min` = '99') AND (`t2max` >= ' { $level } ' OR `t2max` = '99') " : " " ) . " ) AND " : " " ) . " `level` = { $razdel } " . (( $id != null ) ? " AND `id` = { $id } " : " " ) . " ORDER BY `podan` DESC " );
while ( $row = mysql_fetch_array ( $fict )) {
if (( $row [ 'start' ] + 300 ) < time ()) {
if ( mysql_query ( " DELETE FROM `zayavka` WHERE `id` = ' { $row [ 'id' ] } ' LIMIT 1 " )) {
$team1 = $this -> fteam ( $row [ 'team1' ]);
foreach ( $team1 as $k => $v ) {
mysql_query ( " UPDATE `users` SET `zayavka` = '0' WHERE `id` = { $v } " );
}
$team2 = $this -> fteam ( $row [ 'team2' ]);
foreach ( $z [ $zay ][ 'team2' ] as $k => $v ) {
mysql_query ( " UPDATE `users` SET `zayavka` = '0' WHERE `id` = { $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 = 1 , $id , $zay , $r )
{
global $user ;
$owntravma = mysql_fetch_array ( mysql_query ( " SELECT `id`, `type` FROM `effects` WHERE `owner` = " . $id . " AND (`type` = 12 OR `type` = 13) " ));
$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 ( $user [ 'zayavka' ] != 0 ) {
return " Вы находитесь в заявке " ;
}
if ( $user [ 'hp' ] < $user [ 'maxhp' ] * 0.33 ) {
return " Вы слишком ослаблены для боя, восстановитесь. " ;
}
if ( ! $z ) {
return " Эта заявка не может быть принята Вами. " ;
}
if ( $this -> user_status ( $id ) != 0 ) {
return " Эта заявка не может быть принята Вами. " ;
}
if ( $z [ $zay ][ 'type' ] == 3 || $z [ $zay ][ 'type' ] == 5 ) {
} else {
if ( $team == 1 ) {
$teamz = 2 ;
} else {
$teamz = 1 ;
}
foreach ( $z [ $zay ][ 'team' . $teamz ] as $v ) {
$toper = mysql_fetch_array ( mysql_query ( " SELECT `klan`, `align` FROM `users` WHERE `id` = ' { $v } ' LIMIT 1 " ));
if ( $toper [ 'klan' ] > 0 ) {
if (( int ) $user [ 'klan' ] == ( int ) $toper [ 'klan' ]) {
return " Чтите честь Ваших сокланов. " ;
}
}
if (( int ) $user [ 'align' ] == 1 ) {
if (( int ) $toper [ 'align' ] == 1 ) {
return " Чтите честь Паладинов. " ;
}
}
if ( $user [ 'align' ] == 6 ) {
if ( $toper [ 'align' ] == 6 ) {
return " Н е предавайте свет." ;
}
}
if ( $user [ 'align' ] == 3 ) {
if ( $toper [ 'align' ] == 3 ) {
return " Н е предавайте тьму." ;
}
}
}
}
if ( $z [ $zay ][ 't' . $team . 'min' ] == 99 ) {
$toper = $z [ $zay ][ 'team' . $team ][ 0 ];
$toper = mysql_fetch_array ( mysql_query ( " SELECT `id`, `login`, `align`, `klan`, `level` FROM `users` WHERE `id` = ' { $toper } ' LIMIT 1 " ));
if ( $toper [ 'klan' ] != '' ) {
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 " Вы приняли заявку на бой. " ;
2019-06-21 17:42:46 +00:00
} else return 'addteam(): database error!' ;
2018-11-06 01:28:10 +00:00
}
function delteam ( $team = 2 , $id , $zay , $r )
{
$z = $this -> getlist ( $r , null , $zay );
if ( $z [ $zay ][ 'level' ] > 3 || $z [ $zay ][ 'level' ] == null ) {
return " Ай-ай-ай! " ;
}
foreach ( $z [ $zay ][ 'team' . $team ] 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 " Вы отозвали запрос " ;
2019-06-21 17:42:46 +00:00
} else return 'delteam(): database error!' ;
2018-11-06 01:28:10 +00:00
}
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 " Ошибка! " ;
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
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? Что это? Где это?
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
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 ) {
mysql_query ( " UPDATE `users` SET `zayavka` = 0 WHERE `id` = { $v } " );
}
}
if ( count ( $z [ $zay ][ 'team2' ]) > 0 ) {
foreach ( $z [ $zay ][ 'team2' ] as $k => $v ) {
mysql_query ( " UPDATE `users` SET `zayavka` = 0 WHERE `id` = { $v } " );
}
}
return 'Вы отозвали заявку.' ;
2019-06-21 17:42:46 +00:00
} else return 'delzayavka(): database error!' ;
2018-11-06 01:28:10 +00:00
}
function showfiz ( $row )
{
global $user ;
$rr = " <input type= \" radio \" " . (( in_array ( $user [ 'id' ], $row [ 'team1' ]) || in_array ( $user [ 'id' ], $row [ 'team2' ]) || $row [ 'team2' ]) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" /><font class=date> { $row [ 'podan' ] } </font> " ;
foreach ( $row [ 'team1' ] as $k => $v ) {
$rr .= nick :: id ( $v ) -> full ( 1 );
}
if ( $row [ 'team2' ]) {
$rr .= " <i>против</i> " ;
foreach ( $row [ 'team2' ] as $k => $v ) {
$rr .= nick :: id ( $v ) -> full ( 1 );
}
}
$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 ;
}
function showgroup ( $row )
{
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' ] } " ;
}
$rr = " <input type= \" radio \" " . (( in_array ( $user [ 'id' ], $row [ 'team1' ]) || in_array ( $user [ 'id' ], $row [ 'team2' ])) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" ><font class=date> { $row [ 'podan' ] } </font> <b> { $row [ 't1c' ] } </b>( { $range1 } ) ( " ;
foreach ( $row [ 'team1' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
$rr .= nick :: id ( $v ) -> full ( 1 );
}
$rr .= " ) <i>против</i> <b> { $row [ 't2c' ] } </b>( { $range2 } )( " ;
foreach ( $row [ 'team2' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
$rr .= nick :: id ( $v ) -> full ( 1 );
}
if ( count ( $row [ 'team2' ]) == 0 ) {
$rr .= " <i>группа не набрана</i> " ;
}
if ( $row [ 'blood' ] && $row [ 'type' ] == 5 ) {
$rr .= " <img src= \" i/fighttype6.gif \" width= \" 20 \" height= \" 20 \" /> " ;
}
$a = db :: c () -> query ( 'SELECT `align`,`admin` FROM `users` WHERE `id` = ?i' , $user [ 'id' ]) -> fetch_assoc ();
$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> " ;
if (( $a [ 'align' ] > 1.4 && $a [ 'align' ] < 2 ) || $a [ 'admin' ] == 1 ) {
$rr .= " <a href='?zid= { $row [ 'id' ] } &do=clear'><small>Удалить комментарий</small></a><br /> " ;
} else {
$rr .= " <br /> " ;
}
return $rr ;
}
function showhaos ( $row )
{
global $user ;
$rr = " <input type= \" radio \" " . (( in_array ( $user [ 'id' ], $row [ 'team1' ]) || in_array ( $user [ 'id' ], $row [ 'team2' ])) ? " disabled " : " " ) . " name= \" gocombat \" value= \" { $row [ 'id' ] } \" /><font class= \" date \" > { $row [ 'podan' ] } </font> ( " ;
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 .= " <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> " ;
if ( $user [ 'admin' ] == 1 ) {
$rsr = ' | <a href=\'?level=haos&zid=' . $row [ 'id' ] . '&del=true\'>Удалить заявку</a>' ;
} else {
$rsr = '' ;
}
if (( $user [ 'align' ] > 1.4 && $user [ 'align' ] < 2 ) || $user [ 'admin' ] == 1 ) {
$rr .= " <small><a href='?zid= { $row [ 'id' ] } &do=clear'>Удалить коммнтарий</a> $rsr </small><br /> " ;
} else {
$rr .= " <br /> " ;
}
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('<font color=red>Внимание!</font> Ваш бой не может начаться по причине <b>Группа не набрана</b>.', '{[]}' . 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 = mysql_fetch_array ( mysql_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` = ' " . $z [ 'team1' ][ $i ] . " ' LIMIT 1 " ));
} else {
$bt = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `prototype` FROM `bots` WHERE `id` = "' . $z [ 'team1' ][ $i ] . '"' ));
$gamer = mysql_fetch_array ( mysql_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` = ' " . $bt [ 'prototype' ] . " ' LIMIT 1 " ));
}
$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('<font color=red>Внимание!</font> Ваш бой не может начаться по причине "Группа не набрана".', '{[]}' . 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 = " <b> " ;
foreach ( $z [ 'team1' ] as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
}
$rr .= nick :: id ( $v ) -> full ( 1 );
//TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[3]
#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 .= " , " ;
}
$rr .= nick :: id ( $v ) -> full ( 1 );
//TODO Написать добавлялку в чат для определённого чеговека. Плясать от AddChatSystem().[4]
#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_ ) {
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 ( " <script>location.href='fbattle.php';</script> " );
}
}
2018-01-28 16:40:49 +00:00
}
$zay = new zayavka ;
header ( " Cache-Control: no-cache " );
2019-06-21 18:56:59 +00:00
if ( ! empty ( $_POST [ 'open' ])) {
2018-11-06 01:28:10 +00:00
$f = fopen ( " /tmp/zayavka/ " . $user [ 'id' ] . " .txt " , " w+ " );
fputs ( $f , time ());
fclose ( $f );
2018-01-28 16:40:49 +00:00
}
?>
< HTML >
2018-11-06 01:28:10 +00:00
< HEAD >
< link rel = stylesheet href = " css/main.css " >
< meta charset = utf - 8 " >
< 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 >
< script >
function refreshPeriodic () {
2019-06-21 18:55:25 +00:00
< ? php if ( is_null ( $logs )) : ?>
location . href = 'zayavka.php?level=<?= $level ?>&tklogs=<?= $tklogs ?>&logs=<?= $logs ?>' ;
2018-11-06 01:28:10 +00:00
< ? endif ; ?>
}
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
timerID = setTimeout ( " refreshPeriodic() " , 30000 );
</ script >
</ HEAD >
< body onload = " top.setHP(<?= $user['hp'] ?>,<?= $user['maxhp'] ?>,<?php if (! $user['battle'] ) {
echo " 100 " ;
} else {
echo " 0 " ;
} ?> );">
< TABLE width = 100 % cellspacing = 1 cellpadding = 1 >
< FORM METHOD = POST name = F1 >
< TR >
< TD colspan = 5 >
2019-06-21 18:55:25 +00:00
< ? php if ( ! empty ( $level )) echo nick ( $user ); ?>
2018-11-06 01:28:10 +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 >< ? php if ( $user [ 'room' ] != 101 ) echo 'Бои:' ; else echo 'Разделы:' ; ?> </B></TD>
< ? php //FIXME Убрать этот адов пиздец, когда одни и те же ссылки ведут в разные места и называются по разному. Или нормально понять зачем это. ?>
2019-06-21 18:43:56 +00:00
< TD class =< ? = ( $level == 'begin' ) ? " s " : " m " ?> ><?php if ($user['room'] != 101) echo("<A HREF=\"zayavka.php?level=begin&".mt_rand()."\">Новичков</A></TD>"); else echo 'Зал Славы Тьмы</TD>' ?>
< TD class =< ? = ( $level == 'fiz' ) ? " s " : " m " ?> ><?php if ($user['room'] != 101) echo("<A HREF=\"zayavka.php?level=fiz&".mt_rand()."\">Физические</A></TD>"); else echo 'Зал Славы Света</TD>' ?>
< TD class =< ? = ( $level == 'dgv' ) ? " s " : " m " ?> ><?php if ($user['room'] != 101) echo("<A HREF=\"zayavka.php?level=dgv&".mt_rand()."\">Договорные</A></TD>"); else echo 'Квесты</TD>' ?>
< TD class =< ? = ( $level == 'group' ) ? " s " : " m " ?> ><A HREF="zayavka.php?level=group&<?= mt_rand() ?>">
2018-11-06 01:28:10 +00:00
< ? php if ( $user [ 'room' ] != 101 ) {
2019-06-21 17:35:40 +00:00
echo 'Групповые' ;
2018-11-06 01:28:10 +00:00
} else {
2019-06-21 17:35:40 +00:00
echo '<span style="color:red; font-weight: bold;">Тьма vs Свет</span>' ;
2018-11-06 01:28:10 +00:00
}; ?>
</ A ></ TD >
2019-06-21 18:43:56 +00:00
< TD class =< ? = ( $level == 'haos' ) ? " s " : " m " ?> ><?php if ($user['room'] != 101) echo("<A HREF=\"zayavka.php?level=haos&".mt_rand()."\">Хаотичные</A></TD>"); else echo 'В разработке</TD>' ?>
2019-06-21 17:35:40 +00:00
< TD class =< ? = ( input :: check ( 'tklogs' ) == '1' ) ? " s " : " m " ?> ><A HREF="zayavka.php?tklogs=1&<?= mt_rand() ?>">Текущие</A>
2018-11-06 01:28:10 +00:00
</ TD >
2019-06-21 18:55:25 +00:00
< TD class =< ? = ( ! is_null ( $logs )) ? " s " : " m " ?> ><A HREF="zayavka.php?logs=<?= date("d.m.y") ?>&<?= mt_rand() ?>">Завершенные</A></TD>
2018-11-06 01:28:10 +00:00
</ TR >
</ TABLE >
< TABLE width = 100 % cellspacing = 0 cellpadding = 0 >
< TR >
< TD valign = top >
< ? php
2019-06-21 18:55:25 +00:00
if ( ! in_array ( $user [ 'room' ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 15 , 16 , 19 , 101 ]) AND empty ( $logs ) AND empty ( $tklogs )) die ( err ( 'В этой комнате невозможно подавать заявки!' ));
2018-11-06 01:28:10 +00:00
// if ($user['room'] != 1 && $user['room'] != 2 && $user['room'] != 3 && $user['room'] != 4 &&
// $user['room'] != 5 && $user['room'] != 6 && $user['room'] != 7 && $user['room'] != 9 &&
// $user['room'] != 10 && $user['room'] != 15 && $user['room'] != 16 && $user['room'] != 19 &&
2019-06-21 18:55:25 +00:00
// $user['room'] != 8 && $user['room'] != 101 && !$tklogs && !$logs) {
2018-11-06 01:28:10 +00:00
// echo "<BR><BR><BR><CENTER><B>В этой комнате невозможно подавать заявки</b></CENTER>";
// die();
// }
2019-06-21 18:55:25 +00:00
if ( ! $level && ! $tklogs && ! $logs ) {
2018-11-06 01:28:10 +00:00
echo " <BR><BR><BR><CENTER><B>Выберите раздел</b></CENTER> " ;
}
2019-06-21 18:55:25 +00:00
if ( $level == 'begin' ) {
2018-11-06 01:28:10 +00:00
if ( $user [ 'level' ] > 0 ) {
die ( " <BR><BR><BR><CENTER><B>Вы уже выросли из ползунков ;)</b></CENTER> " );
}
//FIXME: Всем функциям прописать return и отказаться от лишних строк.
echo " <font color=red><b> " ;
if ( $_POST [ 'open' ]) {
echo $zay -> addzayavka ( 0 , $_POST [ 'timeout' ], 1 , 1 , $_POST [ 'k' ], $user [ 'level' ], 1 , $user [ 'level' ], 21 , '' , $user [ 'id' ], 1 , 0 );
die ( " <script>document.location='zayavka.php?level=begin';</script> " );
}
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 ( 2 , $user [ 'id' ], $user [ 'zayavka' ], 1 );
}
if ( $_POST [ 'cansel' ]) {
$z = $zay -> getlist ( 1 , null , $user [ 'zayavka' ]);
echo $zay -> delteam ( 2 , $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 ( " <script>document.location='zayavka.php?level=begin';</script> " );
}
if ( $_POST [ 'gofi' ]) {
$zay -> battlestart ( $user [ 'id' ], $user [ 'zayavka' ], 1 );
}
echo " </b></font> " ;
echo '<table><tr><td>' ;
$z = $zay -> getlist ( 1 , null , $user [ 'zayavka' ]);
if ( $zay -> user_status ( $user [ 'id' ]) == 0 ) {
//if ($z[$user['zayavka']]['level'] == 1)
{
echo '<FIELDSET><LEGEND><B>Подать заявку на бой</B> </LEGEND>Таймаут <SELECT NAME=timeout><OPTION value=3>3 мин.<OPTION value=4>4 мин.<OPTION value=5>5 мин.<OPTION value=7>7 мин.<OPTION value=10 selected>10 мин.</SELECT> Тип боя <SELECT NAME=k><OPTION value=1>с оружием<OPTION value=4>кулачный</SELECT><INPUT TYPE=submit name=open value="Подать заявку"> </FIELDSET>' ;
};
}
if ( $zay -> user_status ( $user [ 'id' ]) == 1 ) {
if ( count ( $z [ $user [ 'zayavka' ]][ 'team2' ]) > 0 ) {
echo " <B><font color=red>Внимание! " . nick :: id ( $z [ $user [ 'zayavka' ]][ 'team2' ][ 0 ]) -> full ( 1 ) . " принял заявку на бой, нужно отказать или принять вызов.</font></b> <input type=submit value='Битва!' name=gofi> <input type=submit value='Отказать' name=cansel> " ;
} else {
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 1 )
echo " Заявка на бой подана, ожидаем противника. <input type=submit name=back value='Отозвать заявку'> " ;
$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 );
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`
2018-01-28 16:40:49 +00:00
(
`id` , `coment` , `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `clone`
)
VALUES
(
2018-11-06 01:28:10 +00:00
NULL , '' , '" . 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 ( " INSERT INTO `logs` (`id`,`log`) VALUES(' { $id } ','Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR>'); " );
mysql_query ( " UPDATE `bots` SET `battle` = { $id } WHERE `id` = { $bot } LIMIT 1; " );
$rr = " <b> " . nick :: id ( $user [ 'id' ]) -> full ( 1 ) . " </b> и <b> " . nick :: id ( $bot ) -> full ( 1 ) . " </b> " ;
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $user [ 'id' ] } ; " );
die ( " <script>location.href='fbattle.php';</script> " );
///=======================================================================================
} else {
echo $user [ 'level' ];
}
if ( $user [ 'level' ] == 0 ) {
echo " или <input type=button onclick= \" location.href='zayavka.php?level=begin&trainstart=1'; \" value= \" Начать тренировочный бой \" > " ;
}
}
}
}
if ( $zay -> user_status ( $user [ 'id' ]) == 2 ) {
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 1 )
echo " Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'> " ;
}
echo '</td></tr></table></TD><TD align=right valign=top rowspan=2><INPUT TYPE=submit name=tmp value="Обновить">' ;
echo '<tr><td><INPUT TYPE=hidden name=level value=begin><INPUT TYPE=submit value="Принять вызов" NAME=confirm2><BR>' ;
if ( $z = $zay -> getlist ( 1 ))
foreach ( $z as $k => $v ) {
echo $zay -> showfiz ( $v );
}
echo '<INPUT TYPE=submit value="Принять вызов" NAME=confirm2></TD></TR></TABLE>' ;
}
2019-06-21 18:55:25 +00:00
if ( $level == 'fiz' ) {
2018-11-06 01:28:10 +00:00
if ( $user [ 'level' ] == 0 ) {
die ( " <BR><BR><BR><CENTER><B>Физические бои доступны с 1 уровня.</b></CENTER> " );
}
echo " <font color=red><b> " ;
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 ;
}
echo $zay -> addzayavka ( 0 , $_POST [ 'timeout' ], 1 , 1 , $_POST [ 'k' ], $user [ 'level' ], 1 , $user [ 'level' ], 21 , '' , $user [ 'id' ], 2 , 0 , $blood );
die ( " <script>document.location='zayavka.php?level=fiz';</script> " );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'back' ])) {
2018-11-06 01:28:10 +00:00
unlink ( " /tmp/zayavka/ " . $user [ 'id' ] . " .txt " );
echo $zay -> delzayavka ( $user [ 'id' ], $user [ 'zayavka' ], 2 , 0 );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'back2' ])) {
2018-11-06 01:28:10 +00:00
$z = $zay -> getlist ( 2 , null , $user [ 'zayavka' ]);
AddChatSystem ( 'Внимание!' . nick :: id ( $user [ 'id' ]) -> short () . ' отозвал заявку.' );
echo $zay -> delteam ( 2 , $user [ 'id' ], $user [ 'zayavka' ], 2 );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'cansel' ])) {
2018-11-06 01:28:10 +00:00
$z = $zay -> getlist ( 2 , null , $user [ 'zayavka' ]);
echo $zay -> delteam ( 2 , $z [ $user [ 'zayavka' ]][ 'team2' ][ 0 ], $user [ 'zayavka' ], 2 );
AddChatSystem ( 'Внимание!' . nick :: id ( $user [ 'id' ]) -> short () . ' отказался от поединка.' );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'confirm2' ]) AND empty ( $user [ 'zayavka' ])) {
2018-11-06 01:28:10 +00:00
$z = $zay -> getlist ( 2 , null , $_REQUEST [ 'gocombat' ]);
$toper = $z [ $_REQUEST [ 'gocombat' ]][ 'team1' ][ 0 ];
$toper = mysql_fetch_array ( mysql_query ( " SELECT `klan` FROM `users` WHERE `id`=' { $toper } ' LIMIT 1; " ));
if ( $user [ 'klan' ] != $toper [ 'klan' ] || $user [ 'klan' ] == '' ) {
AddChatSystem ( 'Внимание!' . nick :: id ( $user [ 'id' ]) -> short () . ' принял заявку, нужно принять вызов или отказать.' );
}
echo $zay -> addteam ( 2 , $user [ 'id' ], $_REQUEST [ 'gocombat' ], 2 );
echo " </b></font><BR>Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'> " ;
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'gofi' ])) {
2018-11-06 01:28:10 +00:00
$zay -> battlestart ( $user [ 'id' ], $user [ 'zayavka' ], 2 );
}
echo " </b></font> " ;
echo '<table cellspacing=0 cellpadding=0><tr><td>' ;
if ( $zay -> user_status ( $user [ 'id' ]) == 0 ) {
echo '<FIELDSET><LEGEND><B>Подать заявку на бой</B> </LEGEND>Таймаут <SELECT NAME=timeout><OPTION value=3>3 мин.<OPTION value=4>4 мин.<OPTION value=5>5 мин.<OPTION value=7>7 мин.<OPTION value=10 selected>10 мин.</SELECT> Тип боя <SELECT NAME=k><OPTION value=1>с оружием<OPTION value=4>кулачный<OPTION value=6>кровавый</SELECT><INPUT TYPE=submit name=open value="Подать заявку"> </FIELDSET>' ;
}
$z = $zay -> getlist ( 2 , null , $user [ 'zayavka' ]);
if ( $zay -> user_status ( $user [ 'id' ]) == 1 ) {
if ( count ( $z [ $user [ 'zayavka' ]][ 'team2' ]) > 0 ) {
echo " <B><font color=red>Внимание! " . nick :: id ( $z [ $user [ 'zayavka' ]][ 'team2' ][ 0 ]) -> full ( 1 ) . " принял заявку на бой, нужно отказать или принять вызов.</font></b> <input type=submit value='Битва!' name=gofi> <input type=submit value='Отказать' name=cansel> " ;
} else {
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 2 ) {
echo " Заявка на бой подана, ожидаем противника. <input type=submit name=back value='Отозвать заявку'> " ;
$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`
2018-01-28 16:40:49 +00:00
( `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `clone`
)
VALUES
2018-11-06 01:28:10 +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 " );
$rr = " <b> " . nick :: id ( $user [ 'id' ]) -> full ( 1 ) . " </b> и <b> " . nick :: id ( $bot ) -> full ( 1 ) . " </b> " ;
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $user [ 'id' ] } ; " );
die ( " <script>location.href='fbattle.php';</script> " );
}
$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 " или <input type=button onclick= \" location.href='zayavka.php?level=fiz&trainstart=1'; \" value= \" Начать тренировочный бой \" > " ;
}
}
}
}
}
if ( $zay -> user_status ( $user [ 'id' ]) == 2 ) {
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 2 )
echo " Ожидаем подтверждения боя. <input type=submit name=back2 value='Отозвать заявку'> " ;
}
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 [ 'level' ] . '" ' . (( $_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>' ;
echo '<tr><td><INPUT TYPE=hidden name=level value=fiz><INPUT TYPE=submit value="Принять вызов" NAME=confirm2><BR>' ;
if ( $z = $zay -> getlist ( 2 , $_SESSION [ 'view' ]))
foreach ( $z as $k => $v ) {
echo $zay -> showfiz ( $v );
}
echo '<INPUT TYPE=submit value="Принять вызов" NAME=confirm2></TD></TR></TABLE>' ;
}
2019-06-21 18:55:25 +00:00
if ( $level == 'group' ) {
2018-11-06 01:28:10 +00:00
if ( $user [ 'level' ] < 2 ) {
die ( " <BR><BR><BR><CENTER><B>Групповые бои доступны с 2 уровня.</b></CENTER> " );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'open1' ]) AND empty ( $user [ 'zayavka' ])) {
2018-11-06 01:28:10 +00:00
// room 101 - противостояние сил
echo ' < TABLE >< TR >< TD >
2018-01-28 16:40:49 +00:00
< H3 > Подать заявку на групповой бой </ H3 >
Начало боя через < SELECT NAME = startime >
< option value = 600 > 10 минут
< option value = 900 selected > 15 минут
< option value = 1800 > 30 минут
< option value = 2700 > 45 минут
< option value = 3600 > 1 час
</ SELECT >
& nbsp ; & nbsp ; & nbsp ; & nbsp ; Таймаут < SELECT NAME = timeout >< OPTION value = 3 > 3 мин .< OPTION value = 4 > 4 мин .< OPTION value = 5 selected > 5 мин .< OPTION value = 7 > 7 мин .< OPTION value = 10 > 10 мин .</ SELECT >
< BR >< BR >
Ваша команда < INPUT TYPE = text NAME = nlogin1 size = 3 maxlength = 2 > бойцов < BR > ' ;
2018-11-06 01:28:10 +00:00
if ( $user [ 'room' ] != 101 )
echo ' Уровни союзников & nbsp ; & nbsp ; < SELECT NAME = levellogin1 >
2018-01-28 16:40:49 +00:00
< 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 > ' ;
2018-11-06 01:28:10 +00:00
else echo '<INPUT TYPE=hidden value=0 NAME=levellogin1>' ;
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
echo ' < BR >< BR >
2018-01-28 16:40:49 +00:00
Противники & nbsp ; & nbsp ; < INPUT TYPE = text NAME = nlogin2 size = 3 maxlength = 2 > бойцов < BR > ' ;
2018-11-06 01:28:10 +00:00
if ( $user [ 'room' ] != 101 )
echo ' Уровни противников < SELECT NAME = levellogin2 >
2018-01-28 16:40:49 +00:00
< 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 > ' ;
2018-11-06 01:28:10 +00:00
else echo '<INPUT TYPE=hidden value=0 NAME=levellogin1>' ;
echo '<BR>' ;
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
if ( $user [ 'room' ] != 101 )
echo ' < INPUT TYPE = checkbox NAME = k > Кулачный бой < BR >
2018-01-28 16:40:49 +00:00
< INPUT TYPE = checkbox NAME = travma > Бой без правил ( < font class = dsc > проигравшая сторона получает инвалидность </ font > ) < BR > ' ;
2018-11-06 01:28:10 +00:00
if ( $user [ 'room' ] == 101 )
echo ' < BR >< BR >
2018-01-28 16:40:49 +00:00
Деньги & nbsp ; & nbsp ; < INPUT TYPE = text NAME = nmoney size = 8 maxlength = 8 > кр .< BR >
Опыт & nbsp ; & nbsp ; < INPUT TYPE = text NAME = nexp size = 8 maxlength = 8 > единиц < BR > ' ;
2018-11-06 01:28:10 +00:00
echo ' Комментарий к бою < INPUT TYPE = text NAME = cmt maxlength = 40 size = 40 >
2018-01-28 16:40:49 +00:00
</ 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 > ' ;
2018-11-06 01:28:10 +00:00
die ();
}
2018-01-28 16:40:49 +00:00
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'goconfirm' ]) AND empty ( $user [ 'zayavka' ])) {
2018-11-06 01:28:10 +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 > ' ;
2018-11-06 01:28:10 +00:00
foreach ( $z [ $_POST [ 'gocombat' ]][ 'team1' ] as $k => $v ) {
if ( $k != 0 ) $rr .= " <BR> " ;
echo nick :: id ( $v ) -> full ( 1 );
}
echo '</TD><TD align=center>' ;
foreach ( $z [ $_POST [ 'gocombat' ]][ 'team2' ] as $k => $v ) {
if ( $k != 0 ) $rr .= " <BR> " ;
echo nick :: id ( $v ) -> full ( 1 );
}
echo '</TD></TR><TR>' ;
$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 '<TD align=center><INPUT TYPE=submit name=confirm1 value="Я за этих!"></TD>' ;
else echo '<TD align=center>Силы Х а о с а </TD>' ;
} else echo '<TD align=center>Войдите в комнату "Противостояние", чтобы принять эту заявку!</TD>' ;
} else {
if (( $user [ 'align' ] == 6 ) || ( $user [ 'align' ] == 2.1 ) || ( $user [ 'align' ] == 2.99 ) || (( $user [ 'align' ] > 7 ) && ( $user [ 'align' ] < 8 )) || ( $user [ 'align' ] == 2 )) {
echo '<TD align=center><INPUT TYPE=submit name=confirm1 value="Я за Свет!"></TD>' ;
};
if (( $user [ 'align' ] == 2.1 ) || ( $user [ 'align' ] == 6 )) {
echo '<TD align=center></TD>' ;
};
2018-01-28 16:40:49 +00:00
};
2018-11-06 01:28:10 +00:00
if ( $user [ 'room' ] != 101 ) {
if ( $vs_test [ 'versus' ] == 0 ) {
echo '<TD align=center><INPUT TYPE=submit name=confirm2 value="Я за этих!"></TD>' ;
} else echo '<TD align=center></TD>' ;
} else {
if (( $user [ 'align' ] == 2.2 ) || ( $user [ 'align' ] == 3 )) {
echo '<TD align=center></TD>' ;
};
if (( $user [ 'align' ] == 3 ) || ( $user [ 'align' ] == 2.2 ) || ( $user [ 'align' ] == 2.99 ) || (( $user [ 'align' ] > 7 ) && ( $user [ 'align' ] < 8 )) || ( $user [ 'align' ] == 2 )) {
echo '<TD align=center><INPUT TYPE=submit name=confirm2 value="Я за Тьму!"></TD>' ;
};
};
2018-01-28 16:40:49 +00:00
2018-11-06 01:28:10 +00:00
echo '</TR></TABLE><INPUT TYPE=hidden name=gocombat value="' . $_POST [ 'gocombat' ] . '"><INPUT TYPE=hidden name=level value=group>' ;
die ();
}
echo " <font color=red><b> " ;
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 " </font></b><INPUT TYPE=hidden name=level value=group> " ;
echo '<table cellspacing=0 cellpadding=0><tr><td>' ;
if ( $zay -> user_status ( $user [ 'id' ]) == 0 )
if (( $user [ 'room' ] == 101 ) && ( $user [ 'align' ] != 2.2 ) && ( $user [ 'align' ] != 2.1 )) {
echo " <BR><CENTER><B>Свет и Тьма не снизойдут к вашей просьбе начать новый бой</b></CENTER> " ;
} else {
echo '<INPUT TYPE=hidden name=level value=group><INPUT TYPE=submit value="Подать новую заявку" name=open1>' ;
}
if ( $zay -> user_status ( $user [ 'id' ]) != 0 ) {
$z = $zay -> getlist ( 4 , null , $user [ 'zayavka' ]);
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 4 ) {
echo " <B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round (( $z [ $user [ 'zayavka' ]][ 'start' ] - time ()) / 60 , 1 ) . " мин. " ;
}
}
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 [ 'level' ] . '" ' . (( $_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>' ;
echo '<tr><td width=85%>' ;
echo '<BR><INPUT TYPE=submit value="Принять участие" NAME=goconfirm><BR>' ;
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 '<INPUT TYPE=submit value="Принять участие" NAME=goconfirm></td></tr></table>' ;
}
2019-06-21 18:43:56 +00:00
if ( $level == 'haos' ) {
2018-11-06 01:28:10 +00:00
if ( $user [ 'level' ] < 2 ) {
die ( " <BR><BR><BR><CENTER><B>Хаотичные бои доступны с 2 уровня.</b></CENTER> " );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'open' ]) AND empty ( $user [ 'zayavka' ])) {
2018-11-06 01:28:10 +00:00
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 );
}
2019-06-21 19:01:06 +00:00
if ( ! empty ( $_POST [ 'confirm2' ])) {
2018-11-06 01:28:10 +00:00
echo " <span class='redalert'> " . $zay -> addteam ( 1 , $user [ 'id' ], $_REQUEST [ 'gocombat' ], 5 ) . " </span> " ;
}
echo '<table cellspacing=0 cellpadding=0><tr><td>' ;
if ( $zay -> user_status ( $user [ 'id' ]) == 0 ) {
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>' ;
}
if ( $zay -> user_status ( $user [ 'id' ]) != 0 ) {
$z = $zay -> getlist ( 5 , null , $user [ 'zayavka' ]);
if ( $z [ $user [ 'zayavka' ]][ 'level' ] == 5 )
echo " <B>Ожидаем начала группового боя...</B><BR>Бой начнется через: " . round (( $z [ $user [ 'zayavka' ]][ 'start' ] - time ()) / 60 , 1 ) . " мин. " ;
}
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 [ 'level' ] . '" ' . (( $_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>' ;
echo '<tr><td width=85%><INPUT TYPE=hidden name=level value=haos><INPUT TYPE=submit value="Принять участие" NAME=confirm2><BR>' ;
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 '<INPUT TYPE=submit value="Принять участие" NAME=confirm2></TD></TR></TABLE>' ;
//print_r($_POST);
}
2019-06-21 18:55:25 +00:00
if ( ! is_null ( $tklogs )) {
2018-11-06 01:28:10 +00:00
$t1 = floor ( time () - 900 );
2019-06-21 18:43:56 +00:00
$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 ()) {
2018-11-06 01:28:10 +00:00
echo " <span class=date> { $row [ 'date' ] } </span> " ;
$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 " <img src='i/fighttype { $row [ 'type' ] } .gif'> <a href='logs.php?log= { $row [ 'id' ] } ' target=_blank>»»</a><br /> " ;
}
}
2019-06-21 18:55:25 +00:00
if ( ! is_null ( $logs )) {
2018-11-06 01:28:10 +00:00
echo ' < TABLE width = 100 % cellspacing = 0 cellpadding = 0 >< TR >
< TD valign = top >& nbsp ; < A HREF = " zayavka.php?logs=' .
2019-06-21 18:55:25 +00:00
date ( " d.m.y " , mktime ( 0 , 0 , 0 , substr ( $logs , 3 , 2 ), substr ( $logs , 0 , 2 ) - 1 , " 20 " . substr ( $logs , 6 , 2 )))
2018-11-06 01:28:10 +00:00
. '&filter=' . (( $_REQUEST [ 'filter' ]) ? $_REQUEST [ 'filter' ] : $user [ 'login' ]) . ' " >« Предыдущий день</A></TD>
2019-06-21 18:55:25 +00:00
< TD valign = top align = center >< H3 > Записи о завершенных боях за ' . (($logs != 1) ? "{$logs}" : "" . date("d.m.y")) . ' </ H3 ></ TD >
2018-11-06 01:28:10 +00:00
< TD valign = top align = right >< A HREF = " zayavka.php?logs=' .
2019-06-21 18:55:25 +00:00
date ( " d.m.y " , mktime ( 0 , 0 , 0 , substr ( $logs , 3 , 2 ), substr ( $logs , 0 , 2 ) + 1 , " 20 " . substr ( $logs , 6 , 2 )))
2018-11-06 01:28:10 +00:00
. '&filter=' . (( $_REQUEST [ 'filter' ]) ? $_REQUEST [ 'filter' ] : $user [ 'login' ]) . ' " >Следующий день »</A> </TD>
2019-06-21 18:55:25 +00:00
</ TR >< TR >< TD colspan = 3 align = center > Показать только бои персонажа : < INPUT TYPE = text NAME = filter value = " ' . (( $_REQUEST['filter'] ) ? $_REQUEST['filter'] : $user['login'] ) . ' " > за < INPUT TYPE = text NAME = logs size = 12 value = " ' . (( $logs != 1) ? " { $logs } " : " " . date( " d . m . y " )) . ' " > < INPUT TYPE = submit value = " фильтр! " ></ TD >
2018-01-28 16:40:49 +00:00
</ TR ></ TABLE > ' ;
2018-11-06 01:28:10 +00:00
$u = mysql_fetch_array ( mysql_query ( " SELECT `id` FROM `users` WHERE `login` = ' " . (( $_REQUEST [ 'filter' ]) ? " { $_REQUEST [ 'filter' ] } " : " { $user [ 'login' ] } " ) . " ' LIMIT 1 " ));
2019-06-21 18:55:25 +00:00
$data = mysql_query ( " SELECT * FROM `battle` WHERE ((`t1` LIKE '%; { $u [ 0 ] } ;%' OR `t1` LIKE ' { $u [ 0 ] } ' OR `t1` LIKE ' { $u [ 0 ] } ;%' OR `t1` LIKE '%; { $u [ 0 ] } ') OR (`t2` LIKE '%; { $u [ 0 ] } ;%' OR `t2` LIKE ' { $u [ 0 ] } ' OR `t2` LIKE ' { $u [ 0 ] } ;%' OR `t2` LIKE '%; { $u [ 0 ] } ')) AND `date` LIKE ' " . (( $logs != 1 ) ? " 20 " . substr ( $logs , 6 , 2 ) . " - " . substr ( $logs , 3 , 2 ) . " - " . substr ( $logs , 0 , 2 ) : " " . date ( " Y-m-d " )) . " %' ORDER by `id` DESC " );
2018-11-06 01:28:10 +00:00
while ( $row = @ mysql_fetch_array ( $data )) {
echo " <span class=date> { $row [ 'date' ] } </span> " ;
echo ' ' . $row [ 't1hist' ];
if ( $row [ 'win' ] == 1 ) {
echo '<img src=i/flag.gif>' ;
}
echo " против " ;
echo $row [ 't2hist' ];
if ( $row [ 'win' ] == 2 ) {
echo '<img src=i/flag.gif>' ;
}
if ( $row [ 'type' ] == 10 ) {
$rr = " <IMG SRC= \" i/fighttype6.gif \" WIDTH=20 HEIGHT=20 ALT= \" Кровавый поединок \" > " ;
} elseif ( $row [ 'blood' ] && ( $row [ 'type' ] == 5 OR $row [ 'type' ] == 4 )) {
$rr = " <IMG SRC= \" i/fighttype5.gif \" WIDTH=20 HEIGHT=20 ALT= \" кулачный бой \" ><IMG SRC= \" i/fighttype6.gif \" WIDTH=20 HEIGHT=20 ALT= \" Кровавый поединок \" > " ;
} elseif ( $row [ 'blood' ] && ( $row [ 'type' ] == 2 OR $row [ 'type' ] == 3 OR $row [ 'type' ] == 6 )) {
$rr = " <IMG SRC= \" i/fighttype6.gif \" WIDTH=20 HEIGHT=20 ALT= \" Кровавый поединок \" > " ;
} elseif ( $row [ 'type' ] == 5 OR $row [ 'type' ] == 4 ) {
$rr = " <IMG SRC= \" i/fighttype4.gif \" WIDTH=20 HEIGHT=20 ALT= \" кулачный бой \" > " ;
} elseif ( $row [ 'type' ] == 3 OR $row [ 'type' ] == 2 ) {
$rr = " <IMG SRC= \" i/fighttype3.gif \" WIDTH=20 HEIGHT=20 ALT= \" групповой бой \" > " ;
} elseif ( $row [ 'type' ] == 1 ) {
$rr = " <IMG SRC= \" i/fighttype1.gif \" WIDTH=20 HEIGHT=20 ALT= \" физический бой \" > " ;
}
echo $rr ;
echo " <a href='logs.php?log= { $row [ 'id' ] } ' target=_blank>»»</a><BR> " ;
$i ++ ;
}
if ( $i == 0 ) {
echo '<CENTER><BR><BR><B>В этот день не было боев, или же, летописец опять потерял свитки...</B><BR><BR><BR></CENTER>' ;
}
echo '<HR><BR>' ;
}
db :: c () -> query ( 'UNLOCK TABLES' );
?>
</ form >
2018-01-28 16:40:49 +00:00
</ body >
</ html >