Файл: clan.php
Строк: 838
<?php
include_once ('./core/base.php');
falseauth();
$header = ''.$uclan['name'].'';
include_once ('./core/head.php');
if($uclan){
echo '<div class="b"><div class="title">'.$uclan['name'].'</div>';
echo ''.clan($uclan['id']).'';
switch($_GET['action']){
default:
echo '<div class="line"></div>';
echo '<center><font color="#E0E0E0">'.$uclan['announcement'].'</font></center>';
echo '<div class="line"></div>';
echo '<a class="btn" href="/clan/treasury/"><img src="/images/icons/chest.png"> Казна</a>';
$buildings_sum = $uclan['earth_altar'] + $uclan['water_altar'] + $uclan['wind_altar'] + $uclan['fire_altar'] + $uclan['castle'];
echo '<a class="btn" href="/clan/buildings/"><img src="/images/icons/hammer.png"> Постройки <img src="/images/icons/stats.png" width="16px"><b>'.$buildings_sum.'</b></a>';
$members = $base -> query('SELECT * FROM `users` WHERE `clan` = "'.$uclan['id'].'"') -> num_rows;
echo '<a class="btn" href="/clan/members/"><img src="/images/icons/user.png"> Состав клана ('.$members.'/'.$uclan['max_members'].')</a>';
if($u['clan_rank'] == '4') echo '<a class="btn" href="/clan/settings/"><img src="/images/icons/settings.png"> Управление</a>';
if($uclan['leader'] != $u['id']) echo '<a class="btn" href="/clan/exit/"><img src="/images/icons/no.png"> Покинуть клан</a>';
//ЧАТ
$_GET['reply'] = fl($_GET['reply']);
$_GET['delete'] = fl($_GET['delete']);
$_GET['truncate'] = fl($_GET['truncate']);
$_POST['msg'] = fl($_POST['msg']);
if(isset($_REQUEST['add'])){
if(!$ban){
if(strlen($_POST['msg']) > 3 AND strlen($_POST['msg']) < 1024 AND $_POST['msg'] != ''){
$base -> query('INSERT INTO `clan_chat` SET
`clan_id` = "'.$uclan['id'].'",
`user` = "'.$u['id'].'",
`text` = "'.$_POST['msg'].'",
`time` = "'.time().'"');
header('Location: /clan/');
exit;
}else{
$_SESSION['message'] = 'Сообщение должно содержать не менее 3 символов и не более 1024.';
header('Location: /clan/');
exit;
}
}else{
$_SESSION['message'] = 'Вы сможете писать в чате по истечению срока бана.';
header('Location: /clan/');
exit;
}
}
if($_GET['delete'] != ''){
if($u['clan_rank'] == 4){
$base -> query('DELETE FROM `clan_chat` WHERE `clan_id` = "'.$uclan['id'].'" AND `id` = "'.$_GET['delete'].'" LIMIT 1');
$_SESSION['message'] = 'Сообщение успешно удалено.';
}
header('Location: /clan/');
exit;
}
if($_GET['truncate'] == 'yes'){
if($u['clan_rank'] == 4){
$base -> query('DELETE FROM `clan_chat` WHERE `clan_id` = "'.$uclan['id'].'"');
$_SESSION['message'] = 'Чат успешно очищен.';
}
header('Location: /clan/');
exit;
}
echo '<div class="title">Чат клана</div>';
echo '<center>';
echo '<form action="" method="POST">';
if($_GET['reply'] != ''){
$reply_user = $base -> query('SELECT * FROM `users` WHERE `id` = "'.$_GET['reply'].'" LIMIT 1') -> fetch_assoc();
$reply_text = ''.$reply_user['login'].', ';
}
echo '<input type="text" name="msg" value="'.$reply_text.'" placeholder="Введите сообщение." /> <br/>';
echo '<input type="submit" name="add" value="Написать"></br>';
echo '</form>';
echo '</center>';
$count = $base -> query("SELECT * FROM `clan_chat` WHERE `clan_id` = '".$uclan['id']."'") -> num_rows;
$k_page = k_page($count,5);
$page = page($k_page);
$start = 5*$page-5;
$sql = $base -> query("SELECT * FROM `clan_chat` WHERE `clan_id` = '".$uclan['id']."' ORDER BY `id` DESC LIMIT $start,5");
if($count > 0){
while($msg = $sql -> fetch_assoc()){
if($msg['user'] != $u['id']) $reply = ' <a href="/clan/reply/'.$msg['user'].'/">[отв]</a>';
else $reply = '';
if($u['clan_rank'] == 4) $delete = ' <a href="/clan/delete/'.$msg['id'].'/">[уд]</a>';
else $delete = '';
$msg['text'] = str_replace(array($u['login'].','), "<font style='text-decoration: underline;'><b>".$u['login']."</b></font>, ", $msg['text']);
echo '<div class="event">'.name($msg['user']).' <font color="#B1B1B1">('.tm($msg['time']).')'.$reply.''.$delete.'</font><br/>
<div class="text_line"></div>
'.nl2br(smiles($msg['text'])).'</div>';
}
if($count > '5'){
echo str('?',$k_page,$page);
}
}else{
echo '<center>В чате ещё не было сообщений.</center>';
}
break;
case 'treasury':
$_GET['insert'] = fl($_GET['insert']);
$_POST['sum'] = fl($_POST['sum']);
if($_GET['insert'] == 'silver'){
if($_POST['sum'] > 0){
if($_POST['sum'] <= 0 OR $_POST['sum'] > 1000000){
$_SESSION['message'] = 'Некорректная сумма.';
header('Location: /clan/treasury/insert/silver/');
exit;
}
if($u['silver'] < $_POST['sum']){
$_SESSION['message'] = 'Недостаточно серебра.';
header('Location: /clan/treasury/insert/silver/');
exit;
}
$base -> query('UPDATE `clans` SET `treasury_silver` = `treasury_silver` + "'.$_POST['sum'].'" WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$base -> query('INSERT INTO `clan_treasury_log` SET
`clan` = "'.$uclan['id'].'",
`time` = "'.time().'",
`who` = "'.$u['id'].'",
`type` = "silver",
`sum` = "'.$_POST['sum'].'"');
$base -> query('UPDATE `users` SET `silver` = `silver` - "'.$_POST['sum'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Казна успешно пополнена.';
header('Location: /clan/treasury/');
exit;
}
echo '<div class="title">Взнос серебра</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="sum" placeholder="Введите количество" /> <br/>';
echo '<input type="submit" name="insert" value="Внести"></br>';
echo '</form>';
echo '</center>';
}elseif($_GET['insert'] == 'gold'){
if($_POST['sum'] > 0){
if($_POST['sum'] <= 0 OR $_POST['sum'] > 1000000){
$_SESSION['message'] = 'Некорректная сумма.';
header('Location: /clan/treasury/insert/gold/');
exit;
}
if($u['gold'] < $_POST['sum']){
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /clan/treasury/insert/gold/');
exit;
}
$base -> query('UPDATE `clans` SET `treasury_gold` = `treasury_gold` + "'.$_POST['sum'].'" WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$base -> query('INSERT INTO `clan_treasury_log` SET
`clan` = "'.$uclan['id'].'",
`time` = "'.time().'",
`who` = "'.$u['id'].'",
`type` = "gold",
`sum` = "'.$_POST['sum'].'"');
$base -> query('UPDATE `users` SET `gold` = `gold` - "'.$_POST['sum'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Казна успешно пополнена.';
header('Location: /clan/treasury/');
exit;
}
echo '<div class="title">Взнос золота</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="sum" placeholder="Введите количество" /> <br/>';
echo '<input type="submit" name="insert" value="Внести"></br>';
echo '</form>';
echo '</center>';
}else{
echo '<div class="title">Казна</div>';
echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left;">';
echo '<tr><td><img src="/images/icons/silver.png"> Серебро</td><td><center>'.n_f($uclan['treasury_silver']).'</center></td></tr>';
echo '<tr><td><img src="/images/icons/gold.png"> Золото</td><td><center>'.n_f($uclan['treasury_gold']).'</center></td></tr>';
echo '</table>';
echo '<a class="btn" href="/clan/treasury/insert/silver/"><img src="/images/icons/silver_24.png"> Внести серебро</a>';
echo '<a class="btn" href="/clan/treasury/insert/gold/"><img src="/images/icons/gold_24.png"> Внести золото</a>';
echo '<a class="btn" href="/clan/treasury/log/"><img src="/images/icons/money_bag.png"> Лог взносов</a>';
}
break;
case 'treasury_log':
echo '<div class="title">Лог взносов</div>';
$count = $base->query("SELECT * FROM `clan_treasury_log` WHERE `clan` = '".$uclan['id']."'") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $base->query("SELECT * FROM `clan_treasury_log` WHERE `clan` = '".$uclan['id']."' ORDER BY `id` DESC LIMIT $start,10");
if($count > 0){
while($tlog = $sql -> fetch_assoc()){
echo '<div class="event">('.tm($tlog['time']).') '.name($tlog['who']).' внёс <img src="/images/icons/'.$tlog['type'].'.png">'.n_f($tlog['sum']).'</div>';
}
if($count > '10'){
echo str('?',$k_page,$page);
}
}else{
echo '<br/><center>Взносов ещё не было.</center><br/>';
}
break;
case 'members':
$_GET['exclude'] = fl($_GET['exclude']);
if($_GET['exclude']){
$exclude_nr = $base -> query('SELECT * FROM `users` WHERE `clan` = "'.$u['clan'].'"') -> num_rows;
if($exclude_nr > 0){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Исключать участников клана может только лидер.';
header('Location: /clan/members/');
exit;
}
if($_GET['exclude'] == $uclan['leader']){
$_SESSION['message'] = 'Нельзя исключить лидера клана.';
header('Location: /clan/members/');
exit;
}
$base -> query('UPDATE `users` SET `clan` = "0", `clan_rank` = "0", `clan_exp` = "0" WHERE `id` = "'.$_GET['exclude'].'" LIMIT 1');
$_SESSION['message'] = 'Игрок исключён.';
header('Location: /clan/members/');
exit;
}else{
$_SESSION['message'] = 'В клане нет такого участника.';
header('Location: /clan/members/');
exit;
}
}
echo '<div class="title">Состав клана</div>';
$count = $base -> query("SELECT * FROM `users` WHERE `clan` = '".$uclan['id']."'") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page-10;
$sql = $base -> query("SELECT * FROM `users` WHERE `clan` = '".$uclan['id']."' ORDER BY `clan_exp` DESC LIMIT $start,10");
if($count > 0){
while($member = $sql -> fetch_assoc()){
if($member['clan_rank'] == 4) $rank = ' <b>Лидер</b>';
else $rank = '';
$member_avatar='/images/skins/'.$member['skin'].'_big.png';
if($u['clan_rank'] == 4 AND $member['id'] != $u['id']){
echo '<table width="100%" style="margin-top: 5px; border-spacing: 0px;"><tr><td style="padding: 0px; margin-right: 25px;" width="89%"><a class = "btn_table" href="/user/'.$member['id'].'/"><img src="'.$member_avatar.'" width="24px"> '.nolinkname($member['id']).' <img src="/images/icons/exp.png"><b>'.n_f($member['clan_exp']).''.$rank.'</b></a></td>
<td width="1%"></td><td style="padding: 0px;" width="10%"><center><a class = "btn_table" href="/clan/members/exclude/'.$member['id'].'/"><img src="/images/icons/no.png"></a></center></td></tr></table>';
}else{
echo '<a class="btn" href="/user/'.$member['id'].'/"><img src="'.$member_avatar.'" width="24px"> '.nolinkname($member['id']).' <img src="/images/icons/exp.png"><b>'.n_f($member['clan_exp']).''.$rank.'</b></a>';
}
}
if($count > '10'){
echo str('?',$k_page,$page);
}
}else{
echo '<br/><center>В клане нет участников.</center><br/>';
}
break;
case 'buildings':
$earth_cost_silver = 50000 * $uclan['earth_altar'];
$earth_cost_gold = 100 * $uclan['earth_altar'];
$water_cost_silver = 50000 * $uclan['water_altar'];
$water_cost_gold = 100 * $uclan['water_altar'];
$wind_cost_silver = 50000 * $uclan['wind_altar'];
$wind_cost_gold = 100 * $uclan['wind_altar'];
$fire_cost_silver = 50000 * $uclan['fire_altar'];
$fire_cost_gold = 100 * $uclan['fire_altar'];
$castle_cost_silver = 250000 * $uclan['castle'];
$castle_cost_gold = 500 * $uclan['castle'];
$_GET['upgrade'] = fl($_GET['upgrade']);
if($_GET['upgrade'] == 'earth_altar'){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Улучшать клановые постройки может только лидер.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['treasury_silver'] < $earth_cost_silver OR $uclan['treasury_gold'] < $earth_cost_gold){
$_SESSION['message'] = 'Недостаточно средств в казне клана.';
header('Location: /clan/buildings/');
exit;
}
$base -> query('UPDATE `clans` SET
`earth_altar` = `earth_altar` + "1",
`treasury_silver` = `treasury_silver` - "'.$earth_cost_silver.'",
`treasury_gold` = `treasury_gold` - "'.$earth_cost_gold.'"
WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Уровень Алтаря Земли успешно повышен.';
header('Location: /clan/buildings/');
exit;
}elseif($_GET['upgrade'] == 'water_altar'){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Улучшать клановые постройки может только лидер.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['treasury_silver'] < $water_cost_silver OR $uclan['treasury_gold'] < $water_cost_gold){
$_SESSION['message'] = 'Недостаточно средств в казне клана.';
header('Location: /clan/buildings/');
exit;
}
$base -> query('UPDATE `clans` SET
`water_altar` = `water_altar` + "1",
`treasury_silver` = `treasury_silver` - "'.$water_cost_silver.'",
`treasury_gold` = `treasury_gold` - "'.$water_cost_gold.'"
WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Уровень Алтаря Воды успешно повышен.';
header('Location: /clan/buildings/');
exit;
}elseif($_GET['upgrade'] == 'wind_altar'){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Улучшать клановые постройки может только лидер.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['treasury_silver'] < $wind_cost_silver OR $uclan['treasury_gold'] < $wind_cost_gold){
$_SESSION['message'] = 'Недостаточно средств в казне клана.';
header('Location: /clan/buildings/');
exit;
}
$base -> query('UPDATE `clans` SET
`wind_altar` = `wind_altar` + "1",
`treasury_silver` = `treasury_silver` - "'.$wind_cost_silver.'",
`treasury_gold` = `treasury_gold` - "'.$wind_cost_gold.'"
WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Уровень Алтаря Воздуха успешно повышен.';
header('Location: /clan/buildings/');
exit;
}elseif($_GET['upgrade'] == 'fire_altar'){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Улучшать клановые постройки может только лидер.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['treasury_silver'] < $fire_cost_silver OR $uclan['treasury_gold'] < $fire_cost_gold){
$_SESSION['message'] = 'Недостаточно средств в казне клана.';
header('Location: /clan/buildings/');
exit;
}
$base -> query('UPDATE `clans` SET
`fire_altar` = `fire_altar` + "1",
`treasury_silver` = `treasury_silver` - "'.$fire_cost_silver.'",
`treasury_gold` = `treasury_gold` - "'.$fire_cost_gold.'"
WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Уровень Алтаря Огня успешно повышен.';
header('Location: /clan/buildings/');
exit;
}elseif($_GET['upgrade'] == 'castle'){
if($u['clan_rank'] != 4){
$_SESSION['message'] = 'Улучшать клановые постройки может только лидер.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['treasury_silver'] < $castle_cost_silver OR $uclan['treasury_gold'] < $castle_cost_gold){
$_SESSION['message'] = 'Недостаточно средств в казне клана.';
header('Location: /clan/buildings/');
exit;
}
if($uclan['castle'] == 8){
$_SESSION['message'] = 'У данной постройки максимальный уровень.';
header('Location: /clan/buildings/');
exit;
}
$base -> query('UPDATE `clans` SET
`castle` = `castle` + "1",
`max_members` = `max_members` + "5",
`treasury_silver` = `treasury_silver` - "'.$castle_cost_silver.'",
`treasury_gold` = `treasury_gold` - "'.$castle_cost_gold.'"
WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Уровень Замка успешно повышен.';
header('Location: /clan/buildings/');
exit;
}
echo '<div class="title">Постройки</div>';
echo '<div class="event"><img src="/images/icons/earth.png"> <b>Алтарь Земли <small><font color="#B1B1B1">'.$uclan['earth_altar'].' ур.</font></small></b><br/>
<div class="only_line"></div>
<center><small>Каждый уровень Алтаря Земли даёт +1 к выносливости участникам клана.</small></center>
<div class="only_line"></div>';
if($u['clan_rank'] == 4 AND $uclan['treasury_silver'] >= $earth_cost_silver AND $uclan['treasury_gold'] >= $earth_cost_gold){
echo '<center><a class="btn_small" href="/clan/buildings/upgrade_earth_altar/">Улучшить за <img src="/images/icons/silver.png">'.n_f($earth_cost_silver).' <img src="/images/icons/gold.png">'.n_f($earth_cost_gold).'</a></center>';
}else{
echo '<center><a class="btn_smal_pressed">Улучшить за <img src="/images/icons/silver.png">'.n_f($earth_cost_silver).' <img src="/images/icons/gold.png">'.n_f($earth_cost_gold).'</a></center>';
}
echo '</div>';
echo '<div class="event"><img src="/images/icons/water.png"> <b>Алтарь Воды <small><font color="#B1B1B1">'.$uclan['water_altar'].' ур.</font></small></b><br/>
<div class="only_line"></div>
<center><small>Каждый уровень Алтаря Воды даёт +1 к интеллекту участникам клана.</small></center>
<div class="only_line"></div>';
if($u['clan_rank'] == 4 AND $uclan['treasury_silver'] >= $water_cost_silver AND $uclan['treasury_gold'] >= $water_cost_gold){
echo '<center><a class="btn_small" href="/clan/buildings/upgrade_water_altar/">Улучшить за <img src="/images/icons/silver.png">'.n_f($water_cost_silver).' <img src="/images/icons/gold.png">'.n_f($water_cost_gold).'</a></center>';
}else{
echo '<center><a class="btn_small_pressed">Улучшить за <img src="/images/icons/silver.png">'.n_f($water_cost_silver).' <img src="/images/icons/gold.png">'.n_f($water_cost_gold).'</a></center>';
}
echo '</div>';
echo '<div class="event"><img src="/images/icons/wind.png"> <b>Алтарь Воздуха <small><font color="#B1B1B1">'.$uclan['wind_altar'].' ур.</font></small></b><br/>
<div class="only_line"></div>
<center><small>Каждый уровень Алтаря Воздуха даёт +1 к ловкости участникам клана.</small></center>
<div class="only_line"></div>';
if($u['clan_rank'] == 4 AND $uclan['treasury_silver'] >= $wind_cost_silver AND $uclan['treasury_gold'] >= $wind_cost_gold){
echo '<center><a class="btn_small" href="/clan/buildings/upgrade_wind_altar/">Улучшить за <img src="/images/icons/silver.png">'.n_f($wind_cost_silver).' <img src="/images/icons/gold.png">'.n_f($wind_cost_gold).'</a></center>';
}else{
echo '<center><a class="btn_small_pressed">Улучшить за <img src="/images/icons/silver.png">'.n_f($wind_cost_silver).' <img src="/images/icons/gold.png">'.n_f($wind_cost_gold).'</a></center>';
}
echo '</div>';
echo '<div class="event"><img src="/images/icons/fire.png"> <b>Алтарь Огня <small><font color="#B1B1B1">'.$uclan['fire_altar'].' ур.</font></small></b><br/>
<div class="only_line"></div>
<center><small>Каждый уровень Алтаря Огня даёт +1 к мастерству участникам клана.</small></center>
<div class="only_line"></div>';
if($u['clan_rank'] == 4 AND $uclan['treasury_silver'] >= $fire_cost_silver AND $uclan['treasury_gold'] >= $fire_cost_gold){
echo '<center><a class="btn_small" href="/clan/buildings/upgrade_fire_altar/">Улучшить за <img src="/images/icons/silver.png">'.n_f($fire_cost_silver).' <img src="/images/icons/gold.png">'.n_f($fire_cost_gold).'</a></center>';
}else{
echo '<center><a class="btn_small_pressed">Улучшить за <img src="/images/icons/silver.png">'.n_f($fire_cost_silver).' <img src="/images/icons/gold.png">'.n_f($fire_cost_gold).'</a></center>';
}
echo '</div>';
if($uclan['castle'] == 8) $max = '(макс.)';
else $max = '';
echo '<div class="event"><img src="/images/icons/cross.png"> <b>Замок <small><font color="#B1B1B1">'.$uclan['castle'].' ур. '.$max.'</font></small></b><br/>
<div class="only_line"></div>
<center><small>Каждый новый уровень Замка даёт +5 к вместительности клана.</small></center>
<div class="only_line"></div>';
if($u['clan_rank'] == 4 AND $uclan['treasury_silver'] >= $castle_cost_silver AND $uclan['treasury_gold'] >= $castle_cost_gold AND $max == ''){
echo '<center><a class="btn_small" href="/clan/buildings/upgrade_castle/">Улучшить за <img src="/images/icons/silver.png">'.n_f($castle_cost_silver).' <img src="/images/icons/gold.png">'.n_f($castle_cost_gold).'</a></center>';
}else{
echo '<center><a class="btn_small_pressed">Улучшить за <img src="/images/icons/silver.png">'.n_f($castle_cost_silver).' <img src="/images/icons/gold.png">'.n_f($castle_cost_gold).'</a></center>';
}
echo '</div>';
break;
case 'settings':
if($u['clan_rank'] == 4){
switch($_GET['type']){
default:
echo '<div class="title">Управление</div>';
echo '<a class="btn" href="/clan/settings/emblem/"><img src="/images/icons/cross.png"> Изменить герб</a>';
echo '<a class="btn" href="/clan/settings/announcement/"><img src="/images/icons/info.png"> Изменить объявление</a>';
echo '<a class="btn" href="/clan/settings/mailing/"><img src="/images/icons/blue_fearrow.png"> Рассылка</a>';
echo '<a class="btn" href="/clan/truncate/"><img src="/images/icons/fearrow.png"> Очистить чат</a>';
echo '<a class="btn" href="/clan/settings/delete/"><img src="/images/icons/no.png"> Расформировать клан</a>';
break;
case 'emblem':
$emblem_cost = 1000;
$_GET['emblem'] = fl($_GET['emblem']);
if($_GET['emblem']){
if($_GET['emblem'] > 0 AND $_GET['emblem'] < 16){
if($uclan['treasury_gold'] >= $emblem_cost){
$base -> query('UPDATE `clans` SET `emblem` = "'.$_GET['emblem'].'", `treasury_gold` = `treasury_gold` - "'.$emblem_cost.'" WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Герб успешно сменён.';
header('Location: /clan/settings/emblem/');
exit;
}else{
$_SESSION['message'] = 'Недостаточно золота в казне.';
header('Location: /clan/settings/emblem/');
exit;
}
}else{
$_SESSION['message'] = 'Ошибка.';
header('Location: /clan/settings/emblem/');
exit;
}
}
echo '<div class="title">Изменить герб</div>';
echo '<div class="event"><center>Стоимость смены герба <img src="/images/icons/gold.png">'.n_f($emblem_cost).'</center></div>';
echo '<a class="btn" href="/clan/settings/emblem/1/"><img src="/images/emblems/1.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/2/"><img src="/images/emblems/2.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/3/"><img src="/images/emblems/3.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/4/"><img src="/images/emblems/4.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/5/"><img src="/images/emblems/5.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/6/"><img src="/images/emblems/6.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/7/"><img src="/images/emblems/7.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/8/"><img src="/images/emblems/8.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/9/"><img src="/images/emblems/9.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/10/"><img src="/images/emblems/10.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/11/"><img src="/images/emblems/11.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/12/"><img src="/images/emblems/12.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/13/"><img src="/images/emblems/13.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/14/"><img src="/images/emblems/14.png" width="48px"> <b>Выбрать</b></a>';
echo '<a class="btn" href="/clan/settings/emblem/15/"><img src="/images/emblems/15.png" width="48px"> <b>Выбрать</b></a>';
break;
case 'announcement':
$_POST['text'] = fl($_POST['text']);
if(isset($_REQUEST['save'])){
if(strlen($_POST['text']) < 3 || strlen($_POST['text']) > 100){
$_SESSION['message'] = 'Объявление должно содержать не менее 3 символов и не более 100.';
header('Location: /clan/settings/announcement/');
exit;
}else{
$base -> query('UPDATE `clans` SET `announcement` = "'.$_POST['text'].'" WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$_SESSION['message'] = 'Объявление сохранено.';
header('Location: /clan/settings/announcement/');
exit;
}
}
echo '<div class="title">Изменить объявление</div>';
echo '<div class="event"><center><font color="#B1B1B1">Текущее объявление:</font> '.$uclan['announcement'].'</center></div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="text" placeholder="Введите новое объявление." /> <br/>';
echo '<input type="submit" name="save" value="Сохранить">';
echo '</form>';
echo '</center>';
break;
case 'mailing':
if(isset($_REQUEST['go'])){
$message = fl($_POST['message']);
if(empty($message)) error('Введите сообщение рассылки.');
elseif(strlen($message) < 3 || strlen($message) > 500) error('Сообщение должно содержать не менее 3 и не более 500 символов.');
else{
$clusers_q = $base -> query('SELECT * FROM `users` WHERE `clan` = "'.$uclan['id'].'" AND `id` != "'.$u['id'].'"');
$clusers_nr = $clusers_q -> num_rows;
if($clusers_nr > 0){
while($cluser = $clusers_q -> fetch_assoc()){
$c = $base -> query('SELECT * FROM `message_c` WHERE `kto` = "'.$cluser['id'].'" AND `kogo` = "'.$u['id'].'"') -> num_rows;
if($c == 0) $base -> query('INSERT INTO `message_c` SET `kto` = "'.$cluser['id'].'", `kogo` = "'.$u['id'].'", `time` = "'.time().'"');
$base -> query('INSERT INTO `message` SET
`kto` = "'.$u['id'].'",
`komy` = "'.$cluser['id'].'",
`text` = "'.$message.'",
`time` = "'.time().'"');
}
}
$_SESSION['message'] = 'Сообщение успешно разослано.';
header('location: /clan/settings/mailing/');
exit;
}
}
echo '<div class="title">Рассылка клану</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="message" placeholder="Введите сообщение рассылки." /> <br/>';
echo '<input type="submit" name="go" value="Разослать">';
echo '</form>';
echo '</center>';
break;
case 'delete':
$_GET['answer'] = fl($_GET['answer']);
if($_GET['answer'] == 'yes'){
$base -> query('DELETE FROM `clans` WHERE `id` = "'.$uclan['id'].'" LIMIT 1');
$base -> query('DELETE FROM `clan_chat` WHERE `clan_id` = "'.$uclan['id'].'"');
$base -> query('DELETE FROM `clan_treasury_log` WHERE `clan` = "'.$uclan['id'].'"');
$base -> query('UPDATE `users` SET `clan` = "0", `clan_rank` = "0", `clan_exp` = "0" WHERE `clan` = "'.$uclan['id'].'"');
$_SESSION['message'] = 'Клан успешно расформирован.';
header('Location: /');
exit;
}elseif($_GET['answer'] == 'no'){
header('Location: /clan/settings/');
exit;
}
echo '<div class="title">Расформировать клан</div>';
echo '<div class="event"><center>Вы действительно хотите расформировать клан?</center></div>';
echo '<a class="btn" href="/clan/settings/delete/yes/"><img src="/images/icons/yes.png"> Да</a>';
echo '<a class="btn" href="/clan/settings/delete/no/"><img src="/images/icons/no.png"> Нет</a>';
break;
}
}else{
header('Location: /clan/');
exit;
}
break;
case 'exit';
if($uclan['leader'] != $u['id']){
$_GET['answer'] = fl($_GET['answer']);
if($_GET['answer'] == 'yes'){
$base -> query('UPDATE `users` SET `clan` = "0", `clan_rank` = "0", `clan_exp` = "0" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Вы успешно покинули клан.';
header('Location: /');
exit;
}elseif($_GET['answer'] == 'no'){
header('Location: /clan/');
exit;
}
echo '<div class="title">Покинуть клан</div>';
echo '<div class="event"><center>Вы действительно хотите покинуть клан?</center></div>';
echo '<a class="btn" href="/clan/exit/yes/"><img src="/images/icons/yes.png"> Да</a>';
echo '<a class="btn" href="/clan/exit/no/"><img src="/images/icons/no.png"> Нет</a>';
}else{
header('Location: /clan/');
exit;
}
break;
}
echo '<br/><a class="btn" href="javascript:history.go(-1)"><img src="/images/icons/back.png"> Назад</a>';
echo '</div>';
}else{
$_SESSION['message'] = 'Вы не состоите в клане.';
header('Location: /');
exit;
}
include_once ('./core/foot.php');
?>