default.asp
<html>
<head>
<title>星河影動之磁碟序號加密代碼存取管理</title>
</head>
<% dim conn,fs,f
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};uid=;pwd=3302;dbq="&server.mappath("id.mdb")
set fs=server.createObject("scripting.filesystemobject")
testDrive=Server.MapPath("/DRIVEINFO.ASP")
' 通過MapPath獲得當前盤盤符.
testDrive=Left(testDrive,3)
set f=fs.getdrive(testDrive)
' 調用GetDrive方法賦予磁碟機一個變數.
Mysql="select * From driveinfo where id=1"
set rsCheck = Server.CreateObject("ADODB.Recordset")
rsCheck.open Mysql,conn,1,1
FSER=trim(f.serialnumber)
' 獲得當前盤序號.
StrSerno=trim(rsCheck.fields("SERNO"))
StrMark=rsCheck.fields("WRIMARK")
' Wrimark值為0表示代表合法使用者未安裝系統,值為1代表該系統已安裝.值為1且序號與當前盤不符時,則判定為非法複製使用者
if StrSerno<>FSER and StrMark=0 then
' 如是第一次安裝,則設定寫盤標誌為1.
session("pass")=true
' 定義使用者Session,並設定為全域ASP文檔標識變數.
set rsMain = Server.CreateObject("ADODB.Recordset")
Mysql1="update driveinfo SET SERNO="&FSER&", WRIMARK=1"
rsMain.open Mysql1,conn,1,2
response.write("<a href='success.asp'>安裝成功!歡迎光臨隨風起舞存取網站!</a>"=
set rsMain=nothing
else
if StrSerno=FSER then
' 合法使用者可再次進入.
session("pass")=true
response.write("<a href='success.asp'>再次歡迎!您已被隨風起舞授權,允許進行存取...</a>"=
else
' 非法複製使用者.
session("pass")=false
response.write("<a href='fail.htm'>IT IS ILLEGAL TO COPY THE WEBSITE'S ASP DOCUMENT. YOU ARE NOT RIGRT TO USE THE PROGRAM.</a>"=
end if
end if
set f=nothing
set fs=nothing
%>
</html>