3 /***************************************************************************
4 * Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
26 use DBD::Pg qw(:pg_types);
27 use CGI qw/:standard/;
31 use Encode::Encoder qw(encoder);
32 use MIME::QuotedPrint;
35 for my $file ("/home/whale/nddb.pl")
37 unless (my $return = do $file){
38 warn "couldn't parse $file: $@" if $@;
39 warn "couldn't do $file: $!" unless defined $return;
40 warn "couldn't run $file" unless $return;
45 my $text = join '',@text;
47 my $email = Email::Simple->new(Email::StripMIME::strip_mime($text));;
49 my $subject = encoder(decode_qp($email->header('Subject')))->utf8;
50 my $body = 'FROM:'.encoder(decode_qp($email->header('From')))->utf8 . "\n\n" . encoder($email->body)->utf8;
55 my $new_thread = $dbh->prepare(q{INSERT INTO forum_threads (fbid,subject,uid) VALUES(25,$1,-4)});
57 if ($new_thread->execute(escapeHTML($subject))){
58 my $id = $dbh->last_insert_id(undef,undef,undef,undef,"forum_threads_ftid_seq");
59 my $insert = $dbh->prepare(q{INSERT INTO forum_posts (ftid,message,uid) VALUES($1,$2,-4)});
60 if ($insert->execute($id,escapeHTML($body))){