Просмотр поста

.
VERDAN

ДоХтор, код с

counters (+/-)
static function library()
    {
        $file = ROOTPATH . 'files/cache/count_library.dat';
        if (file_exists($file) && filemtime($file) > (time() - 3200)) {
            $res = unserialize(file_get_contents($file));
            $total = $res['total'];
            $new = $res['new'];
            $mod = $res['mod'];
        } else {
            $total = DB::getInstance()->getCount(DB::getInstance()->query("SELECT COUNT(*) FROM `library_texts` WHERE `premod` = '1'"), 0);
            $new = DB::getInstance()->getCount(DB::getInstance()->query("SELECT COUNT(*) FROM `library_texts` WHERE `time` > '" . (time() - 259200) . "' AND `premod` = '1'"), 0);
            $mod = DB::getInstance()->getCount(DB::getInstance()->query("SELECT COUNT(*) FROM `library_texts` WHERE `premod` = '0'"), 0);
            file_put_contents($file, serialize(array('total' => $total, 'new' => $new, 'mod' => $mod)));
        }
        if ($new) $total .= '&#160;/&#160;<span class="red"><a href="' . core::$system_set['homeurl'] . '/library/index.php?act=new">+' . $new . '</a></span>';
        if ((core::$user_rights == 5 || core::$user_rights >= 6) && $mod) {
            $total .= '&#160;/&#160;<span class="red"><a href="' . core::$system_set['homeurl'] . '/library/index.php?act=premod">M:' . $mod . '</a></span>';
        }
        return $total;
    }