#at=2009-11-20 11:48:53<|>aip=122.....
# my %m = &getGMap;
# print $m{"asid"},"\t",$m{"at"},"\n" if not $m{"asid"} eq "" ;
sub getGMap{
my @arr = split /<\|>/;
my %h;
foreach $d (@arr){
if($d=~/(.*?)=(.*)/){
$h{$1}=$2;
}
}
return %h;
}
# perl -e '
# BEGIN{ require("/data/shell/gmodel/inc_model/utils.pl"); }
# print &diffTime("2009-12-04 16:58:38","2009-12-04 16:58:00");
# '
sub diffTime{
use Time::Local;
my($st1,$st2) = @_;
my $t1=timelocal($6,$5,$4,$3,$2-1,$1-1900) if $st1=~/(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})/;
my $t2=timelocal($6,$5,$4,$3,$2-1,$1-1900) if $st2=~/(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})/;
return $t1-$t2;
}
# perl -e '
# BEGIN{ require("/data/shell/gmodel/inc_model/utils.pl"); }
# print &getAgoday(-3);
# #2009-12-31
# print &getAgoday(3);
# #...
# '
sub getAgoday{
my $nt=$_[0];
$nt = 1 if $nt !~ /(\-)*\d+/;
$nt=`date -d "\$[$nt*-1] day" +%Y-%m-%d` if $nt ne "";
chomp $nt;
return $nt;
}
# print 23
sub getAgohour{
my ($nt)=@_;
$nt = 1 if $nt !~ /(\-)*\d+/;
$nt=`date -d "\$[$nt*-1] hour" +%H`;
chomp $nt;
return $nt;
}
$_vtime=&getAgoday();
$_htime=&getAgohour();
sub setVTime{
$_vtime=$_[0];
$_htime=$_[1] if $_[1] ne "";
}
# perl -e '
# BEGIN{ require("/data/shell/gmodel/inc_model/utils.pl"); }
# # &setVTime('2010-11-12','23');
# print &getConf("logSou","audiobooks_logSou")
# '
use Config::Tiny;
$_Config=Config::Tiny->read("/data/shell/gmodel/inc_model/model.conf");
sub getConf{
my ($_Y,$_M,$_D)=split /-/,$_vtime;
my $_H = $_htime ;
%rp = ("\@Y", $_Y,
"\@M" , $_M,
"\@D", $_D,
"\@H", $_H );
# 需要 cpan>install Config::Tiny
my ($group,$key)=@_;
my $ss=$_Config->{$group}->{$key};
while (($key, $value) = each(%rp)){
$ss=~s/$key/$value/g;
}
return $ss;
}
my $_filtered_ip=&getConf("filter","filtered_ip");
my @_filtered_ips=split(",", $_filtered_ip );
my $_filtered_aop=&getConf("filter","filtered_aop");
my @_filtered_aops=split(",", $_filtered_aop );
my $_permission_app=&getConf("filter","permission_app");
my @_permission_apps=split(",", $_permission_app );
sub my_filter{
my %m=%{$_[0]};
return 0 if $m{auid} eq "" or $m{ab} eq "";
my @aip=split /,/,$m{aip};
return 0 if(grep {$_ eq $m{aip} } @_filtered_ips);
return 0 if(grep {$m{ab} eq $_} @_filtered_aops);
if(not (grep {"ALL" eq $_} @_permission_apps) ){
if (not (grep {$m{aop} eq $_} @_permission_apps)){
return 0;
}
}
return 1 ;
}
return 1;
|