diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index 95ec5f48b..a914b5d48 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -564,6 +564,35 @@ def setObjOpen(): return public.returnJson(True, '设置成功!') +def setSiteObjOpen(): + args = getArgs() + data = checkArgs(args, ['siteName', 'obj']) + if not data[0]: + return data[1] + + siteName = args['siteName'] + obj = args['obj'] + + path = getJsonPath('site') + content = public.readFile(path) + content = json.loads(content) + + if obj in content[siteName]: + if content[siteName][obj]: + content[siteName][obj] = False + else: + content[siteName][obj] = True + else: + if content[siteName][obj]['open']: + content[siteName][obj]['open'] = False + else: + content[siteName][obj]['open'] = True + + cjson = public.getJson(content) + public.writeFile(path, cjson) + return public.returnJson(True, '设置成功!') + + def getWafSrceen(): conf = getJsonPath('total') return public.readFile(conf) @@ -604,6 +633,8 @@ if __name__ == "__main__": print setObjStatus() elif func == 'set_obj_open': print setObjOpen() + elif func == 'set_site_obj_open': + print setSiteObjOpen() elif func == 'set_retry': print setRetry() elif func == 'set_site_retry': diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js index 38b547bef..8843027ad 100755 --- a/plugins/op_waf/js/op_waf.js +++ b/plugins/op_waf/js/op_waf.js @@ -1060,30 +1060,12 @@ function removeSiteRule(siteName, ruleName, index) { site_url_rule(siteName, 1); return; } - + setTimeout(function(){ siteRuleAdmin(siteName, ruleName, 1); },1000); } }); - - // var loadT = layer.msg('正在删除,请稍候..', { icon: 16, time: 0 }); - // $.post('/plugin?action=a&name=btwaf&s=remove_site_rule', pdata, function (rdata) { - // layer.close(loadT); - // layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); - // if (rdata.status) { - // if (ruleName == 'url_tell') { - // site_url_tell(siteName, 1); - // return; - // } - - // if (ruleName == 'url_rule') { - // site_url_rule(siteName, 1); - // return; - // } - // site_rule_admin(siteName, ruleName, 1); - // } - // }); } //网站规则管理 @@ -1243,6 +1225,25 @@ function removeCdnHeader(siteName, cdn_header_key) { }); } +//设置网站防御功能 +function setSiteObjState(siteName, obj) { + // var loadT = layer.msg('正在处理,请稍候..', { icon: 16, time: 0 }); + owPost('set_site_obj_open', { siteName: siteName, obj: obj } , function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + setTimeout(function(){ + siteWafConfig(siteName, 1); + // siteConfig(); + },1000); + }); + // $.post('/plugin?action=a&name=btwaf&s=set_site_obj_open', { siteName: siteName, obj: obj }, function (rdata) { + // layer.close(loadT); + // site_waf_config(siteName, 1); + // siteconfig(); + // layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + // }); +} + //网站规则设置 function setSiteObjConf(siteName, ruleName, type) { @@ -1319,7 +1320,7 @@ function siteWafConfig(siteName, type) { 网站防火墙开关\