local cjson = require("cjson")
local cjson_safe = require("cjson.safe")
local logger = require("logger")
local uuid4= require("uuid4")
local args = {}
local request_method = ngx.var.request_method
function string.split(str, delimiter)
if str==nil or str=='' or delimiter==nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
function string.trim (s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
function getUAField(t)
local separator=';'
local tab={}
local android=string.find(t,"Android")
local iphone=string.find(t,"Mac")
local windows=string.find(t,"Windows")
--android手机
if android then
tab["platform"]="android"
-- tab["number"]=android
tab["ismobiledevice"]="true"
local startIndex =string.find(t,"Build")
if startIndex then
local res=string.sub(t,0,startIndex-1)
local rtable=string.split(res,separator)
local devicename=string.trim(rtable[#rtable])
local name=string.find(t,"XiaoMi")
if name then
local name1 = string.sub(t,name,name+6)
tab["number"]=name
if devicename~=nil then
tab["devicename"]=name1 .. "/" .. devicename
end
else
if devicename~=nil then
tab["devicename"]=devicename
end
end
end
local osvTable=string.split(string.sub(t,android) ,separator)
if osvTable then
local osvTab