Traditional Culture Encyclopedia - Photography and portraiture - Write an automatic activation code function with asp.

Write an automatic activation code function with asp.

I have nothing to do this morning, so I wrote you a few pages:

1, create a new table: Take Access as an example, the table is named activate, and the user activation code is used in the table.

Id (automatic numbering), UserId (user Id), UserCode (activation code, text), CodeFlag (number, status, 0 not activated 1 activated), AcDate (date, expiration time, default value "now ()").

Table 2 Activation Code, activation code table issued by the system.

Id (automatic numbering), UserId (card user Id), AcCode (activation code, text), and CodeFlag (number, usage status, default 0 unused 1 received).

Add a field in the user table, the field name is UserCodeFlag, the number is 0, the initial value is inactive, and 1 is activated (some functions of inactive users are limited, please add it yourself).

2. Set activation code parameters and activation code generation function.

* * * Two functions:

CodeFunction.asp:

& lt%

Dim UserCodeAcnum,UserAcDate

UserCodeAcnum = 5' The number of activation codes that can be collected.

UserAcDate = 365' Effective time and days of activation once.

The function getactivateCode (str _ len)' generates a mixed activation code of uppercase letters and numbers.

Dim Seed,SeedAry,Seed_Str,Seed_Str 1,TempStr,I,m

str_len = Cint(str_len)

seed _ Str = " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "

seed _ str 1 = " 0 1 2 3 4 5 6 7 8 9 "

Seed = " "

Seed = seed & ampseed _ str&"& ampseed _ str1

SeedAry = Split (seed, "")

M = Underload (seed)

TempStr = " "

do While Len(TempStr)& lt; string length

Randomization timer ()

TempStr = TempStr & amp seed orchard (m*Rnd)

ring

GetActivateCode = TempStr

End function

GetActivateValue(n, k): The process of generating an activation code and putting it into storage.

N: the number of pieces generated at one time; K: The length of the activation code can't exceed 50 or 20 at the longest.

Sub-activation value (n, k)

Dim i

For i = 1 to n

conn . Execute(" insert Into activate code(AcCode)Values(" & amp; get activate code(k)& amp; ')")

then

Close the control room

End joint

% & gt

3. The administrator generates the activation code page in the background:

ManageCard.asp

Please replace ""in the next three lines. The first line is the library link file.

& lt! - #include file= "。 ASP“--& gt;

& lt! -# include file = " code function . ASP "-& gt;

& ltLINK href= "。 CSS " type = text/CSS rel = style sheet & gt;

& lt%

Call Main ()

Deputy General Manager ()

Call CodeCss ()

Select a Case Request (Action)

Case "DelAllCard"

Call DelAllCard ()

Case "DelNewCard"

Call DelNewCard ()

Case "Delaur Decca"

Call DelOldCard ()

Case "SeeCard"

Call SeeCard ()

Case "Add Code"

Call UpdateAccode ()

Call management code ()

Case "Form _ Dellall"

Call SetDellCard ()

Other cases

Call ActivateMain ()

Call management code ()

End selection

Connection closed: set connection = none.

End joint

Sub-delay card ()

Call ActivateMain ()

Call list ()

Response. Write "< div class = listdiv & gt" & vbcrlf.

Response. Write "& ltdiv style =" "margin:30;;" " >& ampVbCrLf

Response. Write "& ltform method=POST action=" "? action = Form _ Dell all " " name = Form 2 & gt; & ampVbCrLf

Response. Write "Are you sure you want to delete all activation cards?" & ampVbCrLf

Response. Write "& ltInput type=""submit"" value=" "Are you sure you want to delete" "name =" "button2" ">" & ampVbCrLf?

Response. Write "& lt/form >& ampVbCrLf"

Response. Write "& lt/div >;;" & ampVbCrLf

Response. Write "& lt/div >;;" & ampVbCrLf

End joint

Sub SetDellCard()

Conn.Execute ("remove from activateCode")

response . redirect " manage card . ASP "

End joint

Sub DelNewCard()

Call ActivateMain ()

Call list ()

End joint

Child unlock card ()

Call ActivateMain ()

Call list ()

End joint

Child SeeCard ()

Call ActivateMain ()

Call list ()

End joint

Sublinked list ()

Response. Write "& ltdiv & gt& ltb> activation card management.

Response. Write "<a href=? Action = DelOldCard & gt Delete the used activation card.

Response. Write "<a href=? Action = DelNewCard & gt Delete the unused activation card.

Response. Write "<a href=? Action = DelAllCard & gt delete all activated cards.

End joint

Child ActivateMain ()

Response. Write "< div class = headdiv & gt" & vbcrlf

Response. Write "& ltdiv & gt& ltb> to generate an activation card.

Response. Write "& ltform method=POST action=" "? action = add code " " name = form 1 >& ampVbCrLf

Response. Write "& ltdiv >& ampVbCrLf"

Response. Write "Select the number of sheets generated by activating the card:

Response. Write "< option value =" "10" ">; 10 sheets

Response. Write "< option value =" "50" "selected & gt50 sheets.

Response. Write "< option value =" "100" ">; 100 sheets

Response. Write "< option value =" "500" ">; 500 sheets

Response. Write "& lt/select >& ampVbCrLf"

Response. Write "card number length:

Response. Write "< option value =" "16" "selected > 16 characters; & ampVbCrLf

Response. Write "< option value =" "24" ">; 24 characters

Response. Write "< option value =" "32" ">; 32 characters

Response. Write "& lt/select >& ampVbCrLf"

Response. Write "< type=""submit"" value=" "Make sure to generate" "name =" "button1"">"&; VbCrLf

Response. Write "& lt/div >;;" & ampVbCrLf

Response. Write "& lt/form >& ampVbCrLf"

Response. Write "& lt/DIV >;;" & ampVbCrLf

Response. Write "< div class = linediv1> & lt/DIV >;" & ampVbCrLf

Response. Write "< div class = linediv & gt</div >;" & ampVbCrLf

End joint

Sub UpdateAccode()

Dim CodeNumber,CodeLen

CodeNumber = Trim(Request(" CodeNum "))

CodeLen = Trim(Request("CodeLen "))

If Isnumeric(CodeNum) = False, exit Sub.

If Isnumeric(CodeLen) = False, exit Sub.

Code number = Cint (code number)

CodeLen = Cint(CodeLen)

Call GetActivateValue(CodeNumber, CodeLen)

Response. Write "< div class = headdiv & gt" & vbcrlf

Response. Write "& ltdiv & gt& ltb> activation card generated successfully! & lt/b & gt; & lt/div >;" & ampVbCrLf

Response. Write "< formmethod = postaction = name = form2 > & vbcrlf.

Response. Write "& ltdiv >& code number &" to activate the card. & lta href= " "? Action = Main ""> Continue to generate activation cards.

Response. Write "& lt/div >;;" & ampVbCrLf

Response. Write "& lt/form >& ampVbCrLf"

Response. Write "& lt/DIV >;;" & ampVbCrLf

Response. Write "& ltDIV class = linediv & gt? & lt/DIV >;" & ampVbCrLf

End joint

Child management code ()

Dim MaxPage,totalPut,cPage,Infonum

if Request(" page ")& lt; & gt ""So

CPage=cint (request ("page"))

other

cPage= 1

If ... it will be over.

Infonum = 1

Response. Write "< div style =" "width =:100%; Margin: 0; " " >& ampVbCrLf

Call list ()

Response. Write "< div class = listdiv & gt" & vbcrlf.

Set Rs = server. CreateObject("ADODB。 Recordset ")

SQL = " Select AcCode From activate code Where code flag = 0 Order By Id desc "

Ruby opens the Sql of Connecticut 1, 1

If Rs.eof and rs.bof, then

Response.write "<p> does not have an activation card at present. ”& ampVbCrLf

other

i=0

MaxPage=30

totalPut=Rs.recordcount

InfoNum = total put-(c page- 1)* MaxPage

If InfoNum & lt 100 and InfoNum & gt9 and then InfoNum = "0" & ampInfoNum.

If InfoNum & lt 10 and InfoNum = "00" & ampInfoNum.

Do without doing.

i = i+ 1

Response. Write "& ltli class = Li1> & ampinfonum & amp")? "& amp0 rupees &"</Li > & ampVbCrLf

If I>= MaxPage and then quit Do,

Rs.movenext

InfoNum = InfoNum- 1

If InfoNum & lt 100 and InfoNum & gt9 and then InfoNum = "0" & ampInfoNum.

If InfoNum & lt 10 and InfoNum = "00" & ampInfoNum.

ring

If ... it will be over.

Rupee off: set Rs = none.

Response. Write "& ltdiv >& ampVbCrLf"

Response. Write "& lt/DIV >;;" & ampVbCrLf

End joint

Subcode ()

Response. Write "< style type =" "text/CSS" "> & vbcrlf

Response. Write "body {margin: 0; Fill: 0; Color: # 444; Font series: Song Ti; font-size:9pt } " & amp; VbCrLf

Response. Write "input {border-width:1; Border color: # 000000; Background color: # EFEFEFEF Font Series: Song Ti; Font size: 9pt color: # 333; Line height:14px} "&; VbCrLf

Response. Write "textarea {border-width:1; Border color: # 000000; Background color: # EFEFEFEF Font Series: Song Ti; Font size: 9pt} "& ampVbCrLf

Response. Write "Select {border-width:1; Border color: # 000; Background color: # eee Font Series: Song Ti; Font size: 9pt} "& ampVbCrLf

Response. Write "A {COLOR:# 444;; font-family:Verdana }”& amp; VbCrLf

Response. Write "a: link {color: 0000aa; TEXT-DECORATION:none }”& amp; VbCrLf

Response. Write "a: visited {color: 0000aa; TEXT-DECORATION:none }”& amp; VbCrLf

Response. Write "a: hover {color: # ff2200; TEXT-DECORATION:none }”& amp; VbCrLf

Response. Write ". head div { height:80px; Width:100%; Margin: 0; Fill:10; Background: # f8f8} "&; VbCrLf

Response. Write ".linediv1{border-bottom: # ccc2pxsolid; Width:100%; Margin: 0; Fill: 0; line-heignt: 1px; ; Height:1px} "&; VbCrLf

Response. Write ". linediv { border-top:# 999 1px solid; Width:100%; Margin: 0; Fill: 0; line-heignt: 1px; Height:1px} "&; VbCrLf

Response. Write ". list div { width:480 px; Fill:10; Background: # eee} "&; VbCrLf

Response. Write ".li1{width: 250px; Line height:16px; font-size: 12px; List style: None; color:069 }”& amp; VbCrLf

Response. Write "& lt/style >& ampVbCrLf"

End joint

% & gt

After a few hours' delay, I should do something else. Write it after you give it to me. Remember to add a wonderful answer, or I won't bother to write.