sub insert_msg { my $author = $query->param('author'); my $subject = $query->param('subject'); my $body = $query->param('body'); my $parent = $query->param('parent'); my $thread; if ( $parent ) { my $sth = $dbh->prepare(qq|select id, thread from messaggi where id=?|); $sth->execute( $parent ) || die $DBI::errstr; my $hr = $sth->fetchrow_hashref(); $thread = ($hr->{'thread'} == 0) ? $hr->{'id'} : $hr->{'thread'}; } else { $thread = 0; } $body = validate( $body ); $body = HTML::Entities::encode( $body ); $body =~ s/\[(.*?)\|(.*?)\]/target($1, $2)/eg; $body =~ s/\[(.*?)\]/target($1)/eg; my $sth = $dbh->prepare( qq|insert into messaggi values(null, ?, null, ?, ?, ?, null)| ); $sth->execute( $thread, $author, $subject, $body ) || die $DBI::errstr; $template->process( $config->{'template'}->{'insert'} ); } #### CREATE TABLE `messaggi` ( `id` int(10) unsigned NOT NULL auto_increment, `thread` int(10) unsigned default NULL, `data` timestamp(14) NOT NULL, `author` varchar(100) default NULL, `subject` varchar(200) default NULL, `body` text, `category` int(10) unsigned default NULL, PRIMARY KEY (`id`), FULLTEXT KEY `body` (`body`), ) TYPE=MyISAM