I write some of the functions that ASP often use

Source: Internet
Author: User
Tags filter date chr functions idate numeric sql injection sql injection attack
function for the ASP language, to write a functional module class, that for efficiency, it is not necessarily a very advocated thing, but the modular to small to say, to write some functions as a function, that is, in the development of ASP, a lot of things, the following are some of the functions I often use, there are some I wrote, Some are found on the Internet, such as the CFS code, the network of CFS-encoded functions inside the variables are not declared, so after my page declared Option Explicit can not be used normally, very simple, I in the function of the variable declared on it.

It's just a part of it because I'm in the company and most of my information is on my home computer and I'm going to add it later ... If you have any good and the function, also welcome to communicate with me ...

' @ Conversion date is the day of the week function ' @idate is the standard date format ' @itype is 0 when the English day of the week, otherwise the Chinese function showweek (idate,itype) if Itype <> 0 Then Itype = 1 '// Prevent error Output Error Dim Inum,ndayinum = Weekday (Idate) If Itype = 0 Then select Case inum Case 1 nday = "Sunday" Case 2 Nday = "Monday" C ASE 3 Nday = "Tuesday" Case 4 nday = ' Wednesday ' case 5 nday = ' Thursday ' case 6 nday = ' Friday ' case 7 nday = ' Saturday ' End Selectelse Select Case Inum Case 1 nday = "Sunday" Case 2 Nday = "Monday" Case 3 Nday = "Tuesday" Case 4 Nday = "Wednesday" Case 5 NDA y = "Thursday" Case 6 nday = "Friday" Case 7 Nday = "Saturday" End SelectEnd if '//output Showweek = ndayend function '//**************** *********************************************
' @ Paging list function ' @ parameter description: Totalrecount: Total Records ' @page: Current page number, pagesize: Paging size, URL: page address function pagelist (totalrecount,page,pagesize, URL) Dim Startpage,endpage,ipage,totalpage '//Determine the number of parameters after the link file if InStr (1,url, "?") = 0 Then url = URL & "?" else url = URL & "&" End If//Get total page totalpage = totalrecount \ pagesizeif totalrecount mod pagesize <> 0 Then Totalpage = Cint (totalrecount\pagesize+1) startpage = 1endPage = Totalpageif page > Then startpage = page-4if Total Page < then EndPage = Totalpageelse if page =< then EndPage = Ten Else EndPage = page + 4 if endpage > Total Page then EndPage = Totalpage End IfEnd if%> Total:<%=totalrecount%> <%=pagesize%> pages <%if page>1 Then%><a href= "<%=url%>page=1" ><font face= "Webdings" >9</font></a> <a href= "<%=url%>page=<%=page-1%>" ><font face= "Webdings" >7</font></a> <% End If%><%for IPage = StartPage to Endpageif ipage <> page then%> &Lt;a href= "" ><%=ipage%></a> <%else Response.Write i& " " End ifnext%><%if ( Totalpage-page) >4 then%><a href= "<%=url%>page=<%=page+1%>" ><font face= "Webdings" >8 </font></a> <a href= "<%=url%>page=<%=totalPage%>" ><font face= "Webdings" >:</font></a> <%end if
End Function '//*************************************************************
'//Detect if the component is installed functions function isobjinstalled (strclassstring) on Error Resume Next isobjinstalled = False Err = 0 Dim xtestobj Set x Testobj = Server.CreateObject (strclassstring) If 0 = Err Then isobjinstalled = True Set xtestobj = Nothing Err = 0End Func tion '//*************************************************************
Function saferequest (paraname,paratype) ' Prevent SQL Injection attack code '---incoming parameter---//example: Saferequest ("username", 0) or saferequest ("id", 1) ' Paraname: Parameter name-character ' paratype: Parameter type-numeric type (1 for parameter is number, 0 for character)
Dim paravalue paravalue=request (paraname) If paratype=1 then if not IsNumeric (paravalue) Then ' Response.Write ' <script Language=javascript>alert (' parameter ' & Paraname & ' must be numeric!) ');</script> "Response.Write" <script language=javascript>window.history.back ();</script> " Response.End ElseIf Paravalue < 1 then Paravalue = 1 End If Else paravalue=replace (Paravalue, "'", "" ") End If Safereque St=paravalueend function '//*************************************************************
'//html decoding function HtmlDecode (fstring) If not IsNull (fstring) Then fstring = replace (fstring, ">", ">") fstring = R Eplace (fstring, "<", "<") fstring = replace (fstring, "", CHR ()) ' fstring = replace (fstring, ", CHR (9)) ' FSt Ring = replace (fstring, "" ", CHR (34)) ' Double quotes filter ' fstring = replace (fstring, CHR (39)," ' ") ' single quote filter ' fstring = replace (fstring, , "" CHR) fstring = replace (fstring, "</p><p>", CHR (a) & CHR (a)) fstring = replace (fstring, "&LT;BR&G t; ", CHR ()) HtmlDecode = fstring End IfEnd Function '//*************************************************************
'//html encoded function HTMLEncode (fstring) If not IsNull (fstring) Then fstring = replace (fstring, ">", ">") fstring = R Eplace (fstring, "<", "<") fstring



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.