File size: 9.39Kb
<?
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';
define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);
$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` = '".id."' LIMIT 1"));
// Отмечаем уведомления
if (isset($user))mysql_query("UPDATE `notification` SET `read` = '1' WHERE `type` = 'news_komm' AND `id_user` = '$user[id]' AND `id_object` = '$act[id]'");
// просмотр новости
$view = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_view` WHERE `news` = '".$act['id']."' AND `user` = '".$user['id']."' "),0);
if (empty($view) AND isset($user)){
if ($act['id'] > 0){
mysql_query("INSERT INTO `news_view` (`user`,`time`, `news`) values('".$user['id']."','$time', '".$act['id']."')");
$view_add = $act['view'] + 1;
mysql_query("UPDATE `news` set `view` = '".$view_add."' WHERE `id` = '".$act['id']."'");
}}
$title = htmlspecialchars ($act['title']);
$list = mysql_fetch_assoc(mysql_query("SELECT name FROM `news_list` WHERE `id` = '".$act['list']."' LIMIT 1"));
$name = htmlspecialchars ($list['name']);
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '".$act['id']."' "),0);
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `like_object` WHERE `id_object` = '".$act['id']."' AND `type` = 'news' AND `like` = '1'"),0);
$dlike = mysql_result(mysql_query("SELECT COUNT(*) FROM `like_object` WHERE `id_object` = '".$act['id']."' AND `type` = 'news' AND `like` = '0'"),0);
$arr_l = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` < '".$act['id']."' ORDER BY `id` DESC LIMIT 1"));
$arr_r = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` > '".$act['id']."' ORDER BY `id` ASC LIMIT 1"));
$data = get_user($act['id_user']);
// проверяем существует новость
if (!empty($act)) {
// заголовок страницы
$set['title'] = 'Новости : '.$title.'';
// head
include_once '../../sys/inc/thead.php';
title();
aut();
err();
echo'
<link rel="stylesheet" href="/news/style.css" type="text/css">
<div class="main_bg">
<div class="lc_br wbg font0 relative oh" id="header_path">
<a href="/" style="font-size:0;"> <img src="/news/ico/home.png" alt=""> </a>
<span class="lc_brw">
<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
<a href="/news/">Новости</a></span>
<span class="lc_brw">
<img src="/news/ico/sep.png" alt="" class="lc_br_sep"> <span class="lc_br_text">
Запись</span></span>
</div>
</div>
<div class="wrapper">
<div class="block attaches_limiter">
<div class="oh">
<span class="right"> <span class="grey">' . vremja($act['time']) . '</span> </span>
<img class="p14" src="/news/ico/news.png" alt="(ON)">
<a class="break-word arrow_link strong_link" href="/news/news/?id='.$act['id'].'"> '.text($act['title']) .' </a>
'.($act['file'] > null ?'</br><img src="/news/photo/img/'.$act['file'].'" style =" max-width: 100% !important;max-height: 400px;"class="preview s0_360">':'').'
</br>'.output_text($act['msg']).'
<div class="oh grey pad_t_a"> '.$name.'
<span class="right">
<img src="/news/ico/eye.png " alt="" class="m">
<span class="m">'.$act['view'].'</span>
</span></div>
<span class = "grey">Опубликовал:</span> '.group($data['id']) . user::nick($data['id']).medal($data['id']) . online($data['id']) . '
'.($act['link'] > null ? '
</br>
<div class="pad_t_a">
<a href="'.$act['link'].'" class="inl-link">
<span class="m"> Cсылка </span>
</a>
<img src="/news/ico/arr_r_darkblue.png" class="m arr" width="8" height="12">
</div>
':'').'
</div></div></div>
'.(isset($user) ? '
<div class="oh bord-top js-action_bar action-bar">
<table class="table__wrap table__wrap-fixed grey">
<tbody><tr>
<td class="table__cell relative m" style=" border-left: 1px solid #cdd4e1;">
<a href="/news/like/?id='.$act['id'].'&type=1&s=1" class="link" title="">
<img src="/news/ico/vote_up.png" alt="" class="m p16">
<span class="grey">'.$like.'</span> </a> </td>
<td class="table__cell relative m">
<a href="/news/like/?id='.$act['id'].'&type=0&s=1" class="link" title="">
<img src="/news/ico/vote_down.png" alt="" class="m p16">
<span class="grey">'.$dlike.'</span> </a> </td>
</tr></tbody></table>
</div>
<div class="oh bord-top js-action_bar action-bar"> </div>
':'').'
'.(user_access('adm_news') ? '
</br>
<div class="oh bord-top js-action_bar action-bar">
<table class="table__wrap table__wrap-fixed grey">
<tbody><tr>
<td class="table__cell relative m" style=" border-left: 1px solid #cdd4e1;">
<a href="/news/edit/?id='.$act['id'].'" class="link" title="">
<img src="/news/ico/profile.png" alt="" class="m p16">
</a> </td>
<td class="table__cell relative m">
<a href="/news/delete/?id='.$act['id'].'" class="link" title="">
<img src="/news/ico/delete.png" alt="" class="m p16">
</a></td>
<td class="table__cell relative m">
'.($act['file'] == null ? '
<a href="/news/photo/?id='.$act['id'].'" class="link" title="">
<img src="/news/ico/photo.png" alt="" class="m p16">
':'
<a href="/news/photo/delete.php?id='.$act['id'].'" class="link" title="">
<img src="/news/ico/picture.png" alt="" class="m p16">
').'
</a></td>
</tr></tbody></table>
</div>
<div class="oh bord-top js-action_bar action-bar"> </div>
':'').'
' . ($arr_l['id'] || $arr_r['id'] ? '
</br>
<div class="oh bord-top js-action_bar action-bar">
<table class="table__wrap table__wrap-fixed grey">
<tbody><tr>
<td class="table__cell relative m" style=" border-left: 1px solid #cdd4e1;">
'.($arr_l['id'] ? '<a href="?id=' . $arr_l['id'].'" class="link" title=""> ':'').'
<img src="/news/ico/arr_l_gray.png" alt="" class="m p16"> <span class="grey" style = "font-size: 12px;">Пред.</span>
</a> </td>
<td class="table__cell relative m">
'.($arr_r['id'] ? '<a href="?id=' . $arr_r['id'].'" class="link" title=""> ':'').'
<span class="grey" style = "font-size: 12px;">След.</span> <img src="/news/ico/arr_r_gray.png" alt="" class="m p16">
</a> </td>
</tr></tbody></table>
</div>
<div class="oh bord-top js-action_bar action-bar"> </div>
':'').'';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '".$act['id']."' "),0);
$k_page = k_page($count,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$query = mysql_query("SELECT * FROM `news_komm` WHERE `id_news` = '".$act['id']."' ORDER BY `id` $sort LIMIT $start, $set[p_str]");
echo'
<div class="wrapper block"><span class="grey">Комментарии ('.$comm.')</span>
'.(isset($user) && $count > 0 ? '
<span class="right">
<a href="?id=' . $act['id'] . '&page=' . $page . '&sort=1" style="' . ($user['sort'] == 1 ? 'color: #323232;' : null) . '">Внизу</a> |
<a href="?id=' . $act['id'] . '&page=' . $page . '&sort=0" style="' . ($user['sort'] == 0 ? 'color: #323232;' : null) . '">Вверху</a>
</span>
':'').'
</div>
';
if($count == 0)echo '<div class="wrapper block">Список пуст.</div>';
while ($post = mysql_fetch_assoc($query))
{
$ank = get_user($post['id_user']);
echo'
<div class="comm oh">
<a name="com364731241"></a>
<div class="p40 left t-padd_right">
<a class="tdn" href="">
'.avatar($ank['id'], true, 50, false).'
</a>
</div>
<div class="oh">
<div>
'.group($ank['id']) . user::nick($ank['id']).medal($ank['id']) . online($ank['id']) . '
<div class="right grey"> ' . vremja($post['time']) . '</div>
</div>
'.(isset($user) && ($user['level'] > $ank['level'] || $user['level'] != 0 && $user['id'] == $ank['id']) ? '
<div class="right"><a href="/news/comm_delete/?id='.$post['id'].'&page=' . $page .'"><img src="/style/icons/delete.gif" alt="*"></a></div>
':'').'
'.output_text($post['msg']).'
</div>
'.(isset($user) && $user['id'] != $ank['id'] ? '
<a href="/news/news/?id='.$act['id'].'&response=' . $ank['id'] . '&page=' . $page . '" class="link-grey js-comm_reply">Ответить</a>
':'').'
</div>
';
}
// Вывод страниц
if ($k_page>1)str("/news/news/?id=".$act['id'].'&', $k_page,$page);
// form
echo'
'.(isset($user) ? '
<div class="block oh ">
<div>
<div class="input-txt_wrapper">
<form action="/news/comm_add/?id='.$act['id'].'&page=' . $page . REPLY . '" method="post">
<textarea class="input-txt" rows="5" cols="17" name="msg" placeholder="Напишите комментарий" maxlength="220">' . $insert . '</textarea>
</div></div>
<div class="cf pad_t_a">
<input type="submit" name="save" value="Отправить" class="main_submit right">
</form>
</div></div>
':'').'
';
}else{$_SESSION['message'] = 'Ошибка запись не найдена'; header("location: /news/");}
include_once '../../sys/inc/tfoot.php';
?>