<%@ LANGUAGE = VBScript %> High Scores
High Scores

<% TitleCol = "#4488cc" CellCol = "#a8d6ff" TelCol = "#e0d8c8" session.LCID = 2057 dim tim function Validate_Data(cmdrname, kills, email, regkey) ' Try and validate the email address ' Got to be something@something ' If no @ or @ at beginning or end, fail validation b = instr(email, "@") if b <= 1 or b = len(email) then Validate_Data = false exit function end if cmdrname = ucase(cmdrname) regkey = ucase(regkey) ' response.write(cmdrname + "
") ' response.write(regkey + "
") alpha = "LJEWOSRZBFCUTGXYHVIPDNMAQK" k = asc(regkey) - 65 d = "" for a = 1 to len(regkey) - 2 b = instr(alpha, mid(regkey, a + 1, 1)) - 1 if b = -1 then Validate_Data = false exit function end if b = b - a - k while b < 0 b = b + 26 wend ' response.write(b & ",") if a < 18 then d = d + chr(b + 48) else d = d + chr(b + 65) next crc = 0 for a = 1 to len(d) crc = crc + asc(mid(d, a, 1)) next crc = crc mod 26 if chr(crc + 65) <> right(regkey, 1) then Validate_Data = false exit function end if regkey = left(regkey, len(regkey) - 1) ' Knock off CRC if not isnumeric(kills) then Validate_Data = false exit function end if sc = right("00000" + cstr(cint(kills)), 5) ' response.write(sc + "
") if len(regkey) < 13 + 5 + len(cmdrname) then Validate_Data = false exit function end if ' response.write(d + "
") ' response.write(sc & cmdrname + "
") if mid(d, 13) = sc & cmdrname then Validate_Data = true tim = mid(d, 3, 2) + "/" + mid(d, 5, 2) + "/" + mid(d, 1, 2) + " " + mid(d, 7, 2) + ":" + mid(d, 9, 2) + ":" + mid(d, 11, 2) else Validate_Data = false end if end function intPageSize = 20 'If this is the first time the page is displayed then the score record position is set to page 1 If Request.QueryString("PagePosition") = "" Then intRecordPositionPageNum = 1 'Else the page has been displayed before so the score record postion is set to the Record Position number Else intRecordPositionPageNum = CInt(Request.QueryString("PagePosition")) End If set conn = Server.CreateObject("ADODB.Connection") conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:\hshome\g7jjf\eliteppc.com\dbroot\elite_scores.mdb" set rs = server.createobject("ADODB.recordset") set rs_update = server.createobject("ADODB.recordset") cmdrname = request.form("CMDRNAME") kills = request.form("KILLS") email = request.form("EMAIL") regkey = request.form("REGKEY") if regkey <> "" and cmdrname <> "" and kills <> "" and email <> "" then data_ok = Validate_Data(cmdrname, kills, email, regkey) if data_ok = false then response.write("

Invalid Registration Data Entered !

") else response.write("

Score Registered Successfully !

") sql = "select * from scores where email = '" & email & "' and commander = '" & cmdrname & "'" ' response.write(sql + "
") rs.Open sql,conn,3,3 rc = rs.recordcount ' response.write(rc & "
") if rc = 1 then sql = "update scores set kills = " & kills & ", SCOREDATE = #" & tim & "# WHERE COMMANDER = '" & cmdrname & "' AND email ='" & email & "' " else sql = "insert into scores values ('" + cmdrname + "', " & kills & ", #" & tim & "#, '" & email & "', 0)" end if ' response.write(sql + "
") conn.execute sql rs.close sql = " SELECT COMMANDER, KILLS, SCOREDATE, EMAIL FROM SCORES" & _ " ORDER BY KILLS DESC, SCOREDATE ASC" rs.Open sql,conn,3,3 rc = 1 while not rs.eof sql = " update Scores " & _ " set Position = " & rc & _ " where Commander = '" + rs(0) + "' AND " & _ " Kills = " & rs(1) & " AND " &_ " email = '" & rs(3) & "' AND " &_ " ScoreDate = #" & rs(2) & "#" ' response.Write(sql+"
") rs_update.open sql,conn,3,3 rc = rc + 1 rs.MoveNext 'Loop back round wend rs.close end if end if cmdr = request.form("CMDR") if cmdr = "" then cmdr = "%" sql = " SELECT POSITION, COMMANDER, KILLS, SCOREDATE FROM SCORES" & _ " WHERE COMMANDER LIKE '" & cmdr & "' ORDER BY KILLS DESC, SCOREDATE ASC" 'Set the cursor type property of the record set to dynamic so we can naviagate through the record set rs.CursorType = 3 ' rs.Open sql,conn,3,3 rs.Open sql,conn 'Set the number of records to display on each page rs.PageSize = intPageSize 'Get the record poistion to display from If NOT rs.EOF Then rs.AbsolutePage = intRecordPositionPageNum end if function rating(score) if score >= 0 and score < &H8 then rating = "Harmless" if score >= &H8 and score < &H10 then rating = "Mostly Harmless" if score >= &H10 and score < &H20 then rating = "Poor" if score >= &H20 and score < &H40 then rating = "Average" if score >= &H40 and score < &H80 then rating = "Above Average" if score >= &H80 and score < &H200 then rating = "Competent" if score >= &H200 and score < &HA00 then rating = "Dangerous" if score >= &HA00 and score < &H1900 then rating = "Deadly" if score >= &H1900 then rating = "---- E L I T E ---" end function tcol = TelCol ccol = cellCol 'Count the number of enties in the database intTotalNumEntries = rs.RecordCount 'Count the number of pages there are in the database calculated by the PageSize attribute set above intTotalNumPages = rs.PageCount 'Display the HTML number number the total number of pages and total number of records in the database %> There are <% = intTotalNumEntries %> entries in <% = intTotalNumPages %> pages and you are on page number <% = intRecordPositionPageNum %>
<% rc = (intRecordPositionPageNum - 1) * intPageSize + 1 'For....Next Loop to display records from the guestbook database For intRecordLoopCounter = 0 to intPageSize - 1 'If there are no guestbook records left to display then exit loop If rs.EOF Then Exit For dat = cstr(day(rs(3))) & "/" & cstr(month(rs(3))) & "/" & right(year(rs(3)), 2) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) Response.Write( "" + chr(13) + chr(10)) rc = rc + 1 'Move to the next record in the database rs.MoveNext 'Loop back round Next Response.Write( "
Position Commander Kills Rating Date
" + cstr(rs(0)) + "" + cstr(rs(1)) + "" + cstr(rs(2)) + "" + rating(cint(rs(2))) + "" + dat + "
 
" + chr(13) + chr(10)) 'If there are more pages to display then add a title to the other pages If intRecordPositionPageNum > 1 or NOT rs.EOF Then Response.Write vbCrLf & "Page:  " End If 'If the page number is higher than page 1 then display a back link If intRecordPositionPageNum > 1 Then Response.Write vbCrLf & ("<< Prev") End If 'If there are more pages to display then display links to all the pages If intRecordPositionPageNum > 1 or NOT rs.EOF Then 'Display a link for each page in the guestbook For intLinkPageNum = 1 to intTotalNumPages 'If there is more than 7 pages display ... last page and exit the loop If intLinkPageNum > 15 Then If intTotalNumPages = intRecordPositionPageNum Then Response.Write(" ..." & intTotalNumPages) Else Response.Write(" ..." & intTotalNumPages & "") 'Exit Loop Exit For 'Else display the normal link code Else 'If the page to be linked to is the page displayed then don't make it a hyper-link If intLinkPageNum = intRecordPositionPageNum Then Response.Write(" " & intLinkPageNum) Else Response.Write(" " & intLinkPageNum & "") End If Next End If 'If it is Not the End of the guestbook entries then display a next link for the next guestbook page If NOT rs.EOF then Response.Write (" Next >>") End If 'Finsh HTML the table %>
<% rs.close Conn.Close %>
Enter Commander Name
Register Your Score
Score Key
Commander Name
Kills
e-mail
Game Ships Manual Novella Support Forum Credits Links

Pocket PC Elite
Created by Jon Welch & George Hooper

Website © 2003 by Jon Welch          Website design by Hooplah Productions