From a5d4d538837ff22cc34fd33203102c8a646913ba Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 13 Aug 2022 22:30:30 +0800 Subject: [PATCH] =?UTF-8?q?waf=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/op_waf/waf/lua/init.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/plugins/op_waf/waf/lua/init.lua b/plugins/op_waf/waf/lua/init.lua index c9d079881..f4311e7d9 100644 --- a/plugins/op_waf/waf/lua/init.lua +++ b/plugins/op_waf/waf/lua/init.lua @@ -12,6 +12,37 @@ config = C:read_file_body_decode(cpath .. 'config.json') local site_config = C:read_file_body_decode(cpath .. 'site.json') C:setConfData(config, site_config) +-- D func +local function D(msg) + local _msg = '' + if type(msg) == 'table' then + for key, val in pairs(msg) do + _msg = key..':'..val.."\n" + end + elseif type(msg) == 'string' then + _msg = msg + elseif type(msg) == 'nil' then + _msg = 'nil' + else + _msg = msg + end + + if not debug_mode then return true end + local fp = io.open(cpath..'debug.log', 'ab') + if fp == nil then + return nil + end + local localtime = os.date("%Y-%m-%d %H:%M:%S") + if server_name then + fp:write(tostring(_msg) .. "\n") + else + fp:write(localtime..":"..tostring(_msg) .. "\n") + end + fp:flush() + fp:close() + return true +end + function initParams() local data = {} data['ip'] = C:get_client_ip() @@ -314,6 +345,7 @@ end function post_data_chekc() if params['method'] =="POST" then if C:return_post_data() then return false end + ngx.req.read_body() request_args = ngx.req.get_post_args() if not request_args then return false end