Re: uploading mail batches
"A. Pagaltzis" <[email protected]>
| Newsgroups | gmane.culture.people.kragen.discuss |
|---|---|
| Organization | haphazard |
| Message-ID | <20070223233106.GC9591@klangraum> |
* A. Pagaltzis <[email protected]> [2007-02-21 21:30]: > Overall, something like this: Uhm yeah, good thing I added the “untested” disclaimer; there are at least two obvious bugs: > sub main { > $|++; > > if ( request_method eq 'GET' ) { > page_default; > } > elsif ( request_method eq 'POST' ) { > my $upfh = upload 'file'; > > if ( cgi_error or not $upfh ) { > page_default 'No file uploaded or upload error'; > return; > } > > my $password = <$upfh>; # missing: chomp $password; > unless ( check_password $password_dbm, $password ) { > page_default "Bad password: I don't see $password"; > return; > } > > page_sending sub { > my $data; > local $/ = \65536; # read 64kb chunks > assert 'open pipe', open my $pipe, '-|', $mailmsgpy, 'send'; # is wrong, must be: assert 'open pipe', open my $pipe, '|-', $mailmsgpy, 'send'; > assert 'write to pipe', print $pipe $data > while defined( $data = <$upfh> ); > assert 'close pipe', close $pipe; > }; > } > else { > die "Bad request method\n"; > } > } Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>