<?php
// Админ-панель игры "Новая Эра - Одарённые"
include 'core/system.php';

reg();
only_admin(2);

head('Админ-панель');

echo '
<div class="block_zero center">
<a href="admins.php">
<div class="head"><b>
<font color="cyan">
Админ - панель
</font></b>
</div>
</a>
</div>
<div class="mini-line"></div>
';

####Доделать как нибудь инвентарь пользователя
if(isset($_GET['us_invent']) AND !empty($_GET['ank']) AND $user['id']==23){
	$ank_id = int($_GET['ank']);
$ank =mysql_fetch_assoc( mysql_query("SELECT * FROM `users` WHERE `id`='".$ank_id."' LIMIT 1"));
	if(!$ank){
	echo '<div id="error">Пользователь не найден</div>';
	foot();
	exit;
	}

$invent_q = mysql_query("SELECT * FROM `inventory_user` WHERE `user_id`='".$ank_id."'");
	echo '<div class="row"></div>';
	foot();
	exit;
	}

###  Назначение уровня ###
	if(!empty($_GET['admins']) and $user['id']==23){
	
	$admins = int($_GET['admins']);
	$admins_us = int($_POST['user_admins']);
	
mysql_query("UPDATE `users` SET `admins`='".$admins_us."' WHERE `id`='".$admins."'");
		header('Location: pers.php?ank='.$admins);
	}
	// Шпионим по кланам
	if(!empty($_GET['viewclan'])){
	$clan_id = int($_GET['viewclan']);
$clan = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan` WHERE `id`='".$clan_id."'"));
		if($clan){
			if(isset($_GET['stena'])){
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `clan_stena` WHERE `clan_id`='".$clan_id."'"),0);
$stena_q = mysql_query("SELECT * FROM `clan_stena` WHERE `clan_id`='".$clan_id."' ORDER BY `time` DESC LIMIT ".$page.",".$set['str']." ");
echo '<div class="main">Стена клана - <a href="aclan.php?clan='.$clan_id.'">'.$clan['name'].'</a> |<a href="admins.php?clans">Кланы</a></div>';
				while($stena = mysql_fetch_assoc($stena_q)){
$ank = mysql_fetch_assoc(mysql_query("SELECT `id`,`login` FROM `users` WHERE `id`='".$stena['user_id']."' LIMIT 1"));
echo '<div class="row"><a href="pers.php?ank='.$ank['id'].'">'.$ank['login'].'</a>['.clock($stena['time']).'] '.$stena['text'].'</div>';
				}
			{
pages($page, $total, 'admins.php?viewclan='.$clan_id.'&amp;stena&amp;', $set['str']);
			}
			foot();
			exit;
			}
			// Удаление клана
			if(isset($_GET['del'])){
echo '

Вы действительно хотите удалить клан и выгнать всех участников?<br><a id="link_button" href="admins.php?viewclan='.$clan_id.'&amp;del&amp;yes">Да</a> <a style="float: right;" id="link_button" href="admins.php?viewclan='.$clan_id.'&amp;del&amp;no">Нет</a></div>';
				if(isset($_GET['yes'])){
				unlink('img/clan/'.$clan_id.'.'.$clan['img']);
mysql_query("INSERT INTO `admin_log` SET `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> удалил клан <b>".$clan['name']."</b>',
				`time`='".time()."'");
mysql_query("UPDATE `users` SET `clan`=0,`clan_oput`=0 WHERE `clan`='".$clan_id."'");
mysql_query("DELETE FROM `clan_stena` WHERE `clan_id`='".$clan_id."'");
mysql_query("DELETE FROM `clan` WHERE `id`='".$clan_id."'");
mysql_query("DELETE FROM `clan_invite` WHERE `clan_to`='".$clan_id."'");
				echo '<div id="ok">Клан успешно удален</div>';
				}elseif(isset($_GET['no'])){
				header("Location: clan.php?clan=".$clan_id);
				}
			foot();
			exit;
			}
		
		
		}
	
	foot();
	exit;
	}
	
	
	if(isset($_GET['clans'])){
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `clan`"),0);
$clan_q = mysql_query("SELECT * FROM `clan` ORDER BY `id` DESC LIMIT ".$page.",".$set['str']."");
		while($clan = mysql_fetch_assoc($clan_q)){
echo '<div class="row"><img src="img/clan/'.$clan['id'].'.'.$clan['img'].'" height="50" width="50"> <a href="clan.php?clan='.$clan['id'].'">'.$clan['name'].'</a> ['.$clan['level'].']<br><a href="admins.php?viewclan='.$clan['id'].'&amp;stena">Читать стену</a> | <a href="admins.php?viewclan='.$clan['id'].'&amp;del">Удалить</a></div>';
				}
			if($total > $set['str'])	{
		pages($page, $total, 'admins.php?clans&amp;', $set['str']);
	}
	foot();
	exit;
	}
// Управление рефералами	
if(isset($_GET['refs'])){
echo '<div class="name">Рефералы для модерации</div>';
	if(isset($_GET['ok']) AND !empty($_GET['id'])){
	$id = int($_GET['id']);
$get_ref_us = mysql_fetch_assoc(mysql_query("SELECT `ref_id`,`id` FROM `referal` WHERE `id`='".$id."' LIMIT 1"));
	if($get_ref_us){
	// Рубины за рефа	
	$rubin_ref = 10;
mysql_query("UPDATE `referal` SET `ok`='1' WHERE `id`='".$id."'");
mysql_query("UPDATE `users` SET `rubin`=`rubin`+".$rubin_ref." WHERE `id`='".$get_ref_us['ref_id']."'");
mysql_query("INSERT INTO `journal` SET `user_id`='".$get_ref_us['ref_id']."', `text`='Вам начислено <img src=\"img/money/rubin.png\"> ".$rubin_ref." за реферала!',
	`time`='".time()."'");
	}
	header("Location: admins.php?refs");
	exit;
	}
	if(isset($_GET['del']) AND !empty($_GET['id'])){
	$id = int($_GET['id']);
$get_ref_us = mysql_fetch_assoc(mysql_query("SELECT `ref_id` FROM `referal` WHERE `id`='".$id."' LIMIT 1"));
	if($get_ref_us){
mysql_query("UPDATE `referal` SET `ok`='2' WHERE `id`='".$id."'");
mysql_query("INSERT INTO `journal` SET `user_id`='".$get_ref_us['ref_id']."', `text`='Реферал не засчитан т.к. был заподозрен в клонировании.',
	`time`='".time()."'");
	}
	header("Location: admins.php?refs");
	exit;
	}
$refs_q = mysql_query("SELECT * FROM `referal` WHERE `ok`='0' ORDER BY `time` DESC LIMIT ".$page.",".$set['str']." ");
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `referal` WHERE `ok`='0'"),0);
	if($total == 0){
echo '<div class="row">Рефералов для модерации нет</div>';
	foot();
	exit;
	}
	else	{
		while($refs = mysql_fetch_assoc($refs_q)){
$ref_id = mysql_fetch_assoc(mysql_query("SELECT `id`,`login` FROM `users` WHERE `id`='".$refs['ref_id']."' LIMIT 1"));
$user_ref = mysql_fetch_assoc(mysql_query("SELECT `id`,`login` FROM `users` WHERE `id`='".$refs['user_ref']."' LIMIT 1"));
echo '<div class="row">['.clock($refs['time']).'] <a href="pers.php?ank='.$ref_id['id'].'">'.$ref_id['login'].'</a> пригласил <a href="pers.php?ank='.$user_ref['id'].'">'.$user_ref['login'].'</a><br><a id="link_button" href="admins.php?refs&amp;ok&amp;id='.$refs['id'].'">Подвердить</a><a id="link_button" style="float: right;" href="admins.php?refs&amp;del&amp;id='.$refs['id'].'">Нет это клон</a></div>';
				}
		if($total > $set['str'])	{
		pages($page, $total, 'admins.php?refs&amp;', $set['str']);
	}
	}
foot();
exit;
}
// Логи администрации
if(isset($_GET['logs'])){
if($user['id']!=1){header ('location : index.php');exit;}
echo '<div class="main"><div class="block_zero center">Логи Администрации</div><div class="mini-line"></div>';
if($user['id']==1){
echo '<div class="name"><a href="admins.php?logs&amp;truncate">Очистить</a></div>';
}
	if(isset($_GET['truncate']) AND $user['id']==1){
	header("Location: admins.php?logs");
	mysql_query("TRUNCATE TABLE `admin_log`");
	foot();
	exit;
	}
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `admin_log`"),0);
	if($total==0){
	echo '<div id="error">Логи пусты</div>';
	foot();
	exit;	
	}
$logs_q = mysql_query("SELECT * FROM `admin_log` ORDER BY `time` DESC LIMIT ".$page.",".$set['str']." ");
	while($logs = mysql_fetch_assoc($logs_q)){
echo '<div class="block_zero">['.clock($logs['time']).'] '.$logs['text'].'</div>';
	}
		if($total > $set['str'])	{
		pages($page, $total, 'admins.php?logs&amp;', $set['str']);
		}
foot();
exit;
}
// Изменение счёта
if(isset($_GET['money_pers']) and !empty($_GET['ank']) and $user['id']>0){
if($user['id']!=1283){header ('location : index.php');exit;}
$ank_id = int($_GET['ank']);
$ank = $dbc->query("SELECT `id`,`login`,`gold`,`serebro`,`leg`,`rub`,`almaz` FROM `users` WHERE `id`='".$ank_id."' LIMIT 1")->fetch_assoc();


	if(!$ank){
	echo '<div id="error">Пользователь не найден</div>';
	foot();
	exit;
	}
	?>
<div class="main">
<div class="block_zero center">
Счёт пользователя <a href="pers.php?ank=<?=$ank['id']?>">
<?=$ank['login']?></a>
</div>
<div class="mini-line"></div>
<div class="block_zero center">
<?
	if(empty($_POST['money'])){
?>
<img src="img/money/money.png"><?=$ank['gold']?> 

<form id="idc" method="post"
action="admins.php?money_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="money" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Дать Золото"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `gold`=`gold`+'".$money."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&money_pers");exit;


	}
	
	
	
	
if(empty($_POST['sera'])){
?>
<img src="img/stat/sera.png"><?=$ank['serebro']?> 

<form id="idc" method="post"
action="admins.php?money_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="sera" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Дать Серебро"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `serebro`=`serebro`+'".$sera."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&money_pers");exit;


	}	
	
	
	
	
	
	
	if(empty($_POST['rubin'])){
?>
<img src="img/money/rubin.png"><?=$ank['rub']?> 

<form id="idc" method="post"
action="admins.php?money_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="rubin" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Дать Рубинов"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `rub`=`rub`+'".$rubin."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&money_pers");exit;


	}
	
	
	
	
if(empty($_POST['leg'])){
?>
<img src="img/new/leg.png"><?=$ank['leg']?> 

<form id="idc" method="post"
action="admins.php?money_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="leg" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Дать Осколки"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `leg`=`leg`+'".$leg."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&money_pers");exit;


	}	
	
	
	
	
	
if(empty($_POST['almaz'])){
?>
<img src="img/money/almaz.png"><?=$ank['almaz']?> 

<form id="idc" method="post"
action="admins.php?money_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="almaz" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Дать Алмазов"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `almaz`=`almaz`+'".$almaz."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&money_pers");exit;


	}	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	?>  <center> <a href="/admins.php?ank=<?=$ank_id?>&minus_pers"> Забрать Ресурсы </a></center>	<?
	
foot();
exit;
}


if(isset($_GET['minus_pers']) and !empty($_GET['ank']) and $user['id']>0){
if($user['id']!=1283){header ('location : index.php');exit;}
$ank_id = int($_GET['ank']);
$ank = $dbc->query("SELECT `id`,`login`,`gold`,`serebro`,`leg`,`rub`,`almaz` FROM `users` WHERE `id`='".$ank_id."' LIMIT 1")->fetch_assoc();


	if(!$ank){
	echo '<div id="error">Пользователь не найден</div>';
	foot();
	exit;
	}
	?>
<div class="main">
<div class="block_zero center">
Счёт пользователя <a href="pers.php?ank=<?=$ank['id']?>">
<?=$ank['login']?></a>
</div>
<div class="mini-line"></div>
<div class="block_zero center">
<?
	if(empty($_POST['money'])){
?>
<img src="img/money/money.png"><?=$ank['gold']?> 

<form id="idc" method="post"
action="admins.php?minus_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="money" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Забрать Золото"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `gold`=`gold`-'".$money."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&minus_pers");exit;


	}
	
	
	
	
if(empty($_POST['sera'])){
?>
<img src="img/stat/sera.png"><?=$ank['serebro']?> 

<form id="idc" method="post"
action="admins.php?minus_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="sera" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Забрать Серебро"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `serebro`=`serebro`-'".$sera."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&minus_pers");exit;


	}	
	
	
	
	
	
	
	if(empty($_POST['rubin'])){
?>
<img src="img/money/rubin.png"><?=$ank['rub']?> 

<form id="idc" method="post"
action="admins.php?minus_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="rubin" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Забрать Рубины"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `rub`=`rub`-'".$rubin."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&minus_pers");exit;


	}
	
	
	
	
if(empty($_POST['leg'])){
?>
<img src="img/new/leg.png"><?=$ank['leg']?> 

<form id="idc" method="post"
action="admins.php?minus_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="leg" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Забрать Осколки"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `leg`=`leg`-'".$leg."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&minus_pers");exit;


	}	
	
	
	
	
	
if(empty($_POST['almaz'])){
?>
<img src="img/money/almaz.png"><?=$ank['almaz']?> 

<form id="idc" method="post"
action="admins.php?minus_pers&amp;ank=<?=$ank_id?>"><div style="width:0px;height:0px;position: absolute;left:-100px;top:- 100px;overflow:hidden">
    
    
    
    
    <input type="hidden" name="idc_hf_0" id="idc_hf_0"></div><div class="form-field"><input type="text" value="" name="almaz" id="idb"
autocomplete="off"></div>






<div class="form-submit mt5"><input class="btn" type="submit"
value="Забрать Алмазы"></div></form>




<?
	}
	else{
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
		$sera = int($_POST['sera']);
		
		$leg = int($_POST['leg']);
		
			$almaz = int($_POST['almaz']);
	
	
	;
$dbc->query("UPDATE `users` SET `almaz`=`almaz`-'".$almaz."' WHERE `id`='".$ank_id."'");

$dbc->query("INSERT INTO `admin_log` SET  `text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> изменил счет <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a>', 	`time`='".time()."'");

	header("location: admins.php?ank=$ank_id&minus_pers");exit;


	}	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		?>  <center> <a href="/admins.php?ank=<?=$ank_id?>&money_pers"> Дать Ресурсы </a></center>	<?

	
	
	
foot();
exit;
}









// Журналы
if(isset($_GET['journal'])){
if($user['id']!=23){header ('location : index.php');exit;}
echo '<div class="name">Журналы</div>';
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `journal`"),0);
	if($total == 0){
	echo '<div class="row">Журналы пусты</div>';
	foot();
	exit;
	}
	$journals_q = mysql_query("SELECT * FROM `journal` ORDER BY `time` DESC LIMIT ".$page.",".$set['str']." ");
		while($journals = mysql_fetch_assoc($journals_q)){
		$ank_j = mysql_fetch_assoc(mysql_query("SELECT `login`,`id` FROM `users` WHERE `id`='".$journals['user_id']."' LIMIT 1"));
		echo '<div class="row"><a href="pers.php?ank='.$ank_j['id'].'">'.$ank_j['login'].'</a>->['.clock($journals['time']).']'.$journals['text'].'</div>';
		}
	if($total > $set['str'])
	{
		pages($page, $total, 'admins.php?journal&amp;', $set['str']);
	}
foot();
exit;	
}
### Удаление бана ###
if(isset($_GET['ban_del']) and !empty($_GET['ank'])){
$ank_id = int($_GET['ank']);
$ank = mysql_fetch_assoc(mysql_query("SELECT `login`,`ban` FROM `users` WHERE `id`='".$ank_id."' LIMIT 1"));
	if(!$ank){
	echo '<div id="error">Пользователь не найден</div>';
	foor();
	exit;
	}
	echo '<div id="ok">Пользователь '.$ank['login'].' разбанен</div>';
	mysql_query("UPDATE `users` SET `ban`=0 WHERE `id`='".$ank_id."'");
@	mysql_query("INSERT INTO `admin_log` SET 
`text`='<a href=\"pers.php?ank=".$user['id']."\">".$user['login']."</a> разблокировал <a href=\"pers.php?ank=".$ank['id']."\">".$ank['login']."</a></b>',
	`time`='".time()."'");
foot();
exit;
}
if(isset($_GET['ban_list'])){
echo '<div class="name">Бан-Лист</div><div class="row">';
$total = mysql_result(mysql_query("SELECT COUNT(id) FROM `users` WHERE `ban`=1"),0);
	if($total == 0){
	echo 'Никто еще не провенился</div>';
	foot();
	exit;
	}
$q_ban = mysql_query("SELECT `login`,`id` FROM `users` WHERE `ban`=1 ORDER BY `time` DESC LIMIT ".$page.",".$set['str']." ");
while($row_ban = mysql_fetch_assoc($q_ban)){
echo '<a href="pers.php?ank='.$row_ban['id'].'">'.$row_ban['login'].'</a>|<a class="btn" href="admins.php?ban_del&amp;ank='.$row_ban['id'].'">разбан</a><br>';
}
echo '</div>';
if($total > $set['str'])
	{
		pages($page, $total, 'admins.php?ban_list&amp;', $set['str']);
	}
	foot();
exit;
}


if(isset($_GET['add_invent']) and $user['id']==23){
if($user['id']!=1){header ('location : index.php');exit;}
$sql_cat = mysql_query("SELECT * FROM `inventory_cat`");
/* Проверяем */
echo '<div class="name">Добавить инвентарь</div><div class="row">';
	if(!empty($_POST['name']) and !empty($_POST['cat']) and !empty($_POST['img'])){
	$cat = int($_POST['cat']);
	$name = protect($_POST['name']);
	$img = protect($_POST['img']);
	$hp = int($_POST['hp']);
	$mp = int($_POST['mp']);
	$strength = int($_POST['strength']);
	$defense = int($_POST['defense']);
	$hp_rec = int($_POST['hp_rec']);
	$mp_rec= int($_POST['mp_rec']);
	$money = int($_POST['money']);
	$rubin = int($_POST['rubin']);
	$virus= int($_POST['virus']);
	$vak = int($_POST['vak']);
		if($cat > mysql_num_rows($sql_cat) or $cat ==0){
		echo 'Категория не выбрана!</div>';
		foot();
		exit;
		}
		foot();
		exit;
		}
	
	mysql_query("INSERT INTO `inventory` SET 
	`cat_id`='".$cat."',
	`name`='".$name."',
	`img`='".$img."',
	`hp`='".$hp."',
	`mp`='".$mp."',
	`strength`='".$strength."',
	`defense`='".$defense."',
	`hp_recovery`='".$hp_rec."',
	`mp_recovery`='".$mp_rec."',
	`money`='".$money."',
	`rubin`='".$rubin."'");
	
	echo 'Инвентарь добавлен';
echo '<form action="admins.php?add_invent" method="post">
<select name="cat">';
echo '
</select><br>
Название:<br>
<input type="text" name="name"><br>
Картинка (относительно корня сайта):<br>
<input type="text" name="img" style="width: 90%;"><br>
HP:<br>
<input type="text" name="hp" size="4"><br>
MP:<br>
<input type="text" name="mp" size="4"><br>
Сила:<br>
<input type="text" name="strength" size="4"><br>
Защита:<br>
<input type="text" name="defense" size="4"><br>
Цена (Золото):<br>
<input type="text" name="money" size="4"><br>
Цена (Рубины):<br>
<input type="text" name="rubin" size="4"><br>
<div class="text">Для банок(если не нужно отсавить пустым)<br>
HP:<br>
<input type="text" name="hp_rec"  size="4"><br>
MP:<br>
<input type="text" name="mp_rec"  size="4"><br></div>
<div class="text">Вирусы/Вакцина(если не нужно оставить пустым)<br>
HP-АНТИреген:<br>
<input type="text" name="virus"  size="4"><br>
HP-реген:<br>
<input type="text" name="vak"  size="4"><br></div>
<input type="submit" value="Добавить"><br>
</form>';
echo '</div>';
echo '<div class="row">';

if($user['id']==23){
echo '

<div class="main">

<div class="menuList">

<li><a href="admins.php?clans"><img src="img/ico.png">Кланы</a></li>

<li><a href="admins.php?logs"><img src="img/ico.png">Логи администрации</a></li>

<li><a href="admins.php?add_invent"><img src="img/ico.png">Добавить инвентарь</a></li>

<li><a href="admins.php?ank='.$user['id'].'&amp;money_pers"><img src="img/ico.png">Изменить свой счет</a></li>

<li><a href="admins.php?clear"><img src="img/ico.png">Очистить форум
';

if(isset($_GET['clear'])){
mysql_query("DELETE FROM `forum_topics`");
mysql_query("DELETE FROM `forum_msg`");
echo' - <font color="lime">Форум очищен!</font><br/>';
}

echo'

<li><a href="admins.php?chat"><img src="img/ico.png">Очистить чат

';

if(isset($_GET['chat'])){
mysql_query("DELETE FROM `chat`");
echo' - <font color="lime">Чат очищен!</font><br/>';
}

echo '
</a></li>
';

}

echo '

<div class="main">

<div class="menuList">





<a class="btn" href="admins.php?ban_list"><img src="img/ico.png">Бан-Лист</a>



</div></div></div>';

}
foot();
?>