Вход Регистрация
Файл: modules/forum/topic.php
Строк: 190
<?php
/**
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
 * @link          http://perf-engine.net
 * @package       PerfEngine
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
$locate    'in_forum';
if(!isset(
$_GET['id'])) redirect('/forum');
$topic_id abs(intval($_GET['id']));
if(
User::logged())
{
    
$db->query("UPDATE `notify` SET `read` = '1' WHERE `request_id` = '/forum/topic/".$topic_id."?page=end' AND `user_id` = '".User::Id()."' AND `type` = 'notify_topic_reply'");
}

if(
$db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."'")->rowCount() == 0
{
    
$title _t('forum');
    
include_header($title);
    
$tpl->div('menu'_t('topic_not_exists'));
    
$tpl->div('block'NAV.' <a href="/forum/">'_t('forum') .'</a><br/>' HICO .' <a href="/">'_t('home') .'</a>');
    
include_footer();
    exit;
}

$topict $db->query("SELECT * FROM `forum_t` WHERE `id` = '"$topic_id ."'")->fetch();

///////////////// Vote //////////////////
$topic_vote $db->query("SELECT * FROM `forum_vote` WHERE `topic_id` = '"$topic_id ."' AND `type` = '1'")->fetch();

if (isset(
$_POST['votes']) && $db->query("SELECT * FROM `forum_vote_rez` WHERE `topic_id` = '"$topic_id ."' AND `user_id` = '".User::profile('id')."' ")->rowCount() == && User::logged() && $topict['closed'] == && $topic_vote['closed'] == 0)
{
    
$vote input($_POST['vote']);
    
$vote_u $db->query("SELECT * FROM `forum_vote` WHERE `id` = '"$vote ."' AND `type` = '2'")->rowCount();
    if (isset(
$vote) && $vote_u 0
    {
        
$db->query("INSERT INTO `forum_vote_rez` SET `user_id` = '"User::profile('id')."', `topic_id` = '"$topic_id."', `vote` = '".$vote."'");
        
$db->query("UPDATE `forum_vote` SET `count` = count + 1 WHERE `id` = '".$vote."'");
    }
    
redirect('/forum/topic/'.$topic_id.'?page=end');
    exit;
}
///////////////// Vote //////////////////

$title $topict['name'] .' | '._t('forum');
include_header($title);
$tpl->div('title'$topict['name'] .' | '._t('forum'));

////////////////// Vote //////////////////
$top_vote $db->query("SELECT * FROM `forum_vote` WHERE `topic_id` = '"$topic_id ."' AND `type` = '1'")->rowCount();
if (
$top_vote 0
{
    echo 
'<div class="post">';
    
$votes $db->query("SELECT * FROM `forum_vote` WHERE `topic_id` = '"$topic_id ."' AND `type` = '2' ORDER BY id");
    
$cou $db->query("SELECT * FROM `forum_vote_rez` WHERE `topic_id` = '"$topic_id ."'")->rowCount();

    echo 
img('rating.png').'<b>'.$topic_vote['name'] .'</b> '.($topict['closed'] == || $topic_vote['closed'] == '('._t('vote_close').')' null).'<br />';

    if (
$db->query("SELECT * FROM `forum_vote_rez` WHERE `topic_id` = '"$topic_id ."' AND `user_id` = '".User::profile('id')."' ")->rowCount() == && User::logged() && $topict['closed'] == && $topic_vote['closed'] == 0)
    {

        echo 
'<form action="/forum/topic/'.$topic_id.'/" method="post">';
        foreach(
$votes as $vote)
        {
            echo 
'<input type="radio" value="'.$vote['id'].'" name="vote" /> '.$vote['name'].'<br />';
        }
        echo 
'<input type="submit" name="votes" value="'_t('vote') .'" /></form>';
    }
    else
    {
        foreach(
$votes as $vote)
        {
            
$count $cou round(100 $cou $vote['count'], 1) : 0;
            echo 
$vote['name'].' ('.$db->query("SELECT * FROM `forum_vote_rez` WHERE `topic_id` = '"$topic_id ."' AND `vote` = '".$vote['id']."'")->rowCount().')<br />
            <div class="rang"><span style="width: '
.$count.'%"><center>'.$count.'%</center></span></div>';
        }
    }

    echo  
_t('user_vote') . ' <b>'.$cou .'</b> '_t('user_vot') . '<br />
    <small>------------<br />'
_t('add_votes') .' <b><a href="/user/profile/'.$topic_vote['user_id'] .'">'.tnick($topic_vote['user_id']).'</a></b>, '.rtime($topic_vote['time']) .'</small>';        
    echo 
'</div>';
}
///////////////// Vote //////////////////

(User::logged() && $topict['closed'] == $tpl->div('menu''<a href="/forum/add_post/'$topic_id .'"/>'_t('add_message') .'</a><br/>') : NULL);
$topic_r $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."'")->rowCount();
$pages = new Paginator($topic_r$ames);
if(
$topic_r == 0
{
    echo 
$tpl->div('menu'_t('no_posts'));

else 
{
    if(isset(
$_GET['page']) && $_GET['page'] != && $topic_r $ames)
    {
        
$pinned $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '{$topic_id}' ORDER BY time ASC LIMIT 1")->fetch();
        if(
$pinned['pin'] == 1)
        {
            echo 
'<div class="list id="post'.$pinned['id'].'">
            '
.(User::logged() ? '<span style="float: right;">'.(User::Id() != $pinned['user_id'] && $topict['closed'] == '[<a href="/forum/'.(User::logged() && $settings['fast_mess'] == 'topic/'.$pinned['topic_id'].'?page=end&amp;' 'add_post/'.$pinned['topic_id'].'?'). 'reply_to='.$topic['user_id'].'">'_t('reply').'</a> | <a href="/forum/'.(User::logged() && $settings['fast_mess'] == 'topic/'.$pinned['topic_id'].'?page=end&amp;' 'add_post/'.$topic['topic_id'].'?'). 'quote='$pinned['id'] .'">'_t('quote').'</a>]'NULL
            . (
User::level() == || User::level() >= || (User::Id() == $pinned['user_id'] && $pinned['time'] > (time()-300)) ? ' [<a href="/forum/delete_post/'.$pinned['id'].'?topic_id='.$pinned['topic_id'].'">x</a> | <a href="/forum/edit_post/'.$pinned['id'].'?topic_id='.$pinned['topic_id'].'">+</a>]' NULL).'</span>':NULL)
            . 
nick($pinned['user_id'], '<a href="/forum/post/'.$pinned['id'].'"><small class="gray">'rtime($pinned['time']).'</small></a>') . output($pinned['text']) .
            (
$pinned['count_edit'] > '<small style="font-size: xx-small"><br/>_______________<br />'_t('Edited by').' <b>'tnick($pinned['edit_user_id']) .'</b> ('rtime($pinned['edit_time']) .') ['$pinned['count_edit'] .']</small>':NULL) .'
            '
.(!empty($pinned['file']) ? '<br/><div style="border: dotted 1px;"><a href="/files/forum/'.$pinned['file'].'">'.$pinned['file'].'</a> ('.size($pinned['file_size']).')</div>' NULL).'
            </div>'
;
        }
    }
    
$topic_q $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."' ORDER BY time ASC LIMIT $start$ames");
    while(
$topic $topic_q->fetch()) 
    {
        echo 
'<div class="post" id="post'.$topic['id'].'">
        '
.(User::logged() ? '<span style="float: right;">'.(User::Id() != $topic['user_id'] && $topict['closed'] == '[<a href="/forum/'.(User::logged() && $settings['fast_mess'] == 'topic/'.$topic['topic_id'].'?page=end&amp;' 'add_post/'.$topic['topic_id'].'?'). 'reply_to='.$topic['user_id'].'#reply">'_t('reply').'</a> | <a href="/forum/'.(User::logged() && $settings['fast_mess'] == 'topic/'.$topic['topic_id'].'?page=end&amp;' 'add_post/'.$topic['topic_id'].'?'). 'quote='$topic['id'] .'#reply">'_t('quote').'</a>]'NULL
        . (
User::level() == || User::level() >= || (User::Id() == $topic['user_id'] && $topic['time'] > (time()-300)) ? ' [<a href="/forum/delete_post/'.$topic['id'].'?topic_id='.$topic['topic_id'].'">x</a> | <a href="/forum/edit_post/'.$topic['id'].'?topic_id='.$topic['topic_id'].'">+</a>]' NULL).'</span>':NULL)
        .  
nick($topic['user_id'], '<a href="/forum/post/'.$topic['id'].'"><small class="gray">'rtime($topic['time']).'</small></a>') . output($topic['text']) .
        (
$topic['count_edit'] > '<small style="font-size: xx-small"><br/>_______________<br />'_t('Edited by').' <b>'tnick($topic['edit_user_id']) .'</b> ('rtime($topic['edit_time']) .') ['$topic['count_edit'] .']</small>':NULL) .'
        '
.(!empty($topic['file']) ? '<br/><div style="border: dotted 1px;"><a href="/files/forum/'.$topic['file'].'">'.$topic['file'].'</a> ('.size($topic['file_size']).')</div>' NULL).'
        </div>'
;
    }
    
$pages->view();
}

if(
User::logged() && $settings['fast_mess'] == && $topict['closed'] == 0
{
    echo 
'<div class="menu">
    <form id="reply" action="/forum/add_post/'
$topic_id .'?act=create'.(isset($_GET['reply_to']) ? '&reply_to='.num($_GET['reply_to']) : (isset($_GET['quote']) ? '&quote='.abs(intval($_GET['quote'])) : null)).'" method="post" enctype="multipart/form-data">
    <b>'
_t('message') .'</b>:<br/>';
    
textarea(520, (isset($_GET['reply_to']) ? '[b]'.tnick(num($_GET['reply_to'])).'[/b], ' NULL) . (isset($_GET['quote']) ? "[quote][i][b]".tnick($db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."' AND `id` = '"abs(intval($_GET['quote'])) ."'")->fetchColumn())."[/b] ".date('d.m.Y, H:i'$db->query("SELECT time FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."' AND `id` = '"abs(intval($_GET['quote'])) ."'")->fetchColumn())."[/i]:n".preg_replace("/[quote]|[/quote]/i"''$db->query("SELECT text FROM `forum_pt` WHERE `topic_id` = '"$topic_id ."' AND `id` = '"abs(intval($_GET['quote'])) ."'")->fetchColumn())."n[/quote] " NULL));
    echo 
'<br/><input name="create" type="submit" value="'_t('add') .'" /><br/>
    </form></div>'
;
}
echo 
'<div class="block">'.
(
$topict['closed'] == '<span class="red">'_t('Topic is closed') .'</span>' null);
if(
User::logged() && $topict['closed'] == 0)
{
    echo 
NAV .'<a href="/forum/add_post/'$topic_id .'"/>'_t('add_message') .'</a><br/>'
}

if(
User::level()>=|| User::level() == 3)
{
    echo 
NAV .'<a href="/forum/move_topic/'$topict['id'].'">'._t('move').'</a><br/>';
    
    if(
$topict['closed'] == 0)
    {
        echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=close">'_t('close') .'</a><br/>';
    }
    elseif(
$topict['closed'] == 1)
    {
        echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=open">'_t('open') .'</a><br/>'
    }
}

///////////////// Vote //////////////////
$user_topics $db->query("SELECT * FROM `forum_pt` WHERE `cat_id` != '0' AND `topic_id` = '"$topic_id ."'")->fetch();
if (
User::level()>=|| User::level() == || $user_topics['user_id'] == User::profile('id'))
{
    if (
$top_vote == && $topict['closed'] == 0
    {
        echo 
NAV '<a href="/forum/vote_topic/'$topict['id'].'">'_t('add_vote') .'</a><br/>';
    }
    
    if (
$top_vote != 0
    {
        echo 
NAV '<a href="/forum/vote_edit_topic/'$topict['id'].'">'_t('edit_vote') .'</a><br/>';
        echo 
NAV '<a href="/forum/vote_delete_topic/'$topict['id'].'">'_t('delete_vote') .'</a><br/>';
        
        if(
$topic_vote['closed'] == 0)
        {
            echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=close_vote">'_t('close_vote') .'</a><br/>';
        }
        elseif(
$topic_vote['closed'] == 1)
        {
            echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=open_vote">'_t('open_vote') .'</a><br/>'
        }
    }
}
///////////////// Vote //////////////////

if(User::level()>=&& $topict['attach'] == 0)
{
    echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=attach">'_t('attach') .'</a><br/>';
}
elseif(
User::level()>=&& $topict['attach'] == 1)
{
    echo 
NAV '<a href="/forum/act/'$topict['id'].'?act=unpin">'_t('unpin') .'</a><br/>';
}

echo 
'</div>';
$topicNav $db->query("SELECT * FROM `forum_c` WHERE `id` = '"$topict['cat_id']."'")->fetch();
$tpl->div('block'
img('back.png').' <a href="/forum/section/'$topict['cat_id'] .'/">'.$topicNav['name'].'</a><br/>'.
img('back.png').' <a href="/forum/category/'$topicNav['f_id'] .'">'$db->query("SELECT name FROM `forum` WHERE `id` = '"$topicNav['f_id'] ."'")->fetchColumn().'</a><br/>'.
img('forum.png') .' <a href="/forum">'_t('forum') .'</a><br/>'.
HICO .' <a href="/">'_t('home') .'</a>');
include_footer();
Онлайн: 0
Реклама