diff --git a/class/core/db.py b/class/core/db.py
index 5a92a33f9..104ff5ab5 100755
--- a/class/core/db.py
+++ b/class/core/db.py
@@ -42,8 +42,13 @@ class Sql():
self.__DB_CONN = sqlite3.connect(self.__DB_FILE)
self.__DB_CONN.text_factory = str
except Exception as ex:
+ # print(mw.getTracebackInfo())
return "error: " + str(ex)
+ def changeTextFactoryToBytes(self):
+ self.__DB_CONN.text_factory = bytes
+ return True
+
def autoTextFactory(self):
if sys.version_info[0] == 3:
self.__DB_CONN.text_factory = lambda x: str(
diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py
index 173afed20..674dcd53d 100755
--- a/plugins/webstats/index.py
+++ b/plugins/webstats/index.py
@@ -791,7 +791,23 @@ def getLogsList():
attacHistoryLogHack(conn, domain, query_date)
+ conn.changeTextFactoryToBytes()
clist = conn.limit(limit).order('time desc').inquiry()
+
+ for x in range(len(clist)):
+ req_line = clist[x]
+ for cx in req_line:
+ v = req_line[cx]
+ if type(v) == bytes:
+ try:
+ clist[x][cx] = v.decode('utf-8')
+ except Exception as e:
+ v = str(v)
+ v = v.replace("b'",'').strip("'")
+ clist[x][cx] = v
+ else:
+ clist[x][cx] = v
+
# print(clist)
count_key = "count(*) as num"
count = conn.field(count_key).limit('').order('').inquiry()
diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js
index bc0032aff..35635fceb 100644
--- a/plugins/webstats/js/stats.js
+++ b/plugins/webstats/js/stats.js
@@ -2257,11 +2257,13 @@ function wsTableLogRequest(page){
}
$('#logs_search').attr('req','start');
+ // wsPost('get_logs_list', '' ,args, function(rdata){
wsPostCallbak('get_logs_list', '' ,args, function(rdata){
$('#logs_search').attr('req','end');
var rdata = $.parseJSON(rdata.data);
var list = '';
var data = rdata.data.data;
+ console.log(data);
if (data.length > 0){
for(i in data){
@@ -2346,20 +2348,23 @@ function wsTableLogRequest(page){
var index = $(this).attr('data-id');
var res = data[index];
var request_headers = res.request_headers;
- var req_data = $.parseJSON(request_headers);
var req_data_html = res.method +' ' + res.uri + '
';
- for (var d in req_data) {
- if (d == 'payload'){
- req_data_html += ''+d +":"+req_data[d]+"
";
- } else{
- req_data_html += d+":"+req_data[d]+"
";
+ try {
+ var req_data = $.parseJSON(request_headers);
+ for (var d in req_data) {
+ if (d == 'payload'){
+ req_data_html += ''+d +":"+req_data[d]+"
";
+ } else{
+ req_data_html += d+":"+req_data[d]+"
";
+ }
}
-
-
+ } catch (error) {
+ req_data_html += request_headers;
}
+
layer.open({
type: 1,
title: "【"+res.domain + "】HTTP详情",
diff --git a/plugins/webstats/webstats_index.py b/plugins/webstats/webstats_index.py
index 54cf4cfce..f6cc0734a 100644
--- a/plugins/webstats/webstats_index.py
+++ b/plugins/webstats/webstats_index.py
@@ -791,8 +791,22 @@ def get_logs_list(args):
attacHistoryLogHack(conn, domain, query_date)
+ conn.changeTextFactoryToBytes()
clist = conn.limit(limit).order('time desc').inquiry()
- # print(clist)
+ for x in range(len(clist)):
+ req_line = clist[x]
+ for cx in req_line:
+ v = req_line[cx]
+ if type(v) == bytes:
+ try:
+ clist[x][cx] = v.decode('utf-8')
+ except Exception as e:
+ v = str(v)
+ v = v.replace("b'",'').strip("'")
+ clist[x][cx] = v
+ else:
+ clist[x][cx] = v
+
count_key = "count(*) as num"
count = conn.field(count_key).limit('').order('').inquiry()
# print(count)