Вход Регистрация
Файл: backup/plugin/topic.php
Строк: 142
<?
require_once('../core/start.php');
$id = isset($_GET['id']) ? abs(intval($_GET['id'])) : false;
$them core::$dbs-> queryFetch("SELECT * FROM `forum_theme` WHERE `id` = ? LIMIT 1",array($id));
if(empty(
$them['id'])){
header('location:/');
exit;
}
$praz core::$dbs-> queryFetch("SELECT name,id,id_r FROM `forum_pr` WHERE `id` = ? LIMIT 1",array($them['id_pr']));
$raz core::$dbs-> queryFetch("SELECT name,id FROM `forum_r` WHERE `id` = ? LIMIT 1",array($them['id_r']));
$title 'Форум | '.$raz['name'].' | '.$praz['name'].' | '.$them['name'];
require_once(
root.'core/header.php');
echo 
'<div class="wizart"><a href="/">Форум</a> | <a href="/plugin/topic/'.$raz['id'].'">'.$raz['name'].'</a> | <a href="/plugin/themes/'.$praz['id'].'">'.$praz['name'].'</a> | <b>'.$them['name'].'</b></div>';
func::head_menu();
if(isset(
$user['id'])){
if(isset(
$_GET['delfile'])){
if(
$level<1){
header('location:/');
die();
}
unlink(root.'files/'.$them['file']);
core::$dbs->query("UPDATE `forum_theme` SET `file` = ?, `file_name` = ? WHERE `id` = ?",array('','',$id));
header('location:/plugin/topic/'.$id);
die();
}
if(isset(
$_GET['delfiles'])){
if(
$level<1){
header('location:/');
exit;
}
$files core::$dbs->queryFetch("SELECT * FROM `forum_msg` WHERE `id` = ? LIMIT 1",array(func::num($_GET['uid'])));
unlink(root.'files/'.$files['file']);
core::$dbs->query("UPDATE `forum_msg` SET `file` = ?, `file_name` = ? WHERE `id` = ?",array('','',$files['id']));
header('location:/plugin/topic/'.$id);
die();
}
if(isset(
$_GET['rating'])){
if(
core::$dbs->querySingle("SELECT COUNT(id) FROM `rating` WHERE `id_t` = ? and `user_id` = ?",array($id,$user['id']))==0){
core::$dbs->query("INSERT INTO `rating` SET `id_t` = ?, `user_id` = ?",array($id,$user['id']));
core::$dbs->query("UPDATE `users` SET `rating` = `rating` + ? WHERE `id` = ? LIMIT 1",array(1,$them['user_id']));
header('location:/plugin/topic/'.$id);
} else {
header('location:/plugin/topic/'.$id);
die();
}
}
if(isset(
$_GET['addfav'])){
if(
core::$dbs->querySingle("SELECT COUNT(id) FROM `forum_fav` WHERE `id_t` = ? and `user_id` = ?",array($id,$user_id))==0){
core::$dbs->query("INSERT INTO `forum_fav` SET `id_t` = ?, `user_id` = ?",array($id,$user_id));
header('location:/plugin/topic/'.$id);
die();
} else {
echo 
'<div class="err">Эта тема уже находится у Вас в избранных</div>';
}
}
if(isset(
$_GET['delfav'])){
if(
core::$dbs->querySingle("SELECT COUNT(id) FROM `forum_fav` WHERE `id_t` = ? and `user_id` = ?",array($id,$user_id))==1){
core::$dbs->query("DELETE FROM `forum_fav` WHERE `user_id` = ?",array($user_id));
header('location:/plugin/topic/'.$id);
die();
} else {
echo 
'<div class="err">Такой темы нет у Вас в избранных</div>';
}
}
echo 
'<div class="main">';
echo 
'<a href="javascript:window.location.reload()">Обновить</a>';
if(
$level>=OR $them['user_id'] == $user['id']){
echo (
$them['type']==' | <a href="?closed">Закрыть</a> | ':NULL);
}
if(
$level>=1){
if(
$them['type']==1)echo '<a href="?open">Открыть</a> | ';
}
if(
$level>=2){
echo 
'<a href="?del">Удалить</a>';
}
if(
$level>=2){
if(
$them['type']==0)echo ' | <a href="/plugin/up/'.$id.'">Апдейт</a>';
}
echo 
'</div>';
/* Удалить тему */
if (isset($_GET['del'])){
if(
$level<2){
header('location:/');
die();
}
core::$dbs->query("DELETE FROM `forum_theme` WHERE `id` = ?",array($id));
header('location: /');
die();
}

/* Открыть тему */
if (isset($_GET['open'])) {
if(
$them['type'] == 0){
header('location: /plugin/topic/'.$id);
die();
}
if(
$level<1){
header('location:/');
die();
}
core::$dbs->query("UPDATE `forum_theme` SET `type` = ? WHERE `id` = ? LIMIT 1",array(0,$id));
header('location: /plugin/topic/'.$id);
die();
}
/* Закрыть тему */
if(isset($_GET['closed'])) {
if(
$them['type'] == 1){
header('location: /plugin/topic/'.$id);
die();
}
if(
$level<OR $them['user_id']!=$user['id']){
header('location:/');
die();
}
core::$dbs->query("UPDATE `forum_theme` SET `type` = ? WHERE `id` = ? LIMIT 1",array(1,$id));
header('location: /plugin/topic/'.$id);
die();
}
if(
$them['type'] != 1){
if(isset(
$_GET['delpost'])){
$post core::$dbs->queryFetch("SELECT * FROM `forum_msg` where `id` = ? limit 1",array(abs(intval($_GET['uid']))));
if(
$user['id'] != $post['user_id'] && $level<1){
header('location:/');
die();
}
core::$dbs->query("DELETE FROM `forum_msg` WHERE `id` = ?",array($post['id']));
header('location:/plugin/topic/'.$id);
die();
}
if(isset(
$_POST['ok'])) {
$text func::check($_POST['text']);
if(empty(
$text)){
func::error('Введите сообщение!');
require_once(
root.'core/footer.php');
die();
}
$t = (!empty($uid) ? $uid 0);
core::$dbs->query("INSERT INTO `forum_msg` SET `text` = ?, `id_pr` = ?, `id_r` = ?, `user_id` = ?, `id_t` = ?, `time` = ?, `komu` = ?",array($text,$praz['id'],$raz['id'],$user_id,$id,time(),$t));
core::$dbs->query("UPDATE `forum_theme` SET `last` = ? WHERE `id` = ? LIMIT 1",array(time(),$id));
header('location: /plugin/topic/'.$id);
exit;
}
}
}
echo 
'<div class="main">';
$status func::user_inf($them['user_id'], 'status');
echo 
func::nick($them['user_id']).'<br/>'.(!empty($status) ? '<div class="st_1"></div><div class="st_2">'.$status.'</div>':'');
if(
$them['type']==0){
if(
$them['user_id'] == $user_id || $level>=1){
echo 
'[<a href="/plugin/editposts/'.$them['id'].'">изм</a>]<br/>';
}
}
echo 
func::out($them['text']);
if(!empty(
$them['who_edit'])){
echo 
'<br/><b>Ред.</b> <b>'.func::user_inf($them['who_edit'], 'login').'</b> ('.func::times($them['time_edit']).') ['.$them['kol'].']';
}
echo 
'<br/><img src="/icons/nav.png" alt="*"/> Избранoе: '.core::$dbs->querySingle("SELECT COUNT(id) from `forum_fav` WHERE `id_t` = ?",array($id)).' '.(core::$dbs->querySingle("SELECT COUNT(id) FROM `forum_fav` WHERE `id_t` = ? and `user_id` = ?",array($id,$user_id))=='<a href="?addfav">+</a>':'<a href="?delfav">-</a>').' <img src="/icons/nav.png" alt=""/> Рейтинг '.core::$dbs->querySingle("SELECT COUNT(id) FROM `rating` WHERE `id_t` = ?",array($id)).' '.(core::$dbs->querySingle("SELECT COUNT(id) FROM `rating` WHERE `id_t` = ? and `user_id` = ?",array($id,$user['id']))=='<a href="?rating">+</a>':'');
if(!empty(
$them['file'])){
echo 
'<br/><b>Прикрепленный файл:</b><br/><a href="http://'.HTTPHOME.'/'.$them['file'].'">'.$them['file_name'].'</a> '.($level>=|| ($them['user_id']==$user['id']) ? '[<a href="/plugin/topic/'.$id.'?delfile">del</a>]':'');
}
echo 
'</div>';
if(isset(
$user['id'])){
if(
$them['type'] != 1){
echo 
'<form action="/plugin/topic/'.$id.'" method="post">Сообщение:<br/><textarea name="text"></textarea><br/><input type="submit" name="ok" value="Написать"/></form>';
} else {
echo 
'<div class="err">Тема закрыта для обсуждения!</div>';
}
} else {
echo 
'<div class="err">Вы не авторизован! Пройдите <a href="/pages/login.php">Авторизацию</a> или <a href="/pages/reg.php">Регистрацию</a></div>';
}
$total core::$dbs->querySingle("SELECT COUNT(id) from `forum_msg` where `id_t` = ?",array($id));
if(
$total==0){
func::error('Сообщений нет!');
}
func::nav($total,$num);
$sort = (!empty($_COOKIE['cookie_id']) ? ($user['sort']=='ASC':'DESC') : 'DESC');
$array core::$dbs->query("SELECT * FROM `forum_msg` where `id_t` = ? ORDER BY `time` $sort LIMIT $start,$num",array($id));
$i 1;
while(
$arr $array -> fetch()){
echo 
'<div class="main">';
$status1 func::user_inf($arr['user_id'], 'status');
echo 
func::nick($arr['user_id']).' ('.func::times($arr['time']).')<br/>'.(!empty($status1) ? '<div class="st_1"></div><div class="st_2">'.$status1.'</div>':'');
if(isset(
$user['id'])){
if(
$them['type']==0){
if(
$arr['user_id'] == $user['id'] || $level>=1){
echo 
'[<a href="/plugin/editpost/'.$id.'/'.$arr['id'].'">изм</a>] ';
}
}
if(
$them['type']==0){
if(
$user['id'] != $arr['user_id']){
echo 
'[<a href="/plugin/otv/'.$arr['id'].'">отв</a>]';
}
}
if(
$them['type']==0){
if(
$arr['user_id'] == $user['id'] OR $level>=1){
echo 
'[<a href="/plugin/topic/'.$id.'/'.$arr['id'].'?delpost">удл</a>]';
}
}
echo 
'<br/>';
}
echo (!empty(
$arr['komu']) ? '<b>'.func::user_inf($arr['komu'], 'login').'</b>, ':'').''.func::out($arr['text']);
if(!empty(
$arr['file'])){
echo 
'<br/><b>Прикрепленный файл:</b><br/><a href="http://'.HTTPHOME.'/'.$arr['file'].'">'.$arr['file_name'].'</a> '.($level>='[<a href="/plugin/topic/'.$id.'/'.$arr['id'].'?delfiles">del</a>]':'');
}
if(!empty(
$arr['who_edit'])){
echo 
'<br/><b>Ред.</b> <b>'.func::user_inf($arr['who_edit'], 'login').'</b> ('.func::times($arr['time_edit']).') ['.$arr['kol'].']';
}
echo 
'</div>';
}
func::navig('/plugin/topic/'.$id.'?');
func::footer_menu();
require_once(
root.'core/footer.php');
?>
Онлайн: 0
Реклама