ASP Common Function Collection

Source: Internet
Author: User
Tags empty md5 encryption servervariables
Function 1. Check for valid mailing address functioncheckemail (stremail)
Dimre
Setre=newregexp
Re. Pattern= "^[w-." {1,}@ ([Da-za-z-]{1,}.) {1,} [da-za-z-] {2,3}$ "
Re. Ignorecase=true
Checkemail=re. Test (Stremail)
Endfunction
2. Test whether the variable is null, the meaning of the null value includes: The variable does not exist/is empty, the object is nothing,0, an empty array, the string is empty Functionisblank (Byrefvar)
Isblank=false
Selectcasetrue
Caseisobject (Var)
Ifvarisnothingthenisblank=true
Caseisempty (Var), IsNull (Var)
Isblank=true
Caseisarray (Var)
Ifubound (Var) =0thenisblank=true
Caseisnumeric (Var)
If (var=0) thenisblank=true
Caseelse
Iftrim (Var) = "" Thenisblank=true
Endselect
Endfunction
3. Get the browser current Urlfunctiongetcururl ()
Ifrequest.servervariables ("HTTPS") = "on" Then
Getcurrenturl= "https://"
Else
Getcurrenturl= "http://"
EndIf
Getcururl=getcururl&request.servervariables ("SERVER_NAME")
If (Request.ServerVariables ("Server_port") <>80) thengetcururl=getcururl& ":" & Request.ServerVariables ("Server_port")
Getcururl=getcururl&request.servervariables ("URL")
If (request.querystring<> "") thengetcururl=getcururl& "?" &request.querystring
Endfunction
4.MD5 encryption Function Privateconstbits_to_a_byte=8
Privateconstbytes_to_a_word=4
Privateconstbits_to_a_word=32

Privatem_lonbits (30)
Privatem_l2power (30)

M_lonbits (0) =clng (1)
M_lonbits (1) =clng (3)
M_lonbits (2) =clng (7)
M_lonbits (3) =clng (15)
M_lonbits (4) =clng (31)
M_lonbits (5) =clng (63)
M_lonbits (6) =clng (127)
M_lonbits (7) =clng (255)
M_lonbits (8) =clng (511)
M_lonbits (9) =clng (1023)
M_lonbits (=CLNG) (2047)
M_lonbits (one) =clng (4095)
M_lonbits (=CLNG) (8191)
M_lonbits (=CLNG) (16383)
M_lonbits (=CLNG) (32767)
M_lonbits (=CLNG) (65535)
M_lonbits (=CLNG) (131071)
M_lonbits (=CLNG) (262143)
M_lonbits (=CLNG) (524287)
M_lonbits (=CLNG) (1048575)
M_lonbits (=CLNG) (2097151)
M_lonbits (=CLNG) (4194303)
M_lonbits (=CLNG) (8388607)
M_lonbits (=CLNG) (16777215)
M_lonbits (=CLNG) (33554431)
M_lonbits (=CLNG) (67108863)
M_lonbits (=CLNG) (134217727)
M_lonbits (=CLNG) (268435455)
M_lonbits (=CLNG) (536870911)
M_lonbits (=CLNG) (1073741823)
M_lonbits (=CLNG) (2147483647)

M_l2power (0) =clng (1)
M_l2power (1) =clng (2)
M_l2power (2) =clng (4)
M_l2power (3) =clng (8)
M_l2power (4) =clng (16)
M_l2power (5) =CLNG (32)
M_l2power (6) =CLNG (64)
M_l2power (7) =clng (128)
M_l2power (8) =CLNG (256)
M_l2power (9) =CLNG (512)
M_l2power (=CLNG) (1024)
M_l2power (one) =CLNG (2048)
M_l2power (=CLNG) (4096)
M_l2power (=CLNG) (8192)
M_l2power (=CLNG) (16384)
M_l2power (=CLNG) (32768)
M_l2power (=CLNG) (65536)
M_l2power (=CLNG) (131072)
M_l2power (=CLNG) (262144)
M_l2power (=CLNG) (524288)
M_l2power (=CLNG) (1048576)
M_l2power (=CLNG) (2097152)
M_l2power (=CLNG) (4194304)
M_l2power (=CLNG) (8388608)
M_l2power (=CLNG) (16777216)
M_l2power (=CLNG) (33554432)
M_l2power (=CLNG) (67108864)
M_l2power (=CLNG) (134217728)
M_l2power (=CLNG) (268435456)
M_l2power (=CLNG) (536870912)
M_l2power (=CLNG) (1073741824)

Privatefunctionlshift (Lvalue,ishiftbits)
Ifishiftbits=0then
Lshift=lvalue
Exitfunction
Elseifishiftbits=31then
Iflvalueand1then
lshift=&h80000000
Else
Lshift=0
EndIf
Exitfunction
Elseifishiftbits<0orishiftbits>31then
Err.raise6
EndIf

If (Lvalueandm_l2power (31-ishiftbits)) Then
Lshift= ((Lvalueandm_lonbits (31-(ishiftbits+1)) *m_l2power (ishiftbits)) or&h80000000
Else
Lshift= ((Lvalueandm_lonbits (31-ishiftbits)) *m_l2power (ishiftbits))
EndIf
Endfunction

Privatefunctionrshift (Lvalue,ishiftbits)
Ifishiftbits=0then
Rshift=lvalue
Exitfunction
Elseifishiftbits=31then
Iflvalueand&h80000000then
Rshift=1
Else
Rshift=0
EndIf
Exitfunction
Elseifishiftbits<0orishiftbits>31then
Err.raise6
EndIf

rshift= (Lvalueand&h7ffffffe) m_l2power (ishiftbits)

If (lvalueand&h80000000) Then
Rshift= (Rshiftor (&h40000000m_l2power (iShiftBits-1))
EndIf
Endfunction

Privatefunctionrotateleft (Lvalue,ishiftbits)
Rotateleft=lshift (lvalue,ishiftbits) Orrshift (LValue, (32-ishiftbits))

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.