| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- //decode by http://dezend.qiling.org QQ 2859470
- function bodyimg($obj)
- {
- if (isset($obj)) {
- if (preg_match('<img.*src=["](.*?)["].*?>', $obj, $regs)) {
- return $obj = $regs[1];
- }
- } else {
- return false;
- }
- }
- function mystripslashes($string)
- {
- if (!is_array($string)) {
- return stripslashes($string);
- }
- foreach ($string as $key => $val) {
- $string[$key] = new_stripslashes($val);
- }
- return $string;
- }
- define('CURSCRIPT', 'news');
- require_once dirname(__FILE__) . '/global.php';
- require_once MYMPS_DATA . '/info.level.inc.php';
- require_once MYMPS_INC . '/db.class.php';
- (!defined('IN_ADMIN') || !defined('IN_MYMPS')) && exit('Access Denied');
- $part = $part ? $part : 'list';
- $iscommend_arr = array('待审', '正常', '推荐');
- if (!submit_check(CURSCRIPT . '_submit')) {
- chk_admin_purview('purview_新闻管理');
- if ($part == 'list') {
- $here = '网站新闻管理';
- $iscommend = $iscommend ? $iscommend : '';
- $where .= $title != '' ? 'WHERE a.title LIKE \'%' . $title . '%\'' : 'WHERE 1';
- $where .= $catid ? ' AND a.catid IN (' . get_cat_children($catid, 'channel') . ')' : '';
- if ($iscommend == 'l0') {
- $where .= ' AND a.iscommend = \'0\' ';
- } else {
- if ($iscommend == 'l1') {
- $where .= ' AND a.iscommend = \'1\' ';
- } else {
- if ($iscommend == 'l2') {
- $where .= ' AND a.iscommend = \'2\' ';
- } else {
- $where .= ' ';
- }
- }
- }
- $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';
- $rows_num = $db->getOne('SELECT COUNT(*) FROM `' . $db_mymps . 'news` AS a ' . $where);
- $param = setParam(array('part', 'title', 'catid', 'iscommend'));
- $news = page1($sql);
- include mymps_tpl('news_list');
- } else {
- if ($part == 'edit' && $id) {
- $row = $db->getRow('SELECT * FROM ' . $db_mymps . 'news WHERE id = \'' . $id . '\'');
- $acontent = get_editor('content', 'Default', $row[content], '100%', '600px');
- $here = '编辑新闻';
- include mymps_tpl(CURSCRIPT);
- } else {
- if ($part == 'add') {
- $acontent = get_editor('content', 'Default', '', '100%', '600px');
- $here = '添加新闻';
- include mymps_tpl(CURSCRIPT);
- } else {
- if ($part == 'del') {
- if (empty($id)) {
- write_msg('没有选择记录');
- }
- mymps_delete('news', 'WHERE id = \'' . $id . '\'');
- write_msg('删除新闻 ' . $id . ' 成功', $url, 'Mymps');
- }
- }
- }
- }
- } else {
- if ($part == 'list') {
- if (empty($do_action)) {
- write_msg('请先选择您要修改的操作!');
- exit;
- }
- $i = '';
- if (is_array($id)) {
- $i = 1;
- if ($do_action == 'del_all') {
- foreach ($id as $kids => $vids) {
- mymps_delete('news', 'WHERE id = ' . $vids);
- }
- } else {
- if ($do_action == 'level.0') {
- foreach ($id as $kids => $vids) {
- $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'0\' WHERE id = ' . $vids);
- }
- } else {
- if ($do_action == 'level.1') {
- foreach ($id as $kids => $vids) {
- $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'1\' WHERE id = ' . $vids);
- }
- } else {
- if ($do_action == 'level.2') {
- foreach ($id as $kids => $vids) {
- $db->query('UPDATE `' . $db_mymps . 'news` SET iscommend = \'2\' WHERE id = ' . $vids);
- }
- }
- }
- }
- }
- } else {
- write_msg('你没有指定新闻ID');
- }
- $i == 1 && write_msg('操作成功!', $url, 'insertecord');
- } else {
- if ($part == 'add') {
- !$title && write_msg('请填写新闻标题');
- !$catid && write_msg('请填写分类名称');
- $isjump == 1 && !$redirect_url && write_msg('请输入新闻跳转地址!');
- $isjump != 1 && !$content && write_msg('请填写新闻内容!');
- if ($isjump == 1) {
- $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 . '\')');
- } else {
- $redirect_url = '';
- if ($ifout == 'bodyimg') {
- $imgpath = bodyimg(mystripslashes($content));
- }
- $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 . '\')');
- }
- $id = $db->insert_id();
- $viewpath = $mymps_global['SiteUrl'] . '/news.php?id=' . $id;
- if (is_array($isfocus) && $imgpath) {
- foreach ($isfocus as $kfocus => $vfocus) {
- if ($vfocus == 'index') {
- $typename = '网站首页';
- } else {
- $typename = '新闻首页';
- }
- $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 . '\')');
- }
- clear_cache_files('focus_index');
- clear_cache_files('focus_news');
- }
- $message = '成功增加一篇新闻 <<' . $title . '>>';
- write_msg($message, 'news.php');
- } else {
- if ($part == 'edit') {
- !$id && write_msg('您未指定要编辑的新闻');
- !$title && write_msg('请填写新闻标题');
- !$catid && write_msg('请填写分类名称');
- $isjump == 1 && !$redirect_url && write_msg('请输入新闻跳转地址!');
- $isjump != 1 && !$content && write_msg('请填写新闻内容!');
- $viewpath = $mymps_global['SiteUrl'] . '/news.php?id=' . $id;
- if ($isjump == 1) {
- $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 . '\'');
- } else {
- $redirect_url = '';
- if ($ifout == 'bodyimg') {
- $imgpath = bodyimg(mystripslashes($content));
- }
- $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 . '\'');
- }
- if (is_array($isfocus) && $imgpath) {
- foreach ($isfocus as $kfocus => $vfocus) {
- if ($vfocus == 'index') {
- $typename = '网站首页';
- } else {
- $typename = '新闻首页';
- }
- $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 . '\')');
- }
- clear_cache_files('focus_index');
- clear_cache_files('focus_news');
- }
- $message = '成功修改新闻 <<' . $title . '>>';
- write_msg($message, 'news.php?part=edit&id=' . $id);
- }
- }
- }
- }
- is_object($db) && $db->Close();
- $mymps_global = $db = $db_mymps = $part = NULL;
|