Recommended: How to improve the speed of access to Asp programs When using an asp program for web page design, it is mostly because you need to access the database and then display the data to the page. If there is a lot of data, the access speed of the page will slow down. In order to solve this problem, you can use the following techniques to improve the access speed of the page. One of the tips: It is time-consuming to use the Request collection to access an ASP collection to extract a value
I have collected some practical asp code, which saves everyone's time to search during web page production.Filter characters : FunctionGetSafeStr(str) GetSafeStr=Replace(Replace(Replace(Replace(Replace(Replace(str, ','),),),&,),<,<),>,>) EndFunction Gregorian calendar to lunar calendar <% FunctionNongli() DimWeekName(7), MonthAdd(11), NongliData(99), TianGan(9), DiZhi(11), ShuXiang(11), DayName(30), MonName(12) DimcurTime, curYear, curMonth, curDay, curWeekday DimGongliStr, WeekdayStr, NongliStr, NongliDayStr Dimi,m,n,k,isEnd,bit,TheDate 'Get the current system time curTime=Date 'The name of the week WeekName(0)=* WeekName(1)=Sunday WeekName(2)=Monday WeekName(3)=Tuesday WeekName(4)=Wednesday WeekName(5)= Thursday WeekName(6)=Friday WeekName(7)=Saturday 'The name of the heavenly stems TianGan(0)=A TianGan(1)=B TianGan(2)=C TianGan(3)=Ding TianGan(4)=E TianGan(5)=发 TianGan(6)=Geng TianGan(7)=Xin TianGan(8)=Ren TianGan(9)=Gu 'The name of the earthly branch DiZhi(0)=Sub DiZhi(1)=Ugly DiZhi(2)=Yin DiZhi(3)=口 DiZhi(4)=Chen DiZhi(5)=S DiZhi(6)=可 DiZhi(7)=N DiZhi(8)=Shen DiZhi(9)=Uni DiZhi(10)=Xu DiZhi(11)=Hai 'Zodiac Name ShuXiang(0)=Rat ShuXiang(1)=Nuo ShuXiang(2)=Tiger ShuXiang(3)=Rabbit ShuXiang(4)=Dragon ShuXiang(5)=Snake ShuXiang(6)=Horse ShuXiang(7)=Sheep ShuXiang(8)=Monkey ShuXiang(9)=Chicken ShuXiang(10)=Dog ShuXiang(11)=Pig 'Lunar Date Name DayName(0)=* DayName(1)=First year DayName(2)=Second second grade DayName(3)=First year DayName(4)=Fourth DayName(5)=Fifth day of the first lunar month DayName(6)=First sixth DayName(7)=Quinity DayName(8)=First Eighth DayName(9)=分小 DayName(10)=First ten DayName(11)=11 DayName(12)=Twelve DayName(13)=Thirteen DayName(14)=14 DayName(15)=Fifteen DayName(16)=16 DayName(17)=17 DayName(18)=Eighteen DayName(19)=19 DayName(20)=Twenty DayName(21)=21 DayName(22)=22 DayName(23)=23 DayName(24)=24 DayName(25)=25 DayName(26)=26 DayName(27)=27 DayName(28)=28 DayName(29)=29 DayName(30)=30 'The name of the lunar month MonName(0)=* MonName(1)=Positive MonName(2)=2 MonName(3)=Three MonName(4)=Four MonName(5)=5 MonName(6)=Six MonName(7)=7 MonName(8)=8 MonName(9)=9 MonName(10)=Ten MonName(11)=11 MonName(12)=Water 'The number of days before each month of the Gregorian calendar MonthAdd(0)=0 MonthAdd(1)=31 MonthAdd(2)=59 MonthAdd(3)=90 MonthAdd(4)=120 MonthAdd(5)=151 MonthAdd(6)=181 MonthAdd(7)=212 MonthAdd(8)=243 MonthAdd(9)=273 MonthAdd(10)=304 MonthAdd(11)=334 'Lunar calendar data NongliData(0)=2635 NongliData(1)=333387 NongliData(2)=1701 NongliData(3)=1748 NongliData(4)=267701 NongliData(5)=694 NongliData(6)=2391 NongliData(7)=133423 NongliData(8)=1175 NongliData(9)=396438 NongliData(10)=3402 NongliData(11)=3749 NongliData(12)=331177 NongliData(13)=1453 NongliData(14)=694 NongliData(15)=201326 NongliData(16)=2350 NongliData(17)=465197 NongliData(18)=3221 NongliData(19)=3402 NongliData(20)=400202 NongliData(21)=2901 NongliData(22)=1386 NongliData(23)=267611 NongliData(24)=605 NongliData(25)=2349 NongliData(26)=137515 NongliData(27)=2709 NongliData(28)=464533 NongliData(29)=1738 NongliData(30)=2901 NongliData(31)=330421 NongliData(32)=1242 NongliData(33)=2651 NongliData(34)=199255 NongliData(35)=1323 NongliData(36)=529706 NongliData(37)=3733 NongliData(38)=1706 NongliData(39)=398762 NongliData(40)=2741 NongliData(41)=1206 NongliData(42)=267438 NongliData(43)=2647 NongliData(44)=1318 NongliData(45)=204070 NongliData(46)=3477 NongliData(47)=461653 NongliData(48)=1386 NongliData(49)=2413 NongliData(50)=330077 NongliData(51)=1197 NongliData(52)=2637 NongliData(53)=268877 NongliData(54)=3365 NongliData(55)=531109 NongliData(56)=2900 NongliData(57)=2922 NongliData(58)=398042 NongliData(59)=2395 NongliData(60)=1179 NongliData(61)=267415 NongliData(62)=2635 NongliData(63)=661067 NongliData(64)=1701 NongliData(65)=1748 NongliData(66)=398772 NongliData(67)=2742 NongliData(68)=2391 NongliData(69)=330031 NongliData(70)=1175 NongliData(71)=1611 NongliData(72)=200010 NongliData(73)=3749 NongliData(74)=527717 NongliData(75)=1452 NongliData(76)=2742 NongliData(77)=332397 NongliData(78)=2350 NongliData(79)=3222 NongliData(80)=268949 NongliData(81)=3402 NongliData(82)=3493 NongliData(83)=133973 NongliData(84)=1386 NongliData(85)=464219 NongliData(86)=605 NongliData(87)=2349 NongliData(88)=334123 NongliData(89)=2709 NongliData(90)=2890 NongliData(91)=267946 NongliData(92)=2773 NongliData(93)=592565 NongliData(94)=1210 NongliData(95)=2651 NongliData(96)=395863 NongliData(97)=1323 NongliData(98)=2707 NongliData(99)=265877 'Generate the current calendar year, month, day ==>GongliStr curYear=Year(curTime) curMonth=Month(curTime) curDay=Day(curTime) GongliStr=curYear&year If(curMonth<10)Then GongliStr=GongliStr&0&curMonth&month Else GongliStr=GongliStr&curMonth&month EndIf If(curDay<10)Then GongliStr=GongliStr&0&curDay&Day Else GongliStr=GongliStr&curDay&Day EndIf 'Generate the current Gregorian week ==>WeekdayStr curWeekday=Weekday(curTime) WeekdayStr=WeekName(curWeekday) 'The number of days to the initial time of February 8, 1921: 1921-2-8 (first day of the first lunar month) TheDate=(curYear-1921)*365+Int((curYear-1921)/4)+curDay+MonthAdd(curMonth-1)-38 If((curYearMod4)=0AndcurMonth>2)Then TheDate=TheDate+1 EndIf 'Calculate the lunar calendar stems, earthly branches, month and day isEnd=0 m=0 Do If(NongliData(m)<4095)Then k=11 Else k=12 EndIf n=k Do If(n<0)Then ExitDo EndIf 'Get the value of the nth binary bit of NongliData(m) bit=NongliData(m) Forq=1TonStep1 bit=Int(bit/2) Next bit=bitMod2 If(TheDate<=29+bit)Then isEnd=1 ExitDo EndIf TheDate=TheDate-29-bit n=n-1 Loop If(isEnd=1)Then ExitDo EndIf m=m+1 Loop curYear=1921+m curMonth=k-n+1 curDay=TheDate If(k=12)Then If(curMonth=(Int(NongliData(m)/65536)+1)) Then curMonth=1-curMonth ElseIf(curMonth>(Int(NongliData(m)/65536)+1)) Then curMonth=curMonth-1 EndIf EndIf 'Create the lunar calendar, earthly branches, and zodiac signs ==>NongliStr NongliStr=TianGan(((curYear-4)Mod60)Mod10)&DiZhi(((curYear-4)Mod60)Mod12) NongliStr=NongliStr&<fontcolor= '#ff9000 '><b>(&ShuXiang(((curYear-4)Mod60)Mod12)&)</b></font>Year 'Create the lunar month and day ==>NongljDayStr If(curMonth<1)Then NongliDayStr=Live&MonName(-1*curMonth) Else NongliDayStr=MonName(curMonth) EndIf NongliDayStr=NongliDayStr&month NongliDayStr=NongliDayStr&DayName(curDay) NongLi=NongliStr&&NongliDayStr endFunction dimsdate:sdate=Nongli() response.Write(sdate) %> Formatted strings 'Function name: ZeroFill(Num,Num_Length) 'Function function: 0 was added before 'Parameter description: the number to be operated by Num 'Num_Length displays the number of bits 'Return value: Formatted string ' FunctionZeroFill(Num,Num_Length) DimZeroFill_i,ZeroFill_ReturnNum ForZeroFill_i=len(Num)ToNum_Length-1 ZeroFill_ReturnNum=ZeroFill_ReturnNum&0 Next ZeroFill_ReturnNum=ZeroFill_ReturnNum&Num ZeroFill=ZeroFill_ReturnNum EndFunction Functions that generate security codes functionmake_randomize(max_len,w_n) 'max_len generates length, w_n: 0 may contain letters, 1: only for numbers randomize forintcounter=1tomax_len whatnext=int((1-0+1)*rnd+w_n) ifwhatnext=0then upper=122 lower=97 else upper=57 lower=48 endif strnewpass=strnewpass&chr(int((upper-lower+1)*rnd)+lower) next make_randomize=strnewpass endfunction 'safecode=make_randomize(4,0) 'response.Write(safecode) %> <%random_num=make_randomize(4,0) 'Generate a 4-digit security code session(random_num)=random_num 'Why do session be called? It is completely meaningless without session security code. hehe SetJpeg=Server.createObject(Persits.Jpeg) 'Calling component Jpeg.OpenServer.MapPath(1.jpg) 'Open the prepared picture Jpeg.Canvas.Font.Color=&H006699 Jpeg.Canvas.Font.Family=ArialBlack Jpeg.Canvas.Font.Bold=false Jpeg.Canvas.PrintText0,-2,random_num jpeg.saveServer.MapPath(random_index.jpg) 'Save %> <imgsrc=random_index.jpgborder=0align=absmiddle> |
Share: Detailed explanation of ASP's Session object 1. Attribute 1. SessionID The SessionID property returns the user's session identity. When creating a session, the server generates a separate identity for each session. The session identifier is returned as the elongated data type. In many cases, SessionID can be used for WEB page registration statistics. 2. TimeOut Timeout property is the Sessi of the application in minutes.
4 pages in total Previous page 1234Next page