|
|
adoresimon
发表于 2009-12-29 14:06:45
|
显示全部楼层
生静态功能程序:
<%
server.ScriptTimeout=9999
'=================================================
'过程名:createhtml
'作 用:生成HTML文件
'参 数:无
'=================================================
sub createhtml(url,add)
set http=Server.createobject("Microsoft.XMLHTTP")
rUrl=JoinChar(url)
rUrl = rUrl & "rNum=" & Int((9999) * Rnd(Now())+1)
Http.open "GET",rUrl,false
Http.send()
deleteFiles(add)
set objStream = Server.CreateObject("ADODB.Stream")
objStream.type = 1
objStream.open
objstream.write http.responseBody
objstream.saveToFile server.mappath(add),2
end sub
Function deleteFiles(filespec)
''//功能:文件删除
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If isfile(filespec) = true Then
on error resume next
fso.deleteFile(server.MapPath(filespec))
End if
end function
'文件是否存在
function isfile(files)
set objfso=server.createobject("scripting.filesystemobject")
if objfso.fileexists(server.mappath(files)) then
isfile=True
else
isfile=False
end if
set objfso=nothing
end function
'=================================================
'过程名:createhtmlpage
'作 用:生成有条件的HTML文件,如:分页,大类、其它参数
'参 数:isiclass----是否自定大类,是为1;否为0
' classname----大类的表的名称
' classidname----大类的字段名称
' bigclass----大类值(手动赋值)
' ps----排序
' page----页数
' hlname----转成HTML的文件名
' aspname----默认要转换的文件名,即不带参数的文件名
'说 明: 生成的文件名是[defaultname_bigclass_ps_page],例:product_0_1_1.html,参数值=0,即无。
'=================================================
sub createhtmlpage(isiclass,classname,classidname,bigclass,ps,page,hlname,aspname,zname)
if isiclass=0 and ps=0 and page=0 then
fname=hlname & htmlPostfix
url=siteUrl&"/"&aspname&".asp"
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
elseif isiclass=1 and ps=0 and page=0 then
if bigclass=0 and classname<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
strSQL="select * from " & classname
rs.open strSQL,conn,1,1
do until rs.eof
fname=hlname & "_" & rs(classidname) &"_0_0"&htmlPostfix
url=siteUrl&"/"&aspname&".asp?"&classidname&"="&rs(classidname)
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
rs.movenext
loop
rs.close
set rs=nothing
elseif bigclass<>0 and classname="" then
fname=hlname & "_" & bigclass &"_0_0"&htmlPostfix
url=siteUrl&"/"&aspname&".asp?bigclass="&bigclass
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
else
Response.Write "<script>alert('["&zname&"]参数设置有误,请修改!')</script>"
response.end
end if
elseif isiclass=0 and ps<>0 and page=0 then
for i=1 to ps
fname=hlname & "_0_" & i & "_0"&htmlPostfix
url=siteUrl&"/"&aspname&".asp?ps="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
elseif isiclass=0 and ps=0 and page<>0 then
for i=1 to page
fname=hlname & "_0_0_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
elseif isiclass=1 and ps<>0 and page=0 then
if bigclass=0 and classname<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
strSQL="select * from " & classname
rs.open strSQL,conn,1,1
do until rs.eof
for i=1 to ps
fname=hlname & "_"& rs(classidname) & "_" & i & "_0"&htmlPostfix
url=siteUrl&"/"&aspname&".asp?"&classidname&"="&rs(classidname)&"&ps="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
rs.movenext
loop
rs.close
set rs=nothing
elseif bigclass<>0 and classname="" then
for i=1 to ps
fname=hlname & "_"& bigclass & "_" & i & "_0"&htmlPostfix
url=siteUrl&"/"&aspname&".asp?bigclass="&bigclass&"&ps="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
else
Response.Write "<script>alert('["&zname&"]参数设置有误,请修改!')</script>"
response.end
end if
elseif isiclass=1 and ps=0 and page<>0 then
if bigclass=0 and classname<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
strSQL="select * from " & classname
rs.open strSQL,conn,1,1
do until rs.eof
for i=1 to page
fname=hlname & "_"& rs(classidname) & "_0_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?"&classidname&"="&rs(classidname)&"&page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
rs.movenext
loop
rs.close
set rs=nothing
elseif bigclass<>0 and classname="" then
for i=1 to page
fname=hlname & "_"& bigclass & "_0_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?bigclass="&bigclass&"&page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
else
Response.Write "<script>alert('["&zname&"]参数设置有误,请修改!')</script>"
response.end
end if
elseif isiclass=0 and ps<>0 and page<>0 then
for a=1 to ps
for i=1 to page
fname=hlname & "_0_"& a & "_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?ps="&a&"&page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
next
elseif isiclass=1 and ps<>0 and page<>0 then
if bigclass=0 and classname<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
strSQL="select * from " & classname
rs.open strSQL,conn,1,1
do until rs.eof
for a=1 to ps
for i=1 to page
fname=hlname & "_" & rs(classidname) & "_"& a & "_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?"&classidname&"="&rs(classidname)&"&ps="&a&"&page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
next
rs.movenext
loop
rs.close
set rs=nothing
elseif bigclass<>0 and classname="" then
for a=1 to ps
for i=1 to page
fname=hlname & "_" & bigclass & "_"& a & "_" & i & htmlPostfix
url=siteUrl&"/"&aspname&".asp?bigclass="&bigclass&"&ps="&a&"&page="&i
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
next
next
else
Response.Write "<script>alert('["&zname&"]参数设置有误,请修改!')</script>"
response.end
end if
end if
end sub
'=================================================
'过程名:createhtmlid
'作 用:生成有条件的HTML文件,针对带ID参数的。
'参 数:bigclass----大类
' ps----排序
' page----页数
' hlname----转成HTML的文件名
' aspname----默认要转换的文件名,即不带参数的文件名
'说 明: 生成的文件名是[defaultname_bigclass_ps_page],例:product_0_1_1.html,参数值=0,即无。
'=================================================
sub createhtmlid(strSQL,idname,hlname,aspname,zname)
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open strSQL,conn,1,1
do until rs.eof
fname=hlname & "_" & rs(idname) & htmlPostfix
url=siteUrl&"/"&aspname&".asp?" & idname & "="&rs(idname)
add="../../"&fname
call createhtml(url,add)
response.write "Generated ["&zname&"--"&fname&"], <a href='"&siteUrl&"/"&fname&"' target='_blank'>Click to view</a><br>"
rs.movenext
loop
rs.close
set rs=nothing
end sub
'=================================================
'过程名:createhtml_newsClass
'作 用:生成文章类的HTML文件,包括新闻公告,帮助中心,常见问题等。。
'参 数:strID----类别ID号
' zname----中文名称
' hlname----转成HTML的文件名
' aspname----默认要转换的文件名,即不带参数的文件名
'=================================================
sub createhtml_newsClass(strID,strpage,hlname,aspname,zname)
call createhtmlpage(0,"","",0,0,0,hlname,aspname,zname)
strSQLTemp="select * from news where newsclassID="&strID
pagetotal=intPage(intTotal(strSQLTemp),strpage)
call createhtmlpage(0,"","",0,0,pagetotal,hlname,aspname,zname)
end sub
'=================================================
'过程名:createhtml_product
'作 用:生成产品列表的HTML文件(非产品显示页)
'参 数:classflag--分类数字,0为不分,1为最新上架,2为推荐商品,3为特价商品
'=================================================
sub createhtml_product(classflag)
strDefaultSQL="SELECT product.ID, product.Name, product.price, product.classflag, product.newflag, product.hotflag, product.stock, productclass.Name, product.commendflag, product.flag, product.addDate, product_photo.path, product.Code, product.viewCount, productclass.scoreflag, product.productclassID FROM ((product INNER JOIN product_photo ON product.ID = product_photo.productID) INNER JOIN photo ON product_photo.photoID = photo.ID) INNER JOIN productclass ON product.productclassID = productclass.ID"
strDefaultWhere=" WHERE (((product.flag)=1) AND ((productclass.scoreflag)<>1) AND ((productclass.flag)<>1) AND ((photo.flag)<>1) AND ((photo.indexflag)=1) And ((product.classflag)<>0))"
strSQLTemp=strDefaultSQL&strDefaultWhere
pagetotal=intPage(intTotal(strSQLTemp),11)
if classflag=0 then
call createhtmlpage(0,"","",0,0,0,"product","hl_product","Product Center")
call createhtmlpage(0,"","",0,0,pagetotal,"product","hl_product","Product Center")
call createhtmlpage(0,"","",0,5,pagetotal,"product","hl_product","Product Center")
else
select case classflag
case 1
call createhtmlpage(1,"","",1,5,pagetotal,"product","hl_product","New In")
case 2
call createhtmlpage(1,"","",2,5,pagetotal,"product","hl_product","Special Offer")
case 3
call createhtmlpage(1,"","",3,5,pagetotal,"product","hl_product","Special Offer")
end select
end if
end sub
'=================================================
'过程名:createhtml_productclass
'作 用:生成产品类别列表的HTML文件
'参 数:无
'=================================================
sub createhtml_productclass()
call createhtmlpage(0,"","",0,0,0,"productclass","hl_productclass","Product Category")
strDefaultSQL="SELECT product.ID, product.Name, product.price, product.newflag, product.hotflag, product.stock, productclass.Name, product.commendflag, product.flag, product.addDate, product_photo.path, product.Code, product.viewCount, productclass.scoreflag, product.productclassID FROM ((product INNER JOIN product_photo ON product.ID = product_photo.productID) INNER JOIN photo ON product_photo.photoID = photo.ID) INNER JOIN productclass ON product.productclassID = productclass.ID"
strDefaultWhere=" WHERE (((product.flag)=1) AND ((productclass.flag)<>1) AND ((photo.flag)<>1) AND ((photo.indexflag)=1))"
strOrder=" ORDER BY product.addDate DESC"
strSQLTemp=strDefaultSQL&strDefaultWhere&strOrder
pagetotal=intPage(intTotal(strSQLTemp),40)
call createhtmlpage(0,"","",0,0,pagetotal,"productclass","hl_productclass","Product Category")
Set rsclass= Server.CreateObject("ADODB.Recordset")
strSQL="select * from productclass where flag=0"
rsclass.open strSQL,conn,1,1
do until rsclass.eof
strSQLTemp="select * from product where productclassID="&rsclass("ID")&" and flag=1"
pagetotal=intPage(intTotal(strSQLTemp),40)
call createhtmlpage(1,"productclass where flag=0","ID",0,0,pagetotal,"productclass","hl_productclass","Product Category")
rsclass.movenext
loop
rsclass.close
set rsclass=nothing
end sub
'=================================================
'函数名:intTotal
'作 用:显示产品总数
'参 数:strSQL----要查询的数据表SQL语句
'=================================================
function intTotal(strSQL)
dim sqlTotal
dim rsTotal
sqlTotal=strSQL
Set rsTotal= Server.CreateObject("ADODB.Recordset")
rsTotal.open sqlTotal,conn,1,1
if rsTotal.eof and rsTotal.bof then
intTotal=0
else
intTotal=rsTotal.recordcount
end if
rsTotal.close
set rsTotal=nothing
end function
'=================================================
'函数名:intPage
'作 用:显示产品页数
'参 数:intTotal----产品总数
' maxperpage----每页显示产品数
'=================================================
function intPage(intTotal,maxperpage)
if intTotal mod maxperpage=0 then
intPage= intTotal \ maxperpage
else
intPage= intTotal \ maxperpage+1
end if
end function
%> |
|