<?
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';
only_reg();
$page = (isset($_GET['page'])) ? htmlspecialchars($_GET['page']) : null;
switch($page){
default:
$set['title']='Закладки';
include_once '../sys/inc/thead.php';
title();
aut();
echo '<div class="p_m"><img src="icons/admin.png"> <b><a href="admin.php">Админка закладок</a></b></div>';
echo '<div class="p_m"><img src="icons/edit.png"> <b><a href="?page=set&settings">Настройки закладок</a></b></div>';
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `zakladki_dir` where `id_user`='$user[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if($k_post==0)
{
echo "<div class='err'>Папок нет.</div>";
}
$zakladki = mysql_query("select * from `zakladki_dir` where `id_user`='$user[id]' ORDER by `id` DESC LIMIT $start, $set[p_str];"); 
while ($zakladka = mysql_fetch_array($zakladki)){
echo "<div class='p_t'><img src='icons/dir.png' alt='' /> <a href='dir.php?dir=$zakladka[id]'>$zakladka[name]</a>";
echo " (".mysql_result(mysql_query("SELECT COUNT(*) FROM `zakladki` WHERE `id_dir` = '$zakladka[id]' and `id_user`='$user[id]'"),0).")</div>";
}
if ($k_page>1)str("?",$k_page,$page);
include_once '../sys/inc/tfoot.php';
break;
case 'set':
$set['title']='Настройка закладок';
include_once '../sys/inc/thead.php';
title();
aut();
if (isset($_GET['settings']) && isset($_POST['set']) && is_numeric($_POST['set']))
{
$s=intval($_POST['set']);
if (!isset($err)){
mysql_query("UPDATE `zakladki` SET `set` = '$s' Where `id_user`='$user[id]'");
msg('Настройки изменены.');
}
}
$r = mysql_fetch_array(mysql_query("select * from `zakladki` WHERE `id_user`='$user[id]'"));
if (isset($_GET['settings']))
{
echo "<form class='menu' method='post' action='?page=set&settings'>";
echo "Режим отображения:<br><select name=\"set\">";
if ($r['set']=='0')$choice=' selected="selected"';else $choice=NULL;
echo "<option value=\"0\"$choice>Словами</option>";
if ($r['set']=='1')$choice=' selected="selected"';else $choice=NULL;
echo "<option value=\"1\"$choice>Скриншотами</option>";
echo "</select>";
echo "<input value=\"Изменить\" type=\"submit\" />";
echo "</form>";
}
echo "<div class='p_m'><img src='icons/back.png'> <a href='/zakladki'>В закладки</a></div>";
include_once '../sys/inc/tfoot.php';
break;
}
?>