⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 article.php

📁 phpcms网站管理系统  很不错的 有需要的就下载看看八 
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?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),
	array('审核文章','?mod='.$mod.'&file='.$file.'&action=check&channelid='.$channelid),
	array('<font color="red">管理文章</font>','?mod='.$mod.'&file='.$file.'&action=manage&channelid='.$channelid),
	array('我添加的文章','?mod='.$mod.'&file='.$file.'&action=myitem&channelid='.$channelid),
	array('<font color="red">管理专题文章</font>','?mod='.$mod.'&file='.$file.'&action=special&channelid='.$channelid),
	array('批量移动文章','?mod='.$mod.'&file='.$file.'&action=move&channelid='.$channelid),
	array('回收站管理','?mod='.$mod.'&file='.$file.'&action=recycle&channelid='.$channelid)
);

$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,$catid);
		}
		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");
		}
		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,$catid);
		}
		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',readpoint='$readpoint',editor='$_username',edittime='$timestamp',addtime='$addtime',groupview='$groupview',templateid='$templateid',skinid=$skinid WHERE articleid='$articleid' AND channelid='$channelid'");
		field_update($channelid,"articleid=$articleid");
		if($status==3)
		{
			tohtml("article");
		}
		
		showmessage('操作成功!',$referer);
	}
	else
	{
		if(empty($articleid))
		{
			showmessage('非法参数!请返回!');
		}
		$r=$db->get_one("SELECT * FROM ".TABLE_ARTICLE." WHERE articleid='$articleid' AND channelid='$channelid'");
		if(!$r['articleid']) showmessage("参数错误!");
		@extract($r);

        if($_grade>3 && $status==3) showmessage("您没有权限!");

		$description=htmlspecialchars(stripslashes($description));
		$content=htmlspecialchars(stripslashes($content));
		$addtime=date("Y-m-d",$addtime);
		if($article[savepathfilename])
		{
			$savepathfilenames=explode('|',$savepathfilename);
		}
		//实现自动添加点数
		foreach( $_CAT as $key=>$val)
		{
			$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
		}
		$cat_select = cat_select('catid','请选择栏目',$catid);
		$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
		$showskin = showskin('skinid',$skinid);
		$showtpl = showtpl($mod,'content','templateid',$templateid);
		$showgroup = showgroup('checkbox','groupview[]',$groupview);
		$color_select = color_select('titlefontcolor','颜色',$titlefontcolor);
		$fonttype_select = fonttype_select('titlefonttype','字形',$titlefonttype);
		$keyword_select = keyword_select($channelid);
		$author_select = author_select($channelid);
		$copyfrom_select = copyfrom_select($channelid);
		$fields = field_input($channelid,"tablerow");
		include admintpl('article_edit');
	}
break;

case 'checktitle':
	if(empty($title)) $error_msg='标题不能为空!请返回!';
	$result=$db->query("SELECT articleid,title,addtime FROM ".TABLE_ARTICLE." WHERE status=3 AND recycle=0 AND channelid=$channelid AND title LIKE '%$title%' ORDER BY articleid");
	while($r=$db->fetch_array($result))
	{
		$r[url] = $p->get_itemurl($r[articleid],$r[addtime]);
		$r[adddate]=date("m-d",$r[addtime]);
		$articles[]=$r;
	}
	include admintpl('article_checktitle');
break;


case 'manage':
	$referer=urlencode('?mod='.$mod.'&file='.$file.'&action=manage&channelid='.$channelid.'&catid='.$catid.'&srchtype='.$srchtype.'&keyword='.$keyword.'&ontop='.$ontop.'&elite='.$elite.'&ordertype='.$ordertype.'&page='.$page);
	if(!$page)
	{
		$page=1;
		$offset=0;
	}
	else
	{
		$offset=($page-1)*$pagesize;
	}

	if(!empty($keywords))
	{
		$keyword=str_replace(' ','%',$keywords);
		$keyword=str_replace('*','%',$keyword);
		switch($srchtype)
		{
		case '0':
				$addquery=" AND (title LIKE '%$keyword%' or titleintact LIKE '%$keyword%' or subheading LIKE '%$keyword%') ";
		break;
		case '1':
				$addquery=" AND content LIKE '%$keyword%' ";
		break;
		case '2':
				$addquery=" AND author LIKE '%$keyword%' ";
		break;
		case '3':
				$addquery=" AND username LIKE '%$keyword%' ";
		break;
		default :
				$addquery=" AND (title LIKE '%$keyword%' or titleintact LIKE '%$keyword%' or subheading LIKE '%$keyword%') ";
		}
	}
	if($catid)
	{
		$arrchildid=$_CAT[$catid][child] ? $_CAT[$catid][arrchildid] : $catid;
		$addquery.=" AND catid IN($arrchildid) ";
	}
	$addquery .= $elite ? " AND elite=1 " : "";
	$addquery .= $ontop ? " AND ontop=1 " : "";
	switch($ordertype)
	{
		case 1:
			$dordertype=" articleid DESC ";
		break;
		case 2:
			$dordertype=" articleid ";
		break;
		case 3:
			$dordertype=" hits DESC ";
		break;
		case 4:
			$dordertype=" hits ";
		break;
		default :
			$dordertype=" articleid DESC ";
	}
	if($time) $addquery .= sql_time($time);

	$r = $db->get_one("SELECT COUNT(*) AS num FROM ".TABLE_ARTICLE." WHERE status=3 AND recycle=0 AND channelid='$channelid' $addquery");
	$number=$r["num"];
	$url="?mod=".$mod."&file=".$file."&action=manage&channelid=".$channelid."&catid=".$catid."&srchtype=".$srchtype."&keyword=".$keyword."&ontop=".$ontop."&elite=".$elite."&ordertype=".$ordertype."&page=".$page;
	$pages=phppages($number,$page,$pagesize,$url);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -