<!--#include file="const.asp"-->
<!--#include file="../inc/common.asp"-->
<!--#include file="../../common/news/show.asp"-->
<!--#include file="../inc/head.asp"-->
<%
Dim t,d,TakeCount,maketype,strSQLQuery,m_strNowTitle
Dim totalnumber,u

totalnumber=NewAsp.ChkNumeric(Request("totalnumber"))
maketype=NewAsp.ChkNumeric(Request("maketype"))
t=NewAsp.ChkNumeric(Request("t"))
u=NewAsp.ChkNumeric(Request("u"))
TakeCount=NewAsp.ChkNumeric(Request("TakeCount"))
d=Request("d")
If d="" Then d=Now()

IsNowOutputText = False

Call createdhtml()
NewAsp.PageEnd()

Sub createdhtml()
	Dim Rs,SQL
	Dim m_strDate,m_strLinkUrl
	m_strLinkUrl=""
	Response.Flush
	Select Case t
		Case 1
			m_strDate = CDate(Request("datYear") & "-" & Request("datMonth") & "-" & Request("datDay"))
			m_strLinkUrl="&datYear="&Request("datYear")&"&datMonth="&Request("datMonth")&"&datDay="&Request("datDay")
			If isSqlDataBase = 1 Then
				strSQLQuery = " And datediff(d,WriteTime,getdate())="& DateDiff("d", m_strDate, Now())
			Else
				strSQLQuery = " And datediff('d',WriteTime,now())="& DateDiff("d", m_strDate, Now())
			End If
		Case 2
			strSQLQuery = " And ArticleID in ("& NewAsp.CheckStr(Request("inArticleID")) &")"
			m_strLinkUrl="&inArticleID="&Request("inArticleID")
		Case 3
			strSQLQuery = " And classid in ("& NewAsp.CheckStr(Request("inclassid")) &")"
			m_strLinkUrl="&inclassid="&Request("inclassid")
	Case Else
		strSQLQuery = ""
	End Select
	
	If totalnumber=0 Then
		If maketype=0 Then NewAsp.Execute ("UPDATE NC_Article SET isUpdate=1 WHERE isAccept>0 And ChannelID="&ChannelID & strSQLQuery)
		totalnumber=NewAsp.Execute("SELECT COUNT(*) FROM [NC_Article] WHERE isAccept>0 And ChannelID="&ChannelID&" And isUpdate=1"&strSQLQuery)(0)
	End If
	
	Response.Write "<script>$('planmain').style.display='';</script>"
	Response.Write "<script>$('plantext').style.display='';</script>"
	Set Rs = NewAsp.Execute("SELECT TOP 100 ArticleID,title FROM NC_Article WHERE isAccept>0 And ChannelID="&ChannelID&" And isUpdate=1"&strSQLQuery)
	If Rs.BOF And Rs.EOF Then
		Response.Write "<script>"
		Response.Write "plantext("&totalnumber&","&TakeCount&",'" & ElapsedTime() & "','');"
		Response.Write "planpercent('100%');"
		Response.Write "planwidth(500);"
		Response.Write "</script>" & vbCrLf
		Response.Flush
	Else
		Do While Not Rs.EOF
			If Not Response.IsClientConnected Then Response.End
			TakeCount=TakeCount+1
			showid=Rs(0)
			m_strNowTitle=Replace(Rs(1)&"", "'", "\'")
			CurrentPage=1
			Call BeginCreated()
			If Pcount>1 Then
				For CurrentPage=2 To Pcount
					Call BeginCreated()
				Next
				
			End If
			Response.Write "<script>"
			Response.Write "plantext("&totalnumber&","&TakeCount&",'" & ElapsedTime() & "','"&m_strNowTitle&"');"
			Response.Write "planpercent('" & FormatPercent(TakeCount/totalnumber,2,-1) & "');"
			Response.Write "planwidth("&Fix((TakeCount/totalnumber) * 500)&");"
			Response.Write "</script>" & vbCrLf
			Response.Flush
			Rs.movenext
		Loop
		m_strLinkUrl="admin_makeshow.asp?ChannelID="&ChannelID&"&maketype="&maketype&"&totalnumber="&totalnumber&"&d="&d&"&t="&t&"&TakeCount="&TakeCount&m_strLinkUrl
		If TakeCount<totalnumber Then
			Response.Write "<meta http-equiv=""refresh"" content=""0.5;url='"&m_strLinkUrl&"''"">"
		Else
			Response.Write "<script>"
			Response.Write "planpercent('100%');"
			Response.Write "planwidth(500);"
			Response.Write "</script>" & vbCrLf
			Response.Flush
		End If
	End If
	Rs.Close:Set Rs = Nothing
	If IsObject(TPL_XmlDom) Then Set TPL_XmlDom=Nothing
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 BeginCreated()
	Call Main()
	If u=0 Then NewAsp.Execute ("UPDATE NC_Article SET isUpdate=0 WHERE ArticleID="&showid)
	HtmlFilePath=NewAsp.CheckHtmlFilePath(HtmlFileName)
	NewAsp.CreatPathEx HtmlFilePath
	NewAsp.CreatedTextFile HtmlFileName,TPL_Memory
	TPL_Memory=""
End Sub
%>