I organize some ASP functions to provide friends who begin to learn ASP.

xiaoxiao2021-03-06  108

=============================== Add font color to the specified string =========== ====================================================================================1 FString, strings, "" & strings & "") fontstyle = fstring else fontstyle = "" "" "" "" "" "" "" end ifnd function "= =============================== Take out the string method before and after the specified string ============================================================================================================================================================================ ====================================================================00 , Charflag) IF POS1 <= 20 TMPSTR = Left (str1, pOS1-1) else tmpstr = MID (str1, pos1-20, 20) end ifelse 'takes right pOS1 = INSTR (str1, charflag) len (charflag) IF LEN (STR1) -POS1 <= 20 TMPSTR = Right (str1, len (str1) -pos1) else tmpstr = MID (str1, pos1 1, 20) end ifnd ifdenstrs = TmpStrend function

Function getFileName (STR) POS = INSTR (STR, ".") IF str = "" "" "" "" ============================================================================================================================================================== ============================================== delete file == ============================================ function Delfile (filepath) iMangePath = Trim (filepath) path = server. Mappath (iMangePath) set fs = server.createObject ("scripting.filesystemObject") if fs.fileexists (path) THEN fs.deletefile (path) end if set fs = nothingnd function '============ ======================== Get real client IP ============================================================================================================================================================ ================== PUBLIC FUNCTION getClientip () DIM UIPADDR 'This function refers to Webcn.net/asphouse document uipaddr = request.servervariables ("http_x_forwarded_for ") IF uipaddr =" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

'====================================== to send mail with Jmail ======== ================================================ Function Sendmail (Names, Message, Email) Set mymail = Server. CreateObject ( "jmail.message") mymail.MailServerPassWord = "gwd3209" 'authorization letter mail password mymail.MailServerUserName = "gwd3209@163.com"' authorization letter mail name mymail.ContentType = "text / html" '(whether Support HTML, if don't remove this line) MyMail.Charset = "GB2312" uses character set, do not change mymail.addrecipient "GWD3209@163.com" 'recipient mailbox chg@haigaochem.com mymail.body = message 'Mail body' mymail.body = password: "& pass &" / n "'mail body mymail.from =" "& email' sender mailbox s mymail.subject =" & names & "comments and suggestions !!!" Mail title mymail.send "smtp.163.com", false "mail send server set mymail = nothingend function '========================== ============== Depending on the id ================================ ========= Function GetStr (Getid) Dim Result Result = "" "SELECT CASE GetId Case 1 Result =" One Day "

Case 2 results = "One Week" Case 3 Result = "One Month" Case 4 Result = "Three Month" Case 5 Result = "Half Next SELECT GETSTR =" One Year "End Select GetStr = Result End Function '== ====================================== 四 五 入函 ========= ============================================= Public Function Round_ (V, P) Dim Tempint, Tempdot, Temp , Power Temp = V Power = 10 ^ p tempint = int (Temp * Power) Tempdot = Temp * Power-Tempint if Tempdot> = 0.499 Then 'Tempdot will not be equal to 0.5, equal to 0.4999999999 **, this in numerical calculations There is a detailed introduction 'I didn't write right at the time. Later, when Alert debugged, I suddenly thought of this problem in the programmer exam, memory relief Tempint = Tempint 1 end if round_ = csng (TemPint / Power) 'Because sometimes calculations need to be used, if you don't change, it will cause can't be calculated, and this situation is not constant, I am dizzy, so simply, forcibly converting end function' ============ =============================== SQL function security =========================================================================================================================================================== ========================================= function SQLSHOULDBESAFE ()

DIM STR_ DIM ARRA (1000) DIM Arrb (1000) DIM STRLEN_DIM K_DIM I_ DIM TMPA_ DIM TMPB_DIM TMP_ STR_ = Request.QueryString IF STR _ <> "" "" "" "" "THEN_ = LEN (STR_) k_ = 1 for i_ = 1 to Strlen_ IF MID (STR_, I_, 1) = "%" THENTMPA_ = MID (STR_, I_ 1, 1) TMPB_ = MID (STR_, I_ 2, 1) IF ((ASC (TMPA_)> = 48 and ASC (TMPA _) <= 57) OR (ASC (TMPA _)> = 65 AND ASC (TMPA _) <= 70) OR (ASC (TMPA _)> = 97 And ASC (TMPA _) <= 102)) AND ((ASC (ASC TMPB _)> = 48 and ASC (TMPB _) <= 57) OR (ASC (TMPB_)> = 65 And ASC (TMPB_) <= 70) OR (ASC (TMPB_)> = 97 And ASC (TMPB _) <= 102) ) THEN TMP_ = CHR (CINT (TMPA _) * 16 CINT (TMPB_)) Arra (k _) = "%" & TMPA_ & TMPB_ Arrb (k _) = LCase (TMP_) k_ = k_ 1 end if end if Next for i_ = 1 to k_ str_ = replace (str_, arra (i _), arrb (i_)) NEXT IF INSTR (STR _, "SELECT") or Instr (Str_, "Insert") or Instr (Str_, "Delete from") OR INSTR (STR _, "COUNT (") or INS TR (str_water ") or Instr (str_wick," truncate ") OR INSTR (STR _," ASC (") or Instr (Str_," MID (") or Instr Str_, "CHAR (") OR INSTR (Str_, "Exec Master") or INSTR (Str_, "Net Localgroup Administrators) or Instr (STR_,": ") or Instr (STR_ , "Net User") or INSTR (STR_, "'") or INSTR (STR_, "OR") Then Rest "