Remove detection from awstats dataset for browser

This commit is contained in:
Gregory Soutade 2023-03-23 21:16:54 +01:00
parent 44c76007cd
commit cad3467c25
105 changed files with 65 additions and 64 deletions

File diff suppressed because one or more lines are too long

View File

@ -50,6 +50,18 @@ Statistics deletion :
None
"""
browser_icons = {
'Android':'android',
'Android browser (PDA/Phone browser)':'android',
'iPhone':'pdaphone',
'IPhone (PDA/Phone browser)':'pdaphone',
'Edge':'edge',
'Chrome':'chrome',
'Safari':'safari',
'Firefox':'firefox',
'Mozilla':'mozilla',
}
class IWLADisplayBrowsers(IPlugin):
def __init__(self, iwla):
super(IWLADisplayBrowsers, self).__init__(iwla)
@ -60,7 +72,6 @@ class IWLADisplayBrowsers(IPlugin):
self.icon_path = self.iwla.getConfValue('icon_path', '/')
self.max_browsers = self.iwla.getConfValue('max_browsers_displayed', 0)
self.create_browsers = self.iwla.getConfValue('create_browsers_page', True)
self.icon_names = {v:k for (k, v) in awstats_data.browsers_hashid.items()}
return True
@ -81,15 +92,12 @@ class IWLADisplayBrowsers(IPlugin):
total_browsers = [0]*3
new_list = self.max_browsers and browsers[:self.max_browsers] or browsers
for (browser, entrance) in new_list:
if browser != 'unknown':
try:
name = awstats_data.browsers_icons[self.icon_names[browser]]
icon = '<img alt="%s icon" src="/%s/browser/%s.png"/>' % (name, self.icon_path, name)
except:
icon = '<img alt="Unknown browser icon" src="/%s/browser/unknown.png"/>' % (self.icon_path)
if browser in browser_icons.keys():
name = browser_icons[browser]
icon = f'<img alt="{browser} icon" src="/{self.icon_path}/browser/{name}.png"/>'
else:
icon = '<img alt="Unknown browser icon" src="/%s/browser/unknown.png"/>' % (self.icon_path)
browser = 'Unknown'
icon = f'<img alt="Unknown browser icon" src="/{self.icon_path}/browser/unknown.png"/>'
browser = self.iwla._(browser)
table.appendRow([icon, browser, entrance])
total_browsers[2] += entrance
if self.max_browsers:
@ -114,15 +122,12 @@ class IWLADisplayBrowsers(IPlugin):
table = display.createBlock(DisplayHTMLBlockTable, title, ['', self.iwla._(u'Browser'), self.iwla._(u'Entrance')])
table.setColsCSSClass(['', '', 'iwla_hit'])
for (browser, entrance) in browsers[:10]:
if browser != 'unknown':
try:
name = awstats_data.browsers_icons[self.icon_names[browser]]
icon = '<img alt="%s icon" src="/%s/browser/%s.png"/>' % (name, self.icon_path, name)
except:
icon = '<img alt="Unknown browser icon" src="/%s/browser/unknown.png"/>' % (self.icon_path)
if browser in browser_icons.keys():
name = browser_icons[browser]
icon = f'<img alt="{browser} icon" src="/{self.icon_path}/browser/{name}.png"/>'
else:
icon = '<img alt="Unknown browser icon" src="/%s/browser/unknown.png"/>' % (self.icon_path)
browser = self.iwla._(u'Unknown')
icon = f'<img alt="Unknown browser icon" src="/{self.icon_path}/browser/unknown.png"/>'
browser = self.iwla._(browser)
table.appendRow([icon, browser, entrance])
total_browsers[2] -= entrance
if total_browsers[2]:

View File

@ -55,21 +55,35 @@ Statistics deletion :
None
"""
browser_order = ['android', 'iphone', 'xbox', 'edge', 'chrome', 'safari', 'firefox', 'curl', 'wget', 'w3m']
browser_hashid = {
'android':'Android',
'iphone':'iPhone',
'edge':'Edg',
'chrome':'Chrom',
'safari':'Safari',
'firefox':'Firefox',
'xbox':'Xbox',
'curl':'curl',
'wget':'Wget',
'w3m':'w3m'
}
browser_name = {
'android':'Android',
'iphone':'iPhone',
'edge':'Edge',
'chrome':'Chrome',
'safari':'Safari',
'firefox':'Firefox',
'xbox':'Xbox',
'curl':'Curl',
'wget':'Wget',
'w3m':'w3m'
}
class IWLAPostAnalysisBrowsers(IPlugin):
def __init__(self, iwla):
super(IWLAPostAnalysisBrowsers, self).__init__(iwla)
self.API_VERSION = 1
def load(self):
self.browsers = []
for hashid in awstats_data.browsers:
hashid_re = re.compile(r'.*%s.*' % (hashid), re.IGNORECASE)
if hashid in awstats_data.browsers_hashid.keys():
self.browsers.append((hashid_re, awstats_data.browsers_hashid[hashid]))
return True
def hook(self):
stats = self.iwla.getValidVisitors()
@ -85,19 +99,19 @@ class IWLAPostAnalysisBrowsers(IPlugin):
user_agent = r['http_user_agent']
if not user_agent: continue
browser_name = 'unknown'
for (hashid_re, browser) in self.browsers:
if hashid_re.match(user_agent):
browser_name = browser
name = 'Unknown'
for browser in browser_order:
if browser_hashid[browser] in user_agent:
name = browser_name[browser]
break
super_hit['browser'] = browser_name
super_hit['browser'] = name
break
else:
browser_name = super_hit['browser']
name = super_hit['browser']
if not browser_name in browsers_stats.keys():
browsers_stats[browser_name] = 1
if not name in browsers_stats.keys():
browsers_stats[name] = 1
else:
browsers_stats[browser_name] += 1
browsers_stats[name] += 1
month_stats['browsers'] = browsers_stats

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Some files were not shown because too many files have changed in this diff Show More