<?php

$lng_lib = core::load_lng('library');
$req = mysql_query("SELECT COUNT(*) FROM `lib` WHERE `time` > '" . (time() - 259200) . "' AND `type` = 'bk' AND `moder` = '1'");
$total = mysql_result($req, 0);
    echo '<div class="phdr"><b>' . $lng_lib['new_articles'] . ' (' . $total . ')</b></div>';
if ($total > 0) {
    $req = mysql_query("SELECT * FROM `lib` WHERE `time` > '" . (time() - 259200) . "' AND `type` = 'bk' AND `moder` = '1' ORDER BY `time` DESC LIMIT " . $start . "," . $kmess);
    $i = 0;
    while ($newf = mysql_fetch_array($req)) {
        echo $i % 2 ? '<div class="cmenu">' : '<div class="smenu">';

         $nadir = $newf['refid'];
        $dirlink = $nadir;
        $pat = "";
        while ($nadir != "0") {
            $dnew = mysql_query("select * from `lib` where type = 'cat' and id = '" . $nadir . "';");
            $dnew1 = mysql_fetch_array($dnew);
            $pat = $dnew1['text'] . '/' . $pat;
            $nadir = $dnew1['refid'];
        }
        $l = mb_strlen($pat);
        $pat1 = mb_substr($pat, 0, $l - 1);

        echo '
            <span class="news_time">
                ' . functions::display_date($newf['time']) . '
            </span>
            <b><a href="index.php?id=' . $dirlink . '">' . $pat1 . '</a></b> /
            <b><a href="?id=' . $newf['id'] . '">' . htmlentities($newf['name'], ENT_QUOTES, 'UTF-8') . '</a></b><br/>';
        echo htmlentities($newf['text'], ENT_QUOTES, 'UTF-8') . '<br />';
        echo ' <!-- ' .$lng_lib['added'] . ': ' . $newf['avtor'] . ' --></div>';
        ++$i;
    }
    // Sahifa navigatsiyasi
    if ($total > $kmess) {
        echo '<p>' . functions::display_pagination('index.php?act=new&amp;', $start, $total, $kmess) . '</p>';
    }
} else {
    echo '<p>' . $lng['list_empty'] . '</p>'; //Ro'yhat bo'sh
}

?>
