--- mimex 2001/07/16 09:57:03 1.1.1.1 +++ mimex 2002/04/17 10:28:41 1.6 @@ -8,11 +8,19 @@ use MIME::Parser; -my $outdir = "/tmp/store"; -my $msgdir = "/tmp/mime$$"; # temp -my $to = "dpavlin@pliva.hr"; +my $outdir = "/data/store"; +my $msgdir = "/data/store/tmp/mime$$"; # temp +my $from = 'clipping-info@pliva.hr'; +my $to = 'clipdir@pliva.hr'; +my $log = "/data/store/mimex.log"; -print "From: Press Clipping \nSubject: Press Clipping update\n\n"; +umask 022; # world readable + +open(LOG,">> $log") || warn "log $log: $!"; + +open(MAIL,"| /usr/sbin/sendmail $to") || die "sendmail: $!"; + +print MAIL "From: Press Clipping <$from>\nSubject: Press Clipping update\n\n"; #------------------------------------------------------------ # dump_entity - dump an entity's file info @@ -21,6 +29,9 @@ my $ent = shift; my @parts = $ent->parts; + my $md5=md5_hex(time()); + mkdir "$outdir/$md5",0755 || die "mkdir $outdir/$md5: $!"; + if (@parts) { # multipart... map { dump_entity($_) } @parts; } else { # single part... @@ -28,7 +39,7 @@ # " (", scalar($ent->head->mime_type), ")\n"; if ($ent->head->mime_type =~ m,text/plain,i) { open(I,$ent->bodyhandle->path) || die "$ent->bodyhandle->path: $!"; - while() { print $_; } + while() { print MAIL $_; } close(I); unlink $ent->bodyhandle->path; } else { @@ -37,10 +48,9 @@ $new=~s/ +/_/g; $new=~s/^.*\/([^\/]+)$/$1/g; $new=~s/[^a-zA-Z._0-9]//g; - my $md5=md5_hex($new.time()); - mkdir "$outdir/$md5",0755 || die "mkdir $outdir/$md5: $!"; rename $file,"$outdir/$md5/$new" || die "$file -> $md5 $new: $!"; - print "\nhttp://store.pliva.hr/$md5/$new\n"; + print MAIL "\n","-" x 76,"\nhttp://store.pliva.hr/$md5/$new\n"; + print LOG "$md5/$new\n"; } } } @@ -76,8 +86,3 @@ #------------------------------------------------------------ 1; - - - - -