news.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. function bodyimg($obj)
  4. {
  5. if (isset($obj)) {
  6. if (preg_match('<img.*src=["](.*?)["].*?>', $obj, $regs)) {
  7. return $obj = $regs[1];
  8. }
  9. } else {
  10. return false;
  11. }
  12. }
  13. function mystripslashes($string)
  14. {
  15. if (!is_array($string)) {
  16. return stripslashes($string);
  17. }
  18. foreach ($string as $key => $val) {
  19. $string[$key] = new_stripslashes($val);
  20. }
  21. return $string;
  22. }
  23. define('CURSCRIPT', 'news');
  24. require_once dirname(__FILE__) . '/global.php';
  25. require_once MYMPS_DATA . '/info.level.inc.php';
  26. require_once MYMPS_INC . '/db.class.php';
  27. (!defined('IN_ADMIN') || !defined('IN_MYMPS')) && exit('Access Denied');
  28. $part = $part ? $part : 'list';
  29. $iscommend_arr = array('待审', '正常', '推荐');
  30. if (!submit_check(CURSCRIPT . '_submit')) {
  31. chk_admin_purview('purview_新闻管理');
  32. if ($part == 'list') {
  33. $here = '网站新闻管理';
  34. $iscommend = $iscommend ? $iscommend : '';
  35. $where .= $title != '' ? 'WHERE a.title LIKE \'%' . $title . '%\'' : 'WHERE 1';
  36. $where .= $catid ? ' AND a.catid IN (' . get_cat_children($catid, 'channel') . ')' : '';
  37. if ($iscommend == 'l0') {
  38. $where .= ' AND a.iscommend = \'0\' ';
  39. } else {
  40. if ($iscommend == 'l1') {
  41. $where .= ' AND a.iscommend = \'1\' ';
  42. } else {
  43. if ($iscommend == 'l2') {
  44. $where .= ' AND a.iscommend = \'2\' ';
  45. } else {
  46. $where .= ' ';
  47. }
  48. }
  49. }
  50. $sql = 'SELECT a.*,b.catname FROM `' . $db_mymps . 'news` AS a LEFT JOIN `' . $db_mymps . 'channel` AS b ON a.catid = b.catid ' . $where . ' ORDER BY a.begintime DESC';
  51. $rows_num = $db->getOne('SELECT COUNT(*) FROM `' . $db_mymps . 'news` AS a ' . $where);
  52. $param = setParam(array('part', 'title', 'catid', 'iscommend'));
  53. $news = page1($sql);
  54. include mymps_tpl('news_list');
  55. } else {
  56. if ($part == 'edit' && $id) {
  57. $row = $db->getRow('SELECT * FROM ' . $db_mymps . 'news WHERE id = \'' . $id . '\'');
  58. $acontent = get_editor('content', 'Default', $row[content], '100%', '600px');
  59. $here = '编辑新闻';
  60. include mymps_tpl(CURSCRIPT);
  61. } else {
  62. if ($part == 'add') {
  63. $acontent = get_editor('content', 'Default', '', '100%', '600px');
  64. $here = '添加新闻';
  65. include mymps_tpl(CURSCRIPT);
  66. } else {
  67. if ($part == 'del') {
  68. if (empty($id)) {
  69. write_msg('没有选择记录');
  70. }
  71. mymps_delete('news', 'WHERE id = \'' . $id . '\'');
  72. write_msg('删除新闻 ' . $id . ' 成功', $url, 'Mymps');
  73. }
  74. }
  75. }
  76. }
  77. } else {
  78. if ($part == 'list') {
  79. if (empty($do_action)) {
  80. write_msg('请先选择您要修改的操作!');
  81. exit;
  82. }
  83. $i = '';
  84. if (is_array($id)) {
  85. $i = 1;
  86. if ($do_action == 'del_all') {
  87. foreach ($id as $kids => $vids) {
  88. mymps_delete('news', 'WHERE id = ' . $vids);
  89. }
  90. } else {
  91. if ($do_action == 'level.0') {
  92. foreach ($id as $kids => $vids) {
  93. $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'0\' WHERE id = ' . $vids);
  94. }
  95. } else {
  96. if ($do_action == 'level.1') {
  97. foreach ($id as $kids => $vids) {
  98. $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'1\' WHERE id = ' . $vids);
  99. }
  100. } else {
  101. if ($do_action == 'level.2') {
  102. foreach ($id as $kids => $vids) {
  103. $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'2\' WHERE id = ' . $vids);
  104. }
  105. }
  106. }
  107. }
  108. }
  109. } else {
  110. write_msg('你没有指定新闻ID');
  111. }
  112. $i == 1 && write_msg('操作成功!', $url, 'insertecord');
  113. } else {
  114. if ($part == 'add') {
  115. !$title && write_msg('请填写新闻标题');
  116. !$catid && write_msg('请填写分类名称');
  117. $isjump == 1 && !$redirect_url && write_msg('请输入新闻跳转地址!');
  118. $isjump != 1 && !$content && write_msg('请填写新闻内容!');
  119. if ($isjump == 1) {
  120. $do_mymps = $db->query('INSERT INTO `' . $db_mymps . 'news` (title,catid,redirect_url,isjump,isbold,iscommend,begintime,introduction,author,source,keywords) VALUES (\'' . $title . '\',\'' . $catid . '\',\'' . $redirect_url . '\',\'1\',\'' . $isbold . '\',\'' . $iscommend . '\',\'' . $timestamp . '\',\'' . $introduction . '\',\'' . $author . '\',\'' . $from . '\',\'' . $keywords . '\')');
  121. } else {
  122. $redirect_url = '';
  123. if ($ifout == 'bodyimg') {
  124. $imgpath = bodyimg(mystripslashes($content));
  125. }
  126. $do_mymps = $db->query('INSERT INTO `' . $db_mymps . 'news` (title,keywords,catid,isbold,iscommend,content,hit,perhit,begintime,introduction,author,source,imgpath) VALUES' . "\r\n" . '(\'' . $title . '\',\'' . $keywords . '\',\'' . $catid . '\',\'' . $isbold . '\',\'' . $iscommend . '\',\'' . $content . '\',\'' . $hit . '\',\'' . $perhit . '\',\'' . $timestamp . '\',\'' . $introduction . '\',\'' . $author . '\',\'' . $from . '\',\'' . $imgpath . '\')');
  127. }
  128. $id = $db->insert_id();
  129. $viewpath = $mymps_global['SiteUrl'] . '/news.php?id=' . $id;
  130. if (is_array($isfocus) && $imgpath) {
  131. foreach ($isfocus as $kfocus => $vfocus) {
  132. if ($vfocus == 'index') {
  133. $typename = '网站首页';
  134. } else {
  135. $typename = '新闻首页';
  136. }
  137. $db->query('INSERT INTO `' . $db_mymps . 'focus` (image,pre_image,words,url,pubdate,focusorder,typename)' . "\r\n\t\t\t\t" . 'VALUES(\'' . $imgpath . '\',\'' . $imgpath . '\',\'' . $title . '\',\'' . $viewpath . '\',\'' . $timestamp . '\',\'' . $id . '\',\'' . $typename . '\')');
  138. }
  139. clear_cache_files('focus_index');
  140. clear_cache_files('focus_news');
  141. }
  142. $message = '成功增加一篇新闻 <<' . $title . '>>';
  143. write_msg($message, 'news.php');
  144. } else {
  145. if ($part == 'edit') {
  146. !$id && write_msg('您未指定要编辑的新闻');
  147. !$title && write_msg('请填写新闻标题');
  148. !$catid && write_msg('请填写分类名称');
  149. $isjump == 1 && !$redirect_url && write_msg('请输入新闻跳转地址!');
  150. $isjump != 1 && !$content && write_msg('请填写新闻内容!');
  151. $viewpath = $mymps_global['SiteUrl'] . '/news.php?id=' . $id;
  152. if ($isjump == 1) {
  153. $do_mymps = $db->query('UPDATE `' . $db_mymps . 'news` SET title = \'' . $title . '\' , redirect_url = \'' . $redirect_url . '\' , catid = \'' . $catid . '\', keywords = \'' . $keywords . '\' , iscommend = \'' . $iscommend . '\' , isbold = \'' . $isbold . '\' , isjump = \'1\' , hit = \'' . $hit . '\' , perhit = \'' . $perhit . '\' , imgpath = \'' . $imgpath . '\' , author = \'' . $author . '\' , source = \'' . $from . '\' , introduction = \'' . $introduction . '\' WHERE id = \'' . $id . '\'');
  154. } else {
  155. $redirect_url = '';
  156. if ($ifout == 'bodyimg') {
  157. $imgpath = bodyimg(mystripslashes($content));
  158. }
  159. $do_mymps = $db->query('UPDATE `' . $db_mymps . 'news` SET title = \'' . $title . '\', content = \'' . $content . '\', keywords = \'' . $keywords . '\' , catid = \'' . $catid . '\' , iscommend = \'' . $iscommend . '\' , isbold = \'' . $isbold . '\' , isjump = \'0\' , hit = \'' . $hit . '\' , perhit = \'' . $perhit . '\' , imgpath = \'' . $imgpath . '\' , author = \'' . $author . '\' , source = \'' . $from . '\' , introduction = \'' . $introduction . '\' WHERE id = \'' . $id . '\'');
  160. }
  161. if (is_array($isfocus) && $imgpath) {
  162. foreach ($isfocus as $kfocus => $vfocus) {
  163. if ($vfocus == 'index') {
  164. $typename = '网站首页';
  165. } else {
  166. $typename = '新闻首页';
  167. }
  168. $db->query('INSERT INTO `' . $db_mymps . 'focus` (image,pre_image,words,url,pubdate,focusorder,typename)' . "\r\n\t\t\t\t" . 'VALUES(\'' . $imgpath . '\',\'' . $imgpath . '\',\'' . $title . '\',\'' . $viewpath . '\',\'' . $timestamp . '\',\'' . $id . '\',\'' . $typename . '\')');
  169. }
  170. clear_cache_files('focus_index');
  171. clear_cache_files('focus_news');
  172. }
  173. $message = '成功修改新闻 <<' . $title . '>>';
  174. write_msg($message, 'news.php?part=edit&id=' . $id);
  175. }
  176. }
  177. }
  178. }
  179. is_object($db) && $db->Close();
  180. $mymps_global = $db = $db_mymps = $part = NULL;