Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 2e9d7c5

Browse files
committed
Calculate browser on post instead of on view
1 parent 7d9f49b commit 2e9d7c5

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

class.useragent.plugin.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$PluginInfo['UserAgent'] = array(
44
'Name' => 'User Agent',
55
'Description' => "Record user agent and display it and browser icon above posts.",
6-
'Version' => '2.0',
6+
'Version' => '2.1',
77
'MobileFriendly' => TRUE,
88
'Author' => "Jason Barnabe",
99
'AuthorEmail' => 'jason.barnabe@gmail.com',
@@ -68,7 +68,12 @@ protected function SetAttributes($Sender, &$Args) {
6868
}
6969

7070
// Add user agent data to Attributes
71+
$UserAgent = GetValue('HTTP_USER_AGENT', $_SERVER);
7172
$Args['FormPostValues']['Attributes']['UserAgent'] = GetValue('HTTP_USER_AGENT', $_SERVER);
73+
$BrowserData = @get_browser($UserAgent); // requires browsecap.ini
74+
if ($BrowserData) {
75+
$Args['FormPostValues']['Attributes']['Browser'] = $BrowserData->browser;
76+
}
7277

7378
$Args['FormPostValues']['Attributes'] = serialize($Args['FormPostValues']['Attributes']);
7479
}
@@ -83,14 +88,14 @@ protected function AttachInfo($Sender, $Attributes) {
8388
$Attributes = unserialize($Attributes);
8489
}
8590
$UserAgent = GetValue('UserAgent', $Attributes);
91+
$Browser = GetValue('Browser', $Attributes);
8692
if ($UserAgent) {
87-
$Data = @get_browser($UserAgent); // requires browsecap.ini
88-
if ($Data) {
89-
$Logo = $this->Logos[$Data->browser];
93+
if ($Browser) {
94+
$Logo = $this->Logos[$Browser];
9095
if ($Logo) {
91-
$Info = Img($this->GetResource('logos/'.$Logo, FALSE, FALSE), array('alt' => htmlspecialchars($Data->browser)));
96+
$Info = Img($this->GetResource('logos/'.$Logo, FALSE, FALSE), array('alt' => htmlspecialchars($Browser)));
9297
} else {
93-
$Info = htmlspecialchars($Data->browser);
98+
$Info = htmlspecialchars($Browser);
9499
}
95100
}
96101
If (!$Info) {

0 commit comments

Comments
 (0)