<?

if(isset($_POST['nick']) && isset($_GET['ok']))
{
$nick=my_esc($_POST['nick']);
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `nick` = '$nick'"),0)!=0)
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `nick` = '$nick'"));
header("Location:/?admin=users&edit=$ank[id]");
}
else echo err_game("Игрок не найден");
}

if(isset($_GET['img']) && intval($_GET['img'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['img'])."'"),0)!=0)
{
$edit=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['img'])."'"));

if(isset($_POST['ok'])){
if(isset($_FILES['file'])){
$type = $_FILES['file']['type'];
if($type!=='image/jpeg' && $type!=='image/jpg' && $type!=='image/gif' && $type!=='image/png'){$err=1;err_game('Это не картинка');}



if (eregi('\.jpe?g$',$_FILES['file']['name']) && $imgc=@imagecreatefromjpeg($_FILES['file']['tmp_name'])){
if (imagesx($imgc)>16 || imagesy($imgc)>16)
{
$img_x=imagesx($imgc);
$img_y=imagesy($imgc);
if ($img_x==$img_y)
{
$dstW=16; // ширина
$dstH=16; // высота 
}
elseif ($img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=16;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=16;
$dstW=ceil($dstH/$prop);
}

$screen=imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
imagedestroy($imgc);
@chmod("images/my_iconka/$edit[id].jpg",0777);
@chmod("images/my_iconka/$edit[id].gif",0777);
@chmod("images/my_iconka/$edit[id].png",0777);
@unlink("images/my_iconka/$edit[id].jpg");
@unlink("images/my_iconka/$edit[id].gif");
@unlink("images/my_iconka/$edit[id].png");
imagejpeg($screen,"images/my_iconka/$edit[id].jpg",100);
@chmod("images/my_iconka/$edit[id].jpg",0777);
imagedestroy($screen);}else{
copy($_FILES['file']['tmp_name'],"images/my_iconka/$edit[id].jpg");}}
elseif (eregi('\.gif$',$_FILES['file']['name']) && $imgc=@imagecreatefromgif($_FILES['file']['tmp_name']))
{
include_once 'inc/gif_resize.php';
$screen=gif_resize(fread ( fopen ($_FILES['file']['tmp_name'], "rb" ), filesize ($_FILES['file']['tmp_name']) ),16,16);
@chmod("images/my_iconka/$edit[id].jpg",0777);
@chmod("images/my_iconka/$edit[id].gif",0777);
@chmod("images/my_iconka/$edit[id].png",0777);
@unlink("images/my_iconka/$edit[id].jpg");
@unlink("images/my_iconka/$edit[id].gif");
@unlink("images/my_iconka/$edit[id].png");

file_put_contents("images/my_iconka/$edit[id].gif",$screen);
@chmod("images/my_iconka/$ku[id].gif",0777);}
elseif (eregi('\.png$',$_FILES['file']['name']) && $imgc=@imagecreatefrompng($_FILES['file']['tmp_name'])){
if(imagesx($imgc)>16 || imagesy($imgc)>16){
$img_x=imagesx($imgc);
$img_y=imagesy($imgc);
if ($img_x==$img_y){
$dstW=16; // ширина
$dstH=16; // высота
}
elseif ($img_x>$img_y){
$prop=$img_x/$img_y;
$dstW=16;
$dstH=ceil($dstW/$prop);
}else{
$prop=$img_y/$img_x;
$dstH=16;
$dstW=ceil($dstH/$prop);}

$screen=ImageCreate($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
imagedestroy($imgc);


@chmod("images/my_iconka/$edit[id].jpg",0777);
@chmod("images/my_iconka/$edit[id].gif",0777);
@chmod("images/my_iconka/$edit[id].png",0777);
@unlink("images/my_iconka/$edit[id].jpg");
@unlink("images/my_iconka/$edit[id].gif");
@unlink("images/my_iconka/$edit[id].png");
imagepng($screen,"images/my_iconka/$edit[id].png");
@chmod("images/my_iconka/$edit[id].png",0777);
imagedestroy($screen);
}else{

copy($_FILES['file']['tmp_name'],"images/my_iconka/$edit[id].png");}
}

mysql_query("UPDATE `kolhoz_user` SET `my_iconka` = '1' WHERE `id` = '$edit[id]'");
header("Location:/?admin=$admin&edit=$edit[id]");
$_SESSION['msg']='Изменения успешно приняты';}}
echo "<div class='event'><title>Иконка фермера</title></div>";
echo '<div class="content"><div class="block">';

if($edit['my_iconka']>0){

if (is_file("images/my_iconka/$edit[id].gif"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].gif' alt='o' class='portrait'>\n";
elseif (is_file("images/my_iconka/$edit[id].jpg"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].jpg' alt='o' class='portrait'>\n";
elseif (is_file("images/my_iconka/$edit[id].png"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].png' alt='o' class='portrait'>\n";}
echo "Выберите иконку для загрузки: ";
echo "<form method=\"post\" enctype='multipart/form-data'>";
echo "<input type='file' name='file' /><br>";
echo "<span class='minor'>Можно загружать картинки форматов: GIF, JPG, PNG</span><br>";
echo "<span class='minor'>Качественное преобразование GIF-анимации не гарантируется</span><br>";
echo "<input value='Загрузить' type='submit' name='ok' /><br></form>";
echo "</div>";
include_once 'inc/foot.php';
}

if(isset($_GET['edit']) && intval($_GET['edit'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['edit'])."'"),0)!=0)
{
$edit=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['edit'])."'"));






echo "<div class='event'><h1><a href='/?admin=$admin'>$admin_name</a> / $edit[nick]</h1></div>";
echo '<div class="content"><div class="block">';


if(isset($_POST['ok'])){
$nick=mysql_real_escape_string($_POST['nick']);
$money=($_POST['money']);
$arena_rating=intval($_POST['arena_rating']);
$rubies=($_POST['rubies']);
$level=intval($_POST['level']);
$name=my_esc($_POST['name']);
$city=my_esc($_POST['city']);
$email=my_esc($_POST['email']);
$contacts=my_esc($_POST['contacts']);
$pass=my_esc($_POST['new_pass']);
$arena_rating=intval($_POST['arena_rating']);
$dop_bilet=intval($_POST['dop_bilet']);
$big_rat=intval($_POST['big_rat']);




if(!is_numeric($money) || strlen2($money)<1){$err=1;err_game('Неверное к-во монет');}
if(!is_numeric($rubies) || strlen2($rubies)<1){$err=1;err_game('Неверное к-во рубинов');}
if(!is_numeric($level) || strlen2($level)<1){$err=1;err_game('Неверный уровень');}

if(!is_numeric($arena_rating) || strlen2($arena_rating)<1){$err=1;err_game('Неверное арена рейтинг');}
if (!isset($err))
{
if (isset($_POST['new_pass']) && strlen2($_POST['new_pass'])>5){mysql_query("UPDATE `kolhoz_user` SET `password` = '".md5($_POST['new_pass'])."' WHERE `id` = '$edit[id]' LIMIT 1");}

mysql_query("INSERT INTO `kolhoz_edit_log` SET `id_adm` = '$ku[id]',`id_user` = '$edit[id]',`money` = '$edit[money]',`money_fix` = '$money',`rubies` = '$edit[rubies]',`rubies_fix` = '$rubies',`level` = '$edit[level]',`level_fix` = '$level',`time` = '$time',`name` = '$edit[name]',`name_fix` = '$name',`city` = '$edit[city]',`city_fix` = '$city',`emeil` = '$edit[email]',`emeil_fix` = '$email',`contacts` = '$edit[contacts]',`contacts_fix` = '$contacts',`pass_new` = '$pass',`arena_rating` = '$edit[arena_rating]',`arena_rating_fix` = '$arena_rating',`gold` = '$edit[gold]',`gold_fix` = '$gold'");
//,
mysql_query("UPDATE `kolhoz_user` SET `name` = '$name',`city` = '$city',`email` = '$email',`contacts` = '$contacts',`money` = '$money',`rubies` = '$rubies',`level` = '$level',`gold` = '".($gold)."',`arena_rating` = '$arena_rating',`dop_bilet` = '$dop_bilet',`big_rat` = '$big_rat' WHERE `id` = '$edit[id]'");

$_SESSION['msg']='Изменения успешно приняты';
header("Location:/?admin=$admin");}}

function time_gold_m($tl){
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);

$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);

$minute=floor($tl/60);
$tl=$tl-(60*$minute);
return "$minute";}

function time_gold_c($tl){
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);

$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);

$minute=floor($tl/60);
$tl=$tl-(60*$minute);
return "$hour";}

function time_gold_d($tl){
$hour=floor($tl/86400);
$tl=$tl-(86400*$hour);
return "$hour";}


//$user_admin_mod = mysql_fetch_array(mysql_querll('SELECT `id`,`nick`,`money`,`rating`,`rubies`,`level`,`zkl`,`sh_time`,`almaznaya_time`,`plat_rol_time`,`euro` FROM `kolhoz_user` WHERE `id`="'.intval($_GET['admin_mod']).'"'));






if($edit['my_iconka']>0){
if (is_file("images/my_iconka/$edit[id].gif"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].gif' alt='o' class='portrait'>\n";
elseif (is_file("images/my_iconka/$edit[id].jpg"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].jpg' alt='o' class='portrait'>\n";
elseif (is_file("images/my_iconka/$edit[id].png"))echo "<img width='48' height='48' src='images/my_iconka/$edit[id].png' alt='o' class='portrait'>\n";}

echo '<hr size="1" color="#114411"/>'."\n";
echo "<a href='/?admin=$admin&&img=$edit[id]'>[заменить иконку]</a>\n";
echo " | <a href='/?admin=$admin&&del_img=$edit[id]'>[удалить иконку]</a>\n";
echo '<hr size="1" color="#114411"/>'."\n";


//==========================================================//
if($_POST['nick_submit']!=''){
$a=mysql_real_escape_string($_POST['nick_number']);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="nick_log", `one_value`="'.intval($edit['nick']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `nick`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Ник: <input type="text" size="25" name="nick_number" value="'.htmlspecialchars($edit['nick']).'"/> <input type="submit" name="nick_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';
//=========================у=================================//
if($_POST['name_submit']!=''){
$a=mysql_real_escape_string($_POST['name_number']);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="name_log", `one_value`="'.intval($edit['name']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `name`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Имя в реале: <input type="text" size="25" name="name_number" value="'.htmlspecialchars($edit['name']).'"/> <input type="submit" name="name_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

if($_POST['city_submit']!=''){
$a=mysql_real_escape_string($_POST['city_number']);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="city_log", `one_value`="'.intval($edit['city']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `city`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Город: <input type="text" size="25" name="city_number" value="'.htmlspecialchars($edit['city']).'"/> <input type="submit" name="city_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['email_submit']!=''){
$a=mysql_real_escape_string($_POST['email_number']);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="email_log", `one_value`="'.intval($edit['email']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `email`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'E-mail: <input type="text" size="25" name="email_number" value="'.htmlspecialchars($edit['email']).'"/> <input type="submit" name="email_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['contacts_submit']!=''){
$a=mysql_real_escape_string($_POST['contacts_number']);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="contacts_log", `one_value`="'.intval($edit['contacts']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `contacts`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'О себе: <input type="text" size="25" name="contacts_number" value="'.htmlspecialchars($edit['contacts']).'"/> <input type="submit" name="contacts_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//

echo '<hr size="1" color="#114411"/>'."\n";
//==========================================================//
if($_POST['new_pass_submit']!=''){
$a=mysql_real_escape_string($_POST['new_pass_number']);
$a=md5($a);
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="new_pass_log", `one_value`="", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `password`="'.$a.'",`autologin`="nick:'.$edit['nick'].',password:'.$a.',id:'.$edit['id'].'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Новый пароль: <input type="text" size="25" name="new_pass_number" value=""/> <input type="submit" name="new_pass_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo '<hr size="1" color="#114411"/>'."\n";
//==========================================================//
if($ku['id']==86)
{
if($_POST['fermoney_submit']!=''){
$a = floor($_POST['fermoney_number']);
if(($a < 0)||($a == '')){$a = 0;}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="fermoney_log", `one_value`="'.intval($edit['fermoney']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `fermoney`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Фермани: <input type="text" size="25" name="fermoney_number" value="'.intval($edit['fermoney']).'"/> <input type="submit" name="fermoney_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';
}
if($_POST['money_submit']!=''){
$a = floor($_POST['money_number']);
if(($a < 0)||($a == '')){$a = 0;}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="money_log", `one_value`="'.intval($edit['money']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `money`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Монеты: <input type="text" size="25" name="money_number" value="'.intval($edit['money']).'"/> <input type="submit" name="money_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['rubies_submit']!=''){
$a = floor($_POST['rubies_number']);
if(($a < 0)||($a == '')){$a = 0;}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="rubies_log", `one_value`="'.intval($edit['rubies']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `rubies`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Рубины: <input type="text" size="25" name="rubies_number" value="'.intval($edit['rubies']).'"/> <input type="submit" name="rubies_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['rating_submit']!=''){
$a = floor($_POST['rating_number']);
if(($a < 0)||($a == '')){$a = 0;}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="rating_log", `one_value`="'.intval($edit['rating']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `rating`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Опыт: <input type="text" size="25" name="rating_number" value="'.intval($edit['rating']).'"/> <input type="submit" name="rating_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['level_submit']!=''){

$a = floor($_POST['level_number']);
if(($a < 0)||($a == '')){$a = 1;}
$sql_ww = mysql_query("SELECT * FROM `kolhoz_level` ORDER BY `id`");
$ee_ww = 1;
while($sql_array = mysql_fetch_array($sql_ww)){
$ee_ww += $sql_array['rating'];
if($sql_array['level']>70){$ee_ww += 5000;}
if($sql_array['level'] == $a){break;}
}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="level_log", `one_value`="'.intval($edit['level']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `level`="'.$a.'", `rating`="'.$ee_ww.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Уровень: <input type="text" size="25" name="level_number" value="'.intval($edit['level']).'"/> <input type="submit" name="level_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['arena_rating_submit']!=''){

$a = floor($_POST['arena_rating_number']);
if(($a < 0)||($a == '')){$a = 0;}

// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="arena_rating_log", `one_value`="'.intval($edit['arena_rating']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `arena_rating`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Арена рейтинг: <input type="text" size="25" name="arena_rating_number" value="'.intval($edit['arena_rating']).'"/> <input type="submit" name="arena_rating_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//

echo '<hr size="1" color="#114411"/>'."\n";
//==========================================================//
if($_POST['time_vip_submit']!=''){
$time_vip_m=intval($_POST['time_vip_m']);

$time_vip_c=intval($_POST['time_vip_c']);

$time_vip_d=intval($_POST['time_vip_d']);

if($time_vip_m>0){$time_vip_mw=($time_vip_m*60);}else{$time_vip_mw=0;}

if($time_vip_c>0){$time_vip_cw=($time_vip_c*3600);}else{$time_vip_cw=0;}

if($time_vip_d>0){$time_vip_dw=($time_vip_d*86400);}else{$time_vip_dw=0;}


$a =$time_vip_dw+$time_vip_cw+$time_vip_mw+$time;

// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="time_vip_log", `one_value`="'.intval($edit['time_vip']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `time_vip`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";

echo "VIP Статус: Дней /Часов/минут </br><input name='time_vip_d' type='text' maxlength='2' size='2' value='".($edit['time_vip']>$time?"".time_gold_d($edit['time_vip']-$time)."":"0")."'> <input name='time_vip_c' type='text' maxlength='2' size='2' value='".($edit['time_vip']>$time?"".time_gold_c($edit['time_vip']-$time)."":"0")."'> <input name='time_vip_m' type='text' maxlength='2' size='2' value='".($edit['time_vip']>$time?"".time_gold_m($edit['time_vip']-$time)."":"0")."'> \n";

echo '<input type="submit" name="time_vip_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['time_submit']!=''){
$gold_m=intval($_POST['time_m']);

$gold_c=intval($_POST['time_c']);

$gold_d=intval($_POST['time_d']);

if($gold_m>0){$gold_mw=($gold_m*60);}else{$gold_mw=0;}

if($gold_c>0){$gold_cw=($gold_c*3600);}else{$gold_cw=0;}

if($gold_d>0){$gold_dw=($gold_d*86400);}else{$gold_dw=0;}


$a =$gold_dw+$gold_cw+$gold_mw;

// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="time_log", `one_value`="'.intval($edit['time']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `time`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo "Время онлайн: Дней /Часов/минут </br><input name='time_d' type='text' maxlength='2' size='2' value='".time_gold_d($edit['time'])."'> <input name='time_c' type='text' maxlength='2' size='2' value='".time_gold_c($edit['time'])."'> <input name='time_m' type='text' maxlength='2' size='2' value='".time_gold_m($edit['time'])."'> \n";

echo '<input type="submit" name="time_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['reg_submit']!=''){
$a=strtotime($_POST['reg_number']);
mysql_query('UPDATE `kolhoz_user` SET `time_start`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Дата регистрации: <input type="text" size="25" name="reg_number" value="'.(date("d.m.Y H:i:s",$edit['time_start'])).'"/> <input type="submit" name="reg_submit" value="OK"/>'."\n";
echo '</form>'."\n";
//==========================================================//
echo'<li class="pavelgrey">';

//==========================================================//
if($_POST['dop_bilet_submit']!=''){
$a = floor($_POST['dop_bilet_number']);
if(($a < 0)||($a == '')){$a = 0;}
// Логирование
mysql_query('INSERT INTO `admin_mod_log` SET `id_user`="'.$ku['id'].'", `type`="dop_bilet_log", `one_value`="'.intval($edit['dop_bilet']).'", `two_value`="'.$a.'", `time`="'.time().'", `id_komu`="'.$edit['id'].'"');
mysql_query('UPDATE `kolhoz_user` SET `dop_bilet`="'.$a.'" WHERE id="'.$edit['id'].'"');
header('location:/?admin='.$admin.'&edit='.$edit['id']); exit;
}
echo '<form method="post" action="/?admin='.$admin.'&edit='.$edit['id'].'">'."\n";
echo 'Билеты: <input type="text" size="25" name="dop_bilet_number" value="'.intval($edit['dop_bilet']).'"/> <input type="submit"name="dop_bilet_submit" value="OK"/>'."\n";
echo'</form>'."\n";

//==========================================================//

//==========================================================//
//==========================================================//


echo "</div>";
include_once 'inc/foot.php';
exit;
}

if(isset($_GET['del_img']) && intval($_GET['del_img'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['del_img'])."'"),0)!=0)
{
$del=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['del_img'])."'"));
if(isset($_GET['ok']))
{
mysql_query("UPDATE `kolhoz_user` SET `my_iconka` = '0' WHERE `id` = '$del[id]'");
unlink("images/my_iconka/$del[id].jpg");
unlink("images/my_iconka/$del[id].gif");
unlink("images/my_iconka/$del[id].png");
header("Location:/?admin=$admin&edit=$del[id]");
}
podtv("/?admin=$admin&del_img=$del[id]&ok","/?admin=$admin&edit=$del[id]");
include_once 'inc/foot.php';
}

if(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['del'])."'"),0)!=0)
{
$del=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['del'])."'"));
if(isset($_GET['ok']))
{
mysql_query("DELETE FROM `kolhoz_user` WHERE `id` = '$del[id]'");

header("Location:/?admin=$admin");
}
podtv("/?admin=$admin&del=$del[id]&ok","/?admin=$admin");
include_once 'inc/foot.php';
}

echo "<div class='event'><h1><a href='/?admin=list'>Админка</a> / $admin_name</h1></div>";
echo '<div class="content"><div class="block">';




$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user`"),0);
if ($k_post==0)
{
echo "Список пользователей пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `kolhoz_user` ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo "<ul>";
while($post=mysql_fetch_array($q))
{
echo "<li style='padding-bottom:8px'>";
echo "<div><span><a href= '/?admin=$admin&edit=$post[id]'>ID ".hsc($post['id'])."</a></span><span class='minor'>, </span><span><img width='16' height='16' src='images/icons/money.png' alt='o'><span class='title'>$post[money]</span>, <img width='16' height='16' src='images/icons/ruby.png' alt='o'><span class='title'>$post[rubies]</span></span></div><div style='clear:both'></div></li>";
}
echo "Введите ник игрока:</span><br/><form method='post' action='/?admin=users&ok'>";
echo "<input type='text' name='nick'  value=''><br/>";
echo "<input type='submit' name='ok' value='Пoиcк'>";
if ($k_page>1)new_str("/?admin=$admin&",$k_page,$page); // Вывод страниц
echo "</ul></div>";
include_once 'inc/foot.php';
?>