Display external referers in filter_users plugin

This commit is contained in:
Gregory Soutade 2022-11-07 21:13:49 +01:00
parent 26ad1b4635
commit 6ce0374fe7

View File

@ -74,8 +74,8 @@ 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')])
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')])
table.setColsCSSClass(['iwla_page', '', '', ''])
row = 0
unknown = self.iwla._('Unknown')
for filtered_user in self.filtered_users:
@ -95,9 +95,15 @@ class IWLADisplayFilterUsers(IPlugin):
if not self.iwla.isPage(uri): continue
if not self.iwla.hasBeenViewed(r): continue
referer = ''
if r.get('extract_referer', ''):
referer = r['extract_referer']['extract_uri']
# Display only external referers
if referer == '-' or self.iwla.domain_name_re.match(referer):
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']])
table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded']), r['http_user_agent'], referer])
page.appendBlock(table)
display.addPage(page)