$category) { $catarray[] = $catid; } } else { if(isset($_G['cache']['portalcategory'][$rsscatid])) { $catarray = array($rsscatid); $catname = dhtmlspecialchars($_G['cache']['portalcategory'][$rsscatid]['catname']); } else { exit('Specified article not found'); } } $rewriteflag = 0; $havedomain = implode('', $_G['setting']['domain']['app']); if(is_array($_G['setting']['rewritestatus']) && in_array('portal_article', $_G['setting']['rewritestatus'])) { $rewriteflag = 1; } $charset = $_G['config']['output']['charset']; dheader("Content-type: application/xml"); echo "\n". "\n". " \n". (count($catarray) > 1 ? " {$_G[setting][bbname]}\n". " {$_G[siteurl]}forum.php\n". " Latest $num articles of all categories\n" : " {$_G[setting][bbname]} - $catname\n". " {$_G[siteurl]}portal.php?mod=list&catid=$rsscatid\n". " Latest $num articles of $catname\n" ). " Copyright(C) {$_G[setting][bbname]}\n". " Discuz! Board by Comsenz Inc.\n". " ".gmdate('r', TIMESTAMP)."\n". " $ttl\n". " \n". " {$_G[siteurl]}static/image/common/logo_88_31.gif\n". " {$_G[setting][bbname]}\n". " {$_G[siteurl]}\n". " \n"; if($catarray) { $alldata = C::t('portal_rsscache')->fetch_all_by_catid($catarray, $num); if($alldata) { foreach($alldata as $article) { if(TIMESTAMP - $article['lastupdate'] > $ttl * 60) { updatersscache($num); break; } else { list($article['description'], $attachremote, $attachfile, $attachsize) = explode("\t", $article['description']); if($attachfile) { if($attachremote) { $filename = $_G['setting']['ftp']['attachurl'].'portal/'.$attachfile; } else { $filename = $_G['siteurl'].$_G['setting']['attachurl'].'portal/'.$attachfile; } } echo " \n". " ".$article['subject']."\n". " $_G[siteurl]".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article[aid]) : "portal.php?mod=view&aid=$article[aid]")."\n". " \n". " ".dhtmlspecialchars($article['catname'])."\n". " ".dhtmlspecialchars($article['author'])."\n". ($attachfile ? ''."\n" : ''). " ".gmdate('r', $article['dateline'])."\n". " \n"; } } } else { updatersscache($num); } } echo " \n". ""; function updatersscache($num) { global $_G; $processname = 'portal_rss_cache'; if(discuz_process::islocked($processname, 600)) { return false; } C::t('portal_rsscache')->truncate(); require_once libfile('function/post'); foreach($_G['cache']['portalcategory'] as $catid => $catarray) { $query = C::t('portal_article_title')->fetch_all_for_cat($catid, 0, 1, 0, $num); $catarray['catname'] = addslashes($catarray['catname']); foreach($query as $article) { $article['author'] = $article['author'] != '' ? addslashes($article['author']) : ($article['username'] ? addslashes($article['username']) : 'Anonymous'); $article['title'] = addslashes($article['title']); $articleattach = C::t('portal_attachment')->fetch_by_aid_image($article['aid']); $attachdata = ''; if(!empty($articleattach)) { $attachdata = "\t".$articleattach['remote']."\t".$articleattach['attachment']."\t".$articleattach['filesize']; } $article['description'] = addslashes(messagecutstr($article['summary'], 250 - strlen($attachdata)).$attachdata); C::t('portal_rsscache')->insert(array( 'lastupdate'=>$_G['timestamp'], 'catid'=>$catid, 'aid'=>$article['aid'], 'dateline'=>$article['dateline'], 'catname'=>$catarray['catname'], 'author'=>$article['author'], 'subject'=>$article['title'], 'description'=>$article['description'] )); } } discuz_process::unlock($processname); return true; } ?>