asp easp 开源框架_easp.asp

'#################################################################################

'##easp.asp

'##--------------------------------------------------------------------

'##Feature:EasyAsp Class

'##Version:v2.1

'##Author:Coldstone(coldstone[at]qq.com)

'##Update Date:2009-08-31 16:50

'##Description:EasyAsp Release Version 2.1

'##

'#################################################################################

Dim Easp : Set Easp = New EasyASP

'Easp.db.dbConn = Easp.db.OpenConn(0,"database","sa:pass@localhost"

'Easp.db.Debug = True

%>

Dim EasyAsp_s_html

Class EasyAsp

Public db

Private s_fsoName, s_charset

Private Sub Class_Initialize()

s_fsoName= "Scripting.FilesyStemObject"

s_charset= "GB2312"

Set db= New EasyAsp_db

End Sub

Private Sub Class_Terminate()

Set db = Nothing

End Sub

Public Property Let FsoName(ByVal str)

s_fsoName = str

End Property

Public Property Let CharSet(ByVal str)

s_charset = Ucase(str)

End Property

Sub W(ByVal str)

Response.Write(str)

End Sub

Sub WC(ByVal str)

Response.Write(str & VbCrLf)

End Sub

Sub WN(ByVal str)

Response.Write(str & "
" & VbCrLf)

End Sub

Sub WE(ByVal str)

Response.Write(str)

Response.End()

End Sub

Sub RR(ByVal str)

Response.Redirect(str)

End Sub

Function isN(ByVal str)

isN = Easp_isN(str)

End Function

Function IIF(ByVal Cn, ByVal T, ByVal F)

IIF = Easp_IIF(Cn,T,F)

End Function

Function IfThen(ByVal Cn, ByVal T, ByVal F)

IfThen = Easp_IIF(Cn,T,F)

End Function

Sub Js(ByVal Str)

Response.Write("" & VbCrLf)

Response.Write(VbTab & Str & VbCrLf)

Response.Write("" & VbCrLf)

End Sub

Sub Alert(ByVal str)

Response.Write("alert('" & JsEncode(str) & "\t\t');history.go(-1);"&VbCrLf)

Response.End()

End Sub

Sub AlertUrl(ByVal str, ByVal url)

Response.Write(""&VbCrLf)

Response.Write(VbTab&"alert('" & JsEncode(str) & "\t\t');location.href='" & url & "';"&VbCrLf)

Response.Write(""&VbCrLf)

Response.End()

End Sub

Sub ConfirmUrl(ByVal str, ByVal Turl, ByVal Furl)

Response.Write(""&VbCrLf)

Response.Write(VbTab&"if(confirm('" & JsEncode(str) & "\t\t')){

location.href='" & Turl & "';

}else{

location.href='" & Furl & "';

}"&VbCrLf)

Response.Write(""&VbCrLf)

Response.End()

End Sub

Function JsEncode(ByVal str)

JsEncode = Easp_JsEncode(str)

End Function

Function Escape(ByVal str)

Escape = Easp_Escape(str)

End Function

Function UnEscape(ByVal str)

UnEscape = Easp_UnEscape(str)

End Function

Function DateTime(ByVal iTime, ByVal iFormat)

If Not IsDate(iTime) Then DateTime = "Date Error" : Exit Function

If Instr(",0,1,2,3,4,",","&iFormat&",")>0 Then DateTime = FormatDateTime(iTime,iFormat) : Exit Function

Dim diffs,diffd,diffw,diffm,diffy,dire,before,pastTime

Dim iYear, iMonth, iDay, iHour, iMinute, iSecond,iWeek,tWeek

Dim iiYear, iiMonth, iiDay, iiHour, iiMinute, iiSecond,iiWeek

Dim iiiWeek, iiiMonth, iiiiMonth

Dim SpecialText, SpecialTextRe,i,t

iYear = right(Year(iTime),2) : iMonth = Month(iTime) : iDay = Day(iTime)

iHour = Hour(iTime) : iMinute = Minute(iTime) : iSecond = Second(iTime)

iiYear = Year(iTime) : iiMonth = right("0"&Month(iTime),2)

iiDay = right("0"&Day(iTime),2) : iiHour = right("0"&Hour(iTime),2)

iiMinute = right("0"&Minute(iTime),2) : iiSecond = right("0"&Second(iTime),2)

tWeek = Weekday(iTime)-1 : iWeek = Array("日","一","二","三","四","五","六")

If isDate(iFormat) or isN(iFormat) Then

If isN(iFormat) Then : iFormat = Now() : pastTime = true : End If

dire = "后" : If DateDiff("s",iFormat,iTime)<0 Then : dire = "前" : before = True : End If

diffs = Abs(DateDiff("s",iFormat,iTime))

diffd = Abs(DateDiff("d",iFormat,iTime))

diffw = Abs(DateDiff("ww",iFormat,iTime))

diffm = Abs(DateDiff("m",iFormat,iTime))

diffy = Abs(DateDiff("yyyy",iFormat,iTime))

If diffs < 60 Then DateTime = "刚刚" : Exit Function

If diffs < 1800 Then DateTime = Int(diffs\60) & "分钟" & dire : Exit Function

If diffs < 2400 Then DateTime = "半小时" & dire : Exit Function

If diffs < 3600 Then DateTime = Int(diffs\60) & "分钟" & dire : Exit Function

If diffs < 259200 Then

If diffd = 3 Then DateTime = "3天" & dire & " " & iiHour & ":" & iiMinute : Exit Function

If diffd = 2 Then DateTime = IIF(before,"前天 ","后天 ") & iiHour & ":" & iiMinute : Exit Function

If diffd = 1 Then DateTime = IIF(before,"昨天 ","明天 ") & iiHour & ":" & iiMinute : Exit Function

DateTime = Int(diffs\3600) & "小时" & dire : Exit Function

End If

If diffd < 7 Then DateTime = diffd & "天" & dire & " " & iiHour & ":" & iiMinute : Exit Function

If diffd < 14 Then

If diffw = 1 Then DateTime = IIF(before,"上星期","下星期") & iWeek(tWeek) & " " & iiHour & ":" & iiMinute : Exit Function

If Not pastTime Then DateTime = diffd & "天" & dire : Exit Function

End If

If Not pastTime Then

If diffd < 31 Then

If diffm = 2 Then DateTime = "2个月" & dire : Exit Function

If diffm = 1 Then DateTime = IIF(before,"上个月","下个月") & iDay & "日" : Exit Function

DateTime = diffw & "星期" & dire : Exit Function

End If

If diffm < 36 Then

If diffy = 3 Then DateTime = "3年" & dire : Exit Function

If diffy = 2 Then DateTime = IIF(before,"前年","后年") & iMonth & "月" : Exit Function

If diffy = 1 Then DateTime = IIF(before,"去年","明年") & iMonth & "月" : Exit Function

DateTime = diffm & "个月" & dire : Exit Function

End If

DateTime = diffy & "年" & dire : Exit Function

Else

iFormat = "yyyy-mm-dd hh:ii"

End If

End If

iiWeek = Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")

iiiWeek = Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")

iiiMonth = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

iiiiMonth = Array("January","February","March","April","May","June","July","August","September","October","November","December")

SpecialText = Array("y","m","d","h","i","s","w")

SpecialTextRe = Array(Chr(0),Chr(1),Chr(2),Chr(3),Chr(4),Chr(5),Chr(6))

For i = 0 To 6 : iFormat = Replace(iFormat,"\"&SpecialText(i), SpecialTextRe(i)) : Next

t = Replace(iFormat,"yyyy", iiYear) : t = Replace(t, "yyy", iiYear)

t = Replace(t, "yy", iYear) : t = Replace(t, "y", iiYear)

t = Replace(t, "mmmm", iiiiMonth(iMonth-1)) : t = Replace(t, "mmm", iiiMonth(iMonth-1))

t = Replace(t, "mm", iiMonth) : t = Replace(t, "m", iMonth)

t = Replace(t, "dd", iiDay) : t = Replace(t, "d", iDay)

t = Replace(t, "hh", iiHour) : t = Replace(t, "h", iHour)

t = Replace(t, "ii", iiMinute) : t = Replace(t, "i", iMinute)

t = Replace(t, "ss", iiSecond) : t = Replace(t, "s", iSecond)

t = Replace(t, "www", iiiWeek(tWeek)) : t = Replace(t, "ww", iiWeek(tWeek))

t = Replace(t, "w", iWeek(tWeek))

For i = 0 To 6 : t = Replace(t, SpecialTextRe(i),SpecialText(i)) : Next

DateTime = t

End Function

Function R(ByVal Str, ByVal RType)

R = SafeData("R", Str, RType)

End Function

Function Ra(ByVal Str, ByVal RType)

Ra = SafeData("Ra", Str, RType)

End Function

Function RF(ByVal Str, ByVal RType)

RF = SafeData("RF", Str, RType)

End Function

Function RFa(ByVal Str, ByVal RType)

RFa = SafeData("RFa", Str, RType)

End Function

Function RQ(ByVal Str, ByVal RType)

RQ = SafeData("RQ", Str, RType)

End Function

Function RQa(ByVal Str, ByVal RType)

RQa = SafeData("RQa", Str, RType)

End Function

Function RH(ByVal Str, ByVal RType)

RH = SafeData("RH", Str, RType)

End Function

Function RHa(ByVal Str, ByVal RType)

RHa = SafeData("RHa", Str, RType)

End Function

Function SafeData(fn, ByVal Str, ByVal RType)

Dim TempStr, fna

Dim RDefault,RSplit

Dim TempArr, i

Select Case fn

Case "R", "Ra" TempStr = Request(Str)

Case "RF", "RFa" TempStr = Request.Form(Str)

Case "RQ", "RQa" TempStr = Request.QueryString(Str)

Case "RH", "RHa" TempStr = Request.QueryString()

Case Else TempStr = Str

End Select

fna = IIF(fn = "Ra" or fn = "RFa" or fn = "RQa" or fn = "RHa",True,False)

If fn = "RH" or fn = "RHa" Then

If Not isNumeric(Str) Then SafeData = "" : Exit Function

TempStr = Split(Split(TempStr,".")(0),"-")(Str)

End If

RSplit = ","

If Instr(Cstr(RType),":")=2 Then

RDefault = Mid(RType,3)

If IsN(TempStr) Then TempStr = RDefault

RType = Int(Left(RType,1))

If RType = 2 Or RType = 3 Then RSplit = RDefault

End If

Select Case RType

Case 0

TempStr = Replace(TempStr,"'","''")

Case 1

TempStr = IsNumber(TempStr,IIF(fna,0,1))

Case 2,3

If Instr(TempStr,RSplit)>0 Then

TempArr = split(TempStr,RSplit)

TempStr = ""

For i = 0 To Ubound(TempArr)

If i <>0 Then TempStr = TempStr & RSplit

If RType = 2 Then

TempStr = TempStr & Replace(Trim(TempArr(i)),"'","''")

Else

TempArr(i) = IsNumber(Trim(TempArr(i)),IIF(fna,0,1))

TempStr = TempStr & TempArr(i)

End If

Next

Else

TempStr = IIF(RType = 2,Replace(TempStr,"'","''"),IsNumber(TempStr,IIF(fna,0,1)))

End If

End Select

SafeData = TempStr

End Function

Private Function IsNumber(Str, iType)

If Not IsN(Str) Then

If not isNumeric(Str) Then

If iType = 0 Then

Alert "数据类型不正确!"

Else

IsNumber = ""

End If

Else

IsNumber = Str

End if

End If

End Function

Function CheckDataFrom()

Dim v1, v2

CheckDataFrom = False

v1 = Cstr(Request.ServerVariables("HTTP_REFERER"))

v2 = Cstr(Request.ServerVariables("SERVER_NAME"))

If Mid(v1,8,Len(v2)) = v2 Then

CheckDataFrom = True

End If

end Function

Sub CheckDataFromA()

If Not CheckDataFrom Then alert "禁止从站点外部提交数据!"

end Sub

Function CheckSql()

Dim noSQLStr, noSQL, StrGet,

...

...

(文件超长,未完全显示,请下载后阅读剩余部分)

...

展开> <收缩

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
有了这款基于JavaScript的ASP开源MVC框架,你的asp老项目有可以焕发青春活力了!其实不伦是asp,php,java还是python,任何一种编程语言,只要是开源的,就可以不断更新,获得延续的生命力。 单文件入口。Single entry point. > > 代码和程序的真正分离。A real MVC. > > 模板编译ASP代码。Combine template file to ASP(JScript) code. > > 支持类库扩展以及模板自定义标签扩展。Support Library and Tag extend. > > 支持多种数据库,默认支持ACCESS、MSSQL、MYSQL、SQLITE,可自定义其他类型数据库。Support Muti-Type-Databases. > > 支持多数据库操作。Support Muti-Databases-Operate. > > 表单验证支持,HTTP请求数据可直接用来更新数据库。FormValidatee is supported, and Http Post data can be used for insert or update table record(s). > > 提供HttpRequest,HttpUpload,Soap,OAUTH2.0等模块。"HttpRequest,HttpUpload,Soap,OAUTH2.0" are supported. > > 提供CryptoJS,提供AES/DES/RC4/Rabbit/pbkdf2/ripemd160等算法。CryptoJS is supported. > > 内置Json解析和构建。Json2 is built-in.You can use it to parse or stringify Json data. > > 支持多种路由方式,包括404、URL、isapi_URLRewrite,完全自定义的路由配置。URLRoute is Supported(404 Error Page, URL Route,ISAPI_URIRewrite). > > 路由支持REST。REST is Supported. > > 支持类库缓存,编译缓存,HTML缓存,数据库Model缓存。Library Cache, Combined File Cache, HTML Cache and Model Cache. > > 资源统一管理,统一销毁,使您专心于业务逻辑处理。You can pay much more attention on you business.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值