Файл: dthema.php
Строк: 43
<?
include_once 'system/sys.php';
include 'system/funcs.php';
if(!$cms->us['id']){
header('location: /');
exit;
}
$thema = DB::$dbs->queryFetch("SELECT * FROM `forum_thema` where `id` = ?",array($func->num($_GET['id'])));
$podrazd = DB::$dbs->queryFetch("SELECT * FROM `forum_podrazd` where `id` = ?",array($thema['podrazd']));
$razd = DB::$dbs->queryFetch("SELECT * FROM `forum_razd` where `id` = ?",array($thema['razd']));
if(!$thema['id'] or !$razd['id'] or !$podrazd['id']){
header('location:/forum');
exit;
}
if(isSet($_GET['do'])){
header('content-type: text/plain',true);
header('content-disposition: attachment; filename="'.$thema['id'].'.txt";');
echo "Тема: ".$thema['name'].", создана ".t($thema['time'])."rnrn";
if(DB::$dbs->querySingle("SELECT count(id) from `forum_post` where `razd` = ? and `podrazd` = ? and `thema` = ?",array($razd['id'],$podrazd['id'],$thema['id']))==0){
echo "Сообщений нетrn";
}else{
$posts = DB::$dbs->query("SELECT * from `forum_post` where `razd` = ? and `podrazd` = ? and `thema` = ? and `del`='0' order by `id` ",array($razd['id'],$podrazd['id'],$thema['id']));
$i=1;
while($post = $posts->fetch()){
$post_us = DB::$dbs->queryFetch("SELECT * from `us` where `id` = ?",array($post['us']));
echo $i++.". ".$post_us['nick']." ".($post['us']==$thema['author']?'[автор]':NULL)." (".t($post['time']).")rn";
if($post['otv']){
$otv = DB::$dbs->queryFetch("SELECT * from `us` where `id` = ?",array($post['otv']));
echo ($otv['id']?$post['nick']:'[Удалён]').", ";
}
if(!empty($post['cit'])){
$cit = DB::$dbs->queryFetch("SELECT * from `forum_post` where `id` = ?",array($post['cit']));
echo "Цитата:rn";
if($cit == 0 or $cit['del'] == 1){
echo "Сообщение удалено!rnrn";
}else{
$cit_us = DB::$dbs->queryFetch("SELECT * from `us` where `id` = ?",array($cit['us']));
if(!$cit_us['id']) echo '[Удалён]'; else echo $cit_us['nick']." ".$cit['text']."rn";
}
}
echo $post['text']."rnrn";
}
}
echo '// '.$_SERVER['HTTP_HOST'];
exit;
}
verh($thema['name'],'<a href="/forum" style="color:#ffffff;">Форум</a> | <a href="/forum/'.$razd['id'].'" style="color:#ffffff;">'.$razd['name'].'</a> | <a href="/forum/'.$razd['id'].'" style="color:#ffffff;">'.$podrazd['name'].'</a> | '.$thema['name']);
echo '<div class="lst"><a href="/dthema.php?id='.$thema['id'].'&do">Скачать .txt</a></div>';
niz();
?>