<?php
/**
* ¹«¸æ²å¼þº¯Êý¿â
* @author moufer<moufer@163.com>
* @package modoer_plugin
* @copyright phpdp.com
* @version $Id function.inc.php 1 2008-5-10 19:27 $
*/
!defined('IN_MUDDER') && exit('Access Denied');

function Announcement_Cache($refurbish = false) {
    global $timestamp, $db, $dbpre;
    $cache = new Cache_Base($timestamp);
    $cachefile = MUDDER_CACHEDIR.'cache_plugins_announcement.php';
    if(!$refurbish && $cache->Check_Cachefile($cachefile, -1)) {
        return $cache->Get_CacheArray($cachefile);
    }
    $query = $db->query("SELECT id,title,author,dateline FROM {$dbpre}announcements WHERE available=1 ORDER BY orders,dateline desc LIMIT 10");
    $result = array();
    while($row = $db->fetch_array($query)) {
        $row['dateline'] = date('Y-m-d H:i:s', $row['dateline']);
        $row['title_short'] = trimmed_title($row['title'], 10);
        $result[$row['id']] = $row;
    }
    $cachedata = "<?php\r\n return ".$cache->ArrayEval($result).";\r\n?>";
    $cache->Write_Cache('cache_plugins_announcement.php', MUDDER_CACHEDIR, $cachedata);
    return $result;
}


?>
