Вход Регистрация
Файл: monst/core/pag/forum/topic.php
Строк: 148
<?
$forum_id 
= (int)$index[2];
if ( 
$forum_id OR $forum_id count($forum_names) ) {
    
g('/forum');
}

$topic_id = (int)$index[3];
$find $_forum_topic -> findOne(
    [
        
'id' => $topic_id
    
]
);

if ( !
$find ) {
    
g('/forum?no_topic');
}

$topic $find;

upd_loc('read topic <a href="/forum/topic/'.$forum_id.'/'.$topic_id.'">'.$topic['name'].'</a>');


$_forum_topic -> update(
    [
        
'id' => $topic_id
    
],

    [
        
'$set' => [
            
'views' => $topic['views'] + 1
        
]
    ]
);

if ( !
preg_match('/,'.$user['id'].',/'$topic['uniq_views']) ) {
    
$upd_uniq_views $topic['uniq_views'].','.$user['id'].',';


    
$_forum_topic -> update(
        [
            
'id' => $topic_id
        
],

        [
            
'$set' => [
                
'uniq_views' => $upd_uniq_views
            
]
        ]
    );

}

$forum_name $forum_names[$forum_id]['name'];
$forum_desc $forum_names[$forum_id]['desc'];

?>
<div class='op_top_im'>
    <img src='/core/i/pic/forum/<?=$forum_id?>.jpg?1' alt='' class='title_img' /><br/>

</div>

<div style='position: relative; top: -100px; color: #999; height: 0;'>
    <span style='background: #000; font-size: 20px;'>
        <?=$topic['name']?>
    </span><br/>
    <span style='background: #000; font-size: 11px;'>
        <?=$forum_name?>
        <br/>
        <img src='/core/i/other/views.png' alt='' width='20'/><span style=''><?=$topic['views']?>(<?=@count(@explode(',,'$topic['uniq_views']))?>)</span>, <?=replace_time($topic['time'])?>
    </span><br/>


    <span style='font-size: 10px;'>
        <?=(($topic['warn']) ? '<br/><span style="color: sandybrown;">'.$lang['forum.php']['warn'].'</span>''')?>
        <?=(($topic['close']) ? '<br/><span style="color: deeppink;">'.$lang['forum.php']['close'].'</span>''')?>
    </span>

</div>



<div class='padding'>

    <?


    
if ( isset($_GET['del_mess_id']) AND $user['id'] == $admin_id ) {
        
$del_mess_id = (int)$_GET['del_mess_id'];

        
$_forum_post -> remove(
            [
                
'id' => $del_mess_id,
                
'topic_id' => $topic_id
            
]
        );


        
g('/forum/topic/'.$forum_id.'/'.$topic_id.'?page='.(int)$_GET['page'].'&mess_deleted');
    }

    if ( isset(
$_GET['mess_deleted']) ) {
        echo 
'<div class="error_box">'.$lang['forum.php']['mes_deleted'].'</div><br/><br/>';
    }

    if ( isset(
$_GET['delete']) AND $user['id'] == $admin_id ) {
        
$_forum_post -> remove(
            [
                
'topic_id' => $topic_id
            
]
        );

        
$_forum_topic -> remove(
            [
                
'id' => $topic_id,
            ]
        );


        
g('/forum/thread/'.$forum_id);
    }


    if ( isset(
$_GET['warn']) AND $user['id'] == $admin_id ) {
        
$_forum_topic -> update(
            [
                
'id' => $topic_id
            
],

            [
                
'$set' => [
                    
'warn' => 1
                
]
            ]
        );

        
g('/forum/topic/'.$forum_id.'/'.$topic_id);
    }

    if ( isset(
$_GET['no_warn']) AND $user['id'] == $admin_id ) {
        
$_forum_topic -> update(
            [
                
'id' => $topic_id
            
],

            [
                
'$set' => [
                    
'warn' => 0
                
]
            ]
        );

        
g('/forum/topic/'.$forum_id.'/'.$topic_id);
    }

    if ( isset(
$_GET['close']) AND $user['id'] == $admin_id ) {
        
$_forum_topic -> update(
            [
                
'id' => $topic_id
            
],

            [
                
'$set' => [
                    
'close' => 1
                
]
            ]
        );

        if ( 
$forum_id == ) {
            
$key md5('last_news');
            
$mem -> delete($key);
        }

        
g('/forum/topic/'.$forum_id.'/'.$topic_id);
    }

    if ( isset(
$_GET['open']) AND $user['id'] == $admin_id ) {
        
$_forum_topic -> update(
            [
                
'id' => $topic_id
            
],

            [
                
'$set' => [
                    
'close' => 0
                
]
            ]
        );

        if ( 
$forum_id == ) {
            
$key md5('last_news');
            
$mem -> delete($key);
        }

        
g('/forum/topic/'.$forum_id.'/'.$topic_id);
    }


    if ( !empty(
$_POST['text']) ) {
        
$text null_html($_POST['text']);

        
$err '';

        if ( 
$topic['close'] ) {
            
$err .= 'Топик закрыт<br/>';
        }

        if ( 
mb_strlen($text'UTF-8') > 10000 ) {
            
$err .= 'Слишком длинное сообщение<br/>';
        }

        
$find $_forum_post -> find(
            [
                
'topic_id' => $topic_id,
                
'user_id' => $user['id']
            ]
        );

        
$find -> sort(
            [
                
'time' => -1
            
]
        );

        
$find -> limit(1);

        foreach ( 
$find as $f ) {
            
$last_text $f['text'];
            
$last_time $f['time'];
        }

        if ( 
$last_text == $text ) {
            
$err .= $lang['forum.php']['flood'];
        } else {
        }

        if ( !empty(
$err) ) {
            
?>
            <div class='error_box'>
                <?=$err?>
            </div>
            <br/>
            <?
        
} else {
            
$id new_id('_forum_post');

            
$_forum_post -> insert(
                [
                    
'id' => $id,
                    
'forum_id' => $forum_id,
                    
'topic_id' => $topic_id,
                    
'user_id' => $user['id'],
                    
'time' => time(),
                    
'text' => $text
                
]
            );

            
$_forum_topic -> update(
                [
                    
'id' => $topic_id
                
],

                [
                    
'$set' => [
                        
'last_upd' => time()
                    ]
                ]
            );

            
$_users -> update(
                [
                    
'id' => $user['id']
                ],

                [
                    
'$set' => [
                        
'forum_count' => $user['forum_count'] + 1
                    
]
                ]
            );


            
g('/forum/topic/'.$forum_id.'/'.$topic_id.'?page='.(int)$_GET['page'].'#bottom');
        }

    }

    echo 
'<br/>';


    
$on_page 10;
    
$page = ( isset($_GET['page']) ? (int)$_GET['page'] : );

    
$find $_forum_post -> find(
        [
            
'topic_id' => $topic_id
        
]
    );

    
$count $find -> count(true);

    
$find -> limit($on_page);

    
$find -> sort(
        [
            
'time' => 1
        
]
    );




    
$nav nav($on_page);


    foreach ( 
$find as $post ) {

        
$text nl2br($post['text']);

        if ( 
$post['user_id'] == $admin_id ) {
            
$text preg_replace('/[url=(.+?)](.+?)[/url]/''<a href="$1" target="_blank">$2</a>'$text);
        }
        
?>

        <div>
            <a href='/id<?=$post['user_id']?>'>
                <img src="<?=av($post['user_id'])?>" alt="av" width="70" style="float: left; margin-right: 10px;" class="av"/>
            </a>

            <?=Name($post['user_id'])?>

            <?
            
if ( $user['id'] == $admin_id ) {
                
?>
                <a href='/forum/topic/<?= $forum_id ?>/<?= $topic_id ?>?page=<?= $page ?>&amp;del_mess_id=<?= $post['id'?>'>del</a>
                <?
            
}
            
?>

            <span style='font-size: 10px; color: #555;'><?=replace_time($post['time'])?></span>
            <br/>
            <span class='mess'>
                    <?=$text?>
                </span>
        </div>
        <div style='clear: both;'></div>

        <div style='clear: both;'></div>
        <br/>
        <?
    
}


    print 
$nav;

    if ( !
$topic['close'] ) {
        
?>

        <span id='bottom'></span>
        <br/><br/>
        <div style='text-align: center;'>
            <form method='post' action='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?page=<?=$page?>'>
                <textarea id='text' name='text' rows='5' style='width: 90%;'></textarea>

                <br/><br/>
                <div style='text-align: right;'>
                    <input type='submit' value='<?=$lang['forum.php']['post']?>'/>
                </div>
            </form>
        </div>
        <?
    
}

    
?>

    <br/><br/>
    <?

    
if ( $user['id'] == $admin_id ) {
        echo 
'<div style="text-align: center;">';

        if ( !
$topic['warn'] ) {
            
?>
            <a class='bt_black_min' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?warn'><?=$lang['forum.php']['but_warn1']?></a>
            <?
        
} else {
            
?>
            <a class='bt_black_min' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?no_warn'><?=$lang['forum.php']['but_warn0']?></a>
            <?
        
}

        if ( !
$topic['close'] ) {
            
?>
            <a class='bt_black_min' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?close'><?=$lang['forum.php']['but_close1']?></a>
            <?
        
} else {
            
?>
            <a class='bt_black_min' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?open'><?=$lang['forum.php']['but_close0']?></a>
            <?
        
}

        
?>
        <a class='bt_black_min' href='/forum/edit_topic/<?=$forum_id?>/<?=$topic_id?>'><?=$lang['forum.php']['edit']?></a>

        <a class='bt_black_min' href='/forum/topic/<?=$forum_id?>/<?=$topic_id?>?delete' onclick="return confirm('Точно удалить топик?')"><?=$lang['forum.php']['del']?></a>
        <?

        
echo '</div>
                    <br/><br/>'
;
    }

    
?>
</div>

<div style='text-align: center;'>
    <a href='/forum/thread/<?=$forum_id?>'><div class='bt_black'><< <?=str_replace('color''color2'$forum_names[$forum_id]['name'])?></div></a>
</div>
Онлайн: 1
Реклама