/usr/share/perl5/Octopussy/Plugin/Web.pm is in octopussy 1.0.6-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | # $HeadURL$
# $Revision: 353 $
# $Date: 2010-05-17 18:44:55 +0100 (Mon, 17 May 2010) $
# $Author: sebthebert $
=head1 NAME
Octopussy::Plugin::Web - Octopussy Plugin Web
=cut
package Octopussy::Plugin::Web;
use strict;
use warnings;
use AAT::List;
use AAT::Utils qw( ARRAY NOT_NULL);
use Octopussy;
my @browsers = ();
my @operating_systems = ();
=head1 FUNCTIONS
=head2 Init()
Initializes Browsers and Operating Systems information
=cut
sub Init
{
my $conf_bot = AAT::List::Configuration('AAT_Bot');
my $conf_browser = AAT::List::Configuration('AAT_Browser');
my $conf_mobile = AAT::List::Configuration('AAT_MobilePhone');
my $conf_os = AAT::List::Configuration('AAT_Operating_System');
my @list = (
ARRAY($conf_browser->{item}),
ARRAY($conf_mobile->{item}),
ARRAY($conf_bot->{item}),
);
foreach my $i (@list)
{
push @browsers,
{
label => $i->{label},
logo => $i->{logo},
regexp => qr/$i->{regexp}/
}
if (NOT_NULL($i->{regexp}));
}
foreach my $i (ARRAY($conf_os->{item}))
{
push @operating_systems,
{
label => $i->{label},
logo => $i->{logo},
regexp => qr/$i->{regexp}/
}
if (NOT_NULL($i->{regexp}));
}
return (1);
}
=head2 Logo($logo, $alt)
Returns Browser or Operating System Logo
=cut
sub Logo
{
my ($logo, $alt) = @_;
my $file = "AAT/IMG/${logo}.png";
return ("<img src=\"$file\" alt=\"$alt\"><b>$alt</b>");
}
=head2 UserAgent_Browser($ua)
Returns Browser from UserAgent information
=cut
sub UserAgent_Browser
{
my $ua = shift;
foreach my $i (@browsers)
{
if ($ua =~ $i->{regexp})
{
return (Logo("$i->{logo}", $i->{label}))
if (defined $i->{logo});
return ($i->{label});
}
}
return ($ua);
}
=head2 UserAgent_OS($ua)
Returns Operating System from UserAgent information
=cut
sub UserAgent_OS
{
my $ua = shift;
foreach my $i (@operating_systems)
{
return (Logo(($i->{logo} || ''), $i->{label}))
if ($ua =~ $i->{regexp});
}
return ($ua);
}
1;
=head1 AUTHOR
Sebastien Thebert <octo.devel@gmail.com>
=cut
|