From ab9fc59c13051f1dde12dba21653471c33838135 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 5 May 2019 22:01:40 +0800 Subject: [PATCH] up --- plugins/op_waf/index.py | 30 ++++++++++++++++++++++++++++++ plugins/op_waf/js/op_waf.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index 9d2fe8dbe..2bf09a01c 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -286,6 +286,34 @@ def getRule(): return public.returnJson(True, 'ok', content) +def addRule(): + args = getArgs() + data = checkArgs(args, ['ruleName', 'ruleValue', 'ps']) + if not data[0]: + return data[1] + + ruleValue = args['ruleValue'] + ruleName = args['ruleName'] + ps = args['ps'] + + fpath = getRuleJsonPath(ruleName) + content = public.readFile(fpath) + content = json.loads(content) + + tmp_k = [] + tmp_k.append(1) + tmp_k.append(ruleValue) + tmp_k.append(ps) + tmp_k.append(1) + + content.append(tmp_k) + + cjson = public.getJson(content) + public.writeFile(fpath, cjson) + + return public.returnJson(True, '设置成功!', content) + + def modifyRule(): args = getArgs() data = checkArgs(args, ['index', 'ruleName', 'ruleBody', 'rulePs']) @@ -817,6 +845,8 @@ if __name__ == "__main__": print getConf() elif func == 'get_rule': print getRule() + elif func == 'add_rule': + print addRule() elif func == 'modify_rule': print modifyRule() elif func == 'get_site_rule': diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js index 648da67b7..4c05fe5da 100755 --- a/plugins/op_waf/js/op_waf.js +++ b/plugins/op_waf/js/op_waf.js @@ -234,6 +234,32 @@ function saveRetry(siteName,type) { }); } +function addRule(ruleName) { + var pdata = { + 'ruleValue': $("input[name='ruleValue']").val(), + 'ps': $("input[name='rulePs']").val(), + 'ruleName': ruleName + } + + owPost('add_rule', pdata, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + if (rdata.status) { + setTimeout(function(){ + setObjConf(ruleName, 1); + },1000); + } + }); + + // var loadT = layer.msg('正在添加,请稍候..', { icon: 16, time: 0 }); + // $.post('/plugin?action=a&name=btwaf&s=add_rule', pdata, function (rdata) { + // layer.close(loadT); + // layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + // if (rdata.status) { + // set_obj_conf(ruleName, 1); + // } + // }); +} function modifyRule(index, ruleName) { var ruleValue = $('.rule_body_' + index).text(); @@ -255,7 +281,7 @@ function modifyRuleSave(index, ruleName) { ruleBody: $("textarea[name='rule_body_" + index + "']").val(), rulePs: $("input[name='rule_ps_" + index + "']").val() } - + owPost('modify_rule', pdata, function(data){ var rdata = $.parseJSON(data.data); @@ -282,7 +308,7 @@ function setObjConf(ruleName, type) {
\ \ \ - \
\ + \\
\
\ \