网站统计 xx2

This commit is contained in:
midoks 2022-07-21 00:41:02 +08:00
parent ca54f4b70b
commit fb18ecb324
5 changed files with 85 additions and 3 deletions

View File

@ -4,6 +4,10 @@
margin: 15px 0;
}
.cur {
background-color: #20a53a;
color: #fff;
}
.ws_setting .ws_title {
display: inline-block;

View File

@ -2,7 +2,7 @@
"sort": 7,
"ps": "【DEV】网站统计报表",
"name": "webstats",
"title": "网站统计报表",
"title": "网站统计报表[此插件开发完成后,需要反馈问题,不当小白鼠,慎用!]",
"shell": "install.sh",
"versions":["0.0.1"],
"tip": "soft",

View File

@ -277,10 +277,10 @@ function wsSitesLog(){
var data = rdata.data.data;
for(i in data){
list += '<tr>';
list += '<td>' + data[i]['time']+'</td>';
list += '<td>' + getLocalTime(data[i]['time'])+'</td>';
list += '<td>' + data[i]['domain'] +'</td>';
list += '<td>' + data[i]['ip'] +'</td>';
list += '<td>' + data[i]['body_length'] +'</td>';
list += '<td>' + toSize(data[i]['body_length']) +'</td>';
list += '<td>' + data[i]['request_time'] +'ms</td>';
list += '<td>' + data[i]['uri'] +'</td>';
list += '<td>' + data[i]['status_code']+'/' + data[i]['method'] +'</td>';

View File

@ -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

View File

@ -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);