<?php

    echo '
        <a class="link" href="/forum/" >
            <span class="arrow">
                <i class="iconlar i-pencil"></i>
                Форум
                <span class="count">
                    ' . counters::forum() . '
                </span>
            </span>
        </a>
    ';
if($user_id){
    // iconkalar 
    $icons = array( 
        ($np ? (!$res['vip'] ? '<img style="width: 18px;vertical-align: top;" src="/images/op.png" alt=""/>' 
        : '') : '<i class="icons i-forum"></i>'), 
        ($res['vip'] ? '<img style="width: 18px;vertical-align: top;" src="/images/pt.png" alt="asd"/>' : ''), 
        ($res['realid'] ? '<img style="width: 18px;vertical-align: top;" src="/images/rate.png" alt="asd"/>' : ''), 
        ($res['edit'] ? '<img style="width: 18px;vertical-align: top;" src="/images/tz.png" alt="asd"/>' : '') 
    ); 

    $req = mysql_query("SELECT `id`,`text`, `from`, `user_id`  FROM `forum` where type='t' ORDER BY time DESC LIMIT 5; ");

    $avtor_post = mysql_query("SELECT  `id`, `rights`,  `imname`,  `familya` FROM `users`");
    $avtor = mysql_fetch_assoc($avtor_post);
    while ($arr = mysql_fetch_array($req)){ 
        $nikuser = mysql_query("SELECT `from`,`time`,`text` FROM `forum` WHERE `type` = 'm' AND `close` != '1' AND `refid` = '" . $arr['id'] . "'ORDER BY time DESC LIMIT 1;"); 
        $nam = mysql_fetch_array($nikuser); 
        $colmes = mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type`='m' AND `refid`='" . $arr['id'] . "'" . ($rights >= 7 ? '' : " AND `close` != '1'")); 
        $colmes1 = mysql_result($colmes, 0); 
            echo "<a href='forum/index.php?id=".$arr['id']."'><div class='menu'>" .functions::display_menu($icons). " $arr[text] <span class='count'>$colmes1</span> <br /><span style='font-size: 11px;' class='news_time'>".$nam['from']."  сказал:</span> <small>".$nam['text']."</small> "; 
        $vrp = $nam['time'] + $set_user['sdvig'] * 3600; 
        echo ' <span style="float: right;margin: 5px auto;" class="news_time">(' . date("d.m.y / H:i", $vrp) . ")</span></div></a>"; 
    }

    echo '<div class="news_komm"><b>Последние файлы на форуме</b></div>';
        $files = mysql_query("SELECT `id`, `post`, `filename`, `filetype`, `dlcount` FROM `cms_forum_files` WHERE `del` != '1' ORDER BY `time` DESC LIMIT 5");
        for ($i = 0; $file = mysql_fetch_assoc($files); ++$i) {
            $fls = @filesize('files/forum/attach/' . $file['filename']);
            $fls = round($fls / 1024, 0);
                echo '
                    <a href="/forum/index.php?act=post&amp;id='.$file['post'].'">
                        <div class="list1">
                            <img style="width: 21px;height: 16px;vertical-align: bottom;" src="/images/system/' . $file['filetype'] . '.png" width="22" height="18" />
                            '.htmlspecialchars($file['filename']).' 
                            <span class="news_time">Скачано: ' . $file['dlcount'] . ' раз</span>
                            <span class="count">' . $fls . 'кб</span>
                        </div>
                    </a>
                ';
        }
}
?>