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)
|
path = self.iwla.getCurDisplayPath(filename)
|
||||||
|
|
||||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
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 = 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', '', '', ''])
|
table.setColsCSSClass(['iwla_page', '', '', '', ''])
|
||||||
row = 0
|
row = 0
|
||||||
unknown = self.iwla._('Unknown')
|
unknown = self.iwla._('Unknown')
|
||||||
for filtered_user in self.filtered_users:
|
for filtered_user in self.filtered_users:
|
||||||
ip = filtered_user['remote_ip']
|
ip = filtered_user['remote_ip']
|
||||||
ip_title = ip
|
ip_title = ip
|
||||||
location = filtered_user.get('geo_location', {})
|
location = filtered_user.get('geo_location', {})
|
||||||
if location:
|
isp = location.get('isp', '')
|
||||||
city = location.get('city', unknown)
|
str_location = ''
|
||||||
country = location.get('countryname', unknown)
|
city = location.get('city', unknown)
|
||||||
if not city: city = unknown
|
country = location.get('countryname', unknown)
|
||||||
if not country: country = unknown
|
if location.get('city', '') or location.get('countryname'):
|
||||||
# At least, one information
|
str_location = f'{city}/{country}'
|
||||||
if city != unknown or country != unknown:
|
if isp:
|
||||||
ip_title = f'{ip_title}<br/>({city}/{country})'
|
if str_location: str_location += '<br/>'
|
||||||
table.appendRow([f'<b>{ip_title}</b>', '', ''])
|
str_location += isp
|
||||||
|
table.appendRow([f'<b>{ip_title}</b>', '', '', '', ''])
|
||||||
table.setCellCSSClass(row, 0, '')
|
table.setCellCSSClass(row, 0, '')
|
||||||
for r in hits[ip]['requests'][::-1]:
|
for r in hits[ip]['requests'][::-1]:
|
||||||
uri = r['extract_request']['extract_uri'].lower()
|
uri = r['extract_request']['extract_uri'].lower()
|
||||||
|
@ -105,7 +106,8 @@ class IWLADisplayFilterUsers(IPlugin):
|
||||||
referer = ''
|
referer = ''
|
||||||
uri = "%s%s" % (r.get('server_name', ''),
|
uri = "%s%s" % (r.get('server_name', ''),
|
||||||
r['extract_request']['extract_uri'])
|
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)
|
page.appendBlock(table)
|
||||||
|
|
||||||
display.addPage(page)
|
display.addPage(page)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user