2018-01-28 16:40:49 +00:00
< ? php
ob_start ( " ob_gzhandler " );
2018-03-03 11:50:13 +00:00
session_start ();
if ( $_SESSION [ 'uid' ] == null ) header ( " Location: index.php " );
include_once 'config.php' ;
include_once 'functions.php' ;
2019-06-20 21:48:46 +00:00
$status = null ;
2018-03-03 17:16:13 +00:00
2018-03-03 12:29:30 +00:00
if ( ! $user [ 'klan' ]) {
2018-03-03 11:50:13 +00:00
die ( err ( 'Вы не состоите в клане!' ));
}
2018-03-03 20:56:05 +00:00
$klan = db :: c () -> query ( 'SELECT * FROM `clans` WHERE `id` = ?i' , $user [ 'klan' ]) -> fetch_assoc ();
2018-03-03 12:29:30 +00:00
$polno = [];
2018-03-03 11:50:13 +00:00
$polno = unserialize ( $klan [ 'vozm' ]);
2019-06-20 21:48:46 +00:00
if ( isset ( $_POST [ 'zamok' ])) {
db :: c () -> query ( 'UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?i' , $_SESSION [ 'uid' ]);
$status = " Начат с б о р средств на строительство Кланового Замка. " ;
2019-06-21 14:35:09 +00:00
header ( " Location: clan.php " );
2019-06-20 21:48:46 +00:00
}
if ( isset ( $_POST [ 'kr' ]) && ( $_POST [ 'kolv' ] > 0 )) {
if ( $user [ 'money' ] >= $_POST [ 'kolv' ]) {
db :: c () -> query ( 'UPDATE `clans` SET `zbor` = `zbor` + ?i WHERE `id` = ?i' , $_POST [ 'kolv' ], $user [ 'klan' ]);
db :: c () -> query ( 'UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i' , $_POST [ 'kolv' ], $user [ 'id' ]);
2019-06-21 14:35:09 +00:00
header ( " Location: clan.php " );
2019-06-20 21:48:46 +00:00
} else $status = 'Н е хватает денег!' ;
}
2019-06-20 23:37:39 +00:00
if ( ! empty ( $_POST [ 'login' ]) AND $_POST [ 'action' ] == 'add_member' AND $polno [ $user [ 'id' ]][ 0 ] == 1 ) {
2019-06-22 10:24:29 +00:00
$sok = db :: c () -> query ( 'SELECT `id`,`level`,`klan` FROM `users` WHERE `align` = 0 AND `login` = "?s"' , $_POST [ 'login' ]) -> fetch_assoc ();
2019-06-20 23:37:39 +00:00
$proverka = db :: c () -> query ( 'SELECT 1 FROM `effects` WHERE `type` = 20 AND `owner` = ?i' , $sok [ 'id' ]) -> getNumRows ();
if ( ! $proverka ) echo " Нет проверки! " ;
2019-06-22 10:24:29 +00:00
elseif ( ! empty ( $sok [ 'klan' ])) echo 'Персонаж уже состоит в клане!' ;
2019-06-20 23:37:39 +00:00
elseif ( $sok [ 'level' ] > 0 && $user [ 'money' ] >= 100 ) {
2019-06-20 23:40:39 +00:00
db :: c () -> query ( 'UPDATE `users` SET `money` = `money` - 100 WHERE `id` = ?i' , $_SESSION [ 'uid' ]);
db :: c () -> query ( 'UPDATE `users` SET `status` = "?s", `klan` = "?s", `align` = ?i WHERE `id` = ?i' , 'Боец' , $klan [ 'id' ], $klan [ 'align' ], $sok [ 'id' ]);
2019-06-21 00:02:15 +00:00
$status = 'Персонаж «' . $_POST [ 'login' ] . '» успешно принят в клан.' ;
2019-06-22 10:24:29 +00:00
} else $status = 'Н е хватает денег, или персонажа не существует.' ;
2019-06-20 23:37:39 +00:00
}
2019-06-20 23:55:10 +00:00
if ( ! empty ( $_POST [ 'login' ]) AND $_POST [ 'action' ] == 'remove_member' AND $polno [ $user [ 'id' ]][ 0 ] == 1 ) {
2019-06-20 23:37:39 +00:00
$sok = db :: c () -> query ( 'SELECT `id` FROM `users` WHERE `klan` = "?s" AND `login` = "?s"' , $klan [ 'id' ], $_POST [ 'login' ]) -> fetch_assoc ();
if ( $sok [ 'id' ] != $klan [ 'glava' ] AND $user [ 'money' ] >= 30 ) {
db :: c () -> query ( 'UPDATE `users` SET `money` = `money` - 30 WHERE `id` = ?i' , $_SESSION [ 'uid' ]);
db :: c () -> query ( 'UPDATE `users` SET `klan` = null, `align` = 0 WHERE `id` = ?i' , $sok [ 'id' ]);
2019-06-21 00:02:15 +00:00
$status = 'Персонаж «' . $_POST [ 'login' ] . '» покинул клан.' ;
2019-06-20 23:37:39 +00:00
}
}
2019-06-22 14:05:14 +00:00
if ( ! empty ( $_POST [ 'login' ]) AND $_POST [ 'action' ] == 'change_owner' AND $klan [ 'glava' ] == $_SESSION [ 'uid' ]) {
2019-06-20 23:55:10 +00:00
$sok = db :: c () -> query ( 'SELECT `id` FROM `users` WHERE `klan` = "?s" AND `login` = "?s"' , $klan [ 'id' ], $_POST [ 'login' ]) -> fetch_assoc ();
db :: c () -> query ( 'UPDATE `clans` SET `glava` = ?i WHERE `id` = ?i' , $sok [ 'id' ], $klan [ 'id' ]);
db :: c () -> query ( 'UPDATE `users` SET `status` = null WHERE `id` = ?i' , $sok [ 'id' ]);
db :: c () -> query ( 'UPDATE `users` SET `status` = "?s" WHERE `id` = ?i' , 'Боец' , $_SESSION [ 'uid' ]);
2019-06-20 23:37:39 +00:00
$klan [ 'glava' ] = $sok [ 'id' ];
}
2019-06-22 14:05:14 +00:00
if ( ! empty ( $_POST [ 'login' ]) AND $_POST [ 'action' ] == 'edit_status' ) {
$sok = db :: c () -> query ( 'SELECT `id`, `status` FROM `users` WHERE `klan` = "?s" AND `login` = "?s"' , $klan [ 'id' ], $_POST [ 'login' ]) -> fetch_assoc ();
if ( $sok [ 'id' ] != $klan [ 'glava' ]) {
if ( ! empty ( $_POST [ 'new_status' ])) {
$st = strip_tags ( str_replace ( " < " , " < " , str_replace ( " > " , " > " , $_POST [ 'new_status' ])), " <B><I><U> " );
db :: c () -> query ( 'UPDATE `users` SET `status` = "?s" WHERE `id` = ?i' , $st , $sok [ 'id' ]);
}
if (( ! empty ( $_POST [ 'vin' ]) OR ! empty ( $_POST [ 'tus' ])) AND $klan [ 'glava' ] == $_SESSION [ 'uid' ]) {
if ( $_POST [ 'vin' ] == 'on' ) $polno [ $sok [ 'id' ]][ 0 ] = 1 ;
else $polno [ $sok [ 'id' ]][ 0 ] = 0 ;
if ( $_POST [ 'tus' ] == 'on' ) $polno [ $sok [ 'id' ]][ 1 ] = 1 ;
else $polno [ $sok [ 'id' ]][ 1 ] = 0 ;
db :: c () -> query ( 'UPDATE `clans` SET `vozm` = "?s" WHERE `id` = ?i' , serialize ( $polno ), $klan [ 'id' ]);
}
$sok [ 'status' ] = $st ;
} else $status = 'Главу клана редактировать запрещено!' ;
}
2019-06-22 10:56:52 +00:00
$clan_memberlist = db :: c () -> query ( 'SELECT `id`, `login`, `status`, `level`, `room`, `align`, (select `id` from `online` WHERE `date` >= ?i AND `id` = users.`id`) AS `online` FROM `users` WHERE `klan` = ?i ORDER BY `online` DESC , `login` ASC' , ( time () - 60 ), $klan [ 'id' ]);
2018-01-28 16:40:49 +00:00
?>
2018-03-03 11:50:13 +00:00
<! doctype html >
< html >
< head >
< link rel = stylesheet href = " css/main.css " >
< meta charset = " utf-8 " >
</ head >
2018-03-03 12:29:30 +00:00
< body >
2019-06-22 12:49:35 +00:00
< div >
< button onclick = " location.href='main.php' " > Вернуться </ button > < ? php if ( ! empty ( $status )) err ( $status ); ?> </div>
2019-06-20 21:48:46 +00:00
< table style = " width: 100% " >
2018-03-03 11:50:13 +00:00
< tr >
2019-06-22 12:27:35 +00:00
< td >
< p style = " width: 50%; vertical-align: top; " rowspan = 2 >
2019-06-20 21:48:46 +00:00
< h3 >< img src = " ./i/klan/<?= $klan['short'] ?>.gif " >< ? = $klan [ 'name' ] ?> </h3>
2019-06-22 12:27:35 +00:00
Количество рейтинговых очков клана : < span
2019-06-22 12:38:22 +00:00
style = " color: #428f21; font-size: larger; " >< ? = $klan [ 'rating' ] ?> </span><br>
2019-06-22 10:56:52 +00:00
< ? php if ( $polno [ $user [ 'id' ]][ 0 ] == 1 ) : ?>
< div >
< span id = " add_member " >
< input type = " submit " onclick = " use('add_member') " value = " Принять в клан " >
</ span >
( стоимость услуги : < B > 100 </ B > кр . )
</ div >
< div >
< span id = " remove_member " >
< input type = " submit " onclick = " use('remove_member') " value = " Выгнать из клана " >
</ span >
( стоимость услуги : < B > 30 </ B > кр . )
</ div >
< ? php endif ; ?>
< ? php if ( $polno [ $user [ 'id' ]][ 1 ] == 1 OR $klan [ 'glava' ] == $user [ 'id' ]) : ?>
2019-06-22 14:05:14 +00:00
< ? php if ( ! empty ( $_POST [ 'login' ]) AND $_POST [ 'action' ] == 'edit_status' ) : ?>
< form method = 'post' >
< input placeholder = 'Статус' name = 'new_status' >
< input type = " hidden " name = " login " value = " <?= $_POST['login'] ?> " >
< ? php if ( $klan [ 'glava' ] == $user [ 'id' ]) : ?>
< ? php if ( $polno [ $sok [ 'id' ]][ 0 ] == 1 ) : ?>
< br >< input type = checkbox name = vin checked > Может принимать / выгонять членов клана
< ? php else : ?>
< br >< input type = checkbox name = vin > Может принимать / выгонять членов клана
< ? php endif ; ?>
< ? php if ( $polno [ $sok [ 'id' ]][ 1 ] == 1 ) : ?>
< br >< input type = checkbox name = tus checked > Может менять статус членов клана
< ? php else : ?>
< br >< input type = checkbox name = tus > Может менять статус членов клана
< ? php endif ; ?>
< ? php endif ; ?>
< button name = 'action' value = 'edit_status' type = 'submit' > Ок </ button >
< button > × </ button >
</ form >
< ? php else : ?>
< div >
< span id = " edit_status " >
< input type = " submit " onclick = " use('edit_status') " value = " Редактировать статус " >
</ span >
</ div >
< ? php endif ; ?>
2019-06-22 10:56:52 +00:00
< ? php endif ; ?>
< ? php if ( $klan [ 'glava' ] == $user [ 'id' ]) : ?>
< div >
< span id = " change_owner " >
< input type = " submit " onclick = " use('change_owner') " value = " Сменить главу клана " >
</ span >
( сложить с себя полномочия , назначив < b style = " color: teal; " > Главой Клана </ b > другого персонажа )
</ div >
2019-06-22 12:00:26 +00:00
< ? php if ( empty ( $klan [ 'zamok' ])) : ?>
2019-06-22 12:27:35 +00:00
< ? php if ( $klan [ 'rating' ] < 1000000 ) : ?>
2019-06-22 12:00:26 +00:00
Недостаточно рейтинга для постройки замка . < ? = showProgressBar ( $klan [ 'rating' ], 1000000 ) ?>
< ? php else : ?>
< form method = " post " >
< button type = " submit " name = " zamok " value = " zamok " > Построить Замок </ button >
( собрать силами всего клана 25000 кр . ) < BR >
</ form >
< ? php endif ; ?>
< ? php endif ; ?>
2019-06-22 10:56:52 +00:00
< ? php endif ; ?>
2018-03-03 15:52:28 +00:00
2019-06-22 12:27:35 +00:00
< ? php if ( $klan [ 'zamok' ] == 1 ) : ?>
2019-06-22 12:26:14 +00:00
< p >
2019-06-22 12:27:35 +00:00
< ? php if ( $klan [ 'zbor' ] < 25000 ) : ?>
2019-06-22 12:00:26 +00:00
С б о р средств на постройку кланового замка :
< ? = showProgressBar ( $klan [ 'zbor' ], 25000 ) ?>
2019-06-22 12:20:02 +00:00
< form method = " post " >
< input name = " kolv " size = " 10 " >
< button type = " submit " name = " kr " value = " kr " > Пожертвовать </ button >
</ form >
2019-06-22 12:00:26 +00:00
< ? php else : ?>
Средства на постройку кланового замка собраны !
< ? = showProgressBar ( 25000 , 25000 ) ?>
< ? php endif ; ?>
< ? php endif ; ?>
2018-03-03 11:50:13 +00:00
</ td >
2019-06-21 15:54:48 +00:00
< td style = " vertical-align: top; " >
2019-06-20 23:02:30 +00:00
< h3 > Соклановцы </ h3 >
2019-06-22 12:52:55 +00:00
< table class = " zebra " style = " width: 100%; " >
2019-06-22 12:49:35 +00:00
< tr >
< th > Имя </ th >
< th > Статус </ th >
< th > Местонахождение </ th >
</ tr >
2019-06-22 12:51:07 +00:00
< ? php
while ( $row = $clan_memberlist -> fetch_assoc ()) :
if ( $row [ 'id' ] == $klan [ 'glava' ]) $row [ 'status' ] = '<b style="color: #008080;">Глава клана</b>' ;
if ( empty ( $row [ 'status' ])) $row [ 'status' ] = 'Боец' ;
2019-06-22 14:05:14 +00:00
if ( empty ( $row [ 'online' ])) $rrm = 'Персонаж не в игре' ;
elseif ( $row [ 'room' ] > 500 AND $row [ 'room' ] < 561 ) $rrm = 'Башня смерти' ;
2019-06-22 12:51:07 +00:00
else $rrm = $rooms [ $row [ 'room' ]];
?>
< tr >
2019-06-22 12:49:35 +00:00
< td >< ? = nick :: id ( $row [ 'id' ]) -> full () ?> </td>
< td >< ? = $row [ 'status' ] ?> </td>
< td >< i style = " font-size: smaller; " >< ? = $rrm ?> </i></td>
2019-06-22 12:51:07 +00:00
</ tr >
< ? php endwhile ; ?>
2019-06-22 12:49:35 +00:00
</ table >
2018-03-03 11:50:13 +00:00
</ td >
</ tr >
2018-01-28 16:40:49 +00:00
</ table >
2019-06-20 21:48:46 +00:00
< script type = " text/javascript " >
function use ( option ) {
2019-06-20 23:57:48 +00:00
document . getElementById ( option ) . innerHTML = " <form method='post'><input placeholder='Имя персонажа' name='login'><button name='action' value=' " + option + " ' type='submit'>Ок</button><button>× </button></form> " ;
2019-06-20 21:48:46 +00:00
}
</ script >
2018-01-28 16:40:49 +00:00
</ body >
</ html >