Remove detection from awstats dataset for browser
|
@ -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]:
|
||||
|
|
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 529 B |
Before Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 518 B |
Before Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 617 B |
Before Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 586 B |
Before Width: | Height: | Size: 465 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 427 B |
Before Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 608 B |
Before Width: | Height: | Size: 625 B |
Before Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 519 B |
Before Width: | Height: | Size: 588 B |
Before Width: | Height: | Size: 534 B |
Before Width: | Height: | Size: 461 B |
Before Width: | Height: | Size: 632 B |
Before Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 404 B |
Before Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 568 B |
Before Width: | Height: | Size: 592 B |
Before Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 590 B |
Before Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 209 B |
Before Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 637 B |
Before Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 642 B |
Before Width: | Height: | Size: 476 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 480 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 653 B |
Before Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 376 B |
Before Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 599 B |
Before Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 558 B |
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 531 B |
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 605 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 603 B |
Before Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 461 B |
Before Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 497 B |
Before Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 615 B |