Thread Mail-Benachrichtigung oder RSS ... (22 answers)
Opened by lux at 2008-04-10 10:33

Hagen
 2008-04-22 14:53
#108712 #108712
User since
2007-09-06
233 Artikel
BenutzerIn
[default_avatar]
So, hier ist das erste Ergebnis. Die Zeilen mit $debug' werden später noch entfernt. Wer möchte, dem kann ich das Script natürlich auch per Email schicken.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
Gruß
Hagen

View full thread Mail-Benachrichtigung oder RSS ...