diff --git a/plugins/webstats/index.html b/plugins/webstats/index.html
index 34784649a..ac0e0d30d 100755
--- a/plugins/webstats/index.html
+++ b/plugins/webstats/index.html
@@ -3,7 +3,7 @@
\ No newline at end of file
diff --git a/plugins/webstats/js/setting.js b/plugins/webstats/js/setting.js
new file mode 100644
index 000000000..ee1415ccb
--- /dev/null
+++ b/plugins/webstats/js/setting.js
@@ -0,0 +1,4 @@
+
+function wsGlobalSetting(){
+
+}
\ No newline at end of file
diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js
index e69de29bb..ecb056a6a 100644
--- a/plugins/webstats/js/stats.js
+++ b/plugins/webstats/js/stats.js
@@ -0,0 +1,64 @@
+function str2Obj(str){
+ var data = {};
+ kv = str.split('&');
+ for(i in kv){
+ v = kv[i].split('=');
+ data[v[0]] = v[1];
+ }
+ return data;
+}
+
+function wsPost(method, version, args,callback){
+ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
+
+ var req_data = {};
+ req_data['name'] = 'webstats';
+ req_data['func'] = method;
+ req_data['version'] = version;
+
+ if (typeof(args) == 'string'){
+ req_data['args'] = JSON.stringify(str2Obj(args));
+ } else {
+ req_data['args'] = JSON.stringify(args);
+ }
+
+ $.post('/plugins/run', req_data, function(data) {
+ layer.close(loadT);
+ if (!data.status){
+ //错误展示10S
+ layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']});
+ return;
+ }
+
+ if(typeof(callback) == 'function'){
+ callback(data);
+ }
+ },'json');
+}
+
+function wsPostCallbak(method, version, args,callback){
+ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
+
+ var req_data = {};
+ req_data['name'] = 'webstats';
+ req_data['func'] = method;
+ args['version'] = version;
+
+ if (typeof(args) == 'string'){
+ req_data['args'] = JSON.stringify(str2Obj(args));
+ } else {
+ req_data['args'] = JSON.stringify(args);
+ }
+
+ $.post('/plugins/callback', req_data, function(data) {
+ layer.close(loadT);
+ if (!data.status){
+ layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
+ return;
+ }
+
+ if(typeof(callback) == 'function'){
+ callback(data);
+ }
+ },'json');
+}
\ No newline at end of file
diff --git a/plugins/webstats/lua/web_stats_log.lua b/plugins/webstats/lua/web_stats_log.lua
index f6410a7e7..0dd5e1085 100644
--- a/plugins/webstats/lua/web_stats_log.lua
+++ b/plugins/webstats/lua/web_stats_log.lua
@@ -12,11 +12,7 @@ log_by_lua_block {
package.path = cpath .. "?.lua;" .. package.path
end
- local server_name,ip,today,day,body_length,method,config,cache_count
-
- local db = nil
- local cache = ngx.shared.mw_total
-
+ -- debug func
local function D(msg)
if not debug_mode then return true end
local fp = io.open('{$SERVER_APP}/debug.log', 'ab')
@@ -35,6 +31,33 @@ log_by_lua_block {
end
+ -- cache start ---
+ local cache = ngx.shared.mw_total
+ local function cache_set(server_name, id ,key, val)
+ local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
+ cache:set(line_kv, val)
+ end
+
+ local function cache_clear(server_name, id, key)
+ local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
+ cache:delete(line_kv)
+ end
+
+ local function cache_get(server_name, id, key)
+ local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
+ local value = cache:get(line_kv)
+ return value
+ end
+ -- cache end ---
+
+ -- domain config is import
+ local server_name
+
+ local ip,today,day,body_length,method,config,cache_count
+ local db = nil
+
+
+
local function run_app()
D("debug start")