<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
	sdcms.checkuserlogin
	dim classid:classid=sdcms.getint(sdcms.fget("classid",0),0)
	dim data
	dim catedata,catename,modeid
	catedata=sdcms.getclassdb(classid)
	if not isarray(catedata) then
		sdcms.echo "&#26639;&#30446;&#19981;&#23384;&#22312;&#25110;&#24050;&#34987;&#21024;&#38500;"
		sdcms.die
	end if
	catename=catedata(1)
	modeid=catedata(10)
	if catedata(31)=0 then
		sdcms.echo "&#26639;&#30446;&#31105;&#27490;&#25237;&#31295;"
		sdcms.die
	end if
	dim theme_publish_add:theme_publish_add=catedata(29)
	dim userdata,userid,username,loginbase
	userdata=sdcms.userinfo
	userid=userdata(0)
	username=userdata(1)
	loginbase=sdcms.base64encode(userdata(1)&userdata(2))
	dim is_lock:is_lock=sdcms.db.dbloadone("allowpostverify","sd_user_group","id="&userdata(4)&"")
	
	sub adddb()
		dim t0,t1,t2,data
		dim u0,u1
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.fpost("t1",1)
		t2=sdcms.enhtml(sdcms.fpost("t2",0))
		if sdcms.strlen(t0)=0 then
			sdcms.ajaxjson "&#25991;&#31456;&#26631;&#39064;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.strlen(t1)=0 then
			sdcms.ajaxjson "&#25991;&#31456;&#20869;&#23481;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.strlen(t2)=0 then
			sdcms.ajaxjson "&#39564;&#35777;&#30721;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.loadsession("imgcode")="" then
			sdcms.ajaxjson "&#31995;&#32479;&#39564;&#35777;&#30721;&#38169;&#35823;&#65292;&#35831;&#28857;&#20987;&#21047;&#26032;",0
			exit sub
		end if
		if sdcms.loadsession("imgcode")<>t2 then
			sdcms.ajaxjson "&#39564;&#35777;&#30721;&#38169;&#35823;",0
			exit sub
		end if
		t1=sdcms.replacetext(t1,"("&blacklist&")",string(len("&$1&"),"*"))
		u0=sdcms.get_intro(t1)
		u1=sdcms.iif(is_lock=0,-1,1)
		dim cid:cid=sdcms.getint(sdcms.fget("id",0),0)
		if cid=0 then
			select case sdcms.user_publish_num
				case "-1"
					sdcms.ajaxjson "&#24744;&#25152;&#22312;&#30340;&#29992;&#25143;&#32452;&#31105;&#27490;&#25237;&#31295;",0:exit sub
				case "0"
					sdcms.ajaxjson "&#24744;&#20170;&#26085;&#30340;&#25237;&#31295;&#25968;&#37327;&#24050;&#29992;&#23436;",0:exit sub
			end select
			data=array(array("title",t0,255),array("hits",0,10),array("islock",u1,0),array("isnice",0,1),array("ontop",0,1),array("iscomment",1,1),array("createdate",now(),50),array("likeid","0",0),array("ispic",0,1),array("lastupdate",now(),50),array("classid",classid,0),array("isurl",0,1),array("comments",0,0),array("adminid",0,0),array("userid",userid,0),array("author",username,50),array("intro",u0,0),array("point",0,10))
			if sdcms.db.dbnew("sd_content",data,"title='"&t0&"'")=0 then
				sdcms.ajaxjson "&#25991;&#31456;&#26631;&#39064;&#24050;&#23384;&#22312;&#35831;&#25442;&#20010;&#35797;&#35797;",0
				exit sub
			end if
			cid=sdcms.db.insertid("id","sd_content")
			dim fstr:fstr="array(array(""cid"",cid,0,0),array(""content"",t1,0,1))"
			sdcms.db.insert "sd_model_news",eval(fstr)

			sdcms.deal_user_attachment userid,cid
			sdcms.deal_content_url cid,classid
			if u1=1 then sdcms.deal_user_publish_point cid,userid
		else
			dim edata:edata=sdcms.db.dbload(1,"title","sd_content","id="&cid&" and islock<0 and userid="&userid&"","")
			if ubound(edata)>=0 then
				data=array(array("title",t0,255,1),array("intro",u0,0,1))
				sdcms.db.dbupdate "sd_content","id="&cid&"",data			
				fstr="array(array(""content"",t1,0,1))"
				sdcms.db.dbupdate "sd_model_news","cid="&cid&"",eval(fstr)
				sdcms.deal_user_attachment userid,cid
			end if
		end if
		sdcms.ajaxjson "&#25237;&#31295;&#25552;&#20132;&#25104;&#21151;",1
	end sub

	dim act:act=lcase(sdcms.fget("act",0))
	select case act
		case "db":adddb
		case else
			dim id:id=sdcms.getint(sdcms.fget("id",0),0)
			if id>0 then
				dim edata:edata=sdcms.db.dbload(1,"title","sd_content","id="&id&" and islock<0 and userid="&userid&"","")
				if ubound(edata)<0 then
					id=0
				else
					dim title
					title=edata(0,0)
					dim rsshow
					set rsshow=sdcms.db.exedb("select top 1 * from sd_model_news where cid="&id&"")
					if rsshow.eof then
						sdcms.echo "参数错误":sdcms.die
					end if
				end if
			end if
			sdcms.show theme_publish_add,""
	end select
	sdcms.db.dbclose
%>