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

<%'容错处理
function index_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]=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]=50"
rs_1.open(sql),cn,1,1
if not rs_1.eof and rs_1("FolderName")<>"" then
CasesContent_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]=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]=1"
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&"<li><a href='"&Search_FolderName&"/index.asp?q="&rs("name")&"' target='_blank' >"&rs("name")&"</a> | </li>"
rs.movenext
loop
else
web_HotKeywords=web_HotKeywords&""
end if
rs.close
set rs=nothing

'顶部导航
set rs=server.createobject("adodb.recordset")
sql="select [id],[url],[name] 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 i=1 then
web_TopMenu=web_TopMenu&"<li class='CurrentLi'><a href='"&rs("url")&"'><abbr>"&rs("name")&"</abbr><span>"&rs("name")&"</span></a></li> "
else

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><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><a href='"&rs("url")&"'><abbr>"&rs("name")&"</abbr><span>"&rs("name")&"</span></a></li> "
end if
rss.close
set rss=nothing

end if
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)



'首页顶部幻灯广告读取替换
set rs=server.createobject("adodb.recordset")
sql="select top 10 name,url,image,ADcode from web_ads  where [position]=36 and view_yes=1 order by [order]"
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
web_TopIMGAD=web_TopIMGAD&"<li _src=""url(/images/up_images/"&rs("image")&")"" style='"&BackAD&"'><a href='"&rs("url")&"' target='_blank'></a></li>"

rs.movenext
next
else
web_TopIMGAD=web_TopIMGAD&"无数据"
end if
rs.close
set rs=nothing

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



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

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


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

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



'企业介绍
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid],[image],[content],[description] from [category] where ClassType=5 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebAboutName=rs("name")
WebAboutFolderName=rs("folder")
WebAboutImage=rs("image")
WebAboutContent=left(ClearHtml(rs("content")),400)
WebAboutDes=left(ClearHtml(rs("description")),40)

select case rs("ppid")
case 1
ClassSQL="cid"
WebAboutFolder="/"&rs("folder") 
case 2
ClassSQL="pid"
set rs0=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs("pid")
rs0.open(sql),cn,1,1
if not rs0.eof then
WebAboutFolder="/"&rs0("folder")&"/"&rs("folder")
end if
rs0.close
set rs0=nothing
case 3
ClassSQL="ppid"
set rs0=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs("pid")
rs0.open(sql),cn,1,1
if not rs0.eof then
set rs00=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs0("pid")
rs00.open(sql),cn,1,1
if not rs00.eof then
WebAboutFolder="/"&rs00("folder")&"/"&rs0("folder")&"/"&rs("folder") 
end if
rs00.close
set rs00=nothing
end if
rs0.close
set rs0=nothing
end select
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$WebAboutName$",WebAboutName)
replace_code=replace(replace_code,"$WebAboutFolderName$",WebAboutFolderName)
replace_code=replace(replace_code,"$WebAboutFolder$",WebAboutFolder)
replace_code=replace(replace_code,"$WebAboutImage$",WebAboutImage)
replace_code=replace(replace_code,"$WebAboutContent$",WebAboutContent)
replace_code=replace(replace_code,"$WebAboutDes$",WebAboutDes)



'业务范围
set rs=server.createobject("adodb.recordset")
sql="select top 1  [folder],[id],[name],[description] from [category] where ClassType=5 and id<>"&ItemID&" and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebItemFolderName=rs("folder")
WebItemFolder="/"&rs("folder")
WebItemName=rs("name")
WebItemDes=rs("Description")
end if
rs.close 
set rs=nothing

set rs=server.createobject("adodb.recordset")
sql="select top 4 [name],[folder],[id],[description],[image] from [category] where pid="&ItemID&" and ppid=2 order by [order] "
rs.open(sql),cn,1,1
if not rs.eof then
for i=1 to rs.recordcount

WebItemList=WebItemList&"<li><div class='pic'><a href='"&WebItemFolder&"/"&rs("folder")&"/'><img src='/images/up_images/"&rs("image")&"' alt='"&rs("name")&"' width='285' height='214' class='PicAuto'></a></div>"
WebItemList=WebItemList&"<div class='title'><a href='"&WebItemFolder&"/"&rs("folder")&"/'>"&rs("name")&"</a></div>"
WebItemList=WebItemList&"<div class='intro'><a href='"&WebItemFolder&"/"&rs("folder")&"/'>"&rs("name")&"<p>"&left(rs("description"),40)&"...</p></a></div></li>"
			
rs.movenext
next
end if
rs.close 
set rs=nothing

replace_code=replace(replace_code,"$WebItemList$",WebItemList)
replace_code=replace(replace_code,"$WebItemName$",WebItemName)
replace_code=replace(replace_code,"$WebItemFolderName$",WebItemFolderName)
replace_code=replace(replace_code,"$WebItemFolder$",WebItemFolder)
replace_code=replace(replace_code,"$WebItemDes$",WebItemDes)



'新闻动态
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid],[description] from [category] where ClassType=1 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebNewNewsName=rs("name")
WebNewNewsDes=rs("description")
WebNewNewsFolderName=rs("folder")
select case rs("ppid")
case 1
ClassSQL="cid"
WebNewNewsFolder="/"&rs("folder") 
case 2
ClassSQL="pid"
set rs0=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs("pid")
rs0.open(sql),cn,1,1
if not rs0.eof then
WebNewNewsFolder="/"&rs0("folder")&"/"&rs("folder")
end if
rs0.close
set rs0=nothing
case 3
ClassSQL="ppid"
set rs0=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs("pid")
rs0.open(sql),cn,1,1
if not rs0.eof then
set rs00=server.createobject("adodb.recordset")
sql="select [name],[folder],[id],[pid],[ppid] from [category] where id="&rs0("pid")
rs00.open(sql),cn,1,1
if not rs00.eof then
WebNewNewsFolder="/"&rs00("folder")&"/"&rs0("folder")&"/"&rs("folder") 
end if
rs00.close
set rs00=nothing
end if
rs0.close
set rs0=nothing
end select
end if
rs.close
set rs=nothing

'list
set rsp=server.createobject("adodb.recordset")
sql="select top 9 [title],file_path,[time],[description] from [article] where ArticleType=1 and cid='"&ItemID&"'   and view_yes=1 order by [time] desc"
rsp.open(sql),cn,1,1
if not rsp.eof then
do while not rsp.eof 
rs_url=""
rs_url=ArticleContent_FolderName&"/"&rsp("file_path")

WebNewNewsList=WebNewNewsList&"<li><a href='"&rs_url&"' target='_blank'>"
WebNewNewsList=WebNewNewsList&"<p class='knowTime'><span>"&day(rsp("time"))&"</span>"&year(rsp("time"))&"-"&month(rsp("time"))&"</p><p class='knowTitle' >"&left(rsp("title"),18)&"<span>"&left(rsp("title"),20)&"...</span></p></a> </li>"

rsp.movenext
loop
end if 
rsp.close
set rsp=nothing

replace_code=replace(replace_code,"$WebNewNewsName$",WebNewNewsName)
replace_code=replace(replace_code,"$WebNewNewsDes$",WebNewNewsDes)
replace_code=replace(replace_code,"$WebNewNewsList$",WebNewNewsList)
replace_code=replace(replace_code,"$WebNewNewsFolder$",WebNewNewsFolder)
replace_code=replace(replace_code,"$WebNewNewsFolderName$",WebNewNewsFolderName)



'品牌产品
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid],Description from [category] where ClassType=2 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebProductName=rs("name")
WebProductDes=rs("Description")
WebProductFolderName=rs("folder")
WebProductFolder="/"&rs("folder")
end if
rs.close
set rs=nothing

set rsl=server.createobject("adodb.recordset")
sql="select top 6 [name],[folder],[id],[pid],[ppid] from [category] where pid="&ItemID&" 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>"
Block_LeftClassList=Block_LeftClassList&"<A href='"&WebProductFolder&"/"&rsl("Folder")&"'>"&rsl("name")&" </A> "
Block_LeftClassList=Block_LeftClassList&"</li> "
rsl.movenext
next
end if
rsl.close
set rsl=nothing

set rsp=server.createobject("adodb.recordset")
sql="select top 12 [title],file_path,[image],[description] from [article] where ArticleType=2 and cid='"&ItemID&"'  and view_yes=1 order by OrderCount,[time] desc"
rsp.open(sql),cn,1,1
if not rsp.eof then
do while not rsp.eof 
rs_url=""
rs_url=ProductContent_FolderName&"/"&rsp("file_path")

WebProductList=WebProductList&"<dl><a  href='"&rs_url&"' target='_blank'>"
WebProductList=WebProductList&"<dt><img src='/images/up_images/"&rsp("image")&"' alt='"&rsp("title")&"' width='170' height='170' class='PicAuto'></dt>"
WebProductList=WebProductList&"<dd >"&left(rsp("title"),14)&"</dd></a></dl> "

rsp.movenext
loop
end if 
rsp.close
set rsp=nothing

replace_code=replace(replace_code,"$Block_LeftClassList$",Block_LeftClassList)
replace_code=replace(replace_code,"$WebProductName$",WebProductName)
replace_code=replace(replace_code,"$WebProductFolderName$",WebProductFolderName)
replace_code=replace(replace_code,"$WebProductFolder$",WebProductFolder)
replace_code=replace(replace_code,"$WebProductList$",WebProductList)
replace_code=replace(replace_code,"$WebProductDes$",WebProductDes)



'精彩案例
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid],[description] from [category] where ClassType=3 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebCaseName=rs("name")
WebCaseFolderName=rs("folder")
WebCaseFolder="/"&rs("folder")
WebCaseDes=rs("description")
end if
rs.close
set rs=nothing

set rsp=server.createobject("adodb.recordset")
sql="select top 80 [title],file_path,[image] from [article] where ArticleType=3 and cid='"&ItemID&"' and view_yes=1  order by [OrderCount],[time] desc"
rsp.open(sql),cn,1,1
if not rsp.eof then
do while not rsp.eof 
rs_url=""
rs_url=CasesContent_FolderName&"/"&rsp("file_path")

WebCase_List=WebCase_List&"<DIV class='box'><A class='imgBorder'  href='"&rs_url&"' target='_blank' title='"&rsp("title")&"'><IMG alt='"&rsp("title")&"' src='/images/up_images/"&rsp("image")&"' ></a><p><A class='imgBorder'  href='"&rs_url&"' target='_blank' title='"&rsp("title")&"'>"&left(rsp("title"),12)&"</A></p> </DIV>"

rsp.movenext
loop
end if 
rsp.close
set rsp=nothing

replace_code=replace(replace_code,"$WebCase_List$",WebCase_List)
replace_code=replace(replace_code,"$WebCaseName$",WebCaseName)
replace_code=replace(replace_code,"$WebCaseFolderName$",WebCaseFolderName)
replace_code=replace(replace_code,"$WebCaseFolder$",WebCaseFolder)
replace_code=replace(replace_code,"$WebCaseDes$",WebCaseDes)



%>

<% '判断文件夹是否存在，否则创建
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
%>