// // ------------------------------------------------------------------------ // //*RSS生成 require_once 'config.php'; main(); function main() { //RSS用のcontent-typeを出力する header('content-type: text/xml; charset=utf-8'); // サイト情報を準備する $channel = array( 'about' => CS_ROOT_URL.'rss.xml', // RSSのURL 'title' => SITE_TITLE, // サイト名 'link' => CS_ROOT_URL, // サイトのURL 'description' => SITE_DESC, 'creator' => SYS_MAIL, ); // 各NEWS記事を用意する $all_news = get_entry_datas_limit(MAIN_NEWS_ID,255); // 255文字に切り詰め //ステータスが公開のものだけピックアップ $public_news = get_public_entry_data($all_news); //件数オーバーなら配列を切り取り $top_news = get_limit_entry($public_news, MAIN_NEWS_NUM); $items = array(); foreach ($top_news as $item) { // 連想配列に代入 $items[$item['eid']] = array( 'link' => CS_ROOT_URL.'/news/index.html/'.$item['eid'], // 記事URL 'date' => $item['edate'], // 更新日時 'title' => $item['etitle'], // 記事タイトル 'description' => $item['ebody'], // 調整した記事概要 ); } //smarty require_once ('smarty.php'); $smarty = new CS_Smarty; $smarty->assign('channel',to_utf8($channel, 'EUC-JP')); $smarty->assign('items',to_utf8($items, 'EUC-JP')); $smarty->display('rss.tpl'); } //UTF8変換関数 function to_utf8($str, $from = 'auto' ) { if( is_array($str)){ $result = array(); foreach ($str as $key => $value){ $result[$key] = to_utf8($value , $from); } return $result; }else{ return mb_convert_encoding($str, 'utf8', $from); } } ?>