本示例使用的设备:RFID网络WIFI无线TCP/UDP/HTTP可编程二次开发读卡器POE供电语音-淘宝网 (taobao.com)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%
Function bin2str(bindata)Dim rsStream, strlsSet rsStream = Server.CreateObject("ADODB.Stream")rsStream.Type = 2rsStream.OpenrsStream.WriteText bindatarsStream.Position = 0rsStream.Charset = "utf-8" rsStream.Position = 2strls = rsStream.ReadTextrsStream.CloseSet rsStream = Nothingbin2str = strls
End FunctionFunction getpostval(totalstr, namestr)Dim p1, p2, k, strlsk = Len(namestr) + 2strls = "&" + totalstr + "&"p1 = InStr(strls, "&" + namestr + "=")If p1 = 0 Thengetpostval = ""Exit FunctionEnd Ifp2 = InStr(p1 + k, strls, "&")If p2 > (p1 + k) Thengetpostval = Mid(strls, p1 + k, p2 - (p1 + k))Elsegetpostval = ""End If
End FunctionFunction getjsonval(totalstr, namestr)Dim p1, p2, k, n, strlsn = Len(totalstr)If n < 5 Thengetjsonval = ""Exit FunctionEnd IfIf (Left(totalstr, 1) <> "{") Or (Right(totalstr, 1) <> "}") Thengetjsonval = ""Exit FunctionEnd Ifstrls = "," + Mid(totalstr, 2, n - 2) + ","k = Len(namestr) + 4p1 = InStr(strls, ",""" + namestr + """:")If p1 < 1 Thengetjsonval = ""Exit FunctionEnd Ifp2 = InStr(p1 + k, strls, ",")If p2 > (p1 + k) Thengetjsonval = Mid(strls, p1 + k, p2 - (p1 + k))If (Left(getjsonval, 1) <> """") Or (Right(getjsonval, 1) <> """") Thengetjsonval = ""Exit FunctionEnd Ifn = Len(getjsonval)If n < 3 Thengetjsonval = ""Exit FunctionEnd Ifgetjsonval = Mid(getjsonval, 2, n - 2)Elsegetjsonval = ""End If
End Function'Parse Get information------------------------------------------------------------
info = Request.QueryString("info") 'Information frame
jihao = Request.QueryString("jihao") 'Equipment number(can modify)
caretype = Request.QueryString("cardtype") 'The card type can be IC, ID, or ISO15693
card = Request.QueryString("card") 'Hexadecimal card printing number
Data = Request.QueryString("data") 'Card sector data
dn = Request.QueryString("dn") 'Hardware serial number of equipment, factory has been cured, unique in the world
Status = Request.QueryString("status") 'Read card status. For example, the password authentication failure is 12If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) Then Str = "Response=" 'Fixed prefix that our device uses to retrieve the return informationStr = Str + "1," 'Information type: 1 indicates the display and sound of the driving deviceStr = Str + info 'Information frame Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" 'LCD display infomationStr = Str + ",20" 'Display delay of 20 secondsStr = Str + ",1" 'Buzzer sound typeStr = Str + ",0" 'Chinese phonetic coderesponse.Write (Str)response.end
Else'Parse POST information**********************************poststrlen = Request.TotalBytes 'lengthIf poststrlen > 0 Then poststr = bin2str(Request.BinaryRead(poststrlen)) info = getpostval(poststr, "info") 'Information framejihao = getpostval(poststr, "jihao") 'Equipment number(can modify)caretype = getpostval(poststr, "cardtype") 'The card type can be IC, ID, or ISO15693card = getpostval(poststr, "card") 'Hexadecimal card printing numberData = getpostval(poststr, "data") 'Card sector datadn = getpostval(poststr, "dn") 'Hardware serial number of equipment, factory has been cured, unique in the worldStatus = getpostval(poststr, "status") 'Read card status. For example, the password authentication failure is 12If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) ThenStr = "Response=" 'Fixed prefix that our device uses to retrieve the return informationStr = Str + "1," 'Information type: 1 indicates the display and sound of the driving deviceStr = Str + info 'Information frame Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" ''LCD display infomationStr = Str + ",20" 'Display delay of 20 secondsStr = Str + ",1" 'Buzzer sound typeStr = Str + ",0" 'Chinese phonetic coderesponse.Write (Str)response.endElse'Parse json information**********************************info = getjsonval(poststr, "info") 'Information framejihao = getjsonval(poststr, "jihao") 'Equipment number(can modify)caretype = getjsonval(poststr, "cardtype") 'The card type can be IC, ID, or ISO15693card = getjsonval(poststr, "card") 'Hexadecimal card printing numberData = getjsonval(poststr, "data") 'Card sector datadn = getjsonval(poststr, "dn") 'Hardware serial number of equipment, factory has been cured, unique in the worldStatus = getjsonval(poststr, "status") 'Read card status. For example, the password authentication failure is 12If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) ThenStr = "Response=" 'Fixed prefix that our device uses to retrieve the return informationStr = Str + "1," 'Information type: 1 indicates the display and sound of the driving deviceStr = Str + info 'Information frame Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" ''LCD display infomationStr = Str + ",20" 'Display delay of 20 secondsStr = Str + ",1" 'Buzzer sound typeStr = Str + ",0" 'Chinese phonetic coderesponse.Write (Str)response.endEnd If End IfEnd If
End If%>