多好客

好多优质的分享

ASP文章分页,将一篇过长的文章分页,生成静态页面

现在将他们生成静态页面没有什么问题,但是如何将它们按照某种规则,生成编号为0405-1.htm 0405-2.htm 0405-3.htm这样的静态文件呢?

asp分页生成html的程序脚本代码

这是asp分页列表生成静态页面得asp小程序脚本 

在ASP中使用FSO组件生成HTML页面

共有两个页面index.htm是首页.程序比较简单,主要是用了ASP里的文件操作对象。 
<!--index.htm-------------------------------------------------------------------------------> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
</head> 

<body> 
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0"> 
<tr> 
<td><form name="form1" method="post" action="send.asp"> 
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCFFFF"> 
<tr> 
<td height="20"><div align="center">发送消息</div></td> 
</tr> 
<tr> 
<td><div align="center"> 
<textarea name="msg" cols="100" rows="6"></textarea> 
</div></td> 
</tr> 
<tr> 
<td><div align="center"> 
<input type="submit" name="Submit" value="Submit"> 
<input type="reset" name="Submit2" value="Reset"> 
</div></td> 
</tr> 
</table> 
</form></td> 
</tr> 
</table> 
</body> 
</html> 
'//send.asp 

<% 
function chan_time(shijian)'转换日期时间函数 
s_year=year(shijian) 
if len(s_year)=2 then s_year="20"&s_year 
s_month=month(shijian) 
if s_month<10 then s_month="0"&s_month 
s_day=day(shijian) 
if s_day<10 then s_day="0"&s_day 
s_hour=hour(shijian) 
if s_hour<10 then s_hour="0"&s_hour 
s_minute=minute(shijian) 
if s_minute<10 then s_minute="0"&s_minute 
chan_time=s_year & s_month & s_day & s_hour & s_minute 
end function 

function chan_data(shijian) '转换日期时间函数 
s_year=year(shijian) 
if len(s_year)=2 then s_year="20"&s_year 
s_month=month(shijian) 
if s_month<10 then s_month="0"&s_month 
s_day=day(shijian) 
if s_day<10 then s_day="0"&s_day 
chan_data=s_year & s_month & s_day 
end function 

function chan_file(shijian)'转换日期时间函数 
s_month=month(shijian) 
if s_month<10 then s_month="0"&s_month 
s_day=day(shijian) 
if s_day<10 then s_day="0"&s_day 
s_hour=hour(shijian) 
if s_hour<10 then s_hour="0"&s_hour 
s_minute=minute(shijian) 
if s_minute<10 then s_minute="0"&s_minute 
s_ss=second(shijian) 
if s_ss<10 then s_ss="0"&s_ss 
chan_file = s_month & s_day & s_hour & s_minute & s_ss 
end function 
top="<html><head><title>news</title></head><body>" 
botom="</body></html>" 
msg=request.Form("msg") 
msg=replace(msg,vbcrlf,"") 
msg=replace(msg,chr(9),"") 
msg=replace(msg," "," ") 
msg=replace(msg,"\r\n","<br>") 
msg=replace(msg,"\n","<br>") 
msg=top&msg&botom 
Set fs=Server.CreateObject("Scripting.FileSystemObject") 
all_tree2=server.mappath("news")&"\"&chan_data(now) 
if (fs.FolderExists(all_tree2)) then'判断今天的文件夹是否存在 
else 
fs.CreateFolder(all_tree2) 
end if 
pass=chan_file(now) 
randomize '使用系统计时器来初始化乱数产生器 
pass=rnd(pass) 
pass=get_pass(pass) 
pass=left(pass,10) 

file1=pass 
files=file1&".txt" 
filez=all_tree2&"\"&files 

set ts = fs.createtextfile(filez,true) '写文件 
for z=1 to len(msg) 
write_now=mid(msg,z,1) 
ts.write(write_now) 
next 
' ts.writeline(all_msg) 
ts.close 
set ts=nothing '文件生成 

if err.number<>0 or err then%> 
<script language="javascript"> 
alert("不能完成") 
</script> 
<%else%> 
<script language="javascript"> 
alert("已完成") 
history.back(); 
</script> 
<%end if 
Set MyFile = fs.GetFile(filez) 
all_tree2=server.mappath("news")&"\"&chan_data(now) 
if (fs.FolderExists(all_tree2)) then 
else 
fs.CreateFolder(all_tree2) 
end if 
MyFile.name= left(MyFile.name,len(MyFile.name)-4)&".htm" 
set MyFile=nothing 
set fs=nothing 
set fdir=nothing 
function get_pass(pass) 

pass=cstr(pass) 
pass=replace(pass," ","") 
pass=replace(pass," ","") 
pass=replace(pass,"-","") 
pass=replace(pass," ","") 
pass=replace(pass,":","") 
pass=replace(pass,".","") 
pass=replace(pass,"+","") 
pass=replace(pass,"_","") 
pass=replace(pass,"<","") 
pass=replace(pass,">","") 
pass=replace(pass,"!","") 
pass=replace(pass,"@","") 
pass=replace(pass,"#","") 
pass=replace(pass,"$","") 
pass=replace(pass,"%","") 
pass=replace(pass,"^","") 
pass=replace(pass,"&","") 
pass=replace(pass,"*","") 
pass=replace(pass,"(","") 
pass=replace(pass,")","") 
pass=replace(pass,"=","") 
pass=replace(pass,"\","") 
pass=replace(pass,"/","") 
pass=replace(pass,"|","") 
get_pass=pass 

end function 

%> 


'// 

把send.asp和index.htm放到你的ASP目录下,然后再建一个news文件夹。打开浏览器,在地址栏里输入:http://你的机器名/你的ASP虚拟目录名/index.html输入文字,然后提交,OK!看看你的ASP目录里新建的news文件夹里是不是多了个新的文件夹,而且是以当前日期命名的。里面有你刚刚提交的文字,看看是不是生成了HTML文件。怎么样,你可以在此基础上做个简单的新闻发布系统。

ASP生成html的新方法

目前已经有很多生成html的新闻系统,但是都是用的模板,本函数实现把asp页面产生的html代码保存成为一个html文件,这样就没有必要改动原来的页面就可以轻松完成一个生成html的新闻系统了。^_^

Asp生成HTML方法大全

方法一:FSO

Set fs = CreateObject("Scripting.FileSystemObject")
NewFile=Server.MapPath("/asp/chap06/at/newfile.html")
'新建一文件/newfile.html,若该文件已存在,则覆盖它
Set a = fs.CreateTextFile(NewFile, True)
Response.Write"新文件已建立!"
a.close
File=Server.MapPath("newfile.html")
Set txt=fs.OpenTextFile(File,8,True) '打开成可以在结尾写入数据的文件
data1="这句话是使用WriteLine方法写入的哦!~~"
txt.WriteLine data1
data2="这句话是使用Write方法写入的哦!~~"
txt.Write data2
txt.Close

方法二:XMLHTTP

<%
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'把下面的地址替换成你的首页的文件地址,一定要用http://开头的绝对路径,不能写相对路径
xml.Open "GET", "http://www.phpup.com", False
xml.Send
BodyText=xml.ResponseBody
BodyText=BytesToBstr(BodyText,"gb2312")
Set xml = Nothing
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile(server.MapPath("aa.htm"), True)
MyFile.WriteLine(BodyText)
MyFile.Close

其他:

1

下面的例子是将、index.asp?id=1/index.asp?id=2/index.asp?id=3/这三个动态
页面,分别生成ndex1.htm,index2.htm,index3.htm存在根目录下面:


<%
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="

Windows系统环境变量大全(XP/Win7/Win8)

很多时候,不管我们在XP下还是在VistaWin7Win8下,不管我们是程序员还是普通用户,我们都可能会用到Windows系统环境变量。

asp cookies失效时间,session失效时间

默认cookies失效时间是直到关闭浏览器,cookies失效,也可以指定cookies时间。
 
Response.Cookies("user_name").Expires=Date+1 '指定cookie保存时间
 

javascript实现删除前弹出确认框

<div id="art_demo">删除确认对话框的JS代码,有好几种写法,有简单的,有兼容好的,下面分别说几种方法,可根据自己需要选用</div>

<div id="art_content">

txt=pencat("字符串")

写成方法或函数很简单,但现目前的问题是,你的代码本身就有错误的,
pencat = replace(pencat,""",abc)这段代码有误
 
function pencat(str)
str=replace(str,"<","<")
str = replace(str,">",">")
pencat=replace(str,"'",chr(34))
end function 

调用代码如下
txt=pencat("字符串")

asp获取服务器信息大全(包括客户端证书信息)

一.服务环境变量

Request.ServerVariables("Url")  
返回服务器地址  

Request.ServerVariables("Path_Info")  
客户端提供的路径信息  

Request.ServerVariables("Appl_Physical_Path")  
与应用程序元数据库路径相应的物理路径  

Request.ServerVariables("Path_Translated")  
通过由虚拟至物理的映射后得到的路径  

Request.ServerVariables("Script_Name")  
执行脚本的名称  

Request.ServerVariables("Query_String")  
查询字符串内容  

Request.ServerVariables("Http_Referer")  
请求的字符串内容  

Request.ServerVariables("Server_Port")  
接受请求的服务器端口号  

Request.ServerVariables("Remote_Addr")  
发出请求的远程主机的IP地址  

Request.ServerVariables("Remote_Host")  
发出请求的远程主机名称  

Request.ServerVariables("Local_Addr")  
返回接受请求的服务器地址  

Request.ServerVariables("Http_Host")  
返回服务器地址  

Request.ServerVariables("Server_Name")  
服务器的主机名、DNS地址或IP地址  

Request.ServerVariables("Request_Method")  
提出请求的方法比如GET、HEAD、POST等等  

Request.ServerVariables("Server_Port_Secure")  
如果接受请求的服务器端口为安全端口时,则为1,否则为0  

Request.ServerVariables("Server_Protocol")  
服务器使用的协议的名称和版本  

Request.ServerVariables("Server_Software")  
应答请求并运行网关的服务器软件的名称和版本  

Request.ServerVariables("All_Http")  
客户端发送的所有HTTP标头,前缀HTTP_  

Request.ServerVariables("All_Raw")  
客户端发送的所有HTTP标头,其结果和客户端发送时一样,没有前缀HTTP_  

Request.ServerVariables("Appl_MD_Path")  
应用程序的元数据库路径  

Request.ServerVariables("Content_Length")  
客户端发出内容的长度  

Request.ServerVariables("Https")  
如果请求穿过安全通道(SSL),则返回ON如果请求来自非安全通道,则返回OFF  

Request.ServerVariables("Instance_ID")  
IIS实例的ID号  

Request.ServerVariables("Instance_Meta_Path")  
响应请求的IIS实例的元数据库路径  

Request.ServerVariables("Http_Accept_Encoding")  
返回内容如:gzip,deflate  

Request.ServerVariables("Http_Accept_Language")  
返回内容如:en-us  

Request.ServerVariables("Http_Connection")  
返回内容:Keep-Alive  

Request.ServerVariables("Http_Cookie")  
返回内容如:nVisiT%  

Request.ServerVariables("Http_User_Agent")  
返回内容:Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.1;SV1)  

Request.ServerVariables("Https_Keysize")  
安全套接字层连接关键字的位数,如128  

Request.ServerVariables("Https_Secretkeysize")  
服务器验证私人关键字的位数如1024  

Request.ServerVariables("Https_Server_Issuer")  
服务器证书的发行者字段  

Request.ServerVariables("Https_Server_Subject")  
服务器证书的主题字段  

Request.ServerVariables("Auth_Password")  
当使用基本验证模式时,客户在密码对话框中输入的密码  

Request.ServerVariables("Auth_Type")  
是用户访问受保护的脚本时,服务器用於检验用户的验证方法  

Request.ServerVariables("Auth_User")  
代证的用户名  

Request.ServerVariables("Cert_Cookie")  
唯一的客户证书ID号  

Request.ServerVariables("Cert_Flag")  
客户证书标志,如有客户端证书,则bit0为0如果客户端证书验证无效,bit1被设置为1  

Request.ServerVariables("Cert_Issuer")  
用户证书中的发行者字段  

Request.ServerVariables("Cert_Keysize")  
安全套接字层连接关键字的位数,如128  

Request.ServerVariables("Cert_Secretkeysize")  
服务器验证私人关键字的位数如1024  

Request.ServerVariables("Cert_Serialnumber")  
客户证书的序列号字段  

Request.ServerVariables("Cert_Server_Issuer")  
服务器证书的发行者字段  

Request.ServerVariables("Cert_Server_Subject")  
服务器证书的主题字段  

Request.ServerVariables("Cert_Subject")  
客户端证书的主题字段  

Request.ServerVariables("Content_Type")  
客户发送的form内容或HTTPPUT的数据类型 

--------------------------------------------------------------------------------------

二.ASP获取客户端证书信息

1、环境要求
     服务器端IIS并配置安全站点。
2、读取数字证书(方法一)
数据集合:Request.ClientCertificate(key[SubField])
所有客户证书的信息的集合。对于Key,该集合具有如下的关键字:
Subject      证书持有者的主题,数据格式以英文逗号分隔。(不建议使用)
Issuer      证书的发行颁发者主题,数据格式以英文逗号分隔。(不建议使用)
VadidFrom      证书发行的日期,证书生效日期。
ValidUntil      该证书不再有效的时间。
SerialNumber      证书的序列号。
Certificate      包含整个证书内容的二进制流,使用ASN.1格式。
对于SubField,Subject和Issuer关键字可以具有如下的子域后缀:(比如:SubjectOU或IssuerL)
C      国家。      S      州(或省)。
O      公司或组织名称。      T      个人或公司的标题。
OU      组织单元。      GN      给定名称。
CN      用户的常规名称。      I      初始。
L      地区。           

当文件cervbs.inc(VBScript使用)或cerjavas.inc(Jscript使用)通过使用#i nclude导向包含在你的Active Server Page里时,下面两个标志可以使用:
ceCertPresent      指明客户证书是否存在,其值为TRUE或FALSE。
ceUnrecongnizedIssure      指明在该链表中的最后的证书的发行者是否未知,其值为TRUE或FALSE。
3、读取数字证书(方法二)
数据集合:Request.ServerVaribles(Server Environment Variable)
环境变量的集合,读取HTTP头。可以通过使用HTTP_前缀来读取任何头信息。比如,HTTP_USER_AGENT接受客户代理HTTP头(浏览器类型)。此外,可以使用下表所示的变量获得数字证书相关信息。
CERT_COOKIE      唯一的客户证书ID号。
CERT_FLAG      客户证书标志,如有客户端证书,则bit0为0。如果客户端证书验证无效,bit1被设置为1。
CERT_ISSUER      用户证书中的颁发者字段。
CERT_KEYSIZE      安全套接字层连接关键字的位数,如128。
CERT_SECRETKEYSIZE      服务器验证私人关键字的位数。如1024。
CERT_SERIALNUMBER      客户证书的序列号字段。
CERT_SUBJECT      客户端证书的主题字段。
CERT_SERVER_ISSUER      服务器证书的发行者字段
CERT_SERVER_SUBJECT      服务器证书的主题字段。
HTTPS      如果请求穿过安全通道(SSL),则返回ON。如果请求来自非安全通道,则返回OFF。
HTTPS_KEYSIZE      安全套接字层连接关键字的位数,如128。
HTTPS_SECRETKEYSIZE      服务器验证私人关键字的位数。如1024。
HTTPS_SERVER_ISSUER      服务器证书的发行者字段。
HTTPS_SERVER_SUBJECT      服务器证书的主题字段。

4、补充说明
2中提到的通过Subject和Issuer所获得的相关主题信息在包含中文的情况下是乱码;通过Request.ServerVaribles数据集合获得证书持有者的主题信息和证书颁发机构的主题信息没有任何问题。

 

asp的代码:

<%

Dim SerialNumber
Dim ValidFrom
Dim ValidUntil
Dim UniqueID
Dim Flags
Dim UserName
SerialNumber =Request.ClientCertificate("SerialNumber")
ValidFrom =Request.ClientCertificate("ValidFrom")
ValidUntil =Request.ClientCertificate("ValidUntil")
UniqueID = Request.ClientCertificate("Certificate")
Flags = Request.ClientCertificate("Flags")
UserName = Request.ClientCertificate("Subject")
//Response.Write "<p>证书用户:"& UserName &"</p>"
Response.Write "<p>证书序列号:"& SerialNumber &"</p>"
Response.Write "<p>有效期起始时间:"& ValidFrom &"</p>"
Response.Write "<p>有效期终止时间:"& ValidUntil &"</p>"
Response.Write "<p>Flags:"& Flags &"</p>"
//Response.BinaryWrite  UniqueID

%>

«1234»

免责声明:本站部分内容来自互联网收集,版权归原作者所有,如果侵犯了你的权益,请通知我们,我们会及时删除侵权内容,谢谢合作!

Copyright ©2015-2023 多好客 滇ICP备15001813号