国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp仿php的一些函數分享

2024-05-04 11:08:12
字體:
來源:轉載
供稿:網友
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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浦东新区| 林州市| 西畴县| 社会| 横峰县| 寿阳县| 乐山市| 泉州市| 宜良县| 凤山市| 唐海县| 巫山县| 丹凤县| 桓仁| 进贤县| 醴陵市| 西贡区| 屏东县| 青阳县| 库尔勒市| 台南县| 大厂| 民和| 巴林左旗| 兴仁县| 邳州市| 刚察县| 陇南市| 抚松县| 行唐县| 山丹县| 汉阴县| 巴中市| 黑水县| 新绛县| 定陶县| 天柱县| 东乡族自治县| 邻水| 阿尔山市| 庄河市|