| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- function get_root_channel()
- {
- global $db;
- global $db_mymps;
- $query = $db->query('SELECT catid,catname FROM `' . $db_mymps . 'channel` WHERE parentid = \'0\' AND if_view = \'2\' ORDER BY catorder ASC');
- while ($queryrow = $db->fetchRow($query)) {
- $_array['catid'] = $queryrow['catid'];
- $_array['catname'] = $queryrow['catname'];
- $_array['uri_m'] = mRewrite('news', array('catid' => $queryrow['catid']));
- $channel[] = $_array;
- }
- return $channel;
- }
- CURSCRIPT != 'wap' && exit('FORBIDDEN');
- $id = isset($id) ? intval($id) : '';
- $catid = isset($catid) ? intval($catid) : '';
- $page = isset($page) ? intval($page) : 1;
- if ($id) {
- if (!$id) {
- errormsg('新闻ID不能为空!');
- }
- if (!($news = $db->getRow('SELECT * FROM ' . $db_mymps . 'news WHERE id = \'' . $id . '\''))) {
- errormsg('当前新闻不存在或者已经被删除!');
- }
- $db->query('UPDATE `' . $db_mymps . 'news` SET hit = hit +1 WHERE id = \'' . $id . '\';');
- $news['catname'] = $db->getOne('SELECT catname FROM `' . $db_mymps . 'channel` WHERE catid = \'' . $news['catid'] . '\'');
- $news['caturi'] = mRewrite('news', array('catid' => $news['catid']));
- $loc = get_location_m('channel', $news[catid], $news[title]);
- $page_title = $loc['page_title'];
- $news['keywords'] = $news['keywords'] ? $news['keywords'] : $news['title'];
- $news['description'] = cutstr(clear_html($news['content']), 250);
- $shareIcon = strstr($news['imgpath'], 'http') ? $news['imgpath'] : $mymps_global['SiteUrl'] . $news['imgpath'];
- include mymps_tpl('news');
- }
- else if ($catid) {
- $cat = get_cat_info($catid, 'channel');
- if (!$cat) {
- errormsg('您所指定的新闻栏目不存在或者已经删除!');
- }
- $rootchannel = get_categories_tree($catid, 'channel');
- $cat_children = get_channel_children($catid);
- $perpage = $mayimobile['mobiletopicperpage'] ? $mayimobile['mobiletopicperpage'] : 10;
- $param = setparams(array('mod', 'catid'));
- $rows_num = $db->getOne('SELECT COUNT(*) FROM `' . $db_mymps . 'news` AS a WHERE ' . $cat_children);
- $totalpage = ceil($rows_num / $perpage);
- $num = intval($page - 1) * $perpage;
- $page1 = page1('SELECT * FROM ' . $db_mymps . 'news WHERE ' . $cat_children . ' ORDER BY id DESC', $perpage);
- foreach ($page1 as $kr => $r) {
- $arr['begintime'] = $r['begintime'];
- $arr['begintimej'] = GetTime($r['begintime'], 'm-d');
- $arr['hit'] = $r['hit'];
- $arr['title'] = $r['title'];
- $arr['titlej'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', $r['title']) : $r['title'];
- $arr['iscommend'] = $r['iscommend'];
- $arr['content'] = clear_html($r['content']);
- $arr['contentj'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', cutstr($arr['content'], 60)) : cutstr($arr['content'], 60);
- $arr['uri_m'] = $r['isjump'] ? $r['redirect_url'] : mRewrite('news', array('id' => $r['id']));
- $arr['uri_ma'] = $r['isjump'] ? $r['redirect_url'] : 'index.php?mod=news&id=' . $r['id'];
- $arr['imgpath'] = $r['imgpath'] ? (!strstr($r['imgpath'], 'http') ? $mymps_global[SiteUrl] . $r['imgpath'] : $r['imgpath']) : '';
- $news[] = $arr;
- }
- if ($mayi) {
- $news = 5.4000000000000004 <= PHP_VERSION ? json_encode($news, JSON_UNESCAPED_SLASHES) : str_replace('\\/', '/', json_encode($news));
- echo $news;
- exit();
- }
- $parentcats = get_parent_cats('channel', $catid);
- $parentcats = is_array($parentcats) ? array_reverse($parentcats) : '';
- $loc = get_location_m('channel', $catid);
- $page_title = $loc['page_title'];
- $channel = $cat;
- include mymps_tpl('news_list');
- }
- else {
- !ifplugin('news') && exit('管理员已禁用或未安装资讯插件...');
- $rootchannel = get_root_channel();
- $perpage = $mayimobile['mobiletopicperpage'] ? $mayimobile['mobiletopicperpage'] : 10;
- $param = setparams(array('mod'));
- $rows_num = $db->getOne('SELECT COUNT(*) FROM `' . $db_mymps . 'news` AS a ORDER BY id DESC');
- $totalpage = ceil($rows_num / $perpage);
- $num = intval($page - 1) * $perpage;
- $page1 = page1('SELECT * FROM ' . $db_mymps . 'news ORDER BY id DESC', $perpage);
- foreach ($page1 as $kr => $r) {
- $arr['begintime'] = $r['begintime'];
- $arr['begintimej'] = GetTime($r['begintime'], 'm-d');
- $arr['hit'] = $r['hit'];
- $arr['title'] = $r['title'];
- $arr['titlej'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', $r['title']) : $r['title'];
- $arr['iscommend'] = $r['iscommend'];
- $arr['content'] = clear_html($r['content']);
- $arr['contentj'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', cutstr($arr['content'], 60)) : cutstr($arr['content'], 60);
- $arr['uri_m'] = $r['isjump'] ? $r['redirect_url'] : mRewrite('news', array('id' => $r['id']));
- $arr['uri_ma'] = $r['isjump'] ? $r['redirect_url'] : 'index.php?mod=news&id=' . $r['id'];
- $arr['imgpath'] = $r['imgpath'] ? (!strstr($r['imgpath'], 'http') ? $mymps_global[SiteUrl] . $r['imgpath'] : $r['imgpath']) : '';
- $news[] = $arr;
- }
- if ($mayi) {
- $news = 5.4000000000000004 <= PHP_VERSION ? json_encode($news, JSON_UNESCAPED_SLASHES) : str_replace('\\/', '/', json_encode($news));
- echo $news;
- exit();
- }
- $loc = get_location_m('news', 0, '热点资讯');
- $page_title = $loc['page_title'];
- $s = array();
- $s['keywords'] = $pluginsettings['news']['seokeywords'];
- $s['description'] = $pluginsettings['news']['seodescription'];
- include mymps_tpl('news_index');
- }
- ?>
|