Dim IdList, ProgramStart, TotalNum, FinishedNum,CreateNum
IdList = FLib.SafeSql(Request("IdList"))
ProgramStart = Time()
TotalNum = 0
FinishedNum = 0
CreateNum = 0
If IdList = "" Then
FLib.Alert "参数有误", "BACK", 0
Response.End
End If
Dim Sql, Rs, TempContent,file_url
Sql="select cm_article.*,cm_class.Nvc_name as classname,cm_class.id as classid,cm_template.Nvc_path,cm_template.Nvc_name as temname,cm_article_group.I_flag from cm_article inner join cm_class on cm_article.I_class_id=cm_class.id inner join cm_template on cm_class.I_class_templateid=cm_template.id left join cm_article_group on cm_article.I_group_id=cm_article_group.id where cm_article.id in ("&IdList&")"
dim templateid,Rs1,Sql1,teamid_list
teamid_list = "0,"
Set Rs = Db.ExeCute(Sql)
Dim flag_1
While Not Rs.Eof
If isnull(Rs("I_flag")) or Rs("I_flag")="" Then
flag_1 ="0"
Else
flag_1 = Rs("I_flag")
End If
if cint(Rs("I_checked"))=1 then '生成审核过的文章
If cstr(Rs("I_group_id")) ="0" or cstr(flag_1) = "0" Then '文章不属于组或组内没有文章
TempContent = Cr.ReadTemplate(Cfg.Template_file&Rs("Nvc_path"))
file_url=CreateRes (Rs, TempContent, Rs("id"))
Db.execute("update cm_article set Nvc_visit_Url='"&file_url&"',I_created=1 where id="&Rs("id"))
Else
If instr(teamid_list,Rs("I_group_id")&",") = 0 Then
CreateRes_team Rs("I_group_id"),Rs("id")
teamid_list = teamid_list &Rs("I_group_id")&","
End If
End If
FinishedNum = FinishedNum+1
end if
TotalNum = TotalNum +1
Rs.MoveNext
Wend
Rs.close
Function CreateRes(Rs,byref TempContent,id)
dim Nvc_nametag1
if TempContent="" or not isnumeric(id) then
FLib.Alert "参数错误!","BACK",0
response.end
end if
Nvc_nametag1 = server.HTMLEncode(Rs("Nvc_name"))
if Rs("Nvc_nametag")<>"" and not isnull(Rs("Nvc_nametag")) then
Nvc_nametag1=replace(Rs("Nvc_nametag"),"[title]",Nvc_nametag1)
end if
dim class_folder,date_folder,file_name,month1,day1,temphour,tempMinute,class_folder1
TempContent = replace(TempContent,"<!--snailcity(title)-->",server.HTMLEncode(Rs("Nvc_name")))
TempContent = replace(TempContent,"<!--snailcity(title1)-->",Nvc_nametag1)
if Rs("D_uptime")="" or isnull(RS("D_uptime")) then
TempContent = replace(TempContent,"<!--snailcity(date)-->",Rs("Createtime"))
else
TempContent = replace(TempContent,"<!--snailcity(date)-->",RS("D_uptime"))
end if
if Rs("Nvc_author")="" or isnull(RS("Nvc_author")) then
TempContent = replace(TempContent,"<!--snailcity(author)-->","嘀嗒")
else
TempContent = replace(TempContent,"<!--snailcity(author)-->",RS("Nvc_author"))
end If
If Rs("Nvc_path") = "template3.htm" Then
TempContent = replace(TempContent,"<!--snailcity(class_title)-->",""&server.HTMLEncode(Rs("classname"))&"")
Else
TempContent = replace(TempContent,"<!--snailcity(class_title)-->","<a href=""/article/class.asp?id="&Rs("classid")&""">"&server.HTMLEncode(Rs("classname"))&"</a>")
End If
TempContent = replace(TempContent,"<!--snailcity(content)-->",Rs("Nt_content"))
TempContent = replace(TempContent,"<!--snailcity(classid)-->",Rs("classid"))
TempContent = replace(TempContent,"<!--snailcity(id)-->",Rs("id"))
if instr(Rs("temname"),"新闻") >0 then
class_folder="news"
else
if instr(Rs("temname"),"产品") >0 then
class_folder="product"
else
if instr(Rs("temname"),"知识") >0 then
class_folder="lore"
else
class_folder="other"
end if
end if
end if
if cint(month(now())) <10 then
month1 = "0"&month(now())
else
month1 = month(now())
end if
if cint(day(now())) <10 then
day1 = "0"&day(now())
else
day1 = day(now())
end if
temphour=Hour(now)
tempMinute=Minute(now)
class_folder1 = server.MapPath(Cfg.Create_file&class_folder&"/"&year(now)&month1&day1)
if Rs("Nvc_visit_Url") <>"" and not isnull(Rs("Nvc_visit_Url")) then
file_name = server.MapPath( Rs("Nvc_visit_Url"))
else
file_name = server.MapPath(Cfg.Create_file&class_folder&"/"&year(now)&month1&day1&"/"&temphour&tempMinute&Rs("id")&".htm")
end if
FLib.CreateFolder(class_folder1)
Cr.Write_file TempContent,file_name
TempContent =""
if Rs("Nvc_visit_Url") <>"" and not isnull(Rs("Nvc_visit_Url")) then
CreateRes = Rs("Nvc_visit_Url")
else
CreateRes=Cfg.Create_file&class_folder&"/"&year(now)&month1&day1&"/"&temphour&tempMinute&Rs("id")&".htm"
end if
End Function
Function CreateRes_team(teamid,id)
if teamid="" or not isnumeric(teamid) or id="" Then Exit Function
Dim team_Rs,TempContent,file_url
Set team_Rs = Db.CreateRs()
team_Rs.Open "select cm_article.I_checked,cm_article.id,cm_article.I_created,cm_article.Nvc_name,cm_article.Nvc_nametag,cm_article.Nvc_visit_Url,cm_article.Nt_content,cm_article.Nvc_author,cm_article.D_uptime,cm_article.Createtime,cm_class.Nvc_name as classname,cm_class.id as classid,cm_template.Nvc_path,cm_template.Nvc_name as temname from cm_article inner join cm_class on cm_article.I_class_id=cm_class.id inner join cm_template on cm_class.I_class_templateid=cm_template.id where cm_article.I_group_id="&teamid&" And cm_article.I_deleted=0 And cm_article.I_checked=1 order by I_page",Db.conn,3,3
dim file_url_list,file_id_list,file_a_i
file_a_i =0
DO While Not team_Rs.eof
If cint(team_Rs("I_checked")) =1 Then
TempContent = Cr.ReadTemplate(Cfg.Template_file&team_Rs(12))
file_url=CreateRes (team_Rs, TempContent, team_Rs(1)) Db.execute("update cm_article set Nvc_visit_Url='"&file_url&"',I_created=1 where id="&team_Rs("id")) '加了这条就不行了
End If
team_Rs.MoveNext
Loop
team_Rs.Close
Set team_Rs = nothing
Set team_Rs = Db.CreateRs()
team_Rs.Open "select Nvc_visit_Url,id,Nvc_file_Url from cm_article Where I_deleted=0 and I_checked=1 and I_created=1 And Nvc_visit_url<>'' And I_group_id="&teamid&" And I_checked=1 order by I_page",Db.conn,3,3
Dim page_str,page_i,page_all,P_url,N_url
page_str =""
P_url =""
N_url =""
page_i =1
DO While Not team_Rs.eof
If team_Rs(2)&"a" <>"a" Then
page_str = page_str &" <a href="""&team_Rs(2)&""" class=""ahu"" >["&page_i&"]</a> "
Else
page_str = page_str &" <a href="""&team_Rs(0)&""" class=""ahu"">["&page_i&"]</a> "
End If
If page_i mod 15 =0 Then page_str= page_str & "<br>"
page_i=page_i+1
team_Rs.MoveNext
Loop
'team_Rs.MoveFirst
team_Rs.Close
Set team_Rs = nothing
Set team_Rs = Db.CreateRs()
team_Rs.Open "select Nvc_visit_Url,id,Nvc_file_Url from cm_article Where I_deleted=0 and I_checked=1 and I_created=1 And Nvc_visit_url<>'' And I_group_id="&teamid&" and I_checked=1 order by I_page",Db.conn,3,1
page_all = page_i
page_i =1
DO While Not team_Rs.eof
If page_i>1 Then
team_Rs.movePrevious
If team_Rs(2)&"a" <>"a" Then
P_url = team_Rs(2)
Else
P_url = team_Rs(0)
End If
team_Rs.MoveNext
End If
If page_i < page_all Then
team_Rs.MoveNext
If Not team_Rs.eof Then
If team_Rs(2)&"a" <>"a" Then
N_url = team_Rs(2)
Else
N_url = team_Rs(0)
End If
Else
N_url = ""
End If
team_Rs.movePrevious
End If
If team_Rs(2) = "" or isnull(team_Rs(2)) Then
Cr.Write_page team_Rs(0),page_str,page_i,P_url,N_url
End If
page_i=page_i+1
team_Rs.MoveNext
Loop
team_Rs.Close
Set team_Rs = nothing