📄 generatepage.asp
字号:
<%@ Language=VBScript %>
<%
public sub subMsg(str)
Response.Clear ()
Response.Write ("<font size=5><b>系统信息</b></font><hr color='red'>")
Response.Write ("<font size=2><b>"+ str +"</b></font>")
Response.Write ("<br><b><a href='javascript:window.close()' style='text-decoration=none'>关闭</a></b>")
Response.Write ("<hr color='red'>")
end sub
public function sAnalysis(arr,htm,cate)
dim adiv,sContent
adiv=split(arr,"|")
'if ubound(adiv)<>5 then exit function
sContent="<DIV id="+adiv(0)+" style='position:absolute;left:"+adiv(1)+";top="+adiv(2)+";width:"+adiv(3)+";height:"+adiv(4)+"'>"
sContent=sContent+htm
sContent=sContent+"</DIV>"
if cate=0 then
response.Write(sContent)
exit function
else
sAnalysis=sContent
end if
end function
public function fnGen(ofso,sfilename,scontent)
dim ots
if not isobject(ofso) then
fnGen=false
exit function
end if
if ofso.FileExists(sfilename) then
set ots=ofso.OpenTextFile (sfilename,8,false)
ots.writeline(scontent)
ots.close()
set ots=nothing
else
fnGen=false
exit function
end if
fnGen=true
end function
public function fnGetFilename(strSrc)
sfull=strSrc
if sfull="" or instr(1,sfull,".")=0 then
fnGetFilename=false
else
dim pos
do until instr(1,sfull,"/")=0
pos=instr(1,sfull,"/")
sfull=right(sfull,len(sfull)-pos)
loop
fnGetFilename=sfull
end if
end function
public function fnGetSrc(fulltag)
dim spos
spos=instr(fulltag,"src")
if spos<>0 then
endpos=instr(spos+5,fulltag," ")
fnGetSrc=mid(fulltag,spos+5,endpos-spos-6)
else
fnGetSrc=false
end if
end function
public function fnGetTag(str,tagname)
dim pos,endpos
str=lcase(str)
pos=instr(str,"<"+tagname)
if pos<>0 then
endpos=instr(pos,str,">")
fnGetTag=mid(str,pos,endpos-pos+1)
else
fnGetTag=false
end if
end function
public function fnReplaceImgSrc(html)
if html="" then
fnReplaceImgSrc=html
else
dim tag,src,name
tag=fnGetTag(html,"img")
if tag=true then
src=fnGetSrc(tag)
name=fnGetFilename(src)
fnReplaceImgSrc=replace(html,src,"images/"+name)
else
fnReplaceImgSrc=html
end if
end if
end function
dim sPos,shtml,i,aPos,aHtml,shead,stitle,serverpath,webpath,filename,tmp
'接收网页文件信息
sPos=Request.Form ("sys_divPosition")
shtml=Request.Form ("sys_divHTML")
stitle=Request.Form ("sys_title")
filename=Request.Form ("sys_filename")
shead="<HTML><HEAD><TITLE>"+ stitle +"</TITLE>"+ Request.Form ("sys_head") +"</HEAD>"
'创建文件夹及文件
defaultpath="UserWeb"
webpath=server.MapPath(".")+"/"+defaultpath
fn=webpath+"\"+filename
set fso=server.CreateObject ("Scripting.FileSystemObject")
if not fso.FolderExists (webpath) then
fso.CreateFolder (webpath)
end if
if not fso.FileExists (fn) then
set webfile=fso.CreateTextFile (fn,true)
webfile.writeline(shead) '生成网页文件头
webfile.close()
set webfile=nothing
'生成网页文件正文内容
if instr(sPos,"||")<>0 then
aPos=split(sPos,"||")
aHtml=split(shtml,"||")
for i=0 to ubound(aPos)
aHtml(i)=fnReplaceImgSrc(aHtml(i))
tmp=sAnalysis(aPos(i),aHtml(i),1)
if not fnGen(fso,fn,tmp) then
Response.Write ("网页文件正文生成失败!")
exit for
end if
next
else
shtml=fnReplaceImgSrc(shtml)
tmp=sAnalysis(sPos,shtml,1)
if not fnGen(fso,fn,tmp) then
Response.Write ("网页文件正文生成失败!")
end if
end if
'结束生成网页文件
call fnGen(fso,fn,"</BODY></HTML>")
set fso=nothing
%>
<script>
alert("祝贺您!网页文件已生成,请检查所需文件是否完整上传")
if(confirm("是否现在浏览网页?")){
window.location .href ="<% =defaultpath%>"+"/"+"<% =filename %>";
}
else{
window.opener =null;
window.close ();
}
</script>
<%
else
call subMsg("文件已存在,请后改变文件名后重试")
Response.End ()
end if
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -