Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Filter agents (show desktops for desktops, mobiles for mobiles)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Feb 25, 2012
1 parent cfd5fad commit 2d60e4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions handler.methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ function filter_useragent(& $agents_array) {
return $return_array;
}
function filter_agents($support_array = array(), $useragent_array = array()) {
foreach ($support_array['agents'] as $agent_id =>& $agent_array) {
if ($agent_array['type'] !== $useragent_array['type']) {
unset($support_array['agents'][$agent_id]);
unset($support_array['results'][$agent_id]);
foreach ($support_array['result'] as & $result_array) {
unset($result_array[$agent_id]);
}
}
}
}
/* =============================================================================
Expand Down
2 changes: 2 additions & 0 deletions handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
if (!$option_noagent) {
$useragent_array = filter_useragent($agents_array);

filter_agents($support_array, $useragent_array);

$support_array['agent'] = $useragent_array;

$support_array['supported'] = isset($support_array['results'][$useragent_array['id']]) && version_compare($useragent_array['version'], $support_array['results'][$useragent_array['id']]) > -1;
Expand Down

0 comments on commit 2d60e4e

Please sign in to comment.