<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!--#include file="Connections/conn_news.asp" -->
<!--#include file="yns_config.asp" -->
<!--#include file="yns_chklogin.asp" -->
<% chk_user_login(3) %>
<%
on error resume next
sub show_pro(nowcount,allcount)
	Response.write "<script>"
	dim ps
	ps=FormatPercent((nowcount-1)/allcount,0)
	Response.write "var a=parent;"
	Response.write "a.document.all.pro.style.width='"&ps&"';"
	Response.write "a.document.all.counter.innerHTML='"&ps&" , <font color=red>("&nowcount-1&"/"&allcount&")</font> 估计剩余时间:"&clng((allcount-nowcount+1)/10)&"秒'"
	Response.write "</script>"
end sub




Dim rsn
Dim rsn_numRows


Dim bid,sid,mcount,sql
bid=Trim(Request("bid"))
sid=Trim(Request("sid"))
mcount=Trim(request("mcount"))
if mcount="" then mcount=1
mcount=Ccur(mcount)
sql="SELECT *  FROM (t_news inner join t_type on t_news.n_tid = t_type.t_id) inner join t_type_son on t_news.n_tsid = t_type_son.ts_id where 1=1"
if bid<>"" and isnumeric(bid) then sql=sql+" and t_news.n_tid="&bid
if sid<>"" and isnumeric(sid) then sql=sql+" and t_news.n_tsid="&sid
Set rsn = Server.CreateObject("ADODB.Recordset")
rsn.open sql,MM_conn_news_STRING,1,1,1
dim counts
counts=rsn.recordcount
if mcount<=counts Then
	rsn.AbsolutePosition = mcount
	Response.write mcount
	show_pro mcount,counts
else
	Response.write "<script>parent.document.all.pro.style.width='100%';parent.document.all.counter.innerHTML='完成<font color=red> 100%</font>';parent.d.innerHTML='已完成....'</script>"
	Response.end
end if
dim i
for i=1 to 10
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="style/css.css" rel="stylesheet" type="text/css">
</head>

<body>
<ul>
      <%
	  
	  dim mmdd_path
	  dim mmdd_fpath
	  dim mmdd_tspath
	  dim mmdd_tpath
	  dim mm_template_path
	  mm_template_path = server.MapPath("templates/type_template/type_son_template/detail_template.htm")
	  mmdd_path=server.MapPath((rsn.Fields.Item("t_dir").Value)&"/"&(rsn.Fields.Item("ts_dir").Value)&"/"&(rsn.Fields.Item("n_fpath").Value)&"/"&(rsn.Fields.Item("n_fname").Value))
	  mmdd_fpath=server.MapPath((rsn.Fields.Item("t_dir").Value)&"/"&(rsn.Fields.Item("ts_dir").Value)&"/"&(rsn.Fields.Item("n_fpath").Value))
	  mmdd_tspath=server.MapPath((rsn.Fields.Item("t_dir").Value)&"/"&(rsn.Fields.Item("ts_dir").Value))
	  mmdd_tpath=server.MapPath(rsn.Fields.Item("t_dir").Value)
	 ' response.Write(mmdd_fpath)
	  Set fso = Server.CreateObject("Scripting.FileSystemObject")
	

author=""
fname = (rsn.Fields.Item("n_fname").Value)
hname = (rsn.Fields.Item("n_fname").Value)
N_Title=(rsn.Fields.Item("n_title").Value)
n_content=(""&rsn.Fields.Item("n_content").Value)
n_date=(rsn.Fields.Item("n_date").Value)
fpath=(rsn.Fields.Item("n_fpath").Value)
mpic=(rsn.Fields.Item("n_mpic").Value)
rpic=(rsn.Fields.Item("n_rpic").Value)

if not(fso.FileExists(mm_template_path))  then

%>
<script language=javascript>
alert( "生成失败,模板文件不存在！"  );
location.href = "javascript:history.back()"
</script>
<%
else
set fso_line = fso.opentextfile(mm_template_path,1,True)
pencat=fso_line.readall
end if
pencat=replace(pencat,"t_title",n_title)
pencat=replace(pencat,"t_author",author)
pencat=replace(pencat,"t_content",n_content)
pencat=replace(pencat,"t_date",n_date)
pencat=replace(pencat,"t_name",hname)
if not fso.FolderExists(mmdd_tpath) then
fso.CreateFolder (mmdd_tpath)
end if
if not fso.FolderExists(mmdd_tspath) then
fso.CreateFolder (mmdd_tspath)
end if
if not fso.FolderExists(mmdd_fpath) then
'Response.write mmdd_fpath
fso.CreateFolder (mmdd_fpath)
end if
Set fout = fso.CreateTextFile(mmdd_path)
fout.WriteLine pencat
fout.close
set fso = nothing
Set fout = nothing
set fso_line = nothing
set n_content=nothing

	  %>
  <li class="lh"> <%= ((rsn.Fields.Item("t_dir").Value)&"/"&(rsn.Fields.Item("ts_dir").Value)&"/"&(rsn.Fields.Item("n_fpath").Value)&"/"&(rsn.Fields.Item("n_fname").Value)) %> <font color="#FF0000">被创建</font></li>
</ul>
</body>
</html>
<%
rsn.movenext
mcount=mcount+1
if rsn.eof then exit for
next
if err then
	err.clear()
	Response.write "<script>alert('生成错误,再试一次')</script>"
	Response.end
end if
response.write "<script>setTimeout('window.location=""?bid="&bid&"&sid="&sid&"&mcount="&mcount&"""',1000)</script>"
rsn.Close()
Set rsn = Nothing
set MM_conn_news_STRING=nothing
%>