<?
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';
$set['title']='Добавление в закладки'; //
include_once 'sys/inc/thead.php';
only_reg(); // только для зарегистрированы
title();
##################################################################################################
if (isset($user) && $user['id']!=$ank['id'])
{
$act = isset ( $_GET['act'] ) ? $_GET['act'] : NULL;
switch ($act) {
case 'add_url' :
$url = isset($_GET['url']) ? rawurldecode(trim($_GET['url'])) : null;
if (isset($_POST['submit'])) {
$name = isset($_POST['name']) ? trim($_POST['name']) : null;
if (!$name) {
if (!isset($err))msg('Вы не ввели название закладки<br /><a href="link.php?act=add_url&amp;url=' . htmlentities(rawurlencode($url), ENT_QUOTES, 'UTF-8') . '">Повторить</a>');
require_once ("../incfiles/end.php");
exit;
}
$url =$_GET['url'];
$name=$_POST['name'];
mysql_query("INSERT INTO `favorites` (`id_user`, `time`, `name`, `url`) values('$user[id]', '$time', '$name', '$url')");
if (!isset($err))msg('Закладка добавлена');
}
else {
$name = isset($_GET['textl']) ? htmlentities(rawurldecode(trim($_GET['textl'])), ENT_QUOTES, 'UTF-8') : '';
echo '<div class="phdr"><b>Добавление закладки</b></div>';
echo '<div class="menu"><span style="color:green">Введите имя закладки</span> <span style="color:red">(max. - 200)</span>';
echo '<form action="link.php?act=add_url&amp;url=' . htmlentities(rawurlencode($url), ENT_QUOTES, 'UTF-8') . '" method="post"><input type="text" name="name" value="' . $name . '"/><br /><input type="submit" name="submit" value="Добавить"/></form></div>';
echo '<div class="phdr"><a href="' . htmlentities($url, ENT_QUOTES, 'UTF-8') . '">Вернуться</a></div>';
}
break;
default:
$nik = mysql_query("UPDATE `user` WHERE `id` = '$user[id]' LIMIT 1");
while ($nik1 = mysql_fetch_array($nik))
{
echo '<div class="phdr"><b>Закладки | <a href="anketa.php?id=' . $nik1['id'] . '">'.$nik1['name'].'</a></b></div>';}
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `favorites` 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'];
$req = mysql_query("SELECT * FROM `favorites` WHERE `id_user`='$user[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($res = mysql_fetch_array($req)) {
if($num==1){
echo "<div class='rowdown'>";
$num=0;
}else{
echo "<div class='rowup'>";
$num=1;}
echo '<a href="' . $res['url'] . '">' . $res['name'] . '</a> <span style="color: #209143">[' . date("d.m.y / H:i", $res['time']) . ']</span><br />';
echo '[<a href="/zdelete.php?id='.$res[id].'"><span style="color:red"><b>x</b></span> удал</a>]<br />';
echo "</div>\n";
echo '</div>';
}
if($total==0){
echo '<div class="menu">Список пуст,закладок нет!</div>';
}
echo '<div class="end">Закладок всего: ' . $total . '</div>';
include_once 'sys/inc/tfoot.php';
if ($total > $kmess) {
echo '<p>' . pagenav('link.php?id=' . $user[id] .'&amp;', $start, $total, $kmess) . '</p>';
}
}
}
include_once 'sys/inc/tfoot.php';
?>