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
use strict; use vars qw(%conf); $conf{log_dir} = "$SYSTEM_CONF{'SITE-DIR'}/logs"; $conf{site_active} = $SYSTEM_CONF{'OPERATING-SYSTEM'} =~ /win|dos|nt/i ? "perl $SYSTEM_CONF{'CGI-DIR'}/site_active.pl" : "$SYSTEM_CONF{'CGI-DIR'}/site_active.pl"; sub new { my ($class, %params) = @_; my $self = \%params; bless $self, $class; } sub init { [ { 'FUNCTION' => 'data_news', 'MAX_RUNTIME' => 120, 'EXEC_TIME' => 0, 'PRIORITY' => 25 } ] } sub data_news { my ($self, $container, $log) = @_; return 1 unless ref $container->{msgs}; # no messages my @Jobs; for my $url (@{$container->{msgs}}) { $url =~ /^(\/.+)\/([^\/]+)$/i; my $directory = $1; my $filename = $2; my $country_code; if ($directory =~ m:/data/about/news/pr/([a-z]+)/article:) { $country_code = $1; } else { $country_code = 'special'; } next unless ($directory =~ m:/data/about/news/pr/$country_code/article: || $directory =~ m:/special/about/news/pr/article:); my $job = "TEMPLATE=/siteactive/data/templates/template_data_news_snippet.htms:SAVEPAGE=/data/news/ssi/news_$country_code.ssi:country_code=$country_code"; push(@Jobs,$job); } for my $job (@Jobs) { $log->("$SYSTEM_CONF{'OPERATING-SYSTEM'} MODE: $conf{site_active} $job"); system "$conf{site_active} $job >$conf{log_dir}/SiteActive.lastrun"; } return 1; } 1;
1 2 3 4 5
my $past = DateTime->now->subtract( days => 90 ); my $file_date = DateTime->from_epoch( epoch => $mtime ); if ($file_date < $past) { # älter als 90 tage }
my ($mtime) = (stat $filename)[9];
2011-06-16T13:29:10 pqwenn es nur ungefähr sein soll, kannst du mit den epochsekunden rechnen, ansonsten sieh dir mal DateTime an, um Daten zu vergleichen.
2011-06-16T19:05:33 pqmit ungefähr meine ich, dass 90*24*60*60 nicht immer genau 90 tage sind.
next if (-f $url and time()-(stat($url))[9] > 90*24*60*60);
next if (-f $url and time()-(stat($url))[9] > 90*24*60*60);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
%messages = ( 1 => { 'de' => 'Es sind keine Neuigkeiten vorhanden', 'en' => 'No news', 'fr' => 'Il ya rien du tout', }, 2 => { 'de' => 'Datei kaputt', 'en' => 'Database is corrupted', 'fr' => 'Rien ne va plus', }, # usw. ); $lang = 'de'; if (-M $dateiname > 90) { print $messages{1}->{$lang}; exit; }