App-Squid-Redirector-Fugu
view release on metacpan or search on metacpan
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: App-Squid-Redirector-Fugu
requires:
BerkeleyDB: '0'
Carp: '0'
Config::Any: '0'
DBI: '0'
DateTime: '0'
Getopt::Long: '0'
Log::Handler: '0'
Net::LDAP: '0'
strict: '0'
warnings: '0'
version: 0.0.9
Makefile.PL view on Meta::CPAN
"bin/fugu",
"bin/fugu-build"
],
"LICENSE" => "perl",
"NAME" => "App::Squid::Redirector::Fugu",
"PREREQ_PM" => {
"BerkeleyDB" => 0,
"Carp" => 0,
"Config::Any" => 0,
"DBI" => 0,
"DateTime" => 0,
"Getopt::Long" => 0,
"Log::Handler" => 0,
"Net::LDAP" => 0,
"strict" => 0,
"warnings" => 0
},
"VERSION" => "0.0.9",
"test" => {
"TESTS" => ""
}
);
my %FallbackPrereqs = (
"BerkeleyDB" => 0,
"Carp" => 0,
"Config::Any" => 0,
"DBI" => 0,
"DateTime" => 0,
"Getopt::Long" => 0,
"Log::Handler" => 0,
"Net::LDAP" => 0,
"strict" => 0,
"warnings" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw/ croak /;
use Config::Any;
use DateTime;
use DBI;
use Getopt::Long;
use Log::Handler;
use App::Squid::Redirector::Fugu::BDB;
use App::Squid::Redirector::Fugu::LDAP;
use App::Squid::Redirector::Fugu::SQL;
# global vars
my $config_file;
my $concurrency;
my $config;
my $local_time_zone = DateTime::TimeZone->new( name => 'local' );
# Get options - param values
GetOptions('config=s' => \$config_file, 'concurrency' => \$concurrency);
# Parse config file
if($config_file) {
my $cfg = Config::Any->load_files({ files => [$config_file], force_plugins => ['Config::Any::JSON'] });
(undef, $config) = %{ $$cfg[0] };
} else { croak('You should inform a config file: fugu --config /path/to/fugu.conf'); }
my($setdays) = keys %{ $item };
# the current day is on week days list
if($setdays =~ /$wdays[$curwd]/) {
my($initial_time, $end_time) = split($RGX_DASH, $item->{$setdays});
my($initial_time_hour, $initial_time_minute) = split($RGX_COLON, $initial_time);
my($end_time_hour, $end_time_minute) = split($RGX_COLON, $end_time);
# get initial time, end time and current time
my $itime = DateTime->now( time_zone => $local_time_zone );
$itime->set_hour($initial_time_hour);
$itime->set_minute($initial_time_minute);
my $etime = DateTime->now( time_zone => $local_time_zone );
$etime->set_hour($end_time_hour);
$etime->set_minute($end_time_minute);
my $ctime = DateTime->now( time_zone => $local_time_zone );
# check if current time is inside
if((DateTime->compare($ctime, $itime) == 1) && (DateTime->compare($etime, $ctime) == 1)) {
$allow = 1;
last;
}
}
}
return $allow;
}
( run in 1.643 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )