<!--#include file="const.asp"-->
<!--#include file="../inc/cls_xmlhttp.asp"-->
<!--#include file="collection.asp"-->
<%
If Not ChkAdmin("Collection_"&ChannelID) Then
	Call Transfer_error()
End If
Dim i
Dim StopItem,IsDown,MaxAddress,PathForm,SaveFilePath
Dim AutoRename,IsNowTime,AllHits,star,isLogin
Dim PaginalList,IsPagination,startid,lastid

Dim Action,CacheID,d,p,sType,totalnumber,strFreshLink
Dim HttpArray,ListArray,TaskDone
Dim m_intClassID,m_intRank,m_intArticleID
Dim IsUpdates,blnUpdate,m_strMessage,m_strFullTitle
Dim m_strUploadPicDir,UploadPicPath

ItemID=NewAsp.ChkNumeric(Request("ItemID"))
CacheID=NewAsp.ChkNumeric(Request("CacheID"))
sType=NewAsp.ChkNumeric(Request("stype"))
totalnumber=NewAsp.ChkNumeric(Request("totalnumber"))
p=NewAsp.ChkNumeric(Request("p"))
Action = LCase(Request("action"))
d=Request("d")
If d="" Then d=Now()
If p=0 Then p=1
TaskDone=False

m_strUploadPicDir = Replace(Trim(NewAsp.ChannelSetting(7)), "\", "/")
If Len(m_strUploadPicDir) < 2 Then m_strUploadPicDir = "UploadPic/"
If Right(m_strUploadPicDir,1) <> "/" Then m_strUploadPicDir = m_strUploadPicDir & "/"
UploadPicPath=NewAsp.InstallDir & NewAsp.ChannelDir & m_strUploadPicDir

Select Case Trim(Action)
Case "saveurl"
	Call showmain()
	Call showScript()
	Call LoadListTemplate(listid)
	Call FindHttpList()
	Response.Write "<script>$('DetailedText').innerHTML='友情提示！收集URL列表完成。';</script>"
	Response.Write "<script>$('submit_button').disabled=false;$('submit_button2').disabled=false;</script>"
	Response.Flush
Case "begin"
	Call showmain()
	Call showScript()
	Call LoadListTemplate(listid)
	Call FindHttpList()
	Application(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)=m_strLinkArry
	Response.Write "<script language='JavaScript'>" & vbNewLine
	Response.Write "function reFresh(){window.location.href='admin_savedata.asp?action=savedata&ChannelID="&ChannelID&"&ItemID="&ItemID&"&stype=0';}" & vbNewLine
	Response.Write "setTimeout('reFresh()',1000);" & vbNewLine
	Response.Write "</script>" & vbNewLine
	Response.Flush
Case "savedata"
	Call showsetting()
	If TaskDone=False Then
		Call showmain()
		Call showScript()
		Call LoadListTemplate(listid)
		Call FindHttpData()
		Call showDetailed()
		Call savedata()
		If TaskDone=False Then
			Response.Write "<script language='JavaScript'>" & vbNewLine
			Response.Write "function reFresh(){window.location.href='"&strFreshLink&"';}" & vbNewLine
			Response.Write "setTimeout('reFresh()',"&setInterval&");" & vbNewLine
			Response.Write "</script>" & vbNewLine
			Response.Flush
		End If
	End If
Case Else
	'Call showmain()
End Select

Sub showsetting()
	If sType=1 Then
		HttpArray=Application(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)
		If IsArray(HttpArray) Then
			totalnumber=UBound(HttpArray)
			If totalnumber>0 And p<=totalnumber Then
				ListArray=Split(HttpArray(p), "|")
				m_strFindLink=ListArray(0)
				ItemID=CLng(ListArray(1))
				m_intArticleID=CLng(ListArray(2))
				m_intClassID=CLng(ListArray(3))
				m_intRank=CLng(ListArray(4))
				ListArray=Null
			Else
				TaskDone=True
				Response.Write "<script>showtitle('采集任务完成');</script>" & vbCrLf
				Response.Flush
				Application.Lock
				Application.Contents.Remove(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)
				Application.unLock
			End If
		End If
	Else
		CacheID=ItemID
		HttpArray=Application(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)
		If IsArray(HttpArray) Then
			totalnumber=UBound(HttpArray)
			If totalnumber>0 And p<=totalnumber Then
				m_strFindLink=HttpArray(p)
				m_intArticleID=0
				m_intClassID=0
				m_intRank=0
			Else
				TaskDone=True
				Response.Write "<script>showtitle('采集任务完成');</script>" & vbCrLf
				Response.Flush
				Application.Lock
				Application.Contents.Remove(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)
				Application.unLock
			End If
		End If
	End If
	strFreshLink="admin_savedata.asp?action="&Action&"&ChannelID="&ChannelID&"&ItemID="&ItemID&"&d="&d&"&CacheID="&CacheID&"&stype="&sType&"&p="&p+1&""
End Sub

Sub showmain()
	Dim Node
	If Not IsObject(Application(NewAsp.CacheName&"_newsconfig")) Then Call LoadNewsConfig()
	Set Node=Application(NewAsp.CacheName&"_newsconfig").documentElement.selectSingleNode("row")
	If Not Node is Nothing Then
		stopGather=CLng(Node.selectSingleNode("@stopgather").text)
		RepeatDeal=CLng(Node.selectSingleNode("@repeatdeal").text)
		MaxPicSize=CLng(Node.selectSingleNode("@maxpicsize").text)
		AllowPicExt=Trim(Node.selectSingleNode("@allowpicext").text&"")
		setInterval=CLng(Node.selectSingleNode("@setinterval").text)
	End If
	Set Node=Nothing

	If Not IsObject(Application(NewAsp.CacheName&"_newsitem_"&ChannelID&"_"&ItemID)) Then Call LoadItemSetting(ItemID)
	Set Node=Application(NewAsp.CacheName&"_newsitem_"&ChannelID&"_"&ItemID).documentElement.selectSingleNode("row")
	If Not Node is Nothing Then
		classid=CLng(Node.selectSingleNode("@classid").text)
		specialid=CLng(Node.selectSingleNode("@specialid").text)
		listid=CLng(Node.selectSingleNode("@listid").text)
		infoid=CLng(Node.selectSingleNode("@infoid").text)
		StopItem=CLng(Node.selectSingleNode("@stopitem").text)
		Encoding=Trim(Node.selectSingleNode("@encoding").text)
		IsDown=CLng(Node.selectSingleNode("@isdown").text)
		PathForm=CLng(Node.selectSingleNode("@pathform").text)
		RemoteListUrl=Trim(Node.selectSingleNode("@remotelisturl").text)
		PaginalList=Trim(Node.selectSingleNode("@paginallist").text&"")
		IsPagination=CLng(Node.selectSingleNode("@ispagination").text)
		startid=CLng(Node.selectSingleNode("@startid").text)
		lastid=CLng(Node.selectSingleNode("@lastid").text)
		AutoClass=CLng(Node.selectSingleNode("@autoclass").text)
		RetuneClass=Node.selectSingleNode("@retuneclass").text&""
		strReplace=Node.selectSingleNode("@strreplace").text&""
		RemoveCode=Node.selectSingleNode("@removecode").text&""
		NamedDemourl=Trim(Node.selectSingleNode("@nameddemourl").text&"")
		IsNowTime=CLng(Node.selectSingleNode("@isnowtime").text)
		AllHits=CLng(Node.selectSingleNode("@allhits").text)
		star=CLng(Node.selectSingleNode("@star").text)
		isLogin=CLng(Node.selectSingleNode("@islogin").text)
	End If
	Set Node=Nothing

	If Not IsObject(Application(NewAsp.CacheName&"_infotemplate_"&ChannelID&"_"&infoid)) Then Call LoadInfoTemplate(infoid)
	Set Node=Application(NewAsp.CacheName&"_infotemplate_"&ChannelID&"_"&infoid).documentElement.selectSingleNode("row")
	If Not Node is Nothing Then
		Pagination=CLng(Node.selectSingleNode("@pagination").text)
		FindTitle=Split(Node.selectSingleNode("@findtitle").text&"||||||||||||||||||||||||", "|||")
		FindContent=Split(Node.selectSingleNode("@findcontent").text&"||||||||||||||||||||||||", "|||")
		FindCategory=Split(Node.selectSingleNode("@findcategory").text&"||||||||||||||||||||||||", "|||")
		FindDateTime=Split(Node.selectSingleNode("@finddatetime").text&"||||||||||||||||||||||||", "|||")
		FindOthers=Split(Node.selectSingleNode("@findothers").text&"||||||||||||||||||||||||", "|||")
		FindPagination=Split(Node.selectSingleNode("@findpagination").text&"||||||||||||||||||||||||", "|||")
		AppendUrl=Split(Node.selectSingleNode("@appendurl").text&"|||||||||", "|||")
		TitleReplace=Split(Node.selectSingleNode("@titlereplace").text&"|||||||||", "|||")
		ContentReplace=Split(Node.selectSingleNode("@contentreplace").text&"|||||||||", "|||")
		sourceReplace=Node.selectSingleNode("@sourcereplace").text&""
	End If
	Set Node=Nothing
End Sub

Sub FindHttpList()
	Dim i,strListArry,strURL
	Response.Write "<script>$('DetailedText').innerHTML=$('collectmsg').innerHTML;</script>"
	Response.Write "<script>$('submit_button').disabled=true;$('submit_button2').disabled=true;</script>"
	Response.Flush
	On Error Resume Next
	If IsPagination=0 Then
		m_strHtmlCode=cmHttp.GetRemoteData(RemoteListUrl, Encoding)
		m_strHtmlList=cmHttp.FindHtmlCode(m_strHtmlCode,FindListArea(1),FindListArea(2),FindListArea(0),False)
		If Len(m_strHtmlList)=0 Then
			OutErrors ("友情提示\n\n获取远程列表错误\n请检查采集项目第二步的获取列表开始和结束代码是否有误！")
			Exit Sub
		End If
		strListArry=cmHttp.GetMatchContent(m_strHtmlList,FindListLink(1),FindListLink(2),FindListLink(0))

		If UBound(strListArry)=0 Then
			OutErrors ("友情提示\n\n获取远程列表连接错误\n请检查采集项目第二步的获取连接开始和结束代码是否有误！")
			Exit Sub
		Else
			m_strLinkArry=cmHttp.RearrangedUrl(strListArry,RemoteListUrl,RedirectUrl)
		End If
		strListArry=Null
	Else
		If startid = lastid Then
			strURL=Replace(Replace(PaginalList, "*", startid), "{$pageid}", startid, 1, -1, 1)
			If Not cmHttp.CheckXmlHTTP(strURL) Then strURL=RemoteListUrl
			m_strHtmlCode=cmHttp.GetRemoteData(strURL, Encoding)
			m_strHtmlList=cmHttp.FindHtmlCode(m_strHtmlCode,FindListArea(1),FindListArea(2),FindListArea(0),False)
			strListArry=cmHttp.GetMatchContent(m_strHtmlList,FindListLink(1),FindListLink(2),FindListLink(0))
			If UBound(strListArry)=0 Then Exit Sub
			m_strLinkArry=cmHttp.RearrangedUrl(strListArry,strURL,RedirectUrl)
			strListArry=Null
		Else
			Dim s,l
			If startid<lastid Then
				s=startid:l=lastid
			Else
				s=lastid:l=startid
			End If
			For i=s To l
				If Not Response.IsClientConnected Then Response.End
				strURL=Replace(Replace(PaginalList, "*", i), "{$pageid}", i, 1, -1, 1)
				If Not cmHttp.CheckXmlHTTP(strURL) Then strURL=RemoteListUrl
				m_strHtmlCode=cmHttp.GetRemoteData(strURL, Encoding)
				m_strHtmlList=cmHttp.FindHtmlCode(m_strHtmlCode,FindListArea(1),FindListArea(2),FindListArea(0),False)
				strListArry=cmHttp.GetMatchContent(m_strHtmlList,FindListLink(1),FindListLink(2),FindListLink(0))
				If UBound(strListArry)>0 Then
					m_strLinkArry=cmHttp.ConcatArray(strListArry,m_strLinkArry)
				End If
				strListArry=Null
			Next
			m_strLinkArry=cmHttp.RearrangedUrl(m_strLinkArry,strURL,RedirectUrl)
		End If
	End If
	If FindReplace(0)<>"" Then m_strLinkArry=cmHttp.ReplaceUrlToArray(m_strLinkArry,FindReplace)
	If UBound(m_strLinkArry)>0 Then
		m_strFindLink=m_strLinkArry(1)
	Else
		Response.Write "<script>$('DetailedText').innerHTML='没有收集到可用的URL列表';</script>"
		Response.Flush
		Exit Sub
	End If
End Sub

Sub FindHttpData()
	Response.Write "<script>showtitle('正在采集数据，请稍候...');</script>" & vbCrLf
	Response.Write "<script>$('submit_button').disabled=true;$('submit_button2').disabled=true;</script>"
	Response.Flush
	On Error Resume Next
	m_strHtmlCode=cmHttp.GetRemoteData(m_strFindLink, Encoding)
	If Len(m_strHtmlCode)=0 Then Exit Sub
	m_strHtmlCode=cmHttp.ReplaceSource(m_strHtmlCode,sourceReplace)
	'--获取标题
	m_strTitle=cmHttp.FindHtmlCode(m_strHtmlCode,FindTitle(1),FindTitle(2),FindTitle(0),False)
	If Len(m_strTitle)=0 Then
		'OutErrors ("友情提示\n\n获取文章标题错误\n请检查采集项目第三步的获取标题的开始和结束代码是否有误！")
		'Exit Sub
	End If
	'--获取内容
	m_strContent=cmHttp.FindHtmlCode(m_strHtmlCode,FindContent(1),FindContent(2),FindContent(0),False)
	If m_strContent = "" Then m_strContent = m_strTitle
	'--获取副标题
	If FindTitle(4)<>"" And FindTitle(5)<>"" Then
		m_strSubTitle=cmHttp.FindHtmlCode(m_strHtmlCode,FindTitle(4),FindTitle(5),FindTitle(3),True)
	End If

	If AutoClass>0 And sType=0 Then
		'--获取分类
		If FindCategory(1)<>"" And FindCategory(2)<>"" Then
			m_strClassHtml=cmHttp.FindHtmlCode(m_strHtmlCode,FindCategory(1),FindCategory(2),FindCategory(0),False)
			If m_strClassHtml<>"" Then
				'--获取父分类
				If FindCategory(3)<>"" And FindCategory(4)<>"" Then
					m_strParent=cmHttp.FindHtmlCode(m_strClassHtml,FindCategory(3),FindCategory(4),0,True)
					If m_strParent<>"" Then m_strClassHtml=Replace(m_strClassHtml, m_strParent, "{$parent$}")
				End If
				'--获取子分类
				If FindCategory(5)<>"" And FindCategory(6)<>"" Then
					m_strChild=cmHttp.FindHtmlCode(m_strClassHtml,FindCategory(5),FindCategory(6),0,True)
				End If
				If m_strParent="" And m_strChild="" Then
					m_strChild=cmHttp.RemoveHTML(m_strClassHtml)
				End If
				'--分类替换操作
				If Len(RetuneClass) > 0 Then
					m_strParent=cmHttp.ReplaceClass(m_strParent, RetuneClass)
					m_strChild=cmHttp.ReplaceClass(m_strChild, RetuneClass)
				End If
				'根据分类名称获取分类ID
				If AutoClass=1 Then
					classid=GetClassID(ChannelID, Trim(m_strParent), Trim(m_strChild))
				Else
					classid=GetClassID(ChannelID, vbNullString, Trim(m_strChild))
				End If
			End If
		End If
	Else
		Dim iRs,FileDirArray
		If m_intClassID>0 And sType=1 Then classid=m_intClassID
		Set iRs=NewAsp.Execute("SELECT classid,rootid,depth,HtmlFileDir FROM [NC_Classify] WHERE ChannelID="&ChannelID&" And ClassID="&classid&" And child=0 And TurnLink=0")
		If iRs.BOF And iRs.EOF Then
			classid=0
			Exit Sub
		Else
			FileDirArray=Split(iRs("HtmlFileDir"), "/")
			ClassDirName=FileDirArray(0) & "/"
			FileDirArray=Null
		End If
		Set iRs = Nothing
	End If
	If classid=0 Then Exit Sub
	
	If IsNowTime=0 Then
		'--获取更新时间
		If FindDateTime(1)<>"" And FindDateTime(2)<>"" Then
			m_strDateTime=cmHttp.FindHtmlCode(m_strHtmlCode,FindDateTime(1),FindDateTime(2),FindDateTime(0),False)
			If FindDateTime(3)<>"" And FindDateTime(4)<>"" Then
				m_strDateTime=cmHttp.FindHtmlCode(m_strDateTime,FindDateTime(3),FindDateTime(4),FindDateTime(0),True)
			End If
			m_strDateTime=cmHttp.stringToDate(m_strDateTime)
		Else
			m_strDateTime=Now()
		End If
	Else
		m_strDateTime=Now()
	End If
	'--获取文章作者
	If FindOthers(1)<>"" And FindOthers(2)<>"" Then
		m_strAuthor=cmHttp.FindHtmlCode(m_strHtmlCode,FindOthers(1),FindOthers(2),FindOthers(0),True)
	End If
	If Len(m_strAuthor)<2 Then m_strAuthor="佚名"
	'--获取文件来源
	If FindOthers(4)<>"" And FindOthers(5)<>"" Then
		m_strComeFrom=cmHttp.FindHtmlCode(m_strHtmlCode,FindOthers(4),FindOthers(5),FindOthers(3),True)
	End If
	If Len(m_strComeFrom)<2 Then m_strComeFrom="本站整理"
	'--获取推荐星级
	If FindOthers(7)<>"" And FindOthers(8)<>"" Then
		m_strStar=cmHttp.FindHtmlCode(m_strHtmlCode,FindOthers(7),FindOthers(8),FindOthers(6),False)
		If FindOthers(9)<>"" And FindOthers(10)<>"" Then
			m_strStar=cmHttp.FindHtmlCode(m_strHtmlCode,FindOthers(9),FindOthers(10),FindOthers(6),True)
		End If
		m_strStar=NewAsp.ChkNumeric(m_strStar)
		If m_strStar<2 Or m_strStar>5 Then m_strStar=3
	Else
		If star>1 Then
			m_strStar=star
		Else
			m_strStar=cmHttp.GetRndStar()
		End If
	End If
	If m_intRank>0 Then
		m_intStar=m_intRank
	Else
		m_intStar=NewAsp.ChkNumeric(m_strStar)
	End If
	'--获取内容分页
	If Pagination>0 And FindPagination(1)<>"" And FindPagination(2)<>"" Then
		Dim PaginationHtml,strTempHtml,strTempContent,sTempContent
		Dim strListArry
		If Pagination=1 Then
			PaginationHtml=cmHttp.FindHtmlCode(m_strContent,FindPagination(1),FindPagination(2),1,False)
			'--去掉内容中的分页代码
			If PaginationHtml<>"" Then m_strContent=Replace(m_strContent, PaginationHtml, "")
		Else
			PaginationHtml=cmHttp.FindHtmlCode(m_strHtmlCode,FindPagination(1),FindPagination(2),FindPagination(0),False)
		End If

		If PaginationHtml<>""  And FindPagination(3)<>"" And FindPagination(4)<>"" Then
			strListArry=cmHttp.GetMatchContent(PaginationHtml,FindPagination(3),FindPagination(4),FindPagination(0))
			strListArry=cmHttp.RearrangedUrl(strListArry,m_strFindLink,AppendUrl(0))
			If UBound(strListArry)>0 Then
				strTempContent=m_strContent
				For i=1 To UBound(strListArry)
					If LCase(strListArry(i))<>LCase(m_strFindLink) Then
						strTempHtml=cmHttp.GetRemoteData(strListArry(i), Encoding)
						strTempHtml=cmHttp.ReplaceSource(strTempHtml,sourceReplace)
						sTempContent=cmHttp.FindHtmlCode(strTempHtml,FindContent(1),FindContent(2),FindContent(0),False)
						If Pagination=1 Then
							PaginationHtml=cmHttp.FindHtmlCode(sTempContent,FindPagination(1),FindPagination(2),1,False)
							If PaginationHtml<>"" Then sTempContent=Replace(sTempContent, PaginationHtml, "")
						End If
						strTempContent=strTempContent & "[page_break]" & sTempContent
					End If
				Next
				m_strContent=strTempContent
			End If
			strListArry=Null
		End If
	End If
	'--标题过滤替换
	If TitleReplace(0)<>"" Then
		m_strTitle=cmHttp.Re_Replace(m_strTitle,TitleReplace(0),TitleReplace(1))
	End If
	If TitleReplace(2)<>"" Then
		m_strTitle=cmHttp.Re_Replace(m_strTitle,TitleReplace(2),TitleReplace(3))
	End If
	'--内容替换操作
	If Len(strReplace)>2 Then
		m_strContent=cmHttp.ReplaceClass(m_strContent, strReplace)
	End If
	'--内容字符过虑
	If ContentReplace(0)<>"" Then m_strContent=Replace(m_strContent, ContentReplace(0), "")
	If ContentReplace(1)<>"" Then m_strContent=Replace(m_strContent, ContentReplace(1), "")
	'--过虑内容中的匹配字符
	If ContentReplace(5)<>"" And ContentReplace(6)<>"" Then
		m_strContent=cmHttp.CheckMatchString(m_strContent,ContentReplace(5),ContentReplace(6),ContentReplace(4))
	End If
	If ContentReplace(8)<>"" And ContentReplace(9)<>"" Then
		m_strContent=cmHttp.CheckMatchString(m_strContent,ContentReplace(8),ContentReplace(9),ContentReplace(7))
	End If
	'--内容字符过虑
	m_strContent=cmHttp.Html2Ubb(m_strContent,RemoveCode)
	'-－内容追加字符
	m_strContent=cmHttp.FormatContentUrl(m_strContent,m_strFindLink)
	m_strContent=ContentReplace(2)&m_strContent&ContentReplace(3)
	m_strTitle=cmHttp.CheckNostr(m_strTitle)
	m_strTitle=cmHttp.CheckTitle(m_strTitle, TitleReplace(0), TitleReplace(1))
	m_strTitle=cmHttp.CheckTitle(m_strTitle, TitleReplace(2), TitleReplace(3))
	'--统计
	m_intAllHits=AllHits
	If AllHits=999 Then m_intAllHits=cmHttp.GetRndHits
	If AllHits=99 Then m_intAllHits=cmHttp.GetRandHits
	If AllHits=9 Then m_intAllHits=cmHttp.GetRndNumber
	'--获取文章ID
	If UnsealHttpLog And sType=0 Then
		m_intArticleID=getArticleID(m_strFindLink)
	Else
		m_intArticleID=0
	End If
End Sub

Sub savedata()
	If classid=0 Then
		Response.Write "<script>showtitle('分类ID错误！可能这个分类是外部连接。请编辑采集项目重新选择分类。');</script>" & vbCrLf
		Response.Flush
		Call showTaskDone()
		Exit Sub
	End If
	If Len(m_strTitle)<1 Then
		Response.Write "<script>showtitle('截取标题错误，请检查采集项目第三步标题截取代码。');</script>" & vbCrLf
		Response.Flush
		Call showTaskDone()
		Exit Sub
	End If
	On Error Resume Next
	m_strAlphaTitle=cmHttp.CheckInput(m_strTitle,4)
	m_strFullTitle=Trim(m_strTitle)
	Dim Rs,SQL
	Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
	If m_intArticleID>0 Then
		SQL="SELECT * FROM NC_Article WHERE ChannelID="&ChannelID&" And ArticleID="&m_intArticleID
	Else
		SQL="SELECT * FROM NC_Article WHERE ChannelID="&ChannelID&" And title='"&Replace(m_strTitle, "'", "''")&"'"
	End If
	Rs.Open SQL,Conn,1,3

	If Rs.BOF And Rs.EOF Then
		IsUpdates=True
		blnUpdate=False
		If stopGather <> 9 Then
			ClassUpdateCount ChannelID, classid
		End If
	Else
		If DateDiff("d", Now(), Rs("WriteTime")) = 0 Then
			IsUpdates = False
		End If
		If RepeatDeal = 0 Then
			IsUpdates = False
		ElseIf RepeatDeal = 1 Then
			IsUpdates = True
			blnUpdate = True
		Else
			IsUpdates = True
			blnUpdate = False
			If stopGather <> 9 Then
				ClassUpdateCount ChannelID, classid
			End If
		End If
	End If
	Dim NewsUploadFileList,FileNameArray,NewsBriefTopic
	Dim strFileExt,NewsImageUrl
	NewsImageUrl=""
	NewsBriefTopic=0
	If IsUpdates Then
		'--是否打开下载功能
		If stopGather>0 And IsDown>0 Then
			'--下载缩略图
			Dim strDatePath
			If cmHttp.PictureEx And blnUpdate=False Then
				strDatePath=cmHttp.CreateDatePath(UploadPicPath)
				m_strContent=cmHttp.RemoteToLocal(m_strContent,UploadPicPath & strDatePath,m_strUploadPicDir&strDatePath)
				NewsUploadFileList = cmHttp.AllFileName
				FileNameArray = Split(NewsUploadFileList, "|")
				If UBound(FileNameArray) < 3 Then
					NewsBriefTopic = 1
				Else
					NewsBriefTopic = 2
				End If
				For i = 0 To UBound(FileNameArray)
					If Len(FileNameArray(i)) > 0 Then
						strFileExt = LCase(cmHttp.GetFileExtName(FileNameArray(i)))
						If strFileExt = "gif" Then
							NewsImageUrl = FileNameArray(i)
							Exit For
						End If
						If strFileExt = "jpg" Then
							NewsImageUrl = FileNameArray(i)
							Exit For
						End If
						If strFileExt = "png" Then
							NewsImageUrl = FileNameArray(i)
							Exit For
						End If
						If strFileExt = "bmp" Then
							NewsImageUrl = FileNameArray(i)
							Exit For
						End If
					End If
				Next
				FileNameArray=Null
			End If
		Else

		End If

		If blnUpdate=False Then Rs.Addnew
		Rs("ChannelID") = ChannelID
		Rs("ClassID") = classid
		Rs("SpecialID") = specialid
		Rs("title") = NewAsp.RequestForm(m_strTitle,255)

		If blnUpdate=False Then
			Rs("subtitle") = NewAsp.RequestForm(m_strSubTitle,200)
		Else
			If Len(m_strSubTitle)>1 Then Rs("subtitle") = NewAsp.RequestForm(m_strSubTitle,200)
		End If
		Rs("content") = m_strContent
		Rs("Author") = NewAsp.RequestForm(m_strAuthor,50)
		Rs("ComeFrom") = NewAsp.RequestForm(m_strComeFrom,50)
		Rs("star") = m_intStar
		Rs("WriteTime") = m_strDateTime
		Rs("isUpdate") = 1

		Rs("BriefTopic") = NewsBriefTopic
		Rs("ImageUrl") = Trim(NewsImageUrl)
		Rs("UploadImage") = Trim(NewsUploadFileList)

		If blnUpdate=False Then
			Rs("username") = Trim(AdminName)
			Rs("AllHits") = m_intAllHits : Rs("DayHits") = m_intAllHits : Rs("WeekHits") = m_intAllHits
			Rs("MonthHits") = m_intAllHits : Rs("HitsTime") = Now() : Rs("HtmlFileDate") = Trim(NewAsp.HtmlRndFileName)
			Rs("AlphaIndex") = NewAsp.ReadAlpha(m_strAlphaTitle)
			Rs("PointNum") = 0 : Rs("UserGroup") = 0 : Rs("isAccept") = 1 : Rs("ForbidEssay") = 0
			Rs("isBest") = 0 : Rs("ColorMode") = 0 : Rs("FontMode") = 0 : Rs("isTop") = 0 : Rs("AutoPages") = 0
			Rs("good") = 0 : Rs("bad") = 0 : Rs("Taglist")=""
		End If
		Rs.update
		ArticleID = Rs("ArticleID")
		m_strMessage="恭喜您！文章采集成功。"
	Else
		m_strMessage="文章采集失败！目标文章已存在，不予采集。"
	End If
	Rs.Close: Set Rs = Nothing
	If blnUpdate=False Then
		Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
		Rs.Open "SELECT TOP 1 ArticleID FROM NC_Article WHERE ChannelID="&ChannelID&" ORDER BY ArticleID DESC", Conn, 1, 1
		ArticleID = Rs("ArticleID")
		Rs.Close: Set Rs = Nothing
	End If
	Response.Write "<script>showtitle('"&m_strMessage&"');</script>" & vbCrLf
    Response.Flush
	Call showTaskDone()
End Sub

Sub showTaskDone()
	If p=>totalnumber Then
		TaskDone=True
		Response.Write "<script>showtitle('采集任务完成');</script>" & vbCrLf
		Response.Write "<script>$('submit_button').disabled=false;$('submit_button2').disabled=false;</script>"
		Response.Flush
		Application.Lock
		Application.Contents.Remove(NewAsp.CacheName&"_collectionlist_"&ChannelID&"_"&CacheID)
		Application.unLock
	End If
End Sub

Function ElapsedTime()
	Dim ElapsedSeconds
	ElapsedSeconds=DateDiff("s", d, Now())
	If ElapsedSeconds > 3600 then
		ElapsedTime = ElapsedSeconds \ 3600 & " 时 " & (ElapsedSeconds mod 3600) \ 60 & " 分 " & ElapsedSeconds mod 60 & " 秒"
	ElseIf ElapsedSeconds > 60 then
		ElapsedTime = ElapsedSeconds \ 60 & " 分 " & ElapsedSeconds mod 60 & " 秒"
	Else
		ElapsedTime = ElapsedSeconds mod 60 & " 秒"
	End If
End Function

Sub showDetailed()
	Response.Write "<script>$('planmain').style.display='';</script>"
%>
<div id="DetailedText">
<b>文章标题：</b><%=m_strTitle%><br/>
	<%If m_strSubTitle<>"" Then%><b>副 标 题：</b><%=m_strSubTitle%><br/><%End IF%>
	<b>更新时间：</b><%=m_strDateTime%><br/>
	<b>文章作者：</b><%=m_strAuthor%><br/>
	<b>文章来源：</b><%=m_strComeFrom%><br/>
	<%If m_strParent<>"" Or m_strChild<>"" Then%><b>文章分类：</b><%=m_strParent%> / <%=m_strChild%><br/><%End IF%>
	<b>目标地址：</b><%=cmHttp.PlusLinks(m_strFindLink)%><br/>
</div>
<script type="text/javascript">
<!--
	$("DetailedText").innerHTML=document.getElementById("DetailedText").innerHTML;
	plantext(<%=totalnumber%>,<%=p%>,'<%=ElapsedTime()%>');
	planpercent('<%=FormatPercent(p/totalnumber,2,-1)%>');
	planwidth(<%=Fix((p/totalnumber) * 500)%>);
	//$("urlid").innerHTML='<%=strFreshLink%>';
//-->
</script>
<%
	Response.Flush
End Sub

Sub showScript()
%>
<script type="text/javascript">
<!--
function $(s){return parent.document.getElementById(s);}
function planwidth(iwidth){
	$('ProgressBar').style.width=iwidth+'px';
}

function planpercent(ipercent){
	$('PercentText').innerHTML=ipercent;
}

function planelapsed(ielapsed){
	$('ElapsedTime').innerHTML='用时：'+ielapsed;
}

function plancount(icount){
	$('TakeCount').innerHTML='生成第 <font color="red">'+icount+'</font> 个 ';
}
function showtitle(s){
	$('begintitle').innerHTML=s;
}
function plantext(totalnumber,icount,ielapsed){
	$('plantext').innerHTML='总共：<font color="blue">'+totalnumber+'</font>&nbsp;&nbsp;已完成 <font color="red">'+icount+'</font> 个&nbsp;&nbsp;用时：'+ielapsed;
}
//-->
</script>
<%
	Response.Flush
End Sub
%>