Add parameter to do strToBytes in BlockTable and fix some errors with string and int

This commit is contained in:
2020-12-11 09:18:50 +01:00
parent 3ed8ba40be
commit a6f8c71bf2
7 changed files with 42 additions and 52 deletions

View File

@@ -67,7 +67,7 @@ class IWLADisplayAllVisits(IPlugin):
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Last seen'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Last seen'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')], [3])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
for super_hit in last_access:
@@ -80,7 +80,7 @@ class IWLADisplayAllVisits(IPlugin):
address,
super_hit['viewed_pages'][0],
super_hit['viewed_hits'][0],
bytesToStr(super_hit['bandwidth'][0]),
super_hit['bandwidth'][0],
time.asctime(super_hit['last_access'])
]
table.appendRow(row)

View File

@@ -152,7 +152,7 @@ class IWLADisplayFilterUsers(IPlugin):
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Filtered users'), [self.iwla._(u'Pages'), self.iwla._(u'Last Access')])
table.setColsCSSClass(['iwla_page', ''])
for filtered_user in self.filtered_users:
ip = filtered_user['remote_addr']
ip = filtered_user['remote_ip']
if 'dns_name_replaced' in hits[ip].keys():
ip_title = '<b>%s [%s]</b>' % (hits[ip]['remote_addr'], ip)
else:
@@ -188,7 +188,7 @@ class IWLADisplayFilterUsers(IPlugin):
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Last Access'), self.iwla._(u'Pages'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', '', 'iwla_page', 'iwla_hit'])
for filtered_user in self.filtered_users:
ip = filtered_user['remote_addr']
ip = filtered_user['remote_ip']
if 'dns_name_replaced' in hits[ip].keys():
ip_title = '%s [%s]' % (hits[ip]['remote_addr'], ip)
else:

View File

@@ -70,19 +70,19 @@ class IWLADisplayHoursStats(IPlugin):
# By Day
title = self.iwla._(u'By day')
days = [self.iwla._('Mon'), self.iwla._('Tue'), self.iwla._('Wed'), self.iwla._('Thu'), self.iwla._('Fri'), self.iwla._('Sat'), self.iwla._('Sun')]
table = display.createBlock(DisplayHTMLBlockTableWithGraph, title, [self.iwla._('Day'), self.iwla._('Pages'), self.iwla._('Hits'), self.iwla._('Bandwidth')], days, 7, range(1,4))
table = display.createBlock(DisplayHTMLBlockTableWithGraph, title, [self.iwla._('Day'), self.iwla._('Pages'), self.iwla._('Hits'), self.iwla._('Bandwidth')], days, 7, range(1,4), [3])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth'])
for i in range(0,7):
table.appendRow([days[i], days_stats[i]['pages'], days_stats[i]['hits'], days_stats[i]['bandwidth']])
table.setCellValue(i, 3, bytesToStr(days_stats[i]['bandwidth']))
table.setCellValue(i, 3, days_stats[i]['bandwidth'])
index.appendBlock(table)
# By Hours
title = self.iwla._(u'By Hours')
hours = ['%02d' % i for i in range(0, 24)]
table = display.createBlock(DisplayHTMLBlockTableWithGraph, title, [self.iwla._('Hours'), self.iwla._('Pages'), self.iwla._('Hits'), self.iwla._('Bandwidth')], hours, 24, range(1,4))
table = display.createBlock(DisplayHTMLBlockTableWithGraph, title, [self.iwla._('Hours'), self.iwla._('Pages'), self.iwla._('Hits'), self.iwla._('Bandwidth')], hours, 24, range(1,4), [3])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth'])
for i in range(0,24):
table.appendRow([hours[i], hours_stats[i]['pages'], hours_stats[i]['hits'], hours_stats[i]['bandwidth']])
table.setCellValue(i, 3, bytesToStr(hours_stats[i]['bandwidth']))
table.setCellValue(i, 3, hours_stats[i]['bandwidth'])
index.appendBlock(table)

View File

@@ -78,7 +78,7 @@ class IWLADisplayRobotBandwidth(IPlugin):
path = self.iwla.getCurDisplayPath(filename)
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')], [1])
table.setColsCSSClass(['', 'iwla_bandwidth', ''])
for (super_hit, bandwidth) in bandwidths:
address = super_hit['remote_addr']
@@ -88,7 +88,7 @@ class IWLADisplayRobotBandwidth(IPlugin):
row = [
address,
bytesToStr(bandwidth),
bandwidth,
time.asctime(super_hit['last_access'])
]
table.appendRow(row)
@@ -103,7 +103,7 @@ class IWLADisplayRobotBandwidth(IPlugin):
# Top in index
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')], [1])
table.setColsCSSClass(['', 'iwla_bandwidth', ''])
for (super_hit, bandwidth) in bandwidths[:10]:
@@ -114,7 +114,7 @@ class IWLADisplayRobotBandwidth(IPlugin):
row = [
address,
bytesToStr(bandwidth),
bandwidth,
time.asctime(super_hit['last_access'])
]
table.appendRow(row)

View File

@@ -69,7 +69,7 @@ class IWLADisplayTopVisitors(IPlugin):
top_visitors = [hits[h[0]] for h in top_bandwidth[:10]]
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top visitors'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')])
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top visitors'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')], [3])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
for super_hit in top_visitors:
address = super_hit['remote_addr']
@@ -81,7 +81,7 @@ class IWLADisplayTopVisitors(IPlugin):
address,
super_hit['viewed_pages'][0],
super_hit['viewed_hits'][0],
bytesToStr(super_hit['bandwidth'][0]),
super_hit['bandwidth'][0],
time.asctime(super_hit['last_access'])
]
total[1] -= super_hit['viewed_pages'][0]
@@ -90,7 +90,6 @@ class IWLADisplayTopVisitors(IPlugin):
table.appendRow(row)
if total[1] or total[2] or total[3]:
total[0] = self.iwla._(u'Others')
total[3] = bytesToStr(total[3])
total[4] = ''
table.appendRow(total)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')