แนะนำ: การรวบรวมฟังก์ชั่นที่เป็นประโยชน์ในการพัฒนา ASP (2) คอลเลกชันของฟังก์ชั่นที่มีประโยชน์ในการพัฒนา ASP นั้นมีประโยชน์มากโปรดเก็บไว้! '*************************************' การกรองไฮเปอร์ลิงก์ '******************************* ฟังก์
คอลเลกชันของฟังก์ชั่นที่มีประโยชน์ในการพัฒนา ASP มีประโยชน์มาก! ฉันหวังว่าทุกคนจะเก็บไว้!
-
-
'ป้องกันการส่งภายนอก
-
ฟังก์ชั่น chkpost ()
DIM Server_v1, Server_v2
chkpost = false
server_v1 = cstr (request.serverVariables (http_referer))
server_v2 = cstr (request.serverVariables (server_name))
ถ้า mid (server_v1,8, len (server_v2)) <> server_v2 แล้ว
chkpost = false
อื่น
chkpost = true
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
-
'การกรอง IP
-
ฟังก์ชั่น matchip (IP)
เมื่อเกิดข้อผิดพลาดต่อไป
matchip = false
หรี่
สำหรับแต่ละ SIP ในตัวกรอง
SIP = แทนที่ (sip,*,/d*)
splitip = split (sip,.)
Dim re, strmatchs, Strip
ตั้งค่า re = ใหม่ regexp
re.ignorecase = true
re.global = true
re.pattern = (& splitip (0) |). (& splitip (1) |). (& splitip (2) |). (& splitip (3) |)
ตั้งค่า strmatchs = re.execute (IP)
strip = strmatchs (0) .submatches (0) & & strmatchs (0) .submatches (1) & & strmatchs (0) .submatches (2) & & strmatchs (0) .submatches (3)
ถ้า strip = ip, matchip = true: ออกจากฟังก์ชัน
ตั้งค่า strmatchs = ไม่มีอะไร
ตั้งค่า re = ไม่มีอะไร
ต่อไป
ฟังก์ชันสิ้นสุด
-
'รับรหัสลงทะเบียน
-
ฟังก์ชั่น getCode ()
getCode = <img src = common/getCode.asp alt = style = margin-right: 40px;/>
ฟังก์ชันสิ้นสุด
-
'ประเภทไฟล์ จำกัด
-
ฟังก์ชั่น isvalidfile (file_type)
isValidFile = false
หรี่
สำหรับ gname แต่ละตัวใน UP_FileType
ถ้า file_type = gname แล้ว
isValidFile = true
ออกจาก
สิ้นสุดถ้า
ต่อไป
ฟังก์ชันสิ้นสุด
-
'ตรวจพบว่ามีเพียงภาษาอังกฤษและตัวเลขเท่านั้น
-
ฟังก์ชั่น isvalidchars (str)
Dim re, chkstr
ตั้งค่า re = ใหม่ regexp
re.ignorecase = true
re.global = true
re.pattern = [^_/. a-za-z/d]
isvalidChars = true
chkstr = re.replace (str,)
ถ้า chkstr <> str แล้ว isvalidchars = false
ตั้งค่า re = ไม่มีอะไร
ฟังก์ชันสิ้นสุด
-
'ตรวจพบว่ามีเพียงภาษาอังกฤษและตัวเลขเท่านั้น
-
ฟังก์ชั่น isvalidvalue (arrayn, str)
isValidValue = false
หรี่
สำหรับ gname แต่ละตัวใน Arrayn
ถ้า str = gname แล้ว
isValidValue = true
ออกจาก
สิ้นสุดถ้า
ต่อไป
ฟังก์ชันสิ้นสุด
-
'ตรวจพบว่าจำนวนนั้นถูกต้องหรือไม่
-
ฟังก์ชั่น isinteger (para)
isInteger = false
ถ้าไม่ใช่ (isnull (para) หรือ trim (para) = หรือไม่ isnumeric (para)) แล้ว
Isinteger = true
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
-
'การตรวจจับชื่อผู้ใช้
-
ฟังก์ชั่น isvalidusername (ชื่อผู้ใช้ Byval)
เมื่อเกิดข้อผิดพลาดต่อไป
Dim I, C
dim vusername
isvalidusername = true
สำหรับ i = 1 ถึง len (ชื่อผู้ใช้)
c = lcase (กลาง (ชื่อผู้ใช้, i, 1))
ถ้า instr (! <>?#^%@~ `&*() ;:+= ', c)> 0 แล้ว
isvalidusername = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
ต่อไป
สำหรับแต่ละ vusername ใน register_username
หากชื่อผู้ใช้ = vuserName แล้ว
isvalidusername = false
ออกจาก
สิ้นสุดถ้า
ต่อไป
ฟังก์ชันสิ้นสุด
-
'ตรวจสอบว่าที่อยู่อีเมลนั้นถูกต้องหรือไม่
-
ฟังก์ชั่น isvalidemail (อีเมล)
ชื่อสลัวชื่อฉัน c
isvalidemail = true
ชื่อ = แยก (อีเมล @)
ถ้า ubound (ชื่อ) <> 1 แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
สำหรับแต่ละชื่อในชื่อ
ถ้า len (ชื่อ) <= 0 แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
สำหรับ i = 1 ถึง len (ชื่อ)
c = lcase (กลาง (ชื่อ, i, 1))
ถ้า instr (abcdefghijklmnopqrstuvwxyz_-., c) <= 0 และไม่ใช่ isnumeric (c) แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
ต่อไป
ถ้าซ้าย (ชื่อ, 1) = หรือขวา (ชื่อ 1) = แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
ต่อไป
ถ้า instr (ชื่อ (1),.) <= 0 แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
i = len (ชื่อ (1)) - Instrrev (ชื่อ (1),.)
ถ้าฉัน <> 2 และฉัน <> 3 แล้ว
isValidemail = false
ฟังก์ชั่นออก
สิ้นสุดถ้า
ถ้า instr (อีเมล .. )> 0 แล้ว
isValidemail = false
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
-
'ไฮไลต์คำหลัก
-
ฟังก์ชั่นไฮไลต์ (byval strcontent, byref arraywords)
Dim intcounter, strtemp, intpos, inttaglength, intkeywordlength, bupdate
ถ้า len (arraywords) <1 จากนั้นไฮไลต์ = strContent: ฟังก์ชันออก
สำหรับ intpos = 1 ถึง len (strcontent)
bupdate = false
ถ้า mid (strcontent, intpos, 1) = <จากนั้น
เมื่อเกิดข้อผิดพลาดต่อไป
inttagLength = (instr (intpos, strcontent,>, 1) - intpos)
ถ้าเอ่อแล้ว
ไฮไลต์ = strcontent
err.lear
สิ้นสุดถ้า
strtemp = strtemp & mid (strcontent, intpos, inttaglength)
intpos = intpos + inttaglength
สิ้นสุดถ้า
ถ้า arraywords <> แล้ว
intkeywordLength = len (arraywords)
ถ้า lcase (mid (strcontent, intpos, intkeywordlength)) = lcase (arraywords) แล้ว
strtemp = strtemp & <span class = high1> & mid (strcontent, intpos, intkeywordlength) & </span>
intpos = intpos + intkeywordlength - 1
bupdate = true
สิ้นสุดถ้า
สิ้นสุดถ้า
ถ้า bupdate = false แล้ว
strtemp = strtemp & mid (strcontent, intpos, 1)
สิ้นสุดถ้า
ต่อไป
ไฮไลต์ = strtemp
ฟังก์ชันสิ้นสุด
แบ่งปัน: การรวบรวมฟังก์ชั่นที่เป็นประโยชน์ในการพัฒนา ASP (3) คอลเลกชันของฟังก์ชั่นที่มีประโยชน์ในการพัฒนา ASP นั้นมีประโยชน์มากโปรดเก็บไว้! '*************************************' การแยกเนื้อหาตามบรรทัด '************************************************************************ นาม