sub erzeuge_rss_feed { ### ggf. Beschreibung anpassen ### if ($board_id || $thread_id) { my $sql; if ($thread_id) { $sql = "SELECT title FROM $PBoard::Config::DbTables{threads} WHERE id = '$thread_id' LIMIT 1"; } # if if ($board_id) { $sql = "SELECT name FROM $PBoard::Config::DbTables{boards} WHERE id = '$board_id' LIMIT 1"; } # if my $storage = PBoard::Storage->new( { dbh => undef } ); my $poard = PBoard->new( { cgi => $cgi, storage => $storage } ); my $dbh = PBoard::DB::ConnectToDB( $poard ); $storage->set_dbh( $dbh ); my $sth = &PBoard::DB::FireSql( $poard, $sql ); (my $titel) = $sth->fetchrow_array(); $rss_board_titel .= ' :: '.$titel; } # if ### SQL ### my $sql = "SELECT boards.id as board_id, threads.id as thread_id, messages.position as position, boards.name as board_name, threads.title as thread_title, messages.message_raw as message_raw"; $sql .= " FROM $PBoard::Config::DbTables{boards} AS boards,"; $sql .= " $PBoard::Config::DbTables{threads} as threads,"; $sql .= " $PBoard::Config::DbTables{messages} as messages"; $sql .= " WHERE messages.thread = threads.id AND threads.boardID = boards.id"; $sql .= " AND messages.status != 'deleted' AND threads.status != 'onhold' AND threads.status != 'deleted'"; $sql .= " AND boards.id = $board_id" if $board_id; $sql .= " AND threads.id = $thread_id" if $thread_id; $sql .= " AND messages.authorId = $user_id" if $user_id; $sql .= " AND ((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(messages.posttime)) <= ($last_entries * 24 * 60 * 60))" if lc($action) eq lc('lastMessagesDays'); $sql .= " AND messages.position = '1'" if lc($filter) eq 'no_replies'; $sql .= " ORDER BY messages.posttime DESC"; if (lc($action) eq lc('lastMessagesDays')) { $sql .= " LIMIT $max_entries"; } # if elsif (lc($action) eq lc('lastMessagesNumbers')) { $sql .= " LIMIT $last_entries"; } # if else { $sql .= " LIMIT $max_entries"; } # ifelse print "\n\n$sql\n\n" if $debug; ### DB ### my $storage = PBoard::Storage->new( { dbh => undef } ); my $poard = PBoard->new( { cgi => $cgi, storage => $storage } ); my $dbh = PBoard::DB::ConnectToDB( $poard ); $storage->set_dbh( $dbh ); my $sth = &PBoard::DB::FireSql( $poard, $sql ); ### Feed erzeugen ### my $rss = new XML::RSS (version => '2.0'); $rss->channel(title => $rss_board_titel, link => $rss_board_link, language => $rss_language, description => $rss_description, copyright => $rss_copyright, docs => $rss_docs, managingEditor => $rss_managingEditor, webMaster => $rss_webMaster, ); my %hash_ref; while(my $hash_ref = $sth->fetchrow_hashref) { my $link = $rss_board_link.'/thread/'.${$hash_ref}{'thread_id'}.'/startWithMessage='.(int(${$hash_ref}{'position'}/10)*10).'/#MSG'.${$hash_ref}{'position'}; $rss->add_item( title => ${$hash_ref}{'thread_title'}, link => $link, description => ${$hash_ref}{'message_raw'}, ); } # while $sth->finish; return $rss->as_string; } # sub erzeuge_rss_feed