<?php
/*
*######################################
* PHPCMS v3.00 - Advanced Content Manage System.
* Copyright (c) 2004-2005 phpcms.cn
*
* For further information go to http://www.phpcms.cn/
* This copyright notice MUST stay intact for use.
*######################################
*/
defined('IN_PHPCMS') or exit('Access Denied');
$channelid = intval($channelid);
if(!$channelid) showmessage('非法参数!请返回!',$referer);
$pagesize=$_PHPCMS[pagesize];
$tree = new tree;
$cat_option = cat_option($catid);
$cat_pos = cat_pos($catid);
$submenu=array(
array('<font color="red">添加文章</font>','?mod='.$mod.'&file='.$file.'&action=add&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('审核文章','?mod='.$mod.'&file='.$file.'&action=check&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('<font color="red">管理文章</font>','?mod='.$mod.'&file='.$file.'&action=manage&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('我添加的文章','?mod='.$mod.'&file='.$file.'&action=myitem&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('<font color="red">管理专题文章</font>','?mod='.$mod.'&file='.$file.'&action=special&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('批量移动文章','?mod='.$mod.'&file='.$file.'&action=move&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid),
array('回收站管理','?mod='.$mod.'&file='.$file.'&action=recycle&channelid='.$channelid.'&catid='.$catid.'&specialid='.$specialid)
);
$menu=adminmenu('文章管理',$submenu);
$referer=$referer ? $referer : urlencode($PHP_REFERER);
$action=$action ? $action : 'add';
purview_category($catid,$action);
switch($action){
case 'add':
if(!is_array($_CAT)) showmessage("请先添加栏目!","?mod=phpcms&file=category&action=add&channelid=".$channelid);
if($submit)
{
if($_grade==4 && $status==3) showmessage("您没有权限!");
if(!$catid)
{
showmessage('对不起,请选择所属栏目!请返回!');
}
if($_CAT[$catid][child] && !$_CAT[$catid][enableadd])
{
showmessage('指定栏目不允许添加文章!请返回!');
}
if(empty($title))
{
showmessage('对不起,简短标题不能为空!请返回!');
}
if($linkurl=="" && empty($content))
{
showmessage('对不起,文章内容不能为空!请返回!');
}
$groupview=is_array($groupview) ? implode(',',$groupview) : $groupview;
$addtime=preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/i', $addtime) ? strtotime($addtime.' '.date('H:i:s',$timestamp)) : $timestamp;
if($addkeywords && !empty($keywords))
{
$keyword = explode(",", $keywords);
foreach($keyword as $key)
{
update_keyword($key,$channelid);
}
}
if($addauthors && !empty($author))
{
update_author($author,$channelid,0);
}
if($addcopyfroms && !empty($copyfromname))
{
update_copyfrom($copyfromname,$copyfromurl,$channelid);
}
if($is_saveremotefiles)
{
@set_time_limit(120);
include_once PHPCMS_ROOT."/include/saveremotefiles.php";
$content = save_remotefiles($content,$PHP_DOMAIN,"gif|jpg|jpeg|bmp|png");
}
$db->query("INSERT INTO ".TABLE_ARTICLE."(channelid,catid,specialid,title,titleintact,subheading,includepic,titlefontcolor,titlefonttype,showcommentlink,description,keywords,author,copyfromname,copyfromurl,content,paginationtype,maxcharperpage,thumb,savepathfilename,ontop,elite,stars,status,linkurl,readpoint,groupview,username,addtime,editor,edittime,checker,checktime,templateid,skinid) VALUES('$channelid','$catid','$specialid','$title','$titleintact','$subheading','$includepic','$titlefontcolor','$titlefonttype','$showcommentlink','$description','$keywords','$author','$copyfromname','$copyfromurl','$content','$paginationtype','$maxcharperpage','$thumb','$savepathfilename','$ontop','$elite','$stars','$status','$linkurl','$readpoint','$groupview','$_username','$timestamp','$_username','$addtime','$_username','$addtime','$templateid','$skinid')");
$articleid = $db->insert_id();
field_update($channelid,"articleid=$articleid");
if($status==3)
{
credit_add($_username,$_CAT[$catid]['creditget']);
tohtml("article");
include PHPCMS_ROOT."/include/updatewithinfo.php";
}
showmessage('操作成功!',$referer);
}
else
{
$referer=urlencode('?mod='.$mod.'&file='.$file.'&action=add&channelid='.$channelid.'&catid='.$catid);
//实现自动添加点数
foreach( $_CAT as $key=>$val)
{
$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
}
$cat_select = cat_select('catid','请选择栏目',$catid,"onchange='setff(this.value)'");
$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
$showskin = showskin('skinid',$skinid);
$showtpl = showtpl($mod,'content','templateid',$templateid);
$showgroup = showgroup('checkbox','groupview[]');
$color_select = color_select('titlefontcolor','颜色',$colorcode);
$fonttype_select = fonttype_select('titlefonttype','字形',$defaultfont);
$keyword_select = keyword_select($channelid);
$author_select = author_select($channelid);
$copyfrom_select = copyfrom_select($channelid);
$fields = field_input($channelid,"tablerow");
$today=date('Y-m-d',time());
include admintpl('article_add');
}
break;
case 'edit':
if($submit)
{
if($_grade==4 && $status==3) showmessage("您没有权限!");
if(empty($articleid))
{
showmessage('非法参数!请返回!');
}
if(!$catid)
{
showmessage('对不起,请选择所属栏目!请返回!');
}
if(empty($title))
{
showmessage('对不起,标题不能为空!请返回!');
}
if(!$linkurl && empty($content))
{
showmessage('对不起,文章内容不能为空!请返回!');
}
$groupview=is_array($groupview) ? implode(',',$groupview) : $groupview;
$addtime=preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/i', $addtime) ? strtotime($addtime.' '.date('H:i:s',$timestamp)) : $timestamp;
if($addkeywords && !empty($keywords))
{
$keyword = explode(",", $keywords);
foreach($keyword as $key)
{
update_keyword($key,$channelid);
}
}
if($addauthors && !empty($author))
{
update_author($author,$channelid,0);
}
if($addcopyfroms && !empty($copyfromname))
{
update_copyfrom($copyfromname,$copyfromurl,$channelid);
}
if($is_saveremotefiles)
{
@set_time_limit(120);
include_once PHPCMS_ROOT."/include/saveremotefiles.php";
$content = save_remotefiles($content,$PHP_DOMAIN,"gif|jpg|jpeg|bmp|png");
}
$db->query("UPDATE ".TABLE_ARTICLE." SET catid='$catid',specialid='$specialid',title='$title',titleintact='$titleintact',subheading='$subheading',includepic='$includepic',titlefontcolor='$titlefontcolor',titlefonttype='$titlefonttype',showcommentlink='$showcommentlink',description='$description',keywords='$keywords',author='$author',copyfromname='$copyfromname',copyfromurl='$copyfromurl',content='$content',paginationtype='$paginationtype',maxcharperpage='$maxcharperpage',thumb='$thumb',savepathfilename='$savepathfilename',ontop='$ontop',stars='$stars',status='$status',linkurl='$linkurl',editor='$_username',edittime='$timestamp',addtime='$addtime',readpoint='$readpoint',groupview='$groupview',templateid='$templateid',skinid='$skinid' WHERE articleid='$articleid' AND channelid='$channelid'");
field_update($channelid,"articleid=$articleid");
if($status==3)
{
tohtml("article");
include PHPCMS_ROOT."/include/updatewithinfo.php";
}
showmessage('操作成功!',$referer);
}
else
{
if(empty($articleid))
{
showmessage('非法参数!请返回!');
}
$r=$db->get_one("SELECT * FROM ".TABLE_ARTICLE." WHERE articleid='$articleid' AND chan