From f3fbf8b727e6aa34136be676259f725daf433d92 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Sat, 7 Feb 2015 15:28:24 +0100 Subject: [PATCH] Add pages and hits to track_users --- plugins/display/track_users.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/display/track_users.py b/plugins/display/track_users.py index d0fe2f1..a20e0ad 100644 --- a/plugins/display/track_users.py +++ b/plugins/display/track_users.py @@ -65,6 +65,7 @@ class IWLADisplayTrackUsers(IPlugin): def hook(self): display = self.iwla.getDisplay() hits = self.iwla.getCurrentVisists() + stats = {} # All in a page if self.create_tracked_page: @@ -81,16 +82,21 @@ class IWLADisplayTrackUsers(IPlugin): else: ip_title = '%s' % (ip) table.appendRow([ip_title, '']) + nb_hits = 0 + nb_pages = 0 for r in hits[ip]['requests'][::-1]: uri = r['extract_request']['extract_uri'].lower() + if not self.iwla.hasBeenViewed(r): continue if not self.iwla.isPage(uri) or\ - self.iwla.isMultimediaFile(uri) or\ - not self.iwla.hasBeenViewed(r): + self.iwla.isMultimediaFile(uri): + nb_hits += 1 continue + nb_pages += 1 uri = "%s%s" % (r.get('server_name', ''), r['extract_request']['extract_uri']) table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded'])]) + stats[ip] = (nb_pages, nb_hits) page.appendBlock(table) display.addPage(page) @@ -103,12 +109,12 @@ class IWLADisplayTrackUsers(IPlugin): index = self.iwla.getDisplayIndex() - table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'IP'), self.iwla._(u'Last Access')]) + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'IP'), self.iwla._(u'Last Access'), self.iwla._(u'Pages'), self.iwla._(u'Hits')]) for ip in self.tracked_ip: if not ip in hits.keys(): continue if 'dns_name_replaced' in hits[ip].keys(): ip_title = '%s [%s]' % (hits[ip]['remote_addr'], ip) else: ip_title = ip - table.appendRow([ip_title, time.asctime(hits[ip]['last_access'])]) + table.appendRow([ip_title, time.asctime(hits[ip]['last_access']), stats[ip][0], stats[ip][1]]) index.appendBlock(table)