本示例使用的设备:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Function bin2str(bindata)
Dim rsStream, strls
Set rsStream = Server.CreateObject("ADODB.Stream")
rsStream.Type = 2
rsStream.Open
rsStream.WriteText bindata
rsStream.Position = 0
rsStream.Charset = "utf-8"
rsStream.Position = 2
strls = rsStream.ReadText
rsStream.Close
Set rsStream = Nothing
bin2str = strls
End Function
Function getpostval(totalstr, namestr)
Dim p1, p2, k, strls
k = Len(namestr) + 2
strls = "&" + totalstr + "&"
p1 = InStr(strls, "&" + namestr + "=")
If p1 = 0 Then
getpostval = ""
Exit Function
End If
p2 = InStr(p1 + k, strls, "&")
If p2 > (p1 + k) Then
getpostval = Mid(strls, p1 + k, p2 - (p1 + k))
Else
getpostval = ""
End If
End Function
Function getjsonval(totalstr, namestr)
Dim p1, p2, k, n, strls
n = Len(totalstr)
If n < 5 Then
getjsonval = ""
Exit Function
End If
If (Left(totalstr, 1) <> "{") Or (Right(totalstr, 1) <> "}") Then
getjsonval = ""
Exit Function
End If
strls = "," + Mid(totalstr, 2, n - 2) + ","
k = Len(namestr) + 4
p1 = InStr(strls, ",""" + namestr + """:")
If p1 < 1 Then
getjsonval = ""
Exit Function
End If
p2 = InStr(p1 + k, strls, ",")
If p2 > (p1 + k) Then
getjsonval = Mid(strls, p1 + k, p2 - (p1 + k))
If (Left(getjsonval, 1) <> """") Or (Right(getjsonval, 1) <> """") Then
getjsonval = ""
Exit Function
End If
n = Len(getjsonval)
If n < 3 Then
getjsonval = ""
Exit Function
End If
getjsonval = Mid(getjsonval, 2, n - 2)
Else
getjsonval = ""
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 12
If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) Then
Str = "Response=" 'Fixed prefix that our device uses to retrieve the return information
Str = Str + "1," 'Information type: 1 indicates the display and sound of the driving device
Str = Str + info 'Information frame
Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" 'LCD display infomation
Str = Str + ",20" 'Display delay of 20 seconds
Str = Str + ",1" 'Buzzer sound type
Str = Str + ",0" 'Chinese phonetic code
response.Write (Str)
response.end
Else
'Parse POST information**********************************
poststrlen = Request.TotalBytes 'length
If poststrlen > 0 Then
poststr = bin2str(Request.BinaryRead(poststrlen))
info = getpostval(poststr, "info") 'Information frame
jihao = getpostval(poststr, "jihao") 'Equipment number(can modify)
caretype = getpostval(poststr, "cardtype") 'The card type can be IC, ID, or ISO15693
card = getpostval(poststr, "card") 'Hexadecimal card printing number
Data = getpostval(poststr, "data") 'Card sector data
dn = getpostval(poststr, "dn") 'Hardware serial number of equipment, factory has been cured, unique in the world
Status = getpostval(poststr, "status") 'Read card status. For example, the password authentication failure is 12
If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) Then
Str = "Response=" 'Fixed prefix that our device uses to retrieve the return information
Str = Str + "1," 'Information type: 1 indicates the display and sound of the driving device
Str = Str + info 'Information frame
Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" ''LCD display infomation
Str = Str + ",20" 'Display delay of 20 seconds
Str = Str + ",1" 'Buzzer sound type
Str = Str + ",0" 'Chinese phonetic code
response.Write (Str)
response.end
Else
'Parse json information**********************************
info = getjsonval(poststr, "info") 'Information frame
jihao = getjsonval(poststr, "jihao") 'Equipment number(can modify)
caretype = getjsonval(poststr, "cardtype") 'The card type can be IC, ID, or ISO15693
card = getjsonval(poststr, "card") 'Hexadecimal card printing number
Data = getjsonval(poststr, "data") 'Card sector data
dn = getjsonval(poststr, "dn") 'Hardware serial number of equipment, factory has been cured, unique in the world
Status = getjsonval(poststr, "status") 'Read card status. For example, the password authentication failure is 12
If ((info <> "") And (jihao <> "") And (caretype <> "") And (card <> "")) Then
Str = "Response=" 'Fixed prefix that our device uses to retrieve the return information
Str = Str + "1," 'Information type: 1 indicates the display and sound of the driving device
Str = Str + info 'Information frame
Str = Str + ",{CardNo:}" + card + "\nWelcome to user !" ''LCD display infomation
Str = Str + ",20" 'Display delay of 20 seconds
Str = Str + ",1" 'Buzzer sound type
Str = Str + ",0" 'Chinese phonetic code
response.Write (Str)
response.end
End If
End If
End If
End If
%>
标签:info,HTTP,VbScript,getjsonval,Str,poststr,End,读卡器,card
From: https://blog.51cto.com/RongShi/8102220