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

📄 inc_article.asp

📁 ZD-BS是一个基于asp+access的个人blog系统 程序特点: 1.数据结构合理
💻 ASP
字号:
<script language="JScript" runat="server">

//============================================================
//     Copyright 2006-2007 VAL/ZYI. All Rights Reserved.
//============================================================

function showArticle(arrPara){

	var strErr="";
	
	var intLogID=arrPara["logID"];
	
	var strQuery="select top 1 ";
	strQuery+="(select count(comm_ID) from zd_comment where comm_postID=post_ID and comm_type='comment' and comm_state='publish') as commCount,";
	strQuery+="(select count(comm_ID) from zd_comment where comm_postID=post_ID and comm_state='publish' and comm_type='pingback') as pingCount,";
	strQuery+="(select count(comm_ID) from zd_comment where comm_postID=post_ID and comm_state='publish' and comm_type='trackback') as tbCount,";
	strQuery+="cat_ID,cat_name,cat_state,post_ID,post_title,post_authorID,post_authorName,post_email,post_homepage,post_content,post_textMode,post_editTime,post_postTime,post_viewCount,post_enableComment,post_checkComment,post_enablePingIn,post_state ";
	strQuery+="from zd_post,zd_category where post_catID=cat_ID and post_ID="+intLogID+" and post_type='article' and post_state<>'draft'";
	var arrArticle=dbConn.query(strQuery);
	var arrNext=null,arrPrev=null;

	if(arrArticle==null){
		strErr+="<li>"+zd_ls["error:error para"]+"</li>";
	}else if(
		(arrArticle[0]["post_authorID"]!=zd_userID&&zd_userGroup!="admin")&&
		(arrArticle[0]["cat_state"]=="private"||arrArticle[0]["post_state"]=="private")
	){
		strErr+="<li>"+zd_ls["error:no rights"]+"</li>";
	}else{
		arrArticle=arrArticle[0];
	}

	if(strErr!=""){
		errorMsg(strErr);
	}else{
		strQuery="select top 1 cat_state,post_ID,post_title,post_state from zd_post,zd_category ";
		strQuery+="where post_catID=cat_ID and post_type='article' and post_ID>"+arrArticle["post_ID"]+" and post_type<>'draft' ";
		if(zd_userGroup!="admin"){
			strQuery+="and cat_state<>'private' and post_type<>'draft' and (post_state<>'private' or (post_authorID="+zd_userID+" and post_authorID<>0)) ";
		}
		strQuery+="order by post_ID asc";
		arrNext=dbConn.query(strQuery);
		if(arrNext!=null) arrNext=arrNext[0];

		strQuery="select top 1 cat_state,post_ID,post_title,post_state from zd_post,zd_category ";
		strQuery+="where post_catID=cat_ID and post_type='article' and post_ID<"+arrArticle["post_ID"]+" and post_type<>'draft' ";
		if(zd_userGroup!="admin"){
			strQuery+="and cat_state<>'private' and (post_state<>'private' or (post_authorID="+zd_userID+" and post_authorID<>0)) ";
		}
		strQuery+="order by post_ID desc";
		arrPrev=dbConn.query(strQuery);
		if(arrPrev!=null) arrPrev=arrPrev[0];

		dbConn.updateSql("post_viewCount=post_viewCount+1","zd_post","post_ID="+intLogID);

		var arrLog=checkArticle(arrArticle,arrNext,arrPrev);
		var arrComm=commentList(intLogID);
		var arrPost=commentPostForm(intLogID,arrArticle["post_authorID"],arrArticle["post_enableComment"],arrArticle["post_checkComment"]);
		page_article(arrLog,arrComm,arrPost);
	}
}

function checkArticle(arrArticle,arrNext,arrPrev){
	var arr=new Array();

	arr["commCount"]=arrArticle["commCount"];
	arr["pingCount"]=arrArticle["pingCount"];
	arr["tbCount"]=arrArticle["tbCount"];
	arr["catID"]=arrArticle["cat_ID"];
	arr["catName"]=arrArticle["cat_name"];
	arr["ID"]=arrArticle["post_ID"];
	arr["title"]=arrArticle["post_title"];
	arr["authorID"]=arrArticle["post_authorID"];
	arr["authorName"]=arrArticle["post_authorName"];
	arr["email"]=arrArticle["post_email"];
	arr["homepage"]=arrArticle["post_homepage"];
	arr["content"]=arrArticle["post_content"];
	if(arrArticle["post_textMode"]!="html"){
		arr["content"]=theHTML.ubb(arr["content"]);
	}
	if(zd_set["cacheKeyword"]){
		arr["content"]=theHTML.keyword(arr["content"]);
	}
	arr["editTime"]=func.dateStr(arrArticle["post_editTime"]);
	arr["postTime"]=func.dateStr(arrArticle["post_postTime"],zd_ls["time:type_2"]);
	arr["viewCount"]=arrArticle["post_viewCount"];
	
	arr["nextID"]=arrNext==null?0:arrNext["post_ID"];
	arr["nextTitle"]=arrNext==null?"":theHTML.sliceStr(arrNext["post_title"],24,"...",true);
	arr["prevID"]=arrPrev==null?0:arrPrev["post_ID"];
	arr["prevTitle"]=arrPrev==null?"":theHTML.sliceStr(arrPrev["post_title"],24,"...",true);

	return arr;
}

function commentList(intLogID){
	arr=null;
	var strQuery="select ";
	strQuery+="comm_ID,comm_postID,comm_content,comm_textMode,comm_authorID,comm_authorName,comm_email,comm_homepage,comm_from,comm_editTime,comm_postTime,comm_state,comm_type ";
	strQuery+="from zd_comment where comm_postID="+intLogID+" ";
	if(zd_userGroup!="admin"){
		strQuery+="and comm_state='publish' ";
	}else{
		strQuery+="and comm_state<>'waste' ";
	}
	strQuery+="and (comm_type='comment' or comm_type='trackback' or comm_type='pingback') ";
	strQuery+="order by comm_postTime asc";
	var arrComment=dbConn.query(strQuery);

	if(arrComment!=null){
		arr=checkComment(arrComment);
	}

	return arr;
}

function checkComment(arrComment){
	var arr=new Array();
	for(var i=0;i<arrComment.length;i++){
		arr[i]=new Array();
		arr[i]["checked"]=(arrComment[i]["comm_state"]=="unchecked"?false:true);
		switch(arrComment[i]["comm_type"]){
			case "comment":
			arr[i]["type"]="comment";
			arr[i]["ID"]=arrComment[i]["comm_ID"];
			arr[i]["content"]=theHTML.ubb(arrComment[i]["comm_content"]);
			arr[i]["authorID"]=arrComment[i]["comm_authorID"];
			arr[i]["authorName"]=arrComment[i]["comm_authorName"]+(arrComment[i]["comm_authorID"]<=0?"*":"");
			arr[i]["email"]=arrComment[i]["comm_email"];
			arr[i]["homepage"]=arrComment[i]["comm_homepage"];
			arr[i]["editorTime"]=func.dateStr(arrComment[i]["comm_editorTime"]);
			arr[i]["postTime"]=func.dateStr(arrComment[i]["comm_postTime"]);
			break;
			case "trackback":
			arr[i]["type"]="trackback";
			arr[i]["ID"]=arrComment[i]["comm_ID"];
			arr[i]["URL"]=arrComment[i]["comm_homepage"];
			arr[i]["title"]=arrComment[i]["comm_email"];
			arr[i]["blog"]=arrComment[i]["comm_from"];
			arr[i]["excerpt"]=theHTML.ubb(arrComment[i]["comm_content"]);
			arr[i]["time"]=func.dateStr(arrComment[i]["comm_postTime"]);
			break;
			case "pingback":
			arr[i]["type"]="pingback";
			arr[i]["ID"]=arrComment[i]["comm_ID"];
			arr[i]["URL"]=arrComment[i]["comm_homepage"];
			arr[i]["title"]=arrComment[i]["comm_email"];
			arr[i]["excerpt"]=theHTML.ubb(arrComment[i]["comm_content"]);
			arr[i]["time"]=func.dateStr(arrComment[i]["comm_postTime"]);
			break;
		}
	}
	return arr;
}

function commentPostForm(intLogID,intAuthorID,bEnableComment,bCheckComment){
	var arr=new Array();
	arr["articleID"]=intLogID;
	arr["enableComment"]=true;
	if((!zd_set["enableGuestPost"]&&zd_userGroup=="guest")||!bEnableComment){
		arr["enableComment"]=false;
	}
	arr["checkComment"]=true;
	if(zd_userID==intAuthorID||zd_userGroup=="admin"||!bCheckComment){
		arr["checkComment"]=false;
	}
	arr["userID"]=zd_userID;
	arr["userName"]=zd_userName;
	return arr;
}

function postComment(){
	var strErr="";
	var arrF=func.getInput(1);
	var intLogID=func.checkInt(arrF["articleID"]);

	var strQuery="select top 1 ";
	strQuery+="cat_state,post_authorID,post_enableComment,post_checkComment,post_state ";
	strQuery+="from zd_category,zd_post where post_ID="+intLogID+" and post_catID=cat_ID and post_type='article' and post_state<>'draft'";
	var arrArticle=dbConn.query(strQuery);

	if(arrArticle==null){
		strErr+="<li>"+zd_ls["error:error para"]+"</li>";
	}else if(
		((arrArticle[0]["post_authorID"]!=zd_userID&&zd_userGroup!="admin")&&
		(arrArticle[0]["cat_state"]=="private"||arrArticle[0]["post_state"]=="private"))||
		((!zd_set["enableGuestPost"]&&zd_userGroup=="guest")||!arrArticle[0]["post_enableComment"])
	){
		strErr+="<li>"+zd_ls["error:no rights"]+"</li>";
	}
	
	var authorName=arrF["authorName"];
	var email=arrF["email"];
	var homepage=arrF["homepage"];
	var content=arrF["content"];
	var sCode=arrF["sCode"];

	if(!sys.checkSCode(sCode)){
		strErr+="<li>"+zd_ls["error:error scode"]+"</li>";
	}
	if(zd_userID==0){
		if(!func.checkUsername(authorName)){
			strErr+="<li>"+zd_ls["error:error user name"]+"</li>";
		}
		if(!func.checkEmail(email)){
			strErr+="<li>"+zd_ls["error:error email"]+"</li>";
		}
	}
	if(!content||content.length<1||content.length>zd_set["commentLength"]){
		strErr+="<li>"+zd_ls["error:error comment"]+"</li>";
	}

	if(strErr!=""){
		errorMsg(strErr);
	}else{
		var arrInsert={
			"comm_postID":intLogID,
			"comm_content":theHTML.trim(theHTML.encodeHTML(content)),
			"comm_textMode":"text",
			"comm_authorID":zd_userID,
			"comm_authorName":zd_userID==0?authorName:zd_userName,
			"comm_email":zd_userID==0?email:zd_userEmail,
			"comm_homepage":zd_userID==0?func.checkUrl(theHTML.trim(homepage)):zd_userHomepage,
			"comm_agent":func.getAgent()["name"]+" | "+func.getAgent()["os"],
			"comm_postTime":new Date(),
			"comm_ip":func.getIp(),
			"comm_state":((zd_userID==arrArticle[0]["post_authorID"]||zd_userGroup=="admin"||!arrArticle[0]["post_checkComment"])?"publish":"unchecked"),
			"comm_type":"comment"
		};
		dbConn.insert(arrInsert,"zd_comment");
		if(zd_set["cacheNewComment"]) theCache.loadNewComment();
		if(zd_set["cacheCounter"]) theCache.loadCounter();
		
		completeMsg("<li>"+zd_ls["complete:success comment"]+"</li>","article.asp?/a"+intLogID+".html");
	}
}

function doit(){
	var arrPara=new Array();
	var arrQS=func.getInput(0);
	var strQS=sys.getStaticQuery();
	var intLogID=0;
	var re,arrMach;

	re=/a([0-9]+)/i;
	arrMach=re.exec(strQS);
	if(arrMach!=null){
		intLogID=func.checkInt(arrMach[1]);
	}

	if(func.checkStr(arrQS["act"])=="commPost"){
		postComment();
	}else if(intLogID!=0){
		arrPara["logID"]=intLogID;
		showArticle(arrPara);
	}else{
		errorMsg("<li>"+zd_ls["error:error para"]+"</li>");
	}
}

</script>

⌨️ 快捷键说明

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