首页 > 其他分享 >VbScript脚本Request获取RFID读卡器以HTTP提交的访问文件中的参数Response回应驱动读卡器显示、播报语音

VbScript脚本Request获取RFID读卡器以HTTP提交的访问文件中的参数Response回应驱动读卡器显示、播报语音

时间:2023-10-31 10:31:44浏览次数:27  
标签:info HTTP VbScript getjsonval Str poststr End 读卡器 card


本示例使用的设备:

<%@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

相关文章

  • Tornado实现多线程/多进程的HTTP服务
    用tornadoweb服务的基本流程原文链接1.实现处理请求的Handler,该类继承自tornado.web.RequestHandler,实现用于请求的对应方法如:get,post等。返回内容用self.write方法输出。**2.实例化一个Application。**构造函数的参数是一个Handler列表,通过正则表达式,将请求与Handler对应起来......
  • python爬虫知识体系80页md笔记,0基础到scrapy项目高手,第(2)篇:http协议复习精讲
    本文主要学习一下关于爬虫的相关前置知识和一些理论性的知识,通过本文我们能够知道什么是爬虫,都有那些分类,爬虫能干什么等,同时还会站在爬虫的角度复习一下http协议。完整体系笔记直接地址:请移步这里共8章,37子模块,总计5.6w+字今天这一篇主讲:爬虫基础本阶段本文主要学......
  • XMLHttpRequest拦截请求和响应
    环境:angular实现:拦截请求向请求信息增加字段           拦截响应过滤返回值响应拦截:根据angular使用的XMLHttpRequest将对原本的请求转移到另一个将监听返回事件挂载到另一个世纪发送请求的xml上使用getset将客户端获取的responseText和response按照自己的意......
  • 流畅的Flurl.Http[转]
    流畅的Flurl.Http https://flurl.dev/docs/testable-http/注意:除了URL构建和解析之外的所有内容都需要安装Flurl.Http而不是基本的Flurl包。考虑与HTTP服务交互的一种非常常见的方式是“我想构建一个URL,然后调用它”。Flurl.Http允许您非常简洁地表达:usingFlurl;u......
  • 解决使用 OkHttp 库出现 java.lang.NoSuchMethodError: okhttp3.internal.platform.Pl
    报错:Exceptioninthread"main"java.lang.NoSuchMethodError:okhttp3.internal.platform.Platform.log(ILjava/lang/String;Ljava/lang/Throwable;)Vatokhttp3.logging.HttpLoggingInterceptor$Logger.lambda$static$0(HttpLoggingInterceptor.java:112)......
  • Failed to start The nginx HTTP and reverse proxy server.
    本章教程主要分享一下,当nginx启动时,遇到报这个错误时的一个解决思路。 目录 1、观察报错信息 2、尝试性解决 1、观察报错信息根据日志的信息,我们至少可以知道2个比较关键的信息。1、操作用户执行命令是在非root权限下进行操作的。2、Addressalreadyinuse这个很明显:意思就......
  • 【Asp.net】Asp.net core中IIS配置注意事项一、提示:关于IIS上运行ASP.NET Core 站点的
    1、应用地址池设为无托管代码一、提示:关于IIS上运行ASP.NETCore站点的“HTTP500.19”错误安装dotnet-hosting-3.1.2-win.exeASP.NETCore3.1Runtime(v3.1.2)下载地址:https://download.visualstudio.microsoft.com/download/pr/dd119832-dc46-4ccf-bc12-69e7bfa61b18/990843c6......
  • springMVC controller控制器方法HttpServletRequest等参数的是谁传递进来的
    SpringMVC中两个重要的接口:请求方法参数的处理、响应返回值的处理,分别是HandlerMethodArgumentResolver和HandlerMethodReturnValueHandlerHandlerMethodArgumentResolver的实现类 ServletRequestMethodArgumentResolver 参数类型是实现或继承或是WebRequest、ServletRequest......
  • https://gitlab.com/volian/nala/-/wikis/Installation
    Installation DebianTesting/SidNalaisofficiallyinthetestingandsidrepos.sudoaptinstallnalaVolianScarAlternativelyyoucanusethe VolianScar repo.UpdatesfromthisrepoareslightlyfasterthantheDebianrepos,butusuallyonlyabo......
  • HTTP与HTTPS的区别
    一、HTTP与HTTPS的区别:HTTP是超文本传输协议,信息是明文传输,存在安全风险的问题。HTTPS则解决HTTP不安全的缺陷,在TCP和HTTP网络层之间加入了SSL/TLS安全协议,使得报文能够加密传输。HTTP连接建立相对简单,TCP三次握手之后便可进行HTTP的报文传输。而HTTPS在T......