<?
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/user.php';

if (!isset($user) && !isset($_GET['id'])){header("Location: /index.php?".SID);exit;}
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
$set['title']=$ank['nick'].' - привилегии '; // заголовок страницы
include_once 'sys/inc/thead.php';
title();

aut();
if ((!isset($_SESSION['refer']) || $_SESSION['refer']==NULL)
&& isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL &&
!ereg('info\.php',$_SERVER['HTTP_REFERER']))
$_SESSION['refer']=str_replace('&','&amp;',ereg_replace('^http://[^/]*/','/', $_SERVER['HTTP_REFERER']));

echo "<table class='post'>\n";

echo "<tr>";
echo "  <td class='p_t'>\n";
echo "Пользователь\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";

$q=mysql_query("SELECT * FROM `accesses` WHERE `level` = '0' ORDER BY `type` ASC");
while ($post = mysql_fetch_array($q))
{
echo "<label>";
$ch=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_acсess` WHERE `id_user` = '$ank[id]' AND `type` = '$post[type]' LIMIT 1"),0)==1)
$ch=' checked="checked"';

echo "<input type='checkbox' disabled='disabled'$ch name='$post[type]' value='1' />";

echo $post['name'];
echo "</label><br />\n";
}
echo "  </td>\n";
echo "   </tr>\n";




echo "<tr>";
echo "  <td class='p_t'>\n";
echo "Модератор\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";

$q=mysql_query("SELECT * FROM `accesses` WHERE `level` = '1' ORDER BY `type` ASC");
while ($post = mysql_fetch_array($q))
{
echo "<label>";
$ch=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_acсess` WHERE `id_user` = '$ank[id]' AND `type` = '$post[type]' LIMIT 1"),0)==1)
$ch=' checked="checked"';

echo "<input type='checkbox' disabled='disabled'$ch name='$post[type]' value='1' />";

echo $post['name'];
echo "</label><br />\n";
}
echo "  </td>\n";
echo "   </tr>\n";



echo "<tr>";
echo "  <td class='p_t'>\n";
echo "Супермодератор\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";

$q=mysql_query("SELECT * FROM `accesses` WHERE `level` = '2' ORDER BY `type` ASC");
while ($post = mysql_fetch_array($q))
{
echo "<label>";
$ch=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_acсess` WHERE `id_user` = '$ank[id]' AND `type` = '$post[type]' LIMIT 1"),0)==1)
$ch=' checked="checked"';

echo "<input type='checkbox' disabled='disabled'$ch name='$post[type]' value='1' />";

echo $post['name'];
echo "</label><br />\n";
}
echo "  </td>\n";
echo "   </tr>\n";


echo "<tr>";
echo "  <td class='p_t'>\n";
echo "Администратор\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";

$q=mysql_query("SELECT * FROM `accesses` WHERE `level` = '3' ORDER BY `type` ASC");
while ($post = mysql_fetch_array($q))
{
echo "<label>";
$ch=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_acсess` WHERE `id_user` = '$ank[id]' AND `type` = '$post[type]' LIMIT 1"),0)==1)
$ch=' checked="checked"';

echo "<input type='checkbox' disabled='disabled'$ch name='$post[type]' value='1' />";

echo $post['name'];
echo "</label><br />\n";
}
echo "  </td>\n";
echo "   </tr>\n";


if (isset($user) && $user['level']==4){
echo "<tr>";
echo "  <td class='p_t'>\n";
echo "Главный администратор\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";

$q=mysql_query("SELECT * FROM `accesses` WHERE `level` = '4' ORDER BY `type` ASC");
while ($post = mysql_fetch_array($q))
{
echo "<label>";
$ch=NULL;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user_acсess` WHERE `id_user` = '$ank[id]' AND `type` = '$post[type]' LIMIT 1"),0)==1)
$ch=' checked="checked"';

echo "<input type='checkbox' disabled='disabled'$ch name='$post[type]' value='1' />";

echo $post['name'];
echo "</label><br />\n";
}
echo "  </td>\n";
echo "   </tr>\n";
}

echo "</table>\n";





echo "<div class='foot'>\n";
if (isset($access['user_access_ed']))
echo "&raquo;<a href='/adm_panel/accesses.php?id=$ank[id]'>Изменить привилегии</a><br />";

echo "&laquo;<a href='/info.php?id=$ank[id]'>В анкету</a><br />";

if(isset($_SESSION['refer']) && $_SESSION['refer']!=NULL && otkuda($_SESSION['refer']))
echo "&laquo;<a href='$_SESSION[refer]'>".otkuda($_SESSION['refer'])."</a><br />\n";

echo "</div>\n";
include_once 'sys/inc/tfoot.php';
?>
