<!-- #include file="../access.asp" -->
<!-- #include file="../html_clear.asp" -->
<!-- #include file="../web_config.asp" -->

<%'容错处理
function Feed_to_html(a_id)
On Error Resume Next
%>
<!--common use start-->
<% 
'模板类型获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from web_Models_type where [id]=8"
rs_1.open(sql),cn,1,1
if not rs_1.eof then
Model_FileName=rs_1("FileName")
if rs_1("FolderName")<>"" then
Model_FolderName="/"&rs_1("FolderName")
end if
end if
rs_1.close
set rs_1=nothing
%>
<!--common use end-->


<% ' 文章内容读取替换
set rs=server.createobject("adodb.recordset")
sql="select * from [web_info] where view_yes=1 and [id]="&a_id&""
rs.open(sql),cn,1,1
if not rs.eof then
article_title=rs("title")
ArticleContent=rs("content")
'article_keywords=rs("keywords")
'article_description=rs("description")
article_keywords=rs("title")
article_description=Left(rs("content"),100)
article_time=Year(rs("time"))&"年"&month(rs("time"))&"月"&day(rs("time"))&"日"
Article_FilePath=rs("file_path")
Article_PetName=Left(rs("PetName"),1)&"**"
Article_PetID=rs("PetID")

'Mobile Url
PetMobileUrl="/"&web_Folder&FeedContent_FolderName&"/"&rs("file_path")

If rs("recontent")<>"" Then
Article_ReContent=rs("recontent")
Article_Time2=Year(rs("edit_time"))&"年"&month(rs("edit_time"))&"月"&day(rs("edit_time"))&"日"
Article_FeedStatus="<div class='Sta01'>处理完毕</div>"
Else
Article_ReContent=""
Article_Time2=""
Article_FeedStatus="<div class='Sta02'>等待处理</div>"
End if

'您现在的位置读取替换
set rs_0=server.createobject("adodb.recordset")
sql="select [id],[pid],[ppid],[name],[folder] from [category] where [id]="&rs("cid")&" and ppid=1"
rs_0.open(sql),cn,1,1
folder_name=rs_0("folder")
CategoryName=rs_0("name")
ClassName1=rs_0("name")
ClassFolder1=rs_0("folder")
ClassID1=rs_0("id")
folder_path=MainClass_FolderName&"/"&folder_name&"/"
category_position1="<a href='"&folder_path&"'>"&rs_0("name")&"</a>"
category_position=category_position1
rs_0.close
Set rs_0=Nothing

if rs("pid")<>"" then
set rs_1=server.createobject("adodb.recordset")
sql="select [id],[pid],[ppid],[name],[folder] from [category] where [id]="&rs("pid")&" and ppid=2"
rs_1.open(sql),cn,1,1
folder_name_1=rs_1("folder")
CategoryName=rs_1("name")
folder_path=MainClass_FolderName&"/"&folder_name&"/"&folder_name_1&"/"
category_position2=" > <a href='"&folder_path&"'>"&rs_1("name")&"</a>"
category_position=category_position1&category_position2
rs_1.close
Set rs_1=Nothing
end If

if rs("ppid")<>"" then
set rs_2=server.createobject("adodb.recordset")
sql="select [id],[pid],[ppid],[name],[folder] from [category] where [id]="&rs("ppid")&" and ppid=3"
rs_2.open(sql),cn,1,1
folder_name_2=rs_2("folder")
CategoryName=rs_2("name")
folder_path=MainClass_FolderName&"/"&folder_name&"/"&folder_name_1&"/"&folder_name_2&"/"
category_position3=" > <a href='"&folder_path&"'>"&rs_2("name")&"</a>"
category_position=category_position1&category_position2&category_position3
rs_1.close
Set rs_1=Nothing
end if

end if 
rs.close
set rs=nothing

'侧边栏当前栏目列表
Block_LeftClassList=""
set rsl=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where pid="&ClassID1&" order by [order] "
rsl.open(sql),cn,1,1
if not rsl.eof then
for i=1 to rsl.recordcount
Block_LeftClassList=Block_LeftClassList&"<li class=''>"
'if rsl("id")=ClassID then
'Block_LeftClassList=Block_LeftClassList&"<p class='fuMenu current'><A href='/"&ClassFolder1&"/"&rsl("Folder")&"/'>"&rsl("name")&"</A></p>"
'else
Block_LeftClassList=Block_LeftClassList&"<p class='fuMenu'><A href='/"&ClassFolder1&"/"&rsl("Folder")&"/'>"&rsl("name")&"</A></p>"
'end if

set rs=server.createobject("adodb.recordset")
sql="select  [name],[folder] from [category] where ppid=3 and pid="&rsl("id")&" order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
Block_LeftClassList=Block_LeftClassList&"<img class='xiala' src='/images/xiala.png' />"
Block_LeftClassList=Block_LeftClassList&"<div class='div1'>"
do while not rs.eof 
Block_LeftClassList=Block_LeftClassList&"<p class='zcd'><a href='/"&ClassFolder1&"/"&rsl("Folder")&"/"&rs("folder")&"/' >"&rs("name")&"</a></p>"
rs.movenext
loop
Block_LeftClassList=Block_LeftClassList&"</div>"
end if
rs.close
set rs=nothing
Block_LeftClassList=Block_LeftClassList&"</li>"
rsl.movenext
next
else
Block_LeftClassList=Block_LeftClassList&""
end if
Block_LeftClassList=Block_LeftClassList&"</ul>"
rsl.close
set rsl=nothing

'顶部广告读取
set rs=server.createobject("adodb.recordset")
sql="select top 1 [id],ADtype,[ADcode],[image],[url] from web_ads  where [position]=35 and view_yes=1  order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof then
If rs("ADCode")<>"" Then
Inner_BannerTop=rs("ADCode")
Else
Inner_BannerTop="<script src='/CubeX/Pet"&rs("id")&".js' type='text/javascript'></script>"
End If
end if
rs.close
set rs=nothing

'顶部导航
web_TopMenu=""
set rs=server.createobject("adodb.recordset")
sql="select name,id,url,enname from web_menu_type where TopNav=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
web_TopMenu=web_TopMenu&"<ul id='sddm'>"
for i=1 to rs.recordcount
if rs("url")="/"&ClassFolder1&"/" then
CurrentClass="CurrentLi"
else
CurrentClass=""
end if

set rss=server.createobject("adodb.recordset")
sql="select url,name from web_menu where view_yes=1 and [position]="&rs("id")&" order by [order]"
rss.open(sql),cn,1,1
if not rss.eof then
web_TopMenu=web_TopMenu&"<li class='"&CurrentClass&"'><a href='"&rs("url")&"' onmouseover=mopen('m"&i&"') onmouseout='mclosetime()'><abbr>"&rs("name")&"</abbr><span>"&rs("name")&"</span></a> "
web_TopMenu=web_TopMenu&"<div id='m"&i&"' onmouseover='mcancelclosetime()' onmouseout='mclosetime()'>"
do while not rss.eof
web_TopMenu=web_TopMenu&"<a href='"&rss("url")&"'>"&rss("name")&"</a> "
rss.movenext
loop
web_TopMenu=web_TopMenu&"</div></li> "
else
web_TopMenu=web_TopMenu&"<li  class='"&CurrentClass&"'><a href='"&rs("url")&"'><abbr>"&rs("name")&"</abbr><span>"&rs("name")&"</span></a></li> "
end if
rss.close
set rss=nothing

rs.movenext
next
web_TopMenu=web_TopMenu&"</ul>"
end if
rs.close
set rs=nothing

%>


<%
'读取模板内容
TemplatePath="/templates/"&web_theme&"/"&Model_FileName
replace_code=ReadFromUTF(TemplatePath,"utf-8") 
%>
<%
replace_code=replace(replace_code,"$web_name$",web_name)
replace_code=replace(replace_code,"$web_url$",web_url)
replace_code=replace(replace_code,"$web_image$",web_image)
replace_code=replace(replace_code,"$web_title$",web_title)
replace_code=replace(replace_code,"$web_copyright$",web_copyright)
replace_code=replace(replace_code,"$web_theme$",web_theme)
replace_code=replace(replace_code,"$web_consult$",web_consult)
replace_code=replace(replace_code,"$PageNO$",PageNO)
replace_code=replace(replace_code,"$web_BottomHTML$",web_BottomHTML)
replace_code=replace(replace_code,"$web_tel$",web_tel)
replace_code=replace(replace_code,"$search_FolderName$",search_FolderName)

replace_code=replace(replace_code,"$article_comment$",article_comment)
replace_code=replace(replace_code,"$article_kw$",article_kw)
replace_code=replace(replace_code,"$article_refer$",article_refer)
replace_code=replace(replace_code,"$category_position$",category_position)
replace_code=replace(replace_code,"$CategoryName$",CategoryName)
replace_code=replace(replace_code,"$Block_LeftClassList$",Block_LeftClassList)
replace_code=replace(replace_code,"$ClassName1$",ClassName1)
replace_code=replace(replace_code,"$ClassFolder1$",ClassFolder1)

replace_code=replace(replace_code,"$article_id$",a_id) 
replace_code=replace(replace_code,"$article_title$",article_title)
replace_code=replace(replace_code,"$article_keywords$",article_keywords)
replace_code=replace(replace_code,"$article_description$",article_description)
replace_code=replace(replace_code,"$article_time$",article_time)
replace_code=replace(replace_code,"$article_content$",ArticleContent)
replace_code=replace(replace_code,"$Article_PetName$",Article_PetName)
replace_code=replace(replace_code,"$Article_PetID$",Article_PetID)
replace_code=replace(replace_code,"$Article_ReContent$",Article_ReContent)
replace_code=replace(replace_code,"$Article_Time2$",Article_Time2)
replace_code=replace(replace_code,"$Article_FeedStatus$",Article_FeedStatus)

replace_code=replace(replace_code,"$web_TopMenu$",web_TopMenu)
replace_code=replace(replace_code,"$web_BottomMenu$",web_BottomMenu)
replace_code=replace(replace_code,"$Common_TxtBot$",Common_TxtBot)
replace_code=replace(replace_code,"$web_link$",web_link)
replace_code=replace(replace_code,"$web_HotKeywords$",web_HotKeywords)
replace_code=replace(replace_code,"$web_TopSecMenu$",web_TopSecMenu)
replace_code=replace(replace_code,"$RelateArticleList$",RelateArticleList)
replace_code=replace(replace_code,"$RelateProductList$",RelateProductList)
replace_code=replace(replace_code,"$Inner_BannerTop$",Inner_BannerTop)
replace_code=replace(replace_code,"$PetMobileUrl$",PetMobileUrl)


%>
<% '判断文件夹是否存在，否则创建
Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath(Model_FolderName))=false Then
NewFolderDir=Model_FolderName
call CreateFolderB(NewFolderDir)
end if
%>
<%'声明HTML文件名,指定文件路径
filepath=Model_FolderName&"/"&Article_FilePath
%>
<% '生成静态文件
 '读取模板
'******************************************
'功能：生成UTF-8文件
'******************************************
mappath =filepath
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText=replace_code
.SaveToFile server.mappath(mappath),2
.Close
End With
Set objStream = Nothing
%>

<%
end function
%>