/usr/share/perl5/Octopussy/Plugin/Proxy.pm is in octopussy 1.0.6-0ubuntu1.
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 131 132 133 134 135 136 137 | # $HeadURL$
# $Revision: 353 $
# $Date: 2010-05-17 18:44:55 +0100 (Mon, 17 May 2010) $
# $Author: sebthebert $
=head1 NAME
Octopussy::Plugin::Proxy - Octopussy Plugin Proxy
=cut
package Octopussy::Plugin::Proxy;
use strict;
use warnings;
use Readonly;
use AAT::List;
use AAT::Utils qw( ARRAY NOT_NULL);
use Octopussy;
Readonly my $RE_HIT => qr/^.+_HIT.*$/;
my @mimes = ();
=head1 FUNCTIONS
=head2 Init()
=cut
sub Init
{
my $conf_mime = AAT::List::Configuration('AAT_Mime');
foreach my $i (ARRAY($conf_mime->{item}))
{
push
@mimes,
{
label => $i->{label},
logo => $i->{logo},
regexp => qr/$i->{regexp}/i
}
if (NOT_NULL($i->{regexp}));
}
return (1);
}
=head2 Cache_Status($str)
Returns Cache Status
=cut
sub Cache_Status
{
my $str = shift;
return ('Cached') if ($str =~ $RE_HIT);
return ('Not Cached');
}
=head2 Logo($logo, $alt)
=cut
sub Logo
{
my ($logo, $alt) = @_;
return (qq(<img src="AAT/IMG/${logo}.png" alt="$alt"><b>$alt</b>));
}
=head2 Mime($str)
=cut
sub Mime
{
my $str = shift;
foreach my $i (@mimes)
{
return (Logo('web_mime/' . ($i->{logo} || ''), $i->{label}))
if ((defined $i->{regexp}) && ($str =~ $i->{regexp}));
}
return ($str);
}
=head2 TLD($url)
=cut
sub TLD
{
my $url = shift;
if ( ($url =~ /^(https?:\/\/)?[^\/]*\.([a-z]{2,4})(:\d+)*$/i)
|| ($url =~ /^(https?:\/\/)?[^\/]*\.([a-z]{2,4})(:\d+)*\/.*$/i))
{
my $tld = $2;
return (Logo("flags/$tld", $tld))
if (-f "AAT/IMG/flags/$tld.png");
return ($tld);
}
return ($url);
}
=head2 WebSite($url)
=cut
sub WebSite
{
my $url = shift;
if ( ($url =~ /^(https?:\/\/)?[^\/]*?(\.)?(\d+\.\d+\.\d+\.\d+)(:\d+)*$/i)
|| ($url =~ /^(https?:\/\/)?[^\/]*?(\.)?([a-z0-9_-]+\.[a-z]+)(:\d+)*$/i)
|| ($url =~ /^(https?:\/\/)?[^\/]*?(\.)?([a-z0-9_-]+\.[a-z]+)(:\d+)*\/.*$/i)
)
{
return ($3);
}
return ($url);
}
1;
=head1 AUTHOR
Sebastien Thebert <octo.devel@gmail.com>
=cut
|