Файл: plugins/notes/dir.php
Строк: 163
<?
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';
/* Бан пользователя */
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0)!=0)
{
header('Location: /ban.php?'.SID);exit;
}
$set['title']='Категории';
include_once '../../sys/inc/thead.php';
title();
if (isset($_POST['title']) && user_access('notes_edit'))
{
$title=my_esc($_POST['title'],1);
$msg=my_esc($_POST['msg']);
if (strlen2($title)>32){$err='Название не может превышать больше 32 символов';}
if (strlen2($title)<3){$err='Короткое название';}
if (strlen2($msg)>10024){$err='Содержание не может превышать больше 10024 символов';}
if (strlen2($msg)<2){$err='Содержание слишком короткое';}
if (!isset($err)){
mysql_query("INSERT INTO `notes_dir` (`msg`, `name`) values('$msg', '$title')");
mysql_query("OPTIMIZE TABLE `notes_dir`");
$_SESSION['message']='Категория успешно создана';
header("Location: dir.php?".SID);
exit;
}
}
err();
aut();
//Панель навигации
echo '<table style="text-align:center;" class="mess" cellspacing="0" cellpadding="0">';
echo '<td><a style="border-right:none;" class="panel" href="index.php">Блоги</a></td>';
echo '<td style="border-right:none;" class="panel">Категории</td>';
echo '<td><a class="panel" href="search.php">Поиск</a></td>';
echo '</table>';
echo '<div class="hr"></div>';
/*
==================================
Дневники
==================================
*/
if (isset($_GET['id']))
{
$id_dir=intval($_GET['id']);
$kount=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_dir` WHERE `id` = '$id_dir' "),0);
}
if (isset($_GET['id']) && $kount==1)
{
if (isset($_GET['sort']) && $_GET['sort'] =='t')$order='order by `time` desc';
elseif (isset($_GET['sort']) && $_GET['sort'] =='c') $order='order by `count` desc';
else $order='order by `time` desc';
if (isset($_GET['sort']) && $_GET['sort'] =='t'){
echo'<div class="foot">';
echo"<b>Новые</b> | <a href='?id=$id_dir&sort=c'>Популярные</a>n";
echo '</div>';
}elseif (isset($_GET['sort']) && $_GET['sort'] =='c'){
echo'<div class="foot">';
echo"<a href='?id=$id_dir&sort=t'>Новые</a> | <b>Популярные</b>n";
echo '</div>';
}else{
//echo'<div class="foot">';
//echo"<b>Новые</b> | <a href='?id=$id_dir&sort=c'>Популярные</a>n";
//echo '</div>';
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_dir` = '$id_dir'"),0);
$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 `notes` WHERE `id_dir` = '$id_dir' $order LIMIT $start, $set[p_str]");
if ($k_post==0)
{
echo " <div class='mess'>n";
echo "Нет записейn";
echo " </div>n";
}
$num=0;
while ($post = mysql_fetch_assoc($q)){
echo '<table style="border-bottom:none;" class="mess">';
echo '<td style="vertical-align: top;" width="3%">' .avatar($post['id_user']).'</td><td>';
echo group($post['id_user']);
echo " ".user::nick($post['id_user'])."";
echo '' . online($post['id_user']) . '</br>';
echo "Добавлено ".vremja($post['time'])."</td>";
echo '</table>';
echo '<div class="mess">';
echo "<a href='/plugins/notes/list.php?id=".$post['id']."'><font color='#757577'>".text($post['name'])."</font></a></br>";
echo rez_text($post['msg'],80)."</br></br>";
notes_sh($post['id']);
echo "<span style='font-size: 12px; color: #67676e;'><i class='far fa-eye'></i> ".$post['count']."</span>";
echo '<span style="float:right;">';
echo "<span style='font-size: 12px; color: #67676e;'><i class='far fa-comment-alt'></i> ".mysql_result(mysql_query("SELECT COUNT(`id`)FROM `notes_komm` WHERE `id_notes`='$post[id]'"),0)."</span> ";
$l1=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '0' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$l2=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `like` = '1' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_like` WHERE `id_user` = '".$user['id']."' AND `id_notes` = '".$notes['id']."' LIMIT 1"),0)==0)
echo "<span style='font-size: 12px; color: #67676e;'><i class='fas fa-thumbs-up'></i> ".($l2-$l1)."</span>";
echo '</div>';
}
if (isset($_GET['sort'])) $dop="sort=" . my_esc($_GET['sort']) . "&";
else $dop='';
if ($k_page>1)str('?id='.$id_dir.'&'.$dop.'',$k_page,$page); // Вывод страниц
include_once '../../sys/inc/tfoot.php';
exit;
}
/*
==================================
Категории
==================================
*/
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes_dir` "),0);
$q=mysql_query("SELECT * FROM `notes_dir` ORDER BY `id` DESC");
echo "<table class='post'>n";
if ($k_post==0)
{
echo " <div class='mess'>n";
echo "Нет категорийn";
echo " </div>n";
}
$num=0;
while ($post = mysql_fetch_assoc($q)){
$k_pp=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_dir` = '$post[id]'"),0);
$k_nn=mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_dir` = '$post[id]' AND `time` > '$ftime'"),0);
if ($k_nn>0)
$k_nn="<font color='red'>+$k_nn</font>";
else
$k_nn=NULL;
echo "<a class='link' href='dir.php?id=$post[id]'><i class='fas fa-folder-open'></i> " . output_text($post['name']) . " <span class='c'>$k_pp</span></a>";
if (isset($user) && ($user['level']>3))
echo "<div class='main'><a href='delete.php?dir=$post[id]'><i class='fas fa-times-circle'></i> Удалить категорию</a></div>";
//$k_n= mysql_result(mysql_query("SELECT COUNT(*) FROM `notes` WHERE `id_dir` = $post[id] AND `time` > '".$ftime."'",$db), 0);
//echo output_text($post['msg'])."<br />n";
}
echo "</table>n";
if (isset($user) && user_access('notes_edit')){
if (isset($_GET['create'])){
echo "<form method="post" action="dir.php">n";
echo "Название:<br />n<input name="title" size="16" maxlength="32" value="" type="text" /><br />n";
echo "Описание:<br />n<textarea name="msg" ></textarea><br />n";
echo "<input value="Создать" type="submit" />n";
echo "</form>n";
}else{
echo '<a class="link" href="dir.php?create"><i class="fas fa-plus-circle"></i> Добавить категорию</a>';
}
}
include_once '../../sys/inc/tfoot.php';
?>