1
# Copyright (C) 2002,2004 Stichting LogReport Foundation logreport@logreport.org
3
# This file is part of Lire.
5
# Lire is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program (see COPYING); if not, check with
17
# http://www.gnu.org/copyleft/gpl.html or write to the Free Software
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21
# Francis J. Lacoste <flacoste@logreport.org>
23
package Lire::DlfAnalysers::UserAgentCategoriser;
27
use base qw/Lire::DlfCategoriser/;
29
use Lire::WWW::UserAgent;
32
return bless {}, shift;
36
return "www-user_agent";
40
return "UserAgent DlfAnalyser";
44
return '<para>This categoriser extracts browser, os and language information from the <structfield>useragent</structfield> field.</para>';
52
return "www-user_agent";
56
my ( $self, $config ) = @_;
59
new Lire::WWW::UserAgent( 'os_default' => 'LIRE_UNDEF',
60
'language_default' => 'LIRE_UNDEF',
61
'browser_default' => 'LIRE_UNDEF',
67
my ( $self, $dlf ) = @_;
69
return unless defined $dlf->{'useragent'};
70
$self->{'analyser'}->setUserAgent( $dlf->{ 'useragent'} );
72
$dlf->{'os'} = $self->{'analyser'}->getOS();
73
$dlf->{'lang'} = $self->{'analyser'}->getLanguage();
74
$dlf->{'browser'} = $self->{'analyser'}->getBrowser();
76
foreach my $field ( qw/os lang browser/ ) {
77
$dlf->{$field} = undef if $dlf->{$field} eq 'LIRE_UNDEF';