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

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

<% '读取模板内容
'模板类型获取
set rs_1=server.createobject("adodb.recordset")
sql="select FileName,FolderName from mobile_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/MobileTemplet/"&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)

'底部导航
web_BottomMenu=""
set rs=server.createobject("adodb.recordset")
sql="select [name],[url],[image] from mobile_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&"<li><a href="""&rs("url")&""">"
web_BottomMenu=web_BottomMenu&"<img src='/images/up_images/"&rs("image")&"' alt='"&rs("name")&"'><label>"&rs("name")&"</label></a> </li>"

rs.movenext
next
end if
rs.close
set rs=nothing

'顶部导航
web_TopMenu=""
set rs=server.createobject("adodb.recordset")
sql="select [url],[name] from mobile_web_menu_type where TopNav=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
for i=1 to rs.recordcount
if i=1 or (i-1) mod 4=0 then
web_TopMenu=web_TopMenu&"<li> "
end if
web_TopMenu=web_TopMenu&"<a href='"&rs("url")&"'>"&rs("name")&"</a> "

if i mod 4 =0 or i = rs.recordcount then
web_TopMenu=web_TopMenu&"</li> "
end if

rs.movenext
next
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,"$web_OtherMenu$",web_OtherMenu)



'中部广告读取
Index_BannerTop=""
set rs=server.createobject("adodb.recordset")
sql="select top 1 [id],[ADcode] from mobile_web_ads  where [position]=1 and view_yes=1 order by [time] desc"
rs.open(sql),cn,1,1
if not rs.eof Then

If rs("ADCode")<>"" Then
Index_BannerTop=rs("ADCode")
Else
Index_BannerTop="<script src='/CubeX/PetM"&rs("id")&".js' type='text/javascript'></script>"
End if
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  [name],[folder],[id],[pid],[ppid],[image],[content] 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")),62)

select case rs("ppid")
case 1
ClassSQL="cid"
WebAboutFolder="/"&web_Folder&"/"&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="/"&web_Folder&"/"&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="/"&web_Folder&"/"&rs00("folder")&"/"&rs0("folder")&"/"&rs("folder") 
end if
rs00.close
set rs00=nothing
end if
rs0.close
set rs0=nothing
end select

WebAboutImage="<a href='"&WebAboutFolder&"'><img src='/images/up_images/"&rs("image")&"' alt='"&WebAboutName&"' width='100%'></a>"

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)



'新闻动态
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid] 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")
WebNewNewsFolderName=rs("folder")
select case rs("ppid")
case 1
ClassSQL="cid"
WebNewNewsFolder="/"&web_Folder&"/"&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="/"&web_Folder&"/"&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="/"&web_Folder&"/"&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
'content

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

WebNewNewsList=WebNewNewsList&"<li><div class='DivList'><table class='MBlockTable' width='100%' border='0' cellspacing='0' cellpadding='0'>"
set rsp=server.createobject("adodb.recordset")
sql="select top 10 [title],file_path,[time],[url] from [article] where ArticleType=1 and cid='"&ItemID&"' and pid='"&rs("id")&"' 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&"<tr><td width='80%'><div class='NList'>· <a href='"&rs_url&"' target='_blank' title='"&rsp("title")&"'>"&left(rsp("title"),30)&"</a></div></td>"
WebNewNewsList=WebNewNewsList&"<td width='20%'><span>"&month(rsp("time"))&"月"&day(rsp("time"))&"日</span></td></tr>"
rsp.movenext
loop
end if 
rsp.close
set rsp=nothing

WebNewNewsList=WebNewNewsList&"</table><div class='clearfix'></div></div></li>"
rs.movenext
next
end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$WebNewNewsTitles$",WebNewNewsTitles)
replace_code=replace(replace_code,"$WebNewNewsList$",WebNewNewsList)
replace_code=replace(replace_code,"$WebNewNewsFolder$",WebNewNewsFolder)



'首页顶部幻灯广告读取替换
set rsp=server.createobject("adodb.recordset")
sql="select top 10 [title],file_path,[image],[time] from [article] where ArticleType=1 and cid='"&ItemID&"' and [image]<>'' and view_yes=1 order by [time] desc"
rsp.open(sql),cn,1,1
if not rsp.eof then
for ixx=1 to rsp.recordcount
rs_url=""
rs_url=ArticleContent_FolderName&"/"&rsp("file_path")

web_TopIMGAD=web_TopIMGAD&"<li><a href='"&rs_url&"' target='_blank'><img src='/images/up_images/"&rsp("image")&"' alt='"&rsp("title")&"'></a><p class='caption'>"&rsp("title")&"</p></li>"

rsp.movenext
next

end if 
rsp.close
set rsp=nothing

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



'通知公告
set rs=server.createobject("adodb.recordset")
sql="select top 1  [name],[folder],[id],[pid],[ppid] from [category] where id<>"&ItemID&" and ClassType=1 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebNewNews2Name=rs("name")
WebNewNews2FolderName=rs("folder")
select case rs("ppid")
case 1
ClassSQL="cid"
WebNewNews2Folder="/"&web_Folder&"/"&rs("folder") 
case 2
ClassSQL="pid"
set rs0=server.createobject("adodb.recordset")
sql="select [folder] from [category] where id="&rs("pid")
rs0.open(sql),cn,1,1
if not rs0.eof then
WebNewNews2Folder="/"&web_Folder&"/"&rs0("folder")&"/"&rs("folder")
end if
rs0.close
set rs0=nothing
case 3
ClassSQL="ppid"
set rs0=server.createobject("adodb.recordset")
sql="select [folder],[pid] 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 [folder] from [category] where id="&rs0("pid")
rs00.open(sql),cn,1,1
if not rs00.eof then
WebNewNews2Folder="/"&web_Folder&"/"&rs00("folder")&"/"&rs0("folder")&"/"&rs("folder") 
end if
rs00.close
set rs00=nothing
end if
rs0.close
set rs0=nothing
end select

'List
WebNewNews2List=WebNewNews2List&"<div class='DivList'><table class='MBlockTable' width='100%' border='0' cellspacing='0' cellpadding='0'>"
set rsp=server.createobject("adodb.recordset")
sql="select top 5 [title],file_path,[time] from [article] where ArticleType=1 and "&ClassSQL&"='"&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")
WebNewNews2List=WebNewNews2List&"<tr><td width='80%'><div class='NList'>· <a href='"&rs_url&"' target='_blank' title='"&rsp("title")&"'>"&left(rsp("title"),30)&"</a></div></td>"
WebNewNews2List=WebNewNews2List&"<td width='20%'><span>"&month(rsp("time"))&"月"&day(rsp("time"))&"日</span></td></tr>"
rsp.movenext
loop
end if 
rsp.close
set rsp=nothing

WebNewNews2List=WebNewNews2List&"</table><div class='clearfix'></div></div></li>"

end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$WebNewNews2Name$",WebNewNews2Name)
replace_code=replace(replace_code,"$WebNewNews2List$",WebNewNews2List)
replace_code=replace(replace_code,"$WebNewNews2Folder$",WebNewNews2Folder)



'信息公开 416
set rs=server.createobject("adodb.recordset")
sql="select top 1  [folder],[id],[name],[Description] from [category] where id=416"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebItemFolderName=rs("folder")
WebItemFolder="/"&web_Folder&"/"&rs("folder")
WebItemName=rs("name")
WebItemDes=rs("Description")
'List
set rsl=server.createobject("adodb.recordset")
sql="select top 6 [name],[folder],[image] from [category] where pid="&ItemID&" and  ppid=2 order by [order] "
rsl.open(sql),cn,1,1
if not rsl.eof then
for i=1 to rsl.recordcount

WebItemList=WebItemList&"<li class='ILi_"&i&"'><a href='"&WebItemFolder&"/"&rsl("folder")&"'><img src='/images/up_images/"&rsl("image")&"' alt='"&rsl("name")&"'><span>"&rsl("name")&"</span></a></li>"

rsl.movenext
next
end if
rsl.close 
set rsl=nothing

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] from [category] where ClassType=4 and ppid=1 order by [order]"
rs.open(sql),cn,1,1
if not rs.eof then
ItemID=rs("id")
WebFeedName=rs("name")
WebFeedFolderName=rs("folder")
WebFeedFolder="/"&web_Folder&"/"&rs("folder")

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

WebFeedClassList=WebFeedClassList&"<li class='FLi_"&i&"'><a href='"&WebFeedFolder&"/"&rsl("folder")&"'><span>"&rsl("name")&"</span></a></li>"

rsl.movenext
next
end if
rsl.close 
set rsl=nothing

'List
set rsp=server.createobject("adodb.recordset")
sql="select top 6 [title],file_path,[PetID],[PetName],[ReContent],[time] from [web_info] where  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=FeedContent_FolderName&"/"&rsp("file_path")

If rsp("ReContent")<>"" Then
FeedStatus="<div class='Sta01'>处理完毕</div>"
Else
FeedStatus="<div class='Sta02'>等待处理</div>"
End if
WebFeedList=WebFeedList&"<tr>"
WebFeedList=WebFeedList&"<td>"&Left(rsp("PetName"),1)&"**</td>"
WebFeedList=WebFeedList&"<td><div class='FList'><a href='"&rs_url&"' target='_blank' title='"&rsp("title")&"'>"&left(rsp("title"),25)&"</a></div></td>"
WebFeedList=WebFeedList&"<td>"&FeedStatus&"</td></tr>"

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

end if
rs.close
set rs=nothing

replace_code=replace(replace_code,"$WebFeedClassList$",WebFeedClassList)
replace_code=replace(replace_code,"$WebFeedList$",WebFeedList)
replace_code=replace(replace_code,"$WebFeedName$",WebFeedName)
replace_code=replace(replace_code,"$WebFeedFolderName$",WebFeedFolderName)
replace_code=replace(replace_code,"$WebFeedFolder$",WebFeedFolder)



%>

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