Файл: 4mast/profmas.ru/forums/new_posts.php
Строк: 23
<?php
require_once('../includes/Headers.php');
require_once('../includes/PDO_func.php');
if($us['id'] == false){
header('location: /login/auth');
exit;
}
H ('Новые посты', '<a href="/forums" style="color:white;">Форум</a> | Новые посты');
$items = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`time`>'" . ( time () - 86400 ). "')");
$items_per_page = 10;
$pages = ceil ( $items / $items_per_page );
if ($page < 1) {
$page = 1;
}
if ($page > $pages) {
$page = $pages;
}
$start = $page * $items_per_page - $items_per_page;
if ($items==0) {
echo '<div class="error">Новых постов нет..</div>';
}
else {
$query = DB :: $dbs -> query ("SELECT * FROM `forum_p` WHERE (`time`>'" . (time () - 86400) . "') ORDER BY `id` DESC LIMIT $start, $items_per_page");
while ($p = $query -> fetch()) {
$t = DB :: $dbs -> queryFetch ("SELECT * FROM `forum_t` WHERE (`id`='" . $p['id_t']. "')");
$c_p = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_p` WHERE (`id_t`='" . $t['id'] . "') " . (isset ($us) ? ($us['level']>0 ? '' : 'AND (`status`='0')') : 'AND (`status`='0')'));
echo '<div class="list1">';
echo 'Тема: <img src="/images/' . ($t['top']==1? 'prikrep' : ($t['type']==0 ? 'closed' : 'the')) . '.png" alt=""/> <a href="/forums/thema' . $t['id'] . '">' . $t['name'] . '</a> (' . $c_p.') <a href="/forums/thema' . $t['id'] . '/page' . ceil ( $c_p / 10 ) . '">>></a><br/>';
echo Nick ($p['us']) . ' (' . datef ($p['time']) . ')<br/>';
// if post have quote
if ($p['cit'] != 0) {
echo 'Цитата:<div class="cit">';
$q = DB :: $dbs -> query ("SELECT * FROM `forum_p` WHERE (`id`='" . $p['cit'] . "')");
if ($q -> rowCount () == 0) {
echo '<b>Сообщение удалено!</b>';
} else {
//
$cit = $q -> fetch ();
if ($cit['del'] !=0 ) {
echo'<b>Сообщение удалено!</b>';
}
else {
$citu = DB :: $dbs -> queryFetch ("SELECT * FROM `us` WHERE (`id`='" . $cit['us'] . "')");
echo '
<b style="color:red;">' . $citu['nick'] . '</b>: ' . tag ($cit['text']);
}
}
echo '</div>';
}
echo tag ($p['text']) . '<br/> ';
// if post have attachment files
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_f` WHERE (`id_p`='" . $p['id'] . "')") != 0) {
echo '<b>Прикрепленные файлы:</b><br/>';
$q = DB :: $dbs -> query ("SELECT * FROM `forum_f` WHERE (`id_p`='" . $p['id'] . "') ORDER BY `id`");
while ($f = $q -> fetch ()) {
echo '<a href="/files/forum/' . $f['name'] . '">' . $f['name'] . '</a> (' . sizef ($f['size']) . ')<br/>';
}
}
$q = DB :: $dbs -> query ("SELECT * FROM `forum_reds` WHERE (`id_p`='" . $p['id'] . "')");
if ($q -> rowCount () != 0) {
$redk = DB :: $dbs -> queryFetch ("SELECT * FROM `forum_reds` WHERE (`id_p`='" . $p['id'] . "') ORDER BY `id` DESC LIMIT 1");
echo '
________<br/>
<small>Пост изменён <a href="/forums/reds.php?id=' . $p['id'] . '">' . $q -> rowCount () . ' раз.</a> Посл. ред. ' . Nick ($redk['us']) . ' (' . datef ($redk['time']) . ')</small>
';
}
echo '</div> ';
}
echo '' . page ('/forum/new_posts') . '';
}
require_once('../includes/Footers.php');