asp仿php的一些函数分享_应用技巧

复制代码 代码如下:

'过程:输出字符串[代替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

时间: 2024-08-28 14:02:04

asp仿php的一些函数分享_应用技巧的相关文章

ASP动态网页制作技术经验分享_应用技巧

学好一门编程语言有两个条件是必不可少的,一是理论与实践结合.在实际例程去验证书本上的理论能加深你对理论的理解:二是学会总结,把学习.运用中的心得体会记下来,当成一种经验或者教训加以提炼并在日后的应用中加以改进,一定能提高你对这门编程语言的认识.以下是笔者在学习与运用ASP编程中的两点经验,希望能对大家有所帮助. ASP页面内VBScript和JScript的交互 ASP具备管理不同语言脚本程序的能力,能够自动调用合适的脚本引擎以解释脚本代码和执行内置函数.ASP开发环境提供了两种脚本引擎,即VB

asp仿php的一些函数分享

复制代码 代码如下: '过程:输出字符串[代替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文件运行结果返回

Asp实现的数据库连接池功能函数分享_应用技巧

数据库连接是一种关键的有限的昂贵的资源,这一点在多用户的网页应用程序中体现得尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标.数据库连接池正是针对这个问题提出来的.数据库连接池负责分配.管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而再不是重新建立一个:释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接而引起的数据库连接遗漏.这项技术能明显提高对数据库操作的性能. 但是这项技术一般在java ,php ,.net 里

asp 通用修改和增加函数代码_应用技巧

接下来我利用一点空余时间发一个函数里面包含和添加和删除功能.实验的架构可以使用IIS.5WEB服务器ACCESS数据库.这个我其实不用说的很详细了,因为大家都应该知道的.我就直接把函数贴出来.大家只要稍微修改即可使用. 复制代码 代码如下: <% sub AdminEdit() dim Action,rsCheckAdd,rs,sql Action=request.QueryString("Action") if Action="SaveEdit" then

ASP.Net缓存总结及分析 分享_实用技巧

1.页面缓存        要实现页面输出缓存,只要将一条 OutputCache 指令添加到页面即可.         <%@ OutputCache CacheProfile=" " NoStore="True | False" Duration="#ofseconds" Shared="True | False" Location="Any | Client | Downstream | Server |

asp下实现IP限制函数代码_应用技巧

IP限制函数 大家如果还有好的建议算法,就联系我!!:) "****************************** "Function CheckIp(cInput_Ip,cBound_Ip) "Created by qqdao, qqdao@263.net 2001/11/28 "说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内 "参数: cInput_Ip,代检查的ip "

asp IsValidEmail 验证邮箱地址函数(email)_应用技巧

复制代码 代码如下: '******************************************** '函数名:IsValidEmail '作 用:检查Email地址合法性 '参 数:email ----要检查的Email地址 '返回值:True ----Email地址合法 ' False ----Email地址不合法 '******************************************** Public Function IsValidEmail(Email) D

asp.net文件上传示例分享_实用技巧

方法一:用Web控件FileUpload,上传到网站根目录. Test.aspx关键代码: 复制代码 代码如下: <form id="form1" runat="server"><asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="Button1" runat="server" T

ASP.NET餐饮管理系统制作代码分享_实用技巧

页面介绍展示: 以上是餐饮管理系统制作图片介绍,接下来是代码部分. menu.aspx  <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="menu.aspx.cs" Inherits="menu" Title="无标题页" %> <