<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
user_access('adm_show_adm',null,'index.php?'.SID);
adm_check();
Error_Reporting(E_ALL & ~E_NOTICE);
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
else {header("Location: /index.php?".SID);exit;}


if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}


$ank=get_user($ank['id']);
if ($user['level']<=$ank['level']){header("Location: /index.php?".SID);exit;}




$set['title']='Назначить VIP'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($_POST['save'])){

if(isset($_POST['ank_vip']))
{
$ank['ank_vip'] = intval($_POST['ank_vip']);
mysql_query("UPDATE `user` SET `ank_vip` = '$ank[ank_vip]' WHERE `id` = '$ank[id]' LIMIT 1");
}

if(isset($_POST['ank_odobr']))
{
$ank['ank_odobr'] = intval($_POST['ank_odobr']);
mysql_query("UPDATE `user` SET `ank_odobr` = '$ank[ank_odobr]' WHERE `id` = '$ank[id]' LIMIT 1");
}

if(isset($_POST['ank_doss_k']))
{
$ank['ank_doss_k'] = intval($_POST['ank_doss_k']);
mysql_query("UPDATE `user` SET `ank_doss_k` = '$ank[ank_doss_k]' WHERE `id` = '$ank[id]' LIMIT 1");
}

if(isset($_POST['avtoritet']))
{
$ank['avtoritet'] = intval($_POST['avtoritet']);
mysql_query("UPDATE `user` SET `avtoritet` = '$ank[avtoritet]' WHERE `id` = '$ank[id]' LIMIT 1");
}

if (isset($_POST['ank_wmid']) && (is_numeric($_POST['ank_wmid']) && strlen($_POST['ank_wmid'])>=1 && strlen($_POST['ank_wmid'])<=19 || $_POST['ank_wmid']==NULL))
{
$ank['ank_wmid']=$_POST['ank_wmid'];
mysql_query("UPDATE `user` SET `ank_wmid` = '".my_esc($ank['ank_wmid'])."' WHERE `id` = '$ank[id]' LIMIT 1");
}
else $err='Неверный формат номера WMID';

if (isset($_POST['ank_wmr']) && (is_numeric($_POST['ank_wmr']) && strlen($_POST['ank_wmr'])>=0 && strlen($_POST['ank_wmr'])<=12 || $_POST['ank_wmr']==NULL))
{
$ank['ank_wmr']=$_POST['ank_wmr'];
mysql_query("UPDATE `user` SET `ank_wmr` = '".my_esc($ank['ank_wmr'])."' WHERE `id` = '$ank[id]' LIMIT 1");
}
else $err='Неверный формат номера WMR';


if (!isset($err))msg('Изменения успешно приняты');
}
err();
aut();
echo "<form method='post' action='vip.php?id=$ank[id]'>";
echo "<div class='wm'>\n";
echo "WM Статус:<br/>\n<select name=\"ank_vip\">\n";
if ($ank['ank_vip']==0)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"0\"$sel>--------</option>\n";
if ($ank['ank_vip']==1)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"1\"$sel>Мошенник</option>\n";
if ($ank['ank_vip']==2)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"2\"$sel>VIP юзер</option>\n";
if ($ank['ank_vip']==3)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"3\"$sel>Гарант</option>\n";
if ($ank['ank_vip']==4)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"4\"$sel>PRO</option>\n";
echo "</select><br />\n";

echo "WM Команда:<br />\n<select name=\"ank_doss_k\">\n";
if ($ank['ank_doss_k']==0)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"0\"$sel>НеТ!</option>\n";
if ($ank['ank_doss_k']==1)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"1\"$sel>Да!</option>\n";
echo "</select><br />\n";

echo "Одобрение:<br/>\n<select name=\"ank_odobr\">\n";
if ($ank['ank_odobr']==0)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"0\"$sel>--------</option>\n";
if ($ank['ank_odobr']==1)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"1\"$sel>Да</option>\n";
if ($ank['ank_odobr']==2)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"2\"$sel>Нет</option>\n";
echo "</select><br />\n";

echo "Авторитет:<br/>\n<select name=\"avtoritet\">\n";
if ($ank['avtoritet']==0)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"0\"$sel>--------</option>\n";
if ($ank['avtoritet']==1)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"1\"$sel>1 звезда</option>\n";
if ($ank['avtoritet']==2)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"2\"$sel>2 звезды</option>\n";
if ($ank['avtoritet']==3)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"3\"$sel>3 звезды</option>\n";
if ($ank['avtoritet']==4)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"4\"$sel>4 звезды</option>\n";
if ($ank['avtoritet']==5)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"5\"$sel>5 звезд</option>\n";
echo "</select><br />\n";
echo "WMID:<br />\n<input type='text' name='ank_wmid' value='$ank[ank_wmid]' maxlength='18' /><br />\n";

echo "WMR:<br />\n<input type='text' name='ank_wmr' value='$ank[ank_wmr]' maxlength='12' /><br />\n";

echo "</div>\n";
echo "<div class='wm'>\n";
echo "<input type='submit' name='save' value='Сохранить' />\n";
echo "</form>\n";
echo "</div>\n";
echo "<div class='foot'>\n";
echo "&raquo;<a href=\"/mail.php?id=$ank[id]\">Написать сообщение</a><br />\n";
echo "&laquo;<a href=\"/info.php?id=$ank[id]\">В анкету</a><br />\n";
if (user_access('adm_panel_show'))
echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
?>
