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

<%'容错处理
function SiteMap_to_html()
On Error Resume Next
%>
<%
'首页基本信息内容读取替换
set rs=server.createobject("adodb.recordset")
sql="select web_name,web_url,web_image,web_title,web_keywords,web_contact,web_tel,web_TopHTML,web_BottomHTML,web_description,web_copyright,web_theme from web_settings"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
web_name=rs("web_name")
web_url=rs("web_url")
web_image=rs("web_image")
web_title=rs("web_title")
web_keywords=rs("web_keywords")
web_description=rs("web_description")
web_copyright=rs("web_copyright")
web_theme=rs("web_theme")
web_consult=rs("web_contact")
web_TopHTML=rs("web_TopHTML")
web_BottomHTML=rs("web_BottomHTML")
web_tel=rs("web_tel")
end if
rs.close
set rs=nothing
%>
<% '文件夹获取
'产品内容文件夹获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from web_Models_type where [id]=6"
rs_1.open(sql),cn,1,1
if not rs_1.eof and rs_1("FolderName")<>"" then
ProductContent_FolderName="/"&rs_1("FolderName")
end if
rs_1.close
set rs_1=nothing

'文章内容文件夹获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from web_Models_type where [id]=5"
rs_1.open(sql),cn,1,1
if not rs_1.eof and rs_1("FolderName")<>"" then
ArticleContent_FolderName="/"&rs_1("FolderName")
end if
rs_1.close
set rs_1=nothing

'搜索文件夹获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from web_Models_type where [id]=35"
rs_1.open(sql),cn,1,1
if not rs_1.eof and rs_1("FolderName")<>"" then
Search_FolderName="/"&rs_1("FolderName")
end if
rs_1.close
set rs_1=nothing
%>

<% '读取模板内容
'模板类型获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from web_Models_type where [id]=36"
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

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_keywords$",web_keywords)
replace_code=replace(replace_code,"$web_description$",web_description)
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,"$web_TopHTML$",web_TopHTML)
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)


'底部广告读取
Common_TxtBot=""
set rs=server.createobject("adodb.recordset")
sql="select top 1 [id],ADtype,[ADcode] from web_ads  where [position]=41 and view_yes=1 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof then
if rs("ADtype")=4 then
Common_TxtBot=Common_TxtBot&rs("ADcode")
else
Common_TxtBot=Common_TxtBot&"<script src='/ADs/"&rs("id")&".js' type='text/javascript'></script>"
end if 
else
Common_TxtBot=Common_TxtBot&""
end if
rs.close
set rs=nothing

'底部导航
web_BottomMenu=""
set rs=server.createobject("adodb.recordset")
sql="select [name],[url],[id] from web_menu_type where BottomNav=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
for i=1 to rs.recordcount

web_BottomMenu=web_BottomMenu&"<div class='box_240px_left'><div class='post'><h2><a href='"&rs("url")&"'>"&rs("name")&"</a> </h2> "
set rss=server.createobject("adodb.recordset")
sql="select [name],[url] 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_BottomMenu=web_BottomMenu&"<ul>"
do while not rss.eof
web_BottomMenu=web_BottomMenu&"<li><a href='"&rss("url")&"'>"&rss("name")&"</a></li> "
rss.movenext
loop
rss.close
set rss=nothing
web_BottomMenu=web_BottomMenu&"</ul> "
end if
web_BottomMenu=web_BottomMenu&"</div></div> "
rs.movenext
next
end if
rs.close
set rs=nothing

'友情链接
web_link=""
set rs=server.createobject("adodb.recordset")
sql="select  [name],[url],[image],follow_yes from [web_link] where view_yes=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
do while not rs.eof
if rs("follow_yes")=1 then
NoFollow="rel='nofollow'"
else
NoFollow=""
end if 
web_link=web_link&"<a href='"&rs("url")&"' target='_blank' "&NoFollow&">"&rs("name")&"</a>"
rs.movenext
loop
else
web_link=web_link&"暂无链接。"
end if
rs.close
set rs=nothing

'热门关键词
web_HotKeywords=""
set rs=server.createobject("adodb.recordset")
sql="select top 5 [name] from [web_keywords] where hot_yes=1 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof then
do while not rs.eof
web_HotKeywords=web_HotKeywords&"<a href='"&Search_FolderName&"/index.asp?q="&rs("name")&"' target='_blank' >"&rs("name")&"</a>"
rs.movenext
loop
else
web_HotKeywords=web_HotKeywords&""
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")=Model_FolderName&"/" 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

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)


'顶部广告读取
set rs=server.createobject("adodb.recordset")
sql="select top 10 [id],ADtype,[ADcode],[image],[url] from web_ads  where [position]=35 and ClassID=0 and view_yes=1 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof then
for i=1 to rs.recordcount
if rs("adcode")<>"" then
BackAD="background:"&rs("ADcode")&" center 0 no-repeat;"
else
BackAD="background:#FFF center 0 no-repeat;"
end if
Inner_BannerTop=Inner_BannerTop&"<li _src=""url(/images/up_images/"&rs("image")&")"" style='"&BackAD&"'><a href='"&rs("url")&"' target='_blank'></a></li>"

rs.movenext
next
else
Inner_BannerTop=Inner_BannerTop&""
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$Inner_BannerTop$",Inner_BannerTop)


'最新资讯
RelateArticleList=""
set rs=server.createobject("adodb.recordset")
sql="select top 15 title,file_path,time from [article]  where view_yes=1  and ArticleType=1 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
for i=1 to rs.recordcount
rs_url=""
rs_url=ArticleContent_FolderName&"/"&rs("file_path")

RelateArticleList=RelateArticleList&"<li><a href='"&rs_url&"' target='_blank' title='"&rs("title")&"'>"&left(rs("title"),17)&"</a></li>"
rs.movenext
next
else
RelateArticleList=RelateArticleList&"暂无信息。"
end if
rs.close
set rs=nothing

'最新产品
RelateProductList=""
set rs=server.createobject("adodb.recordset")
sql="select top 15 title,file_path,time from [article]  where view_yes=1  and ArticleType=2 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
for i=1 to rs.recordcount
rs_url=""
rs_url=ProductContent_FolderName&"/"&rs("file_path")

RelateProductList=RelateProductList&"<li><a href='"&rs_url&"' target='_blank' title='"&rs("title")&"'>"&left(rs("title"),17)&"</a></li>"
rs.movenext
next
else
RelateProductList=RelateProductList&"暂无信息。"
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$RelateArticleList$",RelateArticleList)
replace_code=replace(replace_code,"$RelateProductList$",RelateProductList)


'网站地图
SiteMap_List=""
set rsl=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where ppid=1 order by [order] "
rsl.open(sql),cn,1,1
if not rsl.eof then
do while not rsl.eof
SiteMap_List=SiteMap_List&"<li><A href='/"&rsl("Folder")&"'>"&rsl("name")&"</A> "

set rs=server.createobject("adodb.recordset")
sql="select [id],[name],[folder] from [category] where ppid=2 and pid="&rsl("id")&" "
rs.open(sql),cn,1,1
if not rs.eof then
SiteMap_List=SiteMap_List&"<ul>"
do while not rs.eof 
SiteMap_List=SiteMap_List&"<li><a href='/"&rsl("Folder")&"/"&rs("folder")&"/' >"&rs("name")&"</a>"
set rs3=server.createobject("adodb.recordset")
sql="select  [name],[folder] from [category] where ppid=3 and pid="&rs("id")&" "
rs3.open(sql),cn,1,1
if not rs3.eof then
do while not rs3.eof 
SiteMap_List=SiteMap_List&"&nbsp;&nbsp;&nbsp;&nbsp;<a href='/"&rsl("Folder")&"/"&rs("folder")&"/"&rs3("folder")&"/' >"&rs3("name")&"</a>"
rs3.movenext
loop
end if
rs3.close
set rs3=nothing
SiteMap_List=SiteMap_List&"</li> "
rs.movenext
loop
SiteMap_List=SiteMap_List&"</ul>"
end if
rs.close
set rs=nothing
SiteMap_List=SiteMap_List&"</li> "
rsl.movenext
loop
end if
rsl.close
set rsl=nothing

replace_code=replace(replace_code,"$SiteMap_List$",SiteMap_List)






%>

<% '判断文件夹是否存在，否则创建
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&"/index.html"
%>

<% '读取模板
'******************************************
'功能：生成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
%>