Файл: forum/tema.php
Строк: 189
<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
//Бан на форуме
$ban = $db -> query("SELECT * FROM `ban` WHERE `iduser` = '".$ya['id']."' and `serius` = 'forum' LIMIT 1");
if ($ban -> num_rows > 0) {
header('location: '.ROOT.'ban.php?mode=forum');
}
if ($id) {
$type = $db -> query("SELECT * FROM `forum_tems` WHERE `id` = '".$id."'");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
$diz -> head('Форум');
$f_f = $db -> dbcount('name','forum_razdel',"`id` = '".$the['razdel']."'");
$f_fid = $db -> dbcount('razdel','forum_tems',"`id` = '".$id."'");
$f_forum = $db -> dbcount('forum','forum_razdel',"`id` = '".$f_fid."'");
$f_name = $db -> dbcount('name','forums',"`id` = '".$f_forum."'");
$diz -> title("<a href='./'>Форум</a>/<a href='forum.php?id=$f_forum'>".$f_name."</a>/<a href='razdel.php?id=$f_fid'>".$f_f."</a>/<b>".$the['name']."</b>");
$tema = $db -> dbcount('COUNT(`id`)','forum_tems',"`id` = '".$id."'");
$count = $db -> dbcount('COUNT(`id`)','forum_posts',"`tema` = '".$id."'");
if ($tema > 0) {
if($aut==false and $nastr['foprosm']=='1'){
echo '<div class="fon">Извините,но форум был ограничен для просмотра гостям!</div>';
}else{
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$n = $db -> query("SELECT * FROM `nuts` WHERE `where`='forum' and `idwh` = '".(int)$id."' and `user`='$ya[id]' LIMIT 1");
if ($n -> num_rows == 0){$n = ' | <a href="func.php?id='.$id.'&mode=nuts">Добавить в закладки</a>';
}elseif ($n -> num_rows > 0){$n= ' | <a href="del.php?id='.$id.'&do=dnuts">Удалить из закладок</a>';}
if($the['var']==0 and $ya['level']>3){$za='| <a href="./func.php?mode=zakript&id='.$id.'">Закрепить</a>';
}elseif($ya['level']>3 and $the['var']==1){$za='| <a href="./func.php?mode=otkripl&id='.$id.'">Открепить</a>';}
if($the['status']==0 and $ya['level']>1 or $the['user']==$ya['id']){$z='| <a href="./func.php?mode=kript&id='.$id.'">Закрыть</a>';}
if ($the['status']==1 and $ya['level']>1)$z='| <a href="./func.php?mode=otkript&id='.$id.'">Открыть</a>';
if ($aut) {
if($the['status']==0)echo '<div class="fon"/><a href="newpost.php?id='.$id.'&page='.$page.'">Написать</a>';
$g = $db -> dbcount('COUNT(`id`)','golos',"`where` = 'forum' and `id_w` = '$id'");
if ($g == 0) {
if ($the['status']==0 and $the['user']==$ya['id']) echo ' | <a href="func.php?id='.$id.'&mode=opros">Добавить голосование</a>';}
if ($ya['level']>3) echo ' | <a href="del.php?id='.$id.'&do=tema">Удалить тему</a>';
if ($ya['level']>2) echo ' <br/> <a href="func.php?id='.$id.'&mode=perenos">Перенести тему</a>';
if ($the['status']==0 and $ya['level']>1) echo ' | <a href="./func.php?mode=name&id='.$id.'">Переименовать</a>';
echo ' '.$z.' '.$za.' '.$n.'</div>';
}
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='sps$the[user]' and `idwh` = '".(int)$id."' LIMIT 1");
if ($te -> num_rows > 0){
$sps = $db -> dbcount('COUNT(`id`)','comes',"`where`='sps$the[user]' and `idwh` = '".(int)$id."'");
$msg .='<div class="levo">Сказали спасибо: '.$sps.' чел.</div>';}
if($the['status']==1)$msg .= '<div class="fon"><b>Тема закрыта!</b></div>';
$count = $db -> dbcount('COUNT(`id`)','forum_posts',"`tema` = '".$id."'");
if ($count > 0) {
$g = $db -> dbcount('COUNT(`id`)','golos',"`where` = 'forum' and `id_w` = '$id'");
if ($g > 0) {
$golos = $db -> query("SELECT * FROM `golos` WHERE `where`='forum' and `id_w` = '".$id."'")-> fetch_assoc();
$g_us = $db -> dbcount('COUNT(`id`)','golosind',"`golosid` = '$golos[id]' AND `user` = '$ya[id]'");
$msg .= "<form method="post" action="tema.php?act=golos&id=$id&page=$page">n";
$q = $db -> query("SELECT * FROM `golos` WHERE `where`='forum' and `id_w` = '".$id."'");
while ($voice = $q -> fetch_assoc())
{
$msg .= "<div class='fon'><b>".$voice['name']."</b><br />n";
for ($i_v=1;$i_v<=8;$i_v++)
{
if ($voice[$i_v]!='')
{
if ($g_us==0 && $the['status']==0 && $aut==true && ($_GET['act']) && $_GET['act']=='golos' && isset($_POST[$voice['id']]) && $_POST[$voice['id']]==$i_v)
{
$db -> query("INSERT INTO `golosind` (`golos`,`golosid`, `user`, `time`)values('$i_v','$voice[id]', '$ya[id]','".time()."');");
}
$kp1 = $db -> dbcount('COUNT(`id`)','golosind',"`golosid` = '$voice[id]'");
$kp2 = $db -> dbcount('COUNT(`id`)','golosind',"`golosid` = '$voice[id]' AND `golos` = '$i_v'");
if($g_us==0 and $aut==true and $the['status']==0 ){$msg .= "<input name="$voice[id]" type="radio" value="$i_v" /> ";}
$msg .= "".$voice[$i_v]." [$kp2]<br />n";
if($kp2>0){
$proc=round($kp2/$kp1*100, 0);}
else {$proc=0;}
$msg .= "<img src="rat.php?r=$proc" alt="$kp2 голос(ов)"/><br />n";
}
}
}
if($g_us==0 and $the['status']==0 and $aut==true){
$msg .= "<input value="Проголосовать" class="form" type="submit" />n";}
$msg .= "</form>n";
if ($ya['level']>3 && $the['status']==0){$msg .= "<a href='del.php?id=$id&do=golos'>Удалить</a> | <a href='func.php?id=$id&mode=golos'>Изменить</a></div>";}
}
if($page==1){$npost=0;}else{$npost=($page-1)*$num;}
$for = $db -> query("SELECT * FROM `forum_posts` WHERE `tema` = '".$id."' ORDER BY `id` ".$ya['sort']." LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$user = $assoc['user'];
$arr = $db -> query("SELECT `login`,`ava` FROM `users` WHERE `id` = '".$assoc['user']."' LIMIT 1");
if ($arr -> num_rows > 0) {
$array = $arr -> fetch_assoc();
$array['login'] = $func -> user($user);
}
$dop = null;
if($the['status']==0){
if ($aut) {
if ($ya['id'] == $user) {
$dop = ' <a href="func.php?mode=edpost&id='.$assoc['id'].'&page='.$page.'">[Изм]</a> | <a href="del.php?id='.$assoc['id'].'">[Удал]</a>';
} elseif ($ya['level'] > 3) {
$dop = ' <a href="func.php?mode=edpost&id='.$assoc['id'].'&page='.$page.'">[Изм]</a> | <a href="del.php?id='.$assoc['id'].'">[Удал]</a>';
if ($ya['id'] != $user) $dop .= ' <a href="newpost.php?id='.$id.'&cit='.$assoc['id'].'&page='.$page.'">[Цитата]</a> | <a href="newpost.php?id='.$id.'&otv='.$user.'&page='.$page.'">[Ответ]</a>';
} elseif ($ya['id'] != $user) {
$dop = ' <a href="newpost.php?id='.$id.'&cit='.$assoc['id'].'&page='.$page.'">[Цитата]</a> | <a href="newpost.php?id='.$id.'&otv='.$user.'&page='.$page.'">[Ответ]</a>';
}
}
}
$npost++;
echo '<div class="fon">
<table><tr valign="top"><td>'.$func->avatar($assoc['user']).'</td>
<td style="padding-left:5px;"><b>'.$npost.'</b>) '.$array['login'].'';
if($assoc['privat']>0 and $assoc['user']==$ya['id'] or $assoc['privat']>0 and $assoc['privat']==$ya['id'] or $assoc['privat']>0 and $ya['level']>3){
echo ' '.$func -> times(date('d m Y в H:i',$assoc['time'])).'<br/>
<b>[!] Приватное сообщение</b><br/>
<br/>'.$func -> tags($func -> smiles($assoc['text'])).'';
}elseif($assoc['privat']==0){
echo ' '.$func -> times(date('d m Y в H:i',$assoc['time'])).'</br>
<br/>'.$func -> tags($func -> smiles($assoc['text'])).'';
}
else{ echo'<br/><br/><b>Приватное сообщение!</b>';}
echo '<br/><br/>'.$dop.''.$pis;
if (!empty($assoc['edit'])) echo '<span style="font-style:italic;">Изменено <b>'.$assoc['edit'].'</b> '.$func -> times(date('d m Y H:i:s',$assoc['timeedit'])).'</span>';
if(!empty($assoc['file'])){
$ffunc=null;
if($assoc['user']==$ya['id'] or $ya['level']>1){
$ffunc='<a href="func.php?mode=delfile&id='.$assoc['id'].'&page='.$page.'">[Удалить]</a>';
}
if(($aut and $assoc['privat']==0) or ($aut==true and $assoc['privat']==$ya['id'] or $assoc['user']==$ya['id'])or($ya['level']>3)){
if($assoc['file']!='delete'){
$ext = strtolower(pathinfo("files/".$perf."_".$assoc['file']."", PATHINFO_EXTENSION));
echo '<hr>Прикрепленный файл:<br/>';
if ($ext == 'gif' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'png') {
$foto = '../forum/files/'.$assoc['file'];
echo '<img src="../system/resize.php?img='.$foto.'&width=74&height=74&i=0" alt="*"/><br/>';
echo ''.$diz -> img('load/load.gif').' <a href="files/'.$assoc['file'].'">Скачать</a> ['.$func -> size($assoc['size']).'] '.$ffunc.'';}
else echo '<a href="files/'.$assoc['file'].'">'.$assoc['file'].'</a> ('.$func -> size($assoc['size']).') '.$ffunc.'';
}else echo '<hr><font color="#faf0e6">Прикреплённый файл был удалён</font>';
}
}
echo'</td></tr></table></div>';
}
}else echo'<div class="fon">Сообщений пока нет!</div>';
if($the['status']==0){
if ($aut == true and $ya['forma']=='1') {
echo '<div class="fon"><form action="newpost.php?id='.$id.'&page='.$page.'" method="post">';
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='sps$the[user]' and `idwh` = '".(int)$id."' and `user` = '".$ya['id']."' LIMIT 1");
if ($te -> num_rows == 0 and $the['user']!=$ya['id']){
echo 'Сказать спасибо: <input type="checkbox" name="sps" value="'.$id.'"/></br>';}
echo 'Сообщение:<br/>
<textarea name="text" rows="'.$ya['versh'].'" cols="'.$ya['shir'].'"></textarea><br/>
<input type="submit" value="Написать"/></form></div>';
}
}
$act = 'tema.php?id='.$id;
$msg .= ''.$func -> pagenav($act,$page,$total).'';
}
} else echo '<div class="fon">Тема ненайдена или была удалена!</div>';
if ($aut == true) {
$db -> query("UPDATE `online` SET `online` = 'forum' WHERE `login` = '".$ya['login']."'");
echo '<div class="fon"><a href="./pravila.php"><b>Правила</b></a> |
<a href="./settings.php">Настройки</a> |
<a href="./poisk.php">Поиск</a>';
if($nastr['bbcodes']=='on')echo ' | <a href="'.ROOT.'help/?do=bb">BB-code</a>';
if($nastr['smiles']=='on')echo ' | <a href="'.ROOT.'help/smile.php">Смайлы</a>';
echo '</div>';
}
echo '<div class="levo"><a href="/" class="levo_tuch">'.$diz -> img('home.png').' На главную</a></div>';
#####Копирайт#######
$diz -> out($msg);
?>