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

<%'容错处理
function sitemap_to_html()
On Error Resume Next
%>

<%'读取模板内容
Set fso=Server.CreateObject("Scripting.FileSystemObject") 
Set htmlwrite=fso.OpenTextFile(Server.MapPath("/model/sitemap_model.html")) 
replace_code=htmlwrite.ReadAll() 
htmlwrite.close 
%>

<%'首页基本信息内容读取替换
set rs=server.createobject("adodb.recordset")
sql="select web_name,web_url,web_image,web_title,web_keywords,web_description,web_person,web_url,web_email,web_tel,web_copyright from web_settings"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
web_name=rs("web_name")
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_person=rs("web_person")
web_url=rs("web_url")
web_email=rs("web_email")
web_tel=rs("web_tel")
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$web_name$",web_name)
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_person$",web_person)
replace_code=replace(replace_code,"$web_url$",web_url)
replace_code=replace(replace_code,"$web_email$",web_email)
replace_code=replace(replace_code,"$web_tel$",web_tel)



'顶部导航列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select [number],[id] from web_menu_type order by [order]"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
web_menu=web_menu&""
set rs_menu=server.createobject("adodb.recordset")
sql="select top "&rs("number")&" [name],[url] from web_menu where [position]="&rs("id")&" order by [order] "
rs_menu.open(sql),cn,1,1
if not rs_menu.eof and not rs_menu.bof then
for i= 1 to rs_menu.recordcount
if i=1  or i=rs_menu.recordcount/2+1 then
web_menu=web_menu&"<li><a href='"&rs_menu("url")&"' title='"&rs_menu("name")&"' target='_self'>"&left(rs_menu("name"),4)&"</a></li>"
else
web_menu=web_menu&"<li><a href='"&rs_menu("url")&"' title='"&rs_menu("name")&"' target='_self'>"&left(rs_menu("name"),4)&"</a></li>"
end if
if i=rs_menu.recordcount/2 then
web_menu=web_menu&""
end if
rs_menu.movenext
next
else
web_menu=web_menu&"无数据"
end if
rs_menu.close
set rs_menu=nothing

web_menu=web_menu&""
rs.movenext
loop
else
web_menu=web_menu&"无数据"
end if
rs.close
set rs=nothing

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



'二层导航列表读取替换
set rs=server.createobject("adodb.recordset")
sql1="select top 12 name,folder from category where ppid=1 and id > 48 order by id asc"
rs.open(sql1),cn,1,1
if not rs.eof and not rs.bof then
web_menus=web_menus&""
do while not rs.eof 
web_menus=web_menus&"<li><a href='/"&rs("folder")&"/index.html' title='"&rs("name")&"' target='_self'>"&left(rs("name"),4)&"</a></li>"
rs.movenext
loop
web_menus=web_menus&""
else
web_menus=web_menus&"无数据"
end if
rs.close
set rs=nothing

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



'二级导航列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select top 12 [id],[name],[folder],[pid] from [category] where pid=36 and ppid=2 order by id"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
for i=1 to rs.recordcount

folder_name_0=rs("folder")
'ppid=2
set rs_1=server.createobject("adodb.recordset")
sql="select [folder] from [category] where [id]="&rs("pid")&" and ppid=1"
rs_1.open(sql),cn,1,1
if not rs_1.eof then

folder_name_1=rs_1("folder")

if folder_name_1<>"" and  folder_name_0<>"" then

Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&folder_name_0))=true then
folder_path="/"&folder_name_0
else
folder_path="/html/"&rs("folder")
end if

else
folder_path="/html/"&rs("folder")
end if

end if
rs_1.close
set rs_1=nothing

if i=1 then
web_menuss=web_menuss&"<li><a href='"&folder_path&"/index.html' title='"&rs("name")&"' target='_self'>"&rs("name")&"</a></li>"
else
web_menuss=web_menuss&"<li><a href='"&folder_path&"/index.html' title='"&rs("name")&"' target='_self'>"&rs("name")&"</a></li>"
end if
rs.movenext
next
else
web_menuss=web_menuss&"无数据"
end if 
rs.close
set rs=nothing

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



'站点推广①列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select top 5 [name],[url] from web_keywords where hot_yes=1 order by [time] asc"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
hotkeys_url=rs("url")
if rs("url")="" then
hotkeys_url=""
end if
web_hotsearch=web_hotsearch&"<a href='"&hotkeys_url&"' target='_blank' title='"&rs("name")&"'>"&left(rs("name"),6)&"</a>"
rs.movenext
loop
else
web_hotsearch=web_hotsearch&"无数据"
end if
rs.close
set rs=nothing

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



'站内公告列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select top 1 title,image,[url],memo from [web_special]  where index_push=1 and id=17 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
web_gonggao_list=web_gonggao_list&""
web_gonggao_list=web_gonggao_list&"<a href='"&rs("url")&"' title='"&rs("title")&"' target='_blank'><font color=#333333>"&left(rs("title"),27)&"</font></a>"
web_gonggao_list=web_gonggao_list&""
else
web_gonggao_list=web_gonggao_list&"无数据"
end if
rs.close
set rs=nothing

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



'站点推广②列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select top 20 [name],[url] from web_keywords where index_yes=1 order by [time] asc"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
hotkeys_url=rs("url")
if rs("url")="" then
hotkeys_url=""
end if
web_indexsearch=web_indexsearch&"<div><a href='"&hotkeys_url&"' target='_blank' title='"&rs("name")&"'><font color=#333333>"&left(rs("name"),15)&"</font></a></div>"
rs.movenext
loop
else
web_indexsearch=web_indexsearch&"无数据"
end if
rs.close
set rs=nothing

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



'栏目关键字列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select memo from web_models where id=25 order by time asc"
rs.open(sql),cn,1,1
if not rs.eof then
wb_keywords=wb_keywords&""
do while not rs.eof 
wb_keywords=wb_keywords&""&rs("memo")&""
rs.movenext
loop
wb_keywords=wb_keywords&""
else
wb_keywords=wb_keywords&"无数据"
end if
rs.close
set rs=nothing

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



'关于本站列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select type,type_en from web_models where type order by id asc"
rs.open(sql),cn,1,1
if not rs.eof then
web_about_list=web_about_list&""
do while not rs.eof 
web_about_list=web_about_list&"<li><a href='"&rs("type_en")&".html' target='_self' title='"&rs("type")&"'>"&left(rs("type"),4)&"</a></li>"
rs.movenext
loop
web_about_list=web_about_list&""
else
web_about_list=web_about_list&"无数据"
end if
rs.close
set rs=nothing

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



'栏目名称列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select type from web_models where id=32 order by time asc"
rs.open(sql),cn,1,1
if not rs.eof then
wb_name=wb_name&""
do while not rs.eof 
wb_name=wb_name&""&rs("type")&""
rs.movenext
loop
wb_name=wb_name&""
else
wb_name=wb_name&"无数据"
end if
rs.close
set rs=nothing

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



'栏目地址列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select type_en from web_models where id=32 order by time asc"
rs.open(sql),cn,1,1
if not rs.eof then
wb_url=wb_url&""
do while not rs.eof 
wb_url=wb_url&""&rs("type_en")&""
rs.movenext
loop
wb_url=wb_url&""
else
wb_url=wb_url&"无数据"
end if
rs.close
set rs=nothing

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



'栏目内容列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select content from web_models where id=32 order by time asc"
rs.open(sql),cn,1,1
if not rs.eof then
wb_web=wb_web&""
do while not rs.eof 
wb_web=wb_web&""&rs("content")&""
rs.movenext
loop
wb_web=wb_web&""
else
wb_web=wb_web&"无数据"
end if
rs.close
set rs=nothing

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



'招商专区列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select [name],[url],[memo] from web_gov where view_yes=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
web_zhaoshang_list=web_zhaoshang_list&""
do while not rs.eof 
web_zhaoshang_list=web_zhaoshang_list&"<li><a href='"&rs("url")&"' target='_blank' title='"&rs("name")&"'><font color='#"&rs("memo")&"'>"&left(rs("name"),20)&"</font></a></li>"
rs.movenext
loop
web_zhaoshang_list=web_zhaoshang_list&""
else
web_zhaoshang_list=web_zhaoshang_list&"无数据"
end if
rs.close
set rs=nothing

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



'友情链接列表读取替换
set rs=server.createobject("adodb.recordset")
sql="select [name],[url] from web_link where view_yes=1 order by [time] asc"
rs.open(sql),cn,1,1
if not rs.eof then
web_links_list=web_links_list&""
do while not rs.eof 
web_links_list=web_links_list&"<a href='"&rs("url")&"' target='_blank' title='"&rs("name")&"'>"&left(rs("name"),12)&"</a>"
rs.movenext
loop
web_links_list=web_links_list&""
else
web_links_list=web_links_list&"无数据"
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$web_links_list$",web_links_list)
%>

<%'生成HTML文件名,指定文件路径
filepath="/about/sitemap.html"
%>

<% '生成首页静态文件
Set fout = fso.CreateTextFile(Server.MapPath(filepath))
fout.WriteLine replace_code
fout.close
fso.close
set fso=nothing
end function
%>