leikir
Hvernig er forritað leiki?
ValidChrs = "" ChkValid = "" IsErr = False 'Turn on random Randomize Timer 'Create a six character validation code 'of only letters and numbers For x = 0 to 5 'Lowest number is 48, Highest number is 122 RndNum = Int(Rnd * 74) + 48 GetNum = True 'Eliminate punctuation and characters If RndNum >57 AND RndNum < 65 Then x = x - 1 GetNum = False End if 'Eliminate more punctuation and characters If RndNum > 90 AND RndNum < 97 Then x = x - 1 GetNum = False End if If GetNum = True Then ValidChrs = ValidChrs & chr(RndNum) ' Add 42 to each number just to throw off the viewed numbers. RndNum = RndNum + 42 'Hex the number RndNum = Hex(RndNum) While Len(RndNum) < 2 RndNum = "0" & CStr(RndNum) Wend ' Reverse the order of the charcters ChkValid = RndNum & " " & ChkValid End If Next ChkValid = Replace(ChkValid," ","") If Request("DoStuff") = "Check Code" Then V = Request("V") CV = Request("CV") If Len(Trim(V)) <> 6 Then IsErr = True Else 'Unreverse checking string For x = 6 to 1 step -1 'Get hex number TheChr = Mid(CV,(x*2)-1,2) 'convert hex number back to integer TheChr = Cint("&H" & TheChr) 'subtract 42 TheChr = TheChr - 42 'Generate VB escape character TheChr = Chr(TheChr) 'Get input character CVChr = Mid(V,Len(V)-(x-1),1) 'Compare If CVChr <> TheChr Then IsErr = True End If Next End If If IsErr = True Then Response.Write "<b>The validation code you entered is not correct</b><br />" Else Response.Write "You entered a correct validation code.<br />" End If End If %> <form name="Validator" method="post" action="<%=Request.ServerVariables("URL")%>"> <input type="hidden" name="CV" value="<%=ChkValid%>"> Input this value: <span id="ValidChrs"><i><%=ValidChrs%></i></span> <input type="text" name="V" class="reg" size="5" value="" maxlength="6"> <input type="submit" name="DoStuff" value="Check Code"> </form> <script language="JavaScript"> window.onload = function() { var element = document.getElementById('ValidChrs'); element.onselectstart = function () { return false; } // ie element.onmousedown = function () { return false; } // mozilla }