Esempio n. 1
0
 public function index()
 {
     $where = array();
     $catid = I('get.catid', 0, 'intval');
     $rssid = I('get.rssid', 0, 'intval');
     if ($rssid) {
         header("Content-Type: text/xml; charset=" . C("DEFAULT_CHARSET"));
         //检测缓存
         $data = S("Rss_{$rssid}");
         if ($data) {
             echo $data;
             exit;
         }
         $Cat = getCategory($rssid);
         //检查栏目是否存在
         if (empty($Cat)) {
             $this->error('该栏目不存在!');
         }
         //检查栏目类型
         if ($Cat['type'] != 0) {
             $this->error('栏目类型不正确!');
         }
         $where['status'] = array("EQ", 99);
         //判断是否有子栏目
         if (getCategory($rssid, 'child')) {
             $where['catid'] = array("IN", getCategory($rssid, 'arrchildid'));
         } else {
             $where['catid'] = array("EQ", $rssid);
         }
         //模型ID
         $modelid = getCategory($rssid, 'modelid');
         //获取表名
         $tablename = ucwords(getModel($modelid, 'tablename'));
         if (empty($tablename)) {
             $this->error('出现错误!');
         }
         //栏目配置
         $setting = getCategory($rssid, 'setting');
         $data = M($tablename)->where($where)->order(array("updatetime" => "DESC", "id" => "DESC"))->limit(50)->select();
         import('@.ORG.Rss');
         $Rss = new Rss($this->XMLstr(getCategory($rssid, 'catname') . ' - ' . CONFIG_SITENAME), $this->XMLstr(getCategory($rssid, 'url')), $this->XMLstr(getCategory($rssid, 'description')), $this->XMLstr(getCategory($rssid, 'image')));
         foreach ($data as $k => $v) {
             $v = $this->XMLstr($v);
             $Rss->AddItem($v['title'], $v['url'], $v['description'], date("Y-m-d H:i:s A", $v['updatetime']));
         }
         //进行缓存
         S("Rss_{$rssid}", $Rss->Fetch(), 900);
         $Rss->Display();
     }
     $this->assign('catid', $catid);
     $this->assign('rssid', $rssid);
     $this->assign("SEO", seo(0, 'Rss订阅中心'));
     $this->display();
 }
 public function index()
 {
     $where = array();
     $catid = (int) $this->_get('catid');
     $rssid = (int) $this->_get('rssid');
     if ($rssid) {
         header("Content-Type: text/xml; charset=" . C("DEFAULT_CHARSET"));
         //检测缓存
         $data = S("Rss_{$rssid}");
         if ($data) {
             echo $data;
             exit;
         }
         $Category = F("Category");
         $Model = F("Model");
         $where['status'] = array("EQ", 99);
         //判断是否有子栏目
         if ($Category[$rssid]['child']) {
             $where['catid'] = array("IN", $Category[$rssid]['arrchildid']);
         } else {
             $where['catid'] = array("EQ", $rssid);
         }
         //模型ID
         $modelid = $Category[$rssid]['modelid'];
         //获取表名
         $tablename = ucwords($Model[$modelid]['tablename']);
         //栏目配置
         $setting = unserialize($Category[$rssid]['setting']);
         $data = M($tablename)->where($where)->order(array("updatetime" => "DESC", "id" => "DESC"))->limit(50)->select();
         import('@.ORG.Rss');
         $Rss = new Rss($this->XMLstr($Category[$rssid]['catname'] . ' - ' . CONFIG_SITENAME), $this->XMLstr($Category[$rssid]['url']), $this->XMLstr($Category[$rssid]['description']), $this->XMLstr($Category[$rssid]['image']));
         foreach ($data as $k => $v) {
             $v = $this->XMLstr($v);
             $Rss->AddItem($v['title'], $v['url'], $v['description'], date("Y-m-d H:i:s A", $v['updatetime']));
         }
         //进行缓存
         S("Rss_{$rssid}", $Rss->Fetch(), 900);
         $Rss->Display();
     }
     $this->assign('catid', $catid);
     $this->assign('rssid', $rssid);
     $this->assign("SEO", seo(0, 'Rss订阅中心'));
     $this->display();
 }