<!--#include file="../fy.Function.asp"-->
 <!--#include file="../../Field.asp"-->
<!--#include file="../../fy_inc/CreateView.asp"-->
<!--#include file="../../fy_inc/Escape.asp"-->

<%
echo "<link href=""../Images/style.css"" rel=""stylesheet"" type=""text/css"">"
Dim Save_SQL,ShowErr,description
Dim Title,IntactTitle,ChangesLinkUrl,actlink,Intro,Content
Dim Hits,Keywords,CopyFrom,addtime,TypeTitleFont,rs3
Dim IsTop,rev,StrMakeHtml,SpecialID,ClassID,FileName,filenametype
Dim  PicUrl,TemplateUrl,SavePic,Slide,authorRs,Field2,Field,rs
Dim Tags,binding,IF_NULL,ModeID,ID,I,ATT,author
Dim Tmps,TmpUs,url,uptime,reppic,publishtime
 Dim ChargeType,InfoPurview,arrGroupID,ReadPoint,PitchTime,ReadTimes,DividePercent
	 ModeID = ChkNumeric(Request("ModeID"))
	 if ModeID=0 or ModeID="" Then ModeID=1
	ID = ChkNumeric(Request("ID"))
	IF_NULL=fycms.Act_MX_Arr(ModeID,1)
   	If IsArray(IF_NULL) Then
		For I=0 To Ubound(IF_NULL,2)
		 If IF_NULL(8,I)=0  And Trim(fycms.S(IF_NULL(0,I)))<>""  Then  Call fycms.checkValueOnly(ID,ModeID,IF_NULL(0,I),IF_NULL(1,I),IF_NULL(3,I))
 		 If IF_NULL(2,I)=0 And Trim(fycms.S(IF_NULL(0,I)))="" Then  Call  fycms.ALERT(IF_NULL(1,I)&"不能为空","")
		Next
	End If


	
 	reppic = ChkNumeric(Request.Form("reppic"))
	Tags = ChkNumeric(Request.Form("Tags"))
	Title = Request.Form("Title")'简短标题
	description = Request.Form("description")'简短标题
	
	IntactTitle = Request.Form("IntactTitle")'完整标题
	ChangesLinkUrl = Request.Form("ChangesLinkUrl")'转向链接地址
	actlink = ChkNumeric(Request.Form("actlink"))'是否使用转向链接
	ClassID = Request.Form("ClassID")'所属栏目ID
	IsTop = ChkNumeric(Request.Form("IsTop"))'置顶
	rev = ChkNumeric(Request.Form("rev"))'是否允许评论
	FileName = Request.Form("FileName")'生成文件名
	StrMakeHtml = ChkNumeric(Request.Form("MakeHtml"))
	Intro = Request.Form("Intro")'文章导读
	Content = fycms.japanHtml(Request.Form("Content"))'文章内容





	Hits = ChkNumeric(Request.Form("Hits"))'初始点击数
	Keywords = Request.Form("Keywords")'关键字
	author = Request.Form("author")'文章作者
 	CopyFrom = Request.Form("CopyFrom")'文章来源
	addtime = Request.Form("addtime")'添加日期
	publishtime= Request.Form("publishtime")'添加日期
	uptime = Request.Form("uptime")'添加日期
	filenametype = Request.Form("filenametype")
	PicUrl = Request("PicUrl")'图片地址
	TemplateUrl = Request("TemplateUrl")'模板ID
	Slide = ChkNumeric(Request("Slide"))
 	ATT = ChkNumeric(Request("ATT"))
	ReadPoint = ChkNumeric(Request("ReadPoint"))
	ChargeType = ChkNumeric(Request("ChargeType"))
	PitchTime = ChkNumeric(Request("PitchTime"))
	ReadTimes = ChkNumeric(Request("ReadTimes"))
	InfoPurview = ChkNumeric(Request("InfoPurview"))
	DividePercent = ChkNumeric(Request("DividePercent"))
	arrGroupID = Request("arrGroupID")
  
	SavePic = ChkNumeric(Request("SavePic"))'是否远程存图

 	If fycms.ACT_L(ClassID,11)="0" And fycms.ACT_L(ClassID,13)="1" Then 
		 Call fycms.Alert("绑定域名的一级栏目,不能添加文章","")
		response.end
 	End If 
 	If  IsDate(publishtime) =True Then 
		If IsDate(addtime) =False Then addtime=now()
	Else 
		publishtime="2012-02-13"
	End If 
 	If IsDate(uptime) =False Then uptime=now()
	
 	If fycms.ACT_C(ModeID,12) > 0 Then 
		Content=Replace(Content,"[NextPage]","")
		Content=fycms.AutoSplitPage(Content,"[NextPage]", fycms.ACT_C(ModeID,12))
	End If 
 	If CLng(fycms.ACT_L(ClassID,10))<>ModeID Then  
		ShowErr = "该模型并没有该栏目"
		Call fycms.ActErr(ShowErr,"","1")
		Response.End
	End if


	
 

	IF Trim(ClassID) = ""  Then
		ShowErr = "请选择一个栏目"
		Call fycms.ActErr(ShowErr,"","1")
		Response.End
	End if

 

    If ChkNumeric(Request("addauthor")) = 1 And  author<>"" Then 
		 Set authorRs = Server.createobject("Adodb.Recordset")
		 Field = Split(author,"-")
		 If UBound(Field)>0 Then author=Field(0):Field2=Field(1)
		 authorRs.Open "Select * From AC_fy Where Field1 ='" & author & "' And Types =1",Conn,1,3
		 If authorRs.Eof Then
			 authorRs.AddNew
			 authorRs("Field1") =author
			 authorRs("Field2") = Field2
			 authorRs("Types") = 1
			 authorRs.Update
		 End If:authorRs.Close
	End If 



	If ChkNumeric(Request("addCopyFrom")) = 1 And CopyFrom<>"" Then 
		 Set authorRs = Server.createobject("Adodb.Recordset")
		 Field = Split(CopyFrom,"-")
		 If UBound(Field)>0 Then CopyFrom=Field(0):Field2=Field(1)
		 authorRs.Open "Select * From AC_fy Where Field1 ='" & CopyFrom & "' And Types =0",Conn,1,3
		 If authorRs.Eof Then
			 authorRs.AddNew
			 authorRs("Field1") = CopyFrom
			 authorRs("Field2") = Field2
			 authorRs("Types") = 0
			 authorRs.Update
		 End If:authorRs.Close
	End If 
 	 If Trim(Keywords)="" Then 
		Dim WS:Set WS=New Wordsegment_Cls
		Keywords = WS.SplitKey(title,4,20)
	End If 

	If Tags = 1 Then Call fycms.AddTags(1,Keywords)
	If  TemplateUrl="" Then'继承栏目设置
		TemplateUrl=fycms.ACT_L(ClassID,5)
	Else
		TemplateUrl=TemplateUrl
	End If 
 	If filenametype="0" Then filenametype=fycms.ACT_L(ClassID,7)

	If CInt(SavePic) = 1 And CInt(actlink) <> 1 Then
		Dim SaveFilePath
		If CStr(fycms.fycms_Other(7)) = "0" Then
		  SaveFilePath = fycms.actsys & fycms.fycms_Other(6) & Year(Now()) & "-" & Right("0" & Month(Now()), 2) & "/"
		Else
		  SaveFilePath = fycms.actsys & fycms.fycms_Other(6)
		End If
		  Call fycms.CreateFolder(SaveFilePath)
		  Content = fycms.ReplaceUrl(Content, SaveFilePath)
	End If


	If ChkNumeric(Request("dellink")) =1  Then Content=RemoveHref(Content)
    If fycms.s("FilterIframe") = "1" Then  Content = ScriptHtml(Content, "Iframe", 1)
    If fycms.s("FilterObject") = "1" Then  Content = ScriptHtml(Content, "Object", 2)
    If fycms.s("FilterScript") = "1" Then  Content = ScriptHtml(Content, "Script", 2)
    If fycms.s("FilterDiv")    = "1" Then  Content = ScriptHtml(Content, "Div", 3)
    If fycms.s("FilterTable")  = "1" Then  Content = ScriptHtml(Content, "table", 3)
    If fycms.s("FilterTr")     = "1" Then  Content = ScriptHtml(Content, "tr", 3)
    If fycms.s("FilterTd")     = "1" Then  Content = ScriptHtml(Content, "td", 3)
    If fycms.s("FilterTd")     = "1" Then  Content = ScriptHtml(Content, "Span", 3)
    If fycms.s("FilterImg")    = "1" Then  Content = ScriptHtml(Content, "Img", 3)
    If fycms.s("FilterFont")   = "1" Then  Content = ScriptHtml(Content, "Font", 3)
    If fycms.s("FilterA")      = "1" Then  Content = ScriptHtml(Content, "A", 3)
    If fycms.s("FilterHtml")   = "1" Then  Content = delHtml(Content)
 
	Function RemoveHref(HTMLstr)
		Dim ra
		Set ra = New RegExp
		ra.IgnoreCase = True
		ra.Global = True
		ra.Pattern = "<a[^>]+>(.+?)<\/a>"
		RemoveHref= ra.replace(HTMLstr,"$1")
	End Function

	If PicUrl<>"" And ChkNumeric(Request.Form("slt"))=0 Then 
		on error resume next
 	  	 Dim W:Set W = New CreateView
 		 Call W.CreateView(PicUrl,PicUrl,LCase(Mid(PicUrl,InStrRev (PicUrl, ".")+1)))
   	End If 
	PicUrl = Request("PicUrl")'图片地址
   	If reppic > 0 And Trim(PicUrl)="" Then PicUrl=fycms.ExtractionPic(Content,reppic)
  	Set Save_SQL = server.CreateObject("adodb.recordset")
		If Not fycms.fycms_QXYZ(ModeID,"2",ClassID) Then  Call fycms.Alert("对不起，您没有该栏目下添加内容的权限！","")
		Dim ChkFileName,strFileName
		If  Request.Form("FileName")="" Then '获取文件名并且解析
			strFileName=fycms.ACT_L(ClassID,16)
			If Instr(strFileName,"{y}") > 0 Then strFileName = Replace(strFileName,"{y}",Right("0" & Year(Now), 2))
			If Instr(strFileName,"{yy}") > 0 Then strFileName = Replace(strFileName,"{yy}", Year(Now))
			If Instr(strFileName,"{time}") > 0 Then strFileName = Replace(strFileName,"{time}", hour(time))
			If Instr(strFileName,"{m}") > 0 Then strFileName = Replace(strFileName,"{m}",Right("0" & Month(Now), 2))
			If Instr(strFileName,"{d}") > 0 Then strFileName = Replace(strFileName,"{d}",Right("0" & Day(Now), 2))
			If Instr(strFileName,"{date}") > 0 Then strFileName = Replace(strFileName,"{date}",Year(Now) & "-" & Month(Now) & "-" & Day(Now))
			If Instr(strFileName,"{enname}") > 0 Then strFileName = Replace(strFileName,"{enname}",fycms.ACT_L(classid,3))
			If Instr(strFileName,"{md5}") > 0 Then strFileName = Replace(strFileName,"{md5}",MD5(Now,32))
			If Instr(strFileName,"{modeid}") > 0 Then strFileName = Replace(strFileName,"{modeid}",modeid)
			If Instr(strFileName,"{md5-16}") > 0 Then strFileName = Replace(strFileName,"{md5-16}",MD5(Now,16))
			If Instr(strFileName,"{rnd}") > 0 Then strFileName = Replace(strFileName,"{rnd}",fycms.GetRandomize(10))
			If Instr(strFileName,"{pinyin}") > 0 Then strFileName = Replace(strFileName,"{pinyin}",fycms.GetEn(fycms.PinYin(delhtml(Title))))
		Else
			strFileName=Request.Form("FileName")
			If Instr(strFileName,".")>0 Then '截取扩展名
				Tmps = Split(strFileName,".") : TmpUs = Tmps(Ubound(Tmps)-1)
				strFileName=TmpUs
			Else
				strFileName=strFileName
			End If 
 		End If 
		If Right(strFileName,1)="/" Then 
			strFileName=Left(strFileName, Len(strFileName) - 1)
		End If 
	
		If InStr(strFileName, "//") > 0   Then
			strFileName = Replace(strFileName, "//","/")
		End If 
		IF Request("Action") = "add" Then '添加
 			set ChkFileName = conn.execute("select ID From "&fycms.ACT_C(ModeID,2)&" where ClassID="& ClassID &" and FileName='"& strFileName &"' order by ID desc")
		Else 
			set ChkFileName = conn.execute("select ID From "&fycms.ACT_C(ModeID,2)&" where ClassID="& ClassID &" and FileName='"& strFileName &"' and id<>"&id&" order by ID desc")
		End If 
		if Not ChkFileName.eof then
			ShowErr = "文件名意外重复,请返回保存,如果还发现这种情况,请确认生成规则是否正确"
			Call fycms.ActErr(ShowErr,"","1")
			Response.end
		End If

	IF Request("Action") = "add" Then '添加
	If fycms.s("introduce")="1" And Intro="" Then Intro=GetStrValue(Trim(delHtml(Content)),ChkNumeric(Request("contentlength")),"")
		Dim sqlstr
		SqlStr = "select * from " & fycms.ACT_C(ModeID,2) &" where 1=0"
		Save_SQL.Open SqlStr, conn, 1, 3
		Save_SQL.AddNew
		Save_SQL("ClassID") = ClassID
		Save_SQL("allpic") ="fycms"
		Save_SQL("Title") = Title'简短标题
		Save_SQL("pinyin") = fycms.GetEn(fycms.PinYin(title))
 		Save_SQL("IntactTitle")= IntactTitle'完整标题
		Save_SQL("Intro") = Intro'文章导读
 		Save_SQL("IsTop") = IsTop'置顶
		Save_SQL("author") = author'作者
		Save_SQL("isAccept") = 0
 	    Save_SQL("userid") = 0
 		Save_SQL("Slide") = Slide'幻灯片
		Save_SQL("ATT") = ATT
		Save_SQL("Hits") = Hits
		Save_SQL("description") = description
		
		Save_SQL("ReadPoint") = ReadPoint
		Save_SQL("ChargeType") = ChargeType
		Save_SQL("PitchTime") = PitchTime
		Save_SQL("ReadTimes") = ReadTimes
		Save_SQL("InfoPurview") = InfoPurview
		Save_SQL("DividePercent") = DividePercent
		Save_SQL("arrGroupID") = arrGroupID
		Save_SQL("delif") = 0
		Save_SQL("userip") = getip()
		if Clng(actlink) = 1 then '如果是转向链接,则文件名是转向地址
			Save_SQL("actlink") = 1
			Save_SQL("FileName") = ChangesLinkUrl
		Else
			Save_SQL("actlink") = 0
			Save_SQL("FileName") = strFileName'文件名
		 End IF
			Save_SQL("TemplateUrl") = TemplateUrl'内容
			If fycms.ACT_C(modeid,18)="0" Then  	Save_SQL("Content") = Content'内容
			Save_SQL("CopyFrom") = CopyFrom'文章来源
			Save_SQL("Keywords") = Keywords'关键字
			Save_SQL("rev") = rev'评论
			Save_SQL("addtime") = addtime
			Save_SQL("uptime") = uptime
			Save_SQL("publishtime") = publishtime
 			Save_SQL("PicUrl") = PicUrl'图片文章地址
			Save_SQL("ArticleInput") = RSQL(Request.Cookies(fycmsN)("AdminName"))
			If IsArray(IF_NULL) Then
 				For I=0 To Ubound(IF_NULL,2)
 					Select Case IF_NULL(3,I)
						Case "NumberType"
 						   If fycms.regexField(fycms.S(IF_NULL(0,I)),"^\d+$")=True Then 
							   Save_SQL("" & IF_NULL(0,I) & "" )= ChkNumeric(fycms.S(IF_NULL(0,I)))
						   End If 
						Case "DateType"
							If IsDate(fycms.S(IF_NULL(0,I)))=False Then 
								Save_SQL("" & IF_NULL(0,I) & "")= Now()
							Else 
								Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
							End If
						Case "PicType"
							If IF_NULL(7,I)="1" Then
  							   Save_SQL("" & IF_NULL(0,I) & "")=IF_NULL(0,I)
  							 Else 
  									Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
							 End If 
 						
						Case Else 
 							  If IF_NULL(4,I)="2" Then 
										If fycms.regexField(fycms.S(IF_NULL(0,I)),IF_NULL(5,I))=True Then 
											Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
										Else 
											Call fycms.Alert(IF_NULL(6,I),"")
										End If 
								Else 
									Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
								End If 

 					End Select 
 
					actField=""
 				Next
			End If			
		Save_SQL.update
			Set rs=fycms.actexe("Select top 1 id,classid,FileName from "&fycms.ACT_C(ModeID,2)&"  order by id desc")
			If Not rs.eof Then ID = rs("ID")
			If Instr(strFileName,"{id}") > 0 Then 
				strFileName = Replace(rs("FileName"),"{id}",rs("id"))
				fycms.actexe("Update "&fycms.ACT_C(ModeID,2)&" set FileName='"&strFileName&"' where id="&id)
			End If 
			Dim artcount
			artcount=fycms.actexe("select count(id) from  "&fycms.ACT_C(ModeID,2)&" where delif=0 and  isAccept=0 and classid="&classid)(0)
			fycms.actexe("Update class_fy set artcount="&artcount&" where classid="&classid)

			artcount=fycms.actexe("select count(id) from  "&fycms.ACT_C(ModeID,2)&" where delif=0 and  isAccept=0 ")(0)
			fycms.actexe("Update mode_fy set artcount="&artcount&" where modeid="&modeid)
		
			fycms.actexe("Update Upload_fy set AID="&id&",classid="&classid&",modeid="&modeid&" where modeid=0 and AID=0")
			fycms.actexe("Update syspic set AID="&id&" where modeid="&modeid&" and AID=0")
  		Session("ClassName")=delhtml(fycms.ACT_L(ClassID,2))
		Session("ClassID")=ClassID
	ElseIF  Request("Action") = "edit" Then
		If Not fycms.fycms_QXYZ(ModeID,"3",ClassID) Then  Call fycms.Alert("对不起，您没有该栏目下修改内容的权限！","")
		Dim IF_diy_NULL
		IF_diy_NULL=fycms.diy_MX_Arr(ModeID,1,ChkNumeric(ID))
		If IsArray(IF_diy_NULL) Then
			For I=0 To Ubound(IF_diy_NULL,2)
 			 If IF_diy_NULL(2,I)=0 And Trim(fycms.S(IF_diy_NULL(0,I)))="" Then  Call  fycms.ALERT(IF_diy_NULL(1,I)&"不能为空","")
			Next
		End If

 
		dim Save_SQL1
		Save_SQL1= "Select * from "&fycms.ACT_C(ModeID,2)&" where ID="& ChkNumeric(ID) &""
		Save_SQL.Open Save_SQL1,Conn,1,3
		Save_SQL("ClassID") = ClassID
		Save_SQL("Title") = Title'简短标题
	'	Save_SQL("pinyin") = fycms.GetEn(fycms.PinYin(title))'修改的时候是否改变
		Save_SQL("allpic") ="fycms"
		Save_SQL("IntactTitle")= IntactTitle'完整标题
		Save_SQL("Intro") = Intro'文章导读
		Save_SQL("IsTop") = IsTop'置顶
		Save_SQL("author") = author'作者
		Save_SQL("Slide") = Slide'幻灯片
		Save_SQL("ATT") = ATT
		Save_SQL("Hits") = Hits
		Save_SQL("description") = description
		if Clng(actlink) = 1 then '如果是转向链接,则文件名是转向地址
			Save_SQL("actlink") = 1
			Save_SQL("FileName") = ChangesLinkUrl
		Else
			Save_SQL("actlink") = 0
			Save_SQL("FileName") = strFileName'文件名
		 End IF
		Save_SQL("TemplateUrl") = TemplateUrl'内容
		If fycms.ACT_C(modeid,18)="0" Then  	Save_SQL("Content") = Content'内容
  		Save_SQL("CopyFrom") = CopyFrom'文章来源
		Save_SQL("Keywords") = Keywords'关键字
		Save_SQL("rev") = rev'评论
		Save_SQL("uptime") = uptime
		Save_SQL("publishtime") = publishtime
		Save_SQL("PicUrl") = PicUrl'图片文章地址
		Save_SQL("ReadPoint") = ReadPoint
		Save_SQL("ChargeType") = ChargeType
		Save_SQL("PitchTime") = PitchTime
		Save_SQL("ReadTimes") = ReadTimes
		Save_SQL("InfoPurview") = InfoPurview
		Save_SQL("DividePercent") = DividePercent
 		Save_SQL("arrGroupID") = arrGroupID
		Save_SQL("upip") = getip()

		If Request.QueryString("fycms")="sh" Then 
			Save_SQL("isAccept") = 0
		End If 
		'ClassID=Save_SQL("ClassID")
		If IsArray(IF_NULL) Then
			For I=0 To Ubound(IF_NULL,2)
 					Select Case IF_NULL(3,I)
						Case "NumberType"
 						   If fycms.regexField(fycms.S(IF_NULL(0,I)),"^\d+$")=True Then 
							   Save_SQL("" & IF_NULL(0,I) & "" )= fycms.S(IF_NULL(0,I))
						   End If 
						Case "DateType"
							If IsDate(fycms.S(IF_NULL(0,I)))=False Then 
								Save_SQL("" & IF_NULL(0,I) & "")= Now()
							Else 
								Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
							End If
						Case "PicType"
							If IF_NULL(7,I)="1" Then 
  							   Save_SQL("" & IF_NULL(0,I) & "")=IF_NULL(0,I)
  							 Else 
  									Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
							 End If 
 						
						Case Else 
 							  If IF_NULL(4,I)="2" Then 
										If fycms.regexField(fycms.S(IF_NULL(0,I)),IF_NULL(5,I))=True Then 
											Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
										Else 
											Call fycms.Alert(IF_NULL(6,I),"")
										End If 
								Else 
									Save_SQL("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
								End If 

 					End Select 
 				actField=""
			Next
		End If			
		Save_SQL.update


		If IsArray(IF_diy_NULL) Then
			For I=0 To Ubound(IF_diy_NULL,2)
 					Select Case IF_diy_NULL(3,I)
						Case "NumberType"
 						   If fycms.regexField(fycms.S(IF_diy_NULL(0,I)),"^\d+$")=True Then 
 							  Call  noSaveFile(fycms.S(IF_diy_NULL(0,I)),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
						   End If 
						Case "DateType"
							If IsDate(fycms.S(IF_diy_NULL(0,I)))=False Then 
  							  Call  noSaveFile(Now(),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
							Else 
 							  Call  noSaveFile(fycms.S(IF_diy_NULL(0,I)),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
							End If
						Case "PicType"
							If IF_diy_NULL(7,I)="1" Then 
  								 Call  noSaveFile(IF_diy_NULL(0,I),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
							 Else 
 							  Call  noSaveFile(fycms.S(IF_diy_NULL(0,I)),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
							 End If 
						Case Else 
 							  If IF_diy_NULL(4,I)="2" Then 
										If fycms.regexField(fycms.S(IF_diy_NULL(0,I)),IF_diy_NULL(5,I))=True Then 
 											Call  noSaveFile(fycms.S(IF_diy_NULL(0,I)),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
										Else 
											Call fycms.Alert(IF_diy_NULL(6,I),"")
										End If 
								Else 
 									   Call  noSaveFile(fycms.S(IF_diy_NULL(0,I)),fycms.actsys&"data/Field/"&ModeID&"/"&md5(modeid&IF_diy_NULL(0,I)&ID,32)&".txt")
								End If 

 					End Select 
 				actField=""
			Next
		End If			




		Set rs=fycms.actexe("Select top 1 id,classid,FileName from "&fycms.ACT_C(ModeID,2)&"  where  ID="& ChkNumeric(ID) &" order by id desc")
		If Not rs.eof Then ID = rs("ID"):strFileName = rs("FileName")

		If Instr(strFileName,"{id}") > 0 Then 
			strFileName = Replace(rs("FileName"),"{id}",rs("id"))
			fycms.actexe("Update "&fycms.ACT_C(ModeID,2)&" set FileName='"&strFileName&"' where id="&id)
		End If 

	End If
 	


		If fycms.ACT_C(modeid,18)="1" Then 

 			Call fycms.CreateFolder(fycms.ActSys&"data/"&ModeID&"/")
			Call noSaveFile("by www.fycms.com",fycms.ActSys&"data/"&ModeID&"/index.html")
			Call noSaveFile(Content,fycms.ActSys&"data/"&ModeID&"/"&md5(addtime&id,32)&".txt")

		End If 

 


	Call UpDateFile(Content ,id ,ClassID)
	Function UpDateFile(Byval ContentHTML,Byval AID,Byval ClassID)
		Dim RegEx,Matches,Match,Save_SQL2,Save_SQL3,ext
		Set RegEx = New RegExp
		RegEx.Ignorecase = True
		RegEx.Global = True
		RegEx.Pattern = fycms.ACT_C(ModeID,8)&  "(.+?)\.(jpeg|gif|jpg|png|bmp|mp3|wma|rmvb|rm|rar|asf|avi|wmv|swf|ra|exe|zip|doc|xls)"
		Set Save_SQL3 = server.CreateObject("adodb.recordset")
		Set Matches = RegEx.Execute(ContentHtml)
			Save_SQL2= "Select * from Upload_fy where AID="& AID
			Save_SQL3.Open Save_SQL2,Conn,1,3
		For Each Match In Matches
			If Len(Match.Value) > 0 Then
				IF Request("Action") = "add" Then Save_SQL3.AddNew
				If Save_SQL3.eof  Then Save_SQL3.AddNew
				ext=Split(Match.Value,".")
				Save_SQL3("AID") = AID'内容
				Save_SQL3("UpfileDir") = fycms.ActSys&Replace(Match.Value,"'","")
				Save_SQL3("Extension") =ext(1)
				Save_SQL3("ModeID") =ModeID
				Save_SQL3("addtime") =Now()
				Save_SQL3.update
			End If
		Next
	Save_SQL3.close:set Save_SQL3 = Nothing
	End Function
 	If CLng(StrMakeHtml) = 1  Then '立即生成Html
 			echo "<div style=""margin-top:15px;border: #E7E7E7;height:296; overflow: auto; width:100%"">" 
			If fycms.ACT_C(ModeID,3) = 0 Or fycms.ACT_C(ModeID,3) = 2 Or readpoint>0 or infopurview="2" Or (infopurview=0 And (fycms.ACT_L(ClassID,19)=1 Or fycms.ACT_L(ClassID,20)>1 Or fycms.ACT_L(ClassID,19)=2)) And actlink=0 Then 
				URL=fycms.fycms_Sys(2)&fycms.ActSys&fycms.act_c(ModeID,5)&"?id="&rs("ID")
			Else 
				If actlink = 0 Then
 					  echo "<div align=center><iframe src=""../Include/fy.C.asp?ModeID="&ModeID&"&RefreshFlag=ID&ID=" & rs("ID") &""" width=""100%"" height=""40"" frameborder=""0""></iframe></div>"
					Dim PrevArticle
					  set PrevArticle = Conn.execute("select ID From Article where ClassID ="& rs("classid") &" and id<"& rs("ID") &"  and isAccept=0 AND delif=0 order by ID desc")
					  If Not PrevArticle.eof Then
						  echo "<div align=center><iframe src=""../Include/fy.C.asp?ModeID="&ModeID&"&RefreshFlag=ID&ID=" & PrevArticle("id") &""" width=""98%"" height=""0"" frameborder=""0""></iframe></div>"
						  echo "<div style=""margin-left:179;height:25px""><li>系统已经生成了静态文件.同时更新了上一篇文章链接</li></div> "
					  End If 
					  URL = strFileName
			
 					If fycms.ACT_L(fycms.GetParent(ClassID),13)="1" Then 
						 If Right(fycms.ACT_L(ClassID,16),1)<>"/" Then 
								 URL= fycms.ACT_L(fycms.GetParent(ClassID),15)&"/"&strFileName&fycms.ACT_C(ModeID,11)
						 Else
								 URL= fycms.ACT_L(fycms.GetParent(ClassID),15)&"/"&strFileName&"/"
						 End If 
					Else 
 						If Right(fycms.ACT_L(ClassID,16),1)<>"/" Then 
								 URL= fycms.acturl&fycms.ACT_C(ModeID,6)&strFileName&fycms.ACT_C(ModeID,11)
						 Else
								 URL= fycms.acturl&fycms.ACT_C(ModeID,6)&strFileName&"/"
						End If 
					End If 




				Else	
					 echo "<div style=""margin-left:179;height:25px""><li>文章是转向链接.系统没有生成</li></div> "
					  URL = rs("FileName")
				End If 
				If fycms.ACT_C(ModeID,9) = 2 Then 
					  Dim FolderIDArr:FolderIDArr=Split(fycms.GetClassNavStr(rs("ClassID")),",")
					  For I=0 To Ubound(FolderIDArr)
						echo "<div align=center><iframe src=""../Include/fy.L.asp?ModeID="&ModeID&"&RefreshFlag=IDS&CID=" & FolderIDArr(i) &""" width=""0"" height=""0"" frameborder=""0""></iframe></div>"
					  Next
				End If
			End If
			echo "<div style=""margin-left:179;height:25px""><li>地址:<a target=""_blank"" href="&URL&">"&URL&"</a></div>"
		ElseIf  CLng(StrMakeHtml) = 0 Then
		 echo "<div style=""margin-left:179;height:25px""><li>系统没有选中立即生成 ID号为<font color=red>" & ID & "</font>  的文章没有生成!</li></div> "
		Else 
		 echo "<div style=""margin-left:179;height:25px""><li>系统未知错误</li></div> "
		End If
			if fycms.ACT_C(ModeID,9)=>2 And Split(fycms.fycms_Sys(4),".")(1)<>"asp" Then
			echo "<div align=center><iframe src=""../include/MakeIndex.asp"" width=""0"" height=""0"" frameborder=""0""></iframe></div>"
			End If 
		echo "<div style=""margin-left:179;height:25px""><li>文章保存成功! <a href=fy.Add.asp?ModeID="&ModeID&"><b>添加新文章</b></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=fy.Manage.asp?ModeID="&ModeID&"><b><font color=red>返回管理首页</font></b></a></li></div>"
		rs.close:set rs = Nothing
%>