Rework filtered_users output to have full location in a column
This commit is contained in:
parent
07eb919837
commit
83275a8db4
|
@ -74,23 +74,24 @@ class IWLADisplayFilterUsers(IPlugin):
|
|||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Filtered users'), [self.iwla._(u'Pages'), self.iwla._(u'Last Access'), self.iwla._(u'User Agent'), self.iwla._(u'Referer')])
|
||||
table.setColsCSSClass(['iwla_page', '', '', ''])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Filtered users'), [self.iwla._(u'Pages'), self.iwla._(u'Last Access'), self.iwla._(u'User Agent'), self.iwla._(u'Referer'), self.iwla._(u'Location')])
|
||||
table.setColsCSSClass(['iwla_page', '', '', '', ''])
|
||||
row = 0
|
||||
unknown = self.iwla._('Unknown')
|
||||
for filtered_user in self.filtered_users:
|
||||
ip = filtered_user['remote_ip']
|
||||
ip_title = ip
|
||||
location = filtered_user.get('geo_location', {})
|
||||
if location:
|
||||
isp = location.get('isp', '')
|
||||
str_location = ''
|
||||
city = location.get('city', unknown)
|
||||
country = location.get('countryname', unknown)
|
||||
if not city: city = unknown
|
||||
if not country: country = unknown
|
||||
# At least, one information
|
||||
if city != unknown or country != unknown:
|
||||
ip_title = f'{ip_title}<br/>({city}/{country})'
|
||||
table.appendRow([f'<b>{ip_title}</b>', '', ''])
|
||||
if location.get('city', '') or location.get('countryname'):
|
||||
str_location = f'{city}/{country}'
|
||||
if isp:
|
||||
if str_location: str_location += '<br/>'
|
||||
str_location += isp
|
||||
table.appendRow([f'<b>{ip_title}</b>', '', '', '', ''])
|
||||
table.setCellCSSClass(row, 0, '')
|
||||
for r in hits[ip]['requests'][::-1]:
|
||||
uri = r['extract_request']['extract_uri'].lower()
|
||||
|
@ -105,7 +106,8 @@ class IWLADisplayFilterUsers(IPlugin):
|
|||
referer = ''
|
||||
uri = "%s%s" % (r.get('server_name', ''),
|
||||
r['extract_request']['extract_uri'])
|
||||
table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded']), r['http_user_agent'], referer], filtered_user['remote_ip'])
|
||||
table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded']), r['http_user_agent'], referer, str_location], filtered_user['remote_ip'])
|
||||
str_location = ''
|
||||
page.appendBlock(table)
|
||||
|
||||
display.addPage(page)
|
||||
|
|
Loading…
Reference in New Issue
Block a user