diff --git a/plugins/webstats/index.html b/plugins/webstats/index.html index 0c63aba5e..6aae1392b 100755 --- a/plugins/webstats/index.html +++ b/plugins/webstats/index.html @@ -4,6 +4,10 @@ margin: 15px 0; } +.cur { + background-color: #20a53a; + color: #fff; +} .ws_setting .ws_title { display: inline-block; diff --git a/plugins/webstats/info.json b/plugins/webstats/info.json index 69f2fa3e7..592585744 100755 --- a/plugins/webstats/info.json +++ b/plugins/webstats/info.json @@ -2,7 +2,7 @@ "sort": 7, "ps": "【DEV】网站统计报表", "name": "webstats", - "title": "网站统计报表", + "title": "网站统计报表[此插件开发完成后,需要反馈问题,不当小白鼠,慎用!]", "shell": "install.sh", "versions":["0.0.1"], "tip": "soft", diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js index f0a81b20f..9eb7e872e 100644 --- a/plugins/webstats/js/stats.js +++ b/plugins/webstats/js/stats.js @@ -277,10 +277,10 @@ function wsSitesLog(){ var data = rdata.data.data; for(i in data){ list += ''; - list += '' + data[i]['time']+''; + list += '' + getLocalTime(data[i]['time'])+''; list += '' + data[i]['domain'] +''; list += '' + data[i]['ip'] +''; - list += '' + data[i]['body_length'] +''; + list += '' + toSize(data[i]['body_length']) +''; list += '' + data[i]['request_time'] +'ms'; list += '' + data[i]['uri'] +''; list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; diff --git a/plugins/webstats/lua/webstats_log.lua b/plugins/webstats/lua/webstats_log.lua index 298c84672..7a3bece7f 100644 --- a/plugins/webstats/lua/webstats_log.lua +++ b/plugins/webstats/lua/webstats_log.lua @@ -184,6 +184,7 @@ log_by_lua_block { end if "table" == type(data) then + D("get_http_original:"..headers..data) headers = table.concat(headers, data) end end @@ -254,6 +255,53 @@ log_by_lua_block { return unset_server_name end + -- exclude_func start + local function execute_status() + if not config['exclude_status'] then return false end + local the_status = tostring(ngx.status) + for _,v in ipairs(config['exclude_status']) + do + if the_status == v then + return true + end + end + return false + end + + local function exclude_extension() + if not ngx.var.uri then return false end + if not config['exclude_extension'] then return false end + for _,v in ipairs(config['exclude_extension']) + do + if ngx.re.find(ngx.var.uri,"[.]"..v.."$",'ijo') then + return true + end + end + return false + end + + local function exclude_url() + if not ngx.var.uri then return false end + if not config['exclude_url'] then return false end + local the_uri = string.sub(ngx.var.request_uri, 2) + local url_conf = config["exclude_url"] + for i,conf in pairs(url_conf) + do + local mode = conf["mode"] + local url = conf["url"] + if mode == "regular" then + if ngx.re.find(the_uri, url, "ijo") then + return true + end + else + if the_uri == url then + return true + end + end + end + return false + end + -- exclude_func end local function cache_logs() @@ -309,6 +357,12 @@ log_by_lua_block { client_port=client_port } + local request_stat_fields = "req=req+1,length=length+"..body_length + local spider_stat_fields = "x" + local client_stat_fields = "x" + + local stat_fields = request_stat_fields..";"..client_stat_fields..";"..spider_stat_fields + D("stat_fields:"..stat_fields) cache_set(server_name, new_id, "log_kv", json.encode(kv)) end diff --git a/route/static/app/public.js b/route/static/app/public.js index 643a9edd5..fb793c68f 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -166,6 +166,30 @@ function getLocalTime(a) { return new Date(parseInt(a) * 1000).format("yyyy/MM/dd hh:mm:ss") } +function getFormatTime(tm, format) { + if (format == undefined) format = "yyyy/MM/dd hh:mm:ss"; + tm = tm.toString(); + if (tm.length > 10) { + tm = tm.substring(0, 10); + } + var data = new Date(parseInt(tm) * 1000); + var o = { + "M+": data.getMonth() + 1, //month + "d+": data.getDate(), //day + "h+": data.getHours(), //hour + "m+": data.getMinutes(), //minute + "s+": data.getSeconds(), //second + "q+": Math.floor((data.getMonth() + 3) / 3), //quarter + "S": data.getMilliseconds() //millisecond + } + if (/(y+)/.test(format)) format = format.replace(RegExp.$1, + (data.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(format)) + format = format.replace(RegExp.$1,RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); + return format; +} + function changePath(d) { setCookie('SetId', d);