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 ***************************************************************************/
27 use DBD::Pg qw(:pg_types);
28 use CGI qw/:standard/;
32 use Encode::Encoder qw(encoder);
33 use MIME::QuotedPrint;
36 use lib "$FindBin::Bin/../lib";
39 my $dbh = ND::DB::DB();
42 my $text = join '',@text;
44 my $email = Email::Simple->new(Email::StripMIME::strip_mime($text));;
46 my $subject = encoder(decode_qp($email->header('Subject')))->utf8;
47 my $body = 'FROM:'.encoder(decode_qp($email->header('From')))->utf8 . "\n\n" . encoder($email->body)->utf8;
52 my $new_thread = $dbh->prepare(q{INSERT INTO forum_threads (fbid,subject,uid) VALUES(25,$1,-4)});
54 if ($new_thread->execute(escapeHTML($subject))){
55 my $id = $dbh->last_insert_id(undef,undef,undef,undef,"forum_threads_ftid_seq");
56 my $insert = $dbh->prepare(q{INSERT INTO forum_posts (ftid,message,uid) VALUES($1,$2,-4)});
57 if ($insert->execute($id,escapeHTML($body))){