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

Commit

Permalink
Calculate browser on post instead of on view
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonBarnabe committed Nov 6, 2014
1 parent 7d9f49b commit 2e9d7c5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions class.useragent.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$PluginInfo['UserAgent'] = array(
'Name' => 'User Agent',
'Description' => "Record user agent and display it and browser icon above posts.",
'Version' => '2.0',
'Version' => '2.1',
'MobileFriendly' => TRUE,
'Author' => "Jason Barnabe",
'AuthorEmail' => 'jason.barnabe@gmail.com',
Expand Down Expand Up @@ -68,7 +68,12 @@ protected function SetAttributes($Sender, &$Args) {
}

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

$Args['FormPostValues']['Attributes'] = serialize($Args['FormPostValues']['Attributes']);
}
Expand All @@ -83,14 +88,14 @@ protected function AttachInfo($Sender, $Attributes) {
$Attributes = unserialize($Attributes);
}
$UserAgent = GetValue('UserAgent', $Attributes);
$Browser = GetValue('Browser', $Attributes);
if ($UserAgent) {
$Data = @get_browser($UserAgent); // requires browsecap.ini
if ($Data) {
$Logo = $this->Logos[$Data->browser];
if ($Browser) {
$Logo = $this->Logos[$Browser];
if ($Logo) {
$Info = Img($this->GetResource('logos/'.$Logo, FALSE, FALSE), array('alt' => htmlspecialchars($Data->browser)));
$Info = Img($this->GetResource('logos/'.$Logo, FALSE, FALSE), array('alt' => htmlspecialchars($Browser)));
} else {
$Info = htmlspecialchars($Data->browser);
$Info = htmlspecialchars($Browser);
}
}
If (!$Info) {
Expand Down

0 comments on commit 2e9d7c5

Please sign in to comment.