news.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. define('IN_SMT', true);
  3. define('IN_MYMPS', true);
  4. define('CSCRIPT', 'news');
  5. require_once dirname(__FILE__) . '/include/global.php';
  6. require_once MYMPS_DATA . '/config.php';
  7. require_once MYMPS_DATA . '/config.db.php';
  8. require_once MYMPS_INC . '/db.class.php';
  9. ifsiteopen();
  10. !ifplugin(CSCRIPT) && exit('管理员已禁用或未安装新闻插件...');
  11. $id = isset($id) ? intval($id) : '';
  12. $catid = isset($catid) ? intval($catid) : 0;
  13. $page = isset($page) ? intval($page) : 1;
  14. $seo = get_seoset();
  15. $rewrite = $seo['seo_force_news'];
  16. if ($rewrite != 'active') {
  17. $mayimobile = get_mobile_settings();
  18. $mayimobile['mobiledomain'] = $mayimobile['mobiledomain'] ? $mayimobile['mobiledomain'] : $mymps_global['SiteUrl'] . '/m';
  19. $mayimobile['mobileuri'] = $mayimobile['mobiledomain'] . ($_SERVER['HTTP_X_ORIGINAL_URL'] ? $_SERVER['HTTP_X_ORIGINAL_URL'] : $_SERVER['REQUEST_URI']);
  20. if ($ifmobile) {
  21. write_msg('', $mayimobile['mobileuri']);
  22. exit();
  23. }
  24. }
  25. if ($id) {
  26. define('CURSCRIPT', 'news');
  27. $id = isset($id) ? intval($id) : '';
  28. if (!($news = $db->getRow('SELECT * FROM `' . $db_mymps . 'news` WHERE id = \'' . $id . '\' AND iscommend > \'0\''))) {
  29. write_msg('您所指定的新闻不存在或者已被删除!');
  30. exit();
  31. }
  32. $news['view_url'] = $mymps_global['SiteUrl'] . '/news.php?id=' . $id;
  33. if ($news['redirect_url'] != '' && $news['isjump'] == 1) {
  34. write_msg('请稍候,当前页面正跳转至 ' . $news[redirect_url] . ' ', $news[redirect_url]);
  35. }
  36. $loc = get_location('channel', $news[catid], $news[title]);
  37. $location = $loc['location'];
  38. $page_title = $loc['page_title'];
  39. $advertisement = get_advertisement('other');
  40. $adveritems = $advertisement['items'];
  41. $advertisement = $advertisement['all'];
  42. $news['keywords'] = $news['keywords'] ? $news['keywords'] : $news['title'];
  43. $news['description'] = mhtmlspecialchars(substring(clear_html($news['content']), 0, 250));
  44. $news['content'] = replace_insidelink($news['content'], 'news');
  45. }
  46. else if ($catid) {
  47. define('CURSCRIPT', 'news_list');
  48. $catid = isset($catid) ? intval($catid) : 0;
  49. $channel = get_cat_info($catid, 'channel');
  50. if (!$channel) {
  51. write_msg('您所指定的新闻栏目不存在或者已经删除!', '/');
  52. }
  53. $loc = get_location('channel', $catid);
  54. $location = $loc['location'];
  55. $page_title = $loc['page_title'];
  56. $cat_children = get_channel_children($catid);
  57. $param = setParam(array('catid'), $rewrite, 'news-');
  58. $rows_num = $db->getOne('SELECT COUNT(*) FROM `' . $db_mymps . 'news` AS a WHERE ' . $cat_children);
  59. $page1 = page1('SELECT * FROM ' . $db_mymps . 'news WHERE ' . $cat_children . ' ORDER BY id DESC', 10);
  60. foreach ($page1 as $kr => $r) {
  61. if (0 < $r['iscommend']) {
  62. $arr['begintime'] = $r['begintime'];
  63. $arr['hit'] = $r['hit'];
  64. $arr['title'] = $r['title'];
  65. $arr['iscommend'] = $r['iscommend'];
  66. $arr['content'] = clear_html($r['content']);
  67. $arr['uri'] = $r['isjump'] ? $r['redirect_url'] : Rewrite('news', array('id' => $r['id']));
  68. $arr['imgpath'] = $r['imgpath'] ? $r['imgpath'] : '/images/nophoto.jpg';
  69. $news[] = $arr;
  70. }
  71. }
  72. $advertisement = get_advertisement('other');
  73. $adveritems = $advertisement['items'];
  74. $advertisement = $advertisement['all'];
  75. $cat_list = get_categories_tree($catid, 'channel');
  76. $pageview = page2($rewrite);
  77. }
  78. else {
  79. define('CURSCRIPT', 'news_index');
  80. $catquery = $db->query('SELECT catid,catname,html_dir FROM `' . $db_mymps . 'channel` WHERE parentid = \'0\' AND if_view = \'2\' ORDER BY catorder ASC');
  81. while ($queryrow = $db->fetchRow($catquery)) {
  82. $_array['catid'] = $queryrow['catid'];
  83. $_array['catname'] = $queryrow['catname'];
  84. $_array['uri'] = Rewrite('news', array('catid' => $queryrow['catid'], 'html_dir' => $queryrow['html_dir']));
  85. $channel[] = $_array;
  86. }
  87. for ($i = 0; $i < count($channel); $i++) {
  88. $do_sql = $db->query('SELECT iscommend,id,title,catid,begintime,isjump,redirect_url FROM `' . $db_mymps . 'news` WHERE ' . get_channel_children($channel[$i]['catid']) . ' ORDER BY begintime DESC LIMIT 0,8');
  89. while ($row = $db->fetchRow($do_sql)) {
  90. if (0 < $row['iscommend']) {
  91. $arr['id'] = $row['id'];
  92. $arr['iscommend'] = $row['iscommend'];
  93. $arr['title'] = $row['title'];
  94. $arr['begintime'] = $row['begintime'];
  95. $arr['uri'] = $row['isjump'] == 1 ? $row['redirect_url'] : Rewrite('news', array('id' => $row['id']));
  96. $channel[$i]['news'][] = $arr;
  97. }
  98. }
  99. }
  100. $loc = get_location('news', 0, '热点资讯');
  101. $page_title = $loc['page_title'];
  102. $location = $loc['location'];
  103. $s = array();
  104. $s['title'] = $pluginsettings['news']['seotitle'];
  105. $s['keywords'] = $pluginsettings['news']['seokeywords'];
  106. $s['description'] = $pluginsettings['news']['seodescription'];
  107. $advertisement = get_advertisement('other');
  108. $adveritems = $advertisement['items'];
  109. $advertisement = $advertisement['all'];
  110. }
  111. globalassign();
  112. include mymps_tpl(CURSCRIPT);
  113. is_object($db) && $db->Close();
  114. ?>