ASP

推荐列表 站点导航

当前位置:首页 > 脚本编程 > ASP >

asp仿php的一些函数分享

来源:互联网  作者:网友投稿  发布时间:2021-01-10 18:34
asp仿php的一些函数分享,主要是方便先学习php后学习asp的朋友。...


'过程:输出字符串[代替Response.Write] 

Sub echo(Str) 
response.Write(Str) 
End Sub 

'函数:获取表单[代替Request.Form] 

Function reqf(Str) 
reqf = Request.Form(Str) 
End Function 

'过程:结束页面并输出字符串 

Sub die(Str) 
response.Write(Str) 
response.End() 
End Sub 

'函数:将ASP文件运行结果返回为字串 

Function ob_get_contents(Path) 
Dim tmp, a, b, t, matches, m 
Dim Str 
Str = file_iread(Path) 
tmp = "dim htm : htm = """""&vbCrLf 
a = 1 
b = InStr(a, Str, "<%") + 2 
While b > a + 1 
t = Mid(Str, a, b - a -2) 
t = Replace(t, vbCrLf, "{::vbcrlf}") 
t = Replace(t, vbCr, "{::vbcr}") 
t = Replace(t, """", """""") 
tmp = tmp & "htm = htm & """ & t & """" & vbCrLf 
a = InStr(b, Str, "%\>") + 2 
tmp = tmp & str_replace("^\s*=", Mid(Str, b, a - b -2), "htm = htm & ") & vbCrLf 
b = InStr(a, Str, "<%") + 2 
Wend 
t = Mid(Str, a) 
t = Replace(t, vbCrLf, "{::vbcrlf}") 
t = Replace(t, vbCr, "{::vbcr}") 
t = Replace(t, """", """""") 
tmp = tmp & "htm = htm & """ & t & """" & vbCrLf 
tmp = Replace(tmp, "response.write", "htm = htm & ", 1, -1, 1) 
tmp = Replace(tmp, "echo", "htm = htm & ", 1, -1, 1) 
'execute(tmp) 
executeglobal(tmp) 
htm = Replace(htm, "{::vbcrlf}", vbCrLf) 
htm = Replace(htm, "{::vbcr}", vbCr) 
ob_get_contents = htm 
End Function 

'过程:动态包含文件 

Sub include(Path) 
echo ob_get_contents(Path) 
End Sub 

'函数:base64加密 

Function base64encode(byval Str) 
If IsNull(Str) Then Exit Function 
Dim base64 
Set base64 = New base64_class 
Str = base64.encode(Str) 
Set base64 = Nothing 
base64encode = Str 
End Function 

'函数:base64解密 

Function base64decode(byval Str) 
If IsNull(Str) Then Exit Function 
Dim base64 
Set base64 = New base64_class 
Str = base64.decode(Str) 
Set base64 = Nothing 
base64decode = Str 
End Function 

'函数:URL加密 

Function urlencode(byval Str) 
If IsNull(Str) Then Exit Function 
Str = server.URLEncode(Str) 
urlencode = Str 
End Function 

'函数:Escape加密 

Function escape(byval Str) 
If IsNull(Str) Then Exit Function 
Dim i, c, a, tmp 
tmp = "" 
For i = 1 To Len(Str) 
c = Mid(Str, i, 1) 
a = ascw(c) 
If (a>= 48 And a<= 57) Or (a>= 65 And a<= 90) Or (a>= 97 And a<= 122) Then 
tmp = tmp & c 
ElseIf InStr("@*_+-./", c) > 0 Then 
tmp = tmp & c 
ElseIf a>0 And a<16 Then 
tmp = tmp & "%0" & Hex(a) 
ElseIf a>= 16 And a<256 Then 
tmp = tmp & "%" & Hex(a) 
Else 
tmp = tmp & "%u" & Hex(a) 
End If 
Next 
escape = tmp 
End Function 

'函数:Escape解密 

Function unescape(byval Str) 
If IsNull(Str) Then Exit Function 
Dim i, c, tmp 
tmp = "" 
For i = 1 To Len(Str) 
c = Mid(Str, i, 1) 
If Mid(Str, i, 2) = "%u" And i<= Len(Str) -5 Then 
If IsNumeric("&H" & Mid(Str, i + 2, 4)) Then 
tmp = tmp & chrw(CInt("&H" & Mid(Str, i + 2, 4))) 
i = i + 5 
Else 
tmp = tmp & c 
End If 
ElseIf c = "%" And i<= Len(Str) -2 Then 
If IsNumeric("&H" & Mid(Str, i + 1, 2)) Then 
tmp = tmp & chrw(CInt("&H" & Mid(Str, i + 1, 2))) 
i = i + 2 
Else 
tmp = tmp & c 
End If 
Else 
tmp = tmp & c 
End If 
Next 
unescape = tmp 
End Function

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/asp/12313.shtml

最新文章
所有我们手工回收一下就 所有我们手工回收一下就

时间:2021-01-18

 最近网站改版正好发现原 最近网站改版正好发现原

时间:2021-01-17

现在完全支持ACCESS 现在完全支持ACCESS

时间:2021-01-17

出现错误的时候 出现错误的时候

时间:2021-01-13

ASP常见错误详解及解决方 ASP常见错误详解及解决方

时间:2021-01-05

查看ASP详细错误提示信息 查看ASP详细错误提示信息

时间:2021-01-05

4款傻瓜型的ASP服务器软件 4款傻瓜型的ASP服务器软件

时间:2020-12-23

ASP 数字分页效果代码 ASP 数字分页效果代码

时间:2020-12-23

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

asp仿php的一些函数分享

2021-01-10 编辑:网友投稿


'过程:输出字符串[代替Response.Write] 

Sub echo(Str) 
response.Write(Str) 
End Sub 

'函数:获取表单[代替Request.Form] 

Function reqf(Str) 
reqf = Request.Form(Str) 
End Function 

'过程:结束页面并输出字符串 

Sub die(Str) 
response.Write(Str) 
response.End() 
End Sub 

'函数:将ASP文件运行结果返回为字串 

Function ob_get_contents(Path) 
Dim tmp, a, b, t, matches, m 
Dim Str 
Str = file_iread(Path) 
tmp = "dim htm : htm = """""&vbCrLf 
a = 1 
b = InStr(a, Str, "<%") + 2 
While b > a + 1 
t = Mid(Str, a, b - a -2) 
t = Replace(t, vbCrLf, "{::vbcrlf}") 
t = Replace(t, vbCr, "{::vbcr}") 
t = Replace(t, """", """""") 
tmp = tmp & "htm = htm & """ & t & """" & vbCrLf 
a = InStr(b, Str, "%\>") + 2 
tmp = tmp & str_replace("^\s*=", Mid(Str, b, a - b -2), "htm = htm & ") & vbCrLf 
b = InStr(a, Str, "<%") + 2 
Wend 
t = Mid(Str, a) 
t = Replace(t, vbCrLf, "{::vbcrlf}") 
t = Replace(t, vbCr, "{::vbcr}") 
t = Replace(t, """", """""") 
tmp = tmp & "htm = htm & """ & t & """" & vbCrLf 
tmp = Replace(tmp, "response.write", "htm = htm & ", 1, -1, 1) 
tmp = Replace(tmp, "echo", "htm = htm & ", 1, -1, 1) 
'execute(tmp) 
executeglobal(tmp) 
htm = Replace(htm, "{::vbcrlf}", vbCrLf) 
htm = Replace(htm, "{::vbcr}", vbCr) 
ob_get_contents = htm 
End Function 

'过程:动态包含文件 

Sub include(Path) 
echo ob_get_contents(Path) 
End Sub 

'函数:base64加密 

Function base64encode(byval Str) 
If IsNull(Str) Then Exit Function 
Dim base64 
Set base64 = New base64_class 
Str = base64.encode(Str) 
Set base64 = Nothing 
base64encode = Str 
End Function 

'函数:base64解密 

Function base64decode(byval Str) 
If IsNull(Str) Then Exit Function 
Dim base64 
Set base64 = New base64_class 
Str = base64.decode(Str) 
Set base64 = Nothing 
base64decode = Str 
End Function 

'函数:URL加密 

Function urlencode(byval Str) 
If IsNull(Str) Then Exit Function 
Str = server.URLEncode(Str) 
urlencode = Str 
End Function 

'函数:Escape加密 

Function escape(byval Str) 
If IsNull(Str) Then Exit Function 
Dim i, c, a, tmp 
tmp = "" 
For i = 1 To Len(Str) 
c = Mid(Str, i, 1) 
a = ascw(c) 
If (a>= 48 And a<= 57) Or (a>= 65 And a<= 90) Or (a>= 97 And a<= 122) Then 
tmp = tmp & c 
ElseIf InStr("@*_+-./", c) > 0 Then 
tmp = tmp & c 
ElseIf a>0 And a<16 Then 
tmp = tmp & "%0" & Hex(a) 
ElseIf a>= 16 And a<256 Then 
tmp = tmp & "%" & Hex(a) 
Else 
tmp = tmp & "%u" & Hex(a) 
End If 
Next 
escape = tmp 
End Function 

'函数:Escape解密 

Function unescape(byval Str) 
If IsNull(Str) Then Exit Function 
Dim i, c, tmp 
tmp = "" 
For i = 1 To Len(Str) 
c = Mid(Str, i, 1) 
If Mid(Str, i, 2) = "%u" And i<= Len(Str) -5 Then 
If IsNumeric("&H" & Mid(Str, i + 2, 4)) Then 
tmp = tmp & chrw(CInt("&H" & Mid(Str, i + 2, 4))) 
i = i + 5 
Else 
tmp = tmp & c 
End If 
ElseIf c = "%" And i<= Len(Str) -2 Then 
If IsNumeric("&H" & Mid(Str, i + 1, 2)) Then 
tmp = tmp & chrw(CInt("&H" & Mid(Str, i + 1, 2))) 
i = i + 2 
Else 
tmp = tmp & c 
End If 
Else 
tmp = tmp & c 
End If 
Next 
unescape = tmp 
End Function

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/asp/12313.shtml

相关文章

风云图片

推荐阅读

返回ASP频道首页