Файл: world-faces.ru/world-faces.ru/forum/new.php
Строк: 116
<?
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/dbPDO.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$new = DB::$dbs->querySingle("select count(id) from `forum_t` LEFT JOIN `forum_rdm` ON `forum_t`.`id` = `forum_rdm`.`t_id` AND `forum_rdm`.`user_id` =? WHERE (`forum_rdm`.`t_id` Is Null OR `forum_t`.`time` > `forum_rdm`.`time`)",array($user['id']));
$set['title']='Непрочитанное '.$new;
include_once '../sys/inc/thead.php';
title();
aut(); // форма авторизации
// Удаление выбранных
if (isset ($_GET['resetmn'])) {
if (isset ($_POST['delp'])) {
foreach ($_POST['delp'] as $v) {
$dc[] = intval($v);
}
foreach ($dc as $delid) {
$res = DB::$dbs->queryFetch("SELECT * FROM `forum_rdm` WHERE `t_id` =? LIMIT 1",array(abs(intval($delid))));
if(!$res['id']){
DB::$dbs->query("INSERT INTO `forum_rdm` SET `t_id`=?, `user_id`=?, `time`=?",array(abs((int)$delid),$user['id'],$time));
}else{
DB::$dbs->query("UPDATE `forum_rdm` SET `time`=? WHERE `t_id`=? AND `user_id`=? LIMIT 1",array($time,abs((int)$delid),$user['id']));
}
//mysql_query("UPDATE `forum_msg` SET `del` = '1', `del_id` = '".$user['id']."' WHERE `id` = '".check(intval($delid))."'");
}
header ('Location: ?'.SID);
unset($_POST['delp']);
unset($_GET['delp']);
} else echo "<br /><b>Ничего не отмечено</b><br/>";
}
if (isset($_GET['reset'])){
echo '<a href="/forum/index.php">Форумы</a>|<b>Непрочитанное</b><br />';
$req = DB::$dbs->query("SELECT * FROM `forum_t` LEFT JOIN `forum_rdm` ON `forum_t`.`id` = `forum_rdm`.`t_id` AND `forum_rdm`.`user_id` = ? WHERE `forum_rdm`.`t_id` Is Null",array($user['id']));
while ($res = $req -> fetch()) {
DB::$dbs->query("INSERT INTO `forum_rdm` SET `t_id`=?, `user_id`=?, `time`=?",array($res['id'],$user['id'],$time));
}
$req = DB::$dbs->query("SELECT * FROM `forum_t` LEFT JOIN `forum_rdm` ON `forum_t`.`id` = `forum_rdm`.`t_id` AND `forum_rdm`.`user_id` =? WHERE `forum_t`.`time` > `forum_rdm`.`time`",array($user['id']));
while ($res = $req -> fetch()) {
DB::$dbs->query("UPDATE `forum_rdm` SET `time`=? WHERE `t_id`=? AND `user_id`=? LIMIT 1",array($time,$res['id'],$user['id']));
}
echo '<b>Все темы помеченны как прочитанные</b><br />';
echo "<div class="menu">n";
//echo "<a href='new_p.php'>Темы с новыми сообщениями</a><br />n";
echo "<a href="index.php" title="Вернуться к подфорумам">Форум</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
}
echo '<form action="?resetmn" method="post">';
$total = $new;
echo '<a href="/forum/index.php">Форумы</a>|<b>Непрочитанное (<b>'.$total.'</b>)</b><br />';
$max = $set['p_str'];
$k_page=k_page($total,$max);
$page=page($k_page);
$start=$max*$page-$max;
// `forum_t`.`close` != '1' AND
$te = DB::$dbs->query("SELECT * FROM `forum_t` LEFT JOIN `forum_rdm` ON `forum_t`.`id` = `forum_rdm`.`t_id` AND `forum_rdm`.`user_id` =? WHERE (`forum_rdm`.`t_id` Is Null OR `forum_t`.`time` > `forum_rdm`.`time`) ORDER BY `forum_t`.`time` DESC LIMIT $start, $max",array($user['id']));
$theme = $te -> fetchAll();
$k = count($theme);
if ($k == 0){echo '<b>Непрочитанного пока нет :)</b><br />';}
foreach($theme AS $tem) {
$forum = DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array($tem['id_forum']));
$razdel = DB::$dbs->queryFetch("SELECT * FROM `forum_r` WHERE `id` =? LIMIT 1",array($tem['id_razdel']));
$ank = DB::$dbs->queryFetch("SELECT nick,ncolor FROM `user` WHERE `id` =? LIMIT 1",array($tem['id_user']));
$ank2 = DB::$dbs->queryFetch("SELECT nick,ncolor FROM `user` WHERE `id` =? LIMIT 1",array($tem['p_id_user']));
echo "<div class='ind'>";
$cc = DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` =? && `id_razdel` =? && `id_them` =?",array($forum['id'],$razdel['id'],$tem['id']));
echo '<input type="checkbox" name="delp[]" value="' . $tem['id'] . '" /> ';
echo "<img src='/style/themes/$set[set_them]/forum/14/them_$tem[up]$tem[close].png' alt='' />";
echo "<a href='/forum/$forum[id]/$razdel[id]/$tem[id]/'>$tem[name]</a> (".$cc.") <a href='/forum/$forum[id]/$razdel[id]/$tem[id]/?page=end'>»</a><br/>n";
echo "<a href='/forum/$forum[id]'>$forum[name]</a> / <a href='/forum/$forum[id]/$razdel[id]'>$razdel[name]</a>n";
echo "</div>";
echo "<span style="color:$ank[ncolor]">$ank[nick]</span>".($tem['p_id_user']!=''?" / <span style="color:$ank2[ncolor]">$ank2[nick]</span>n":"n");
echo " <span class="ank_n"><small>(".vr($tem['time']).")</small></span><br/>n";
//}else echo "<b>Нет доступа к теме</b>";
}
if ($k_page>1) str("?",$k_page,$page); // Вывод страниц
if($new > 0) echo '<br/><input type="submit" value="Сбросить выбранное" /></form>';
if($new > 0) echo '<br /><a href="?reset">Сбросить все</a>';
echo "<div class="menu">n";
//echo "<a href='new_p.php'>Темы с новыми сообщениями</a><br />n";
echo "<a href="index.php" title="Вернуться к подфорумам">Форум</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
?>