Neue Beiträge außerhalb des Forums anzeigen
Mit dem folgenden Script können (in der Forenversion JKBB 2.0) die neuesten Beiträge auch außerhalb des Forums angezeigt werden. Voraussetzung ist, dass sich die betreffende Seite im selben Webspace befindet, so dass die Dateien /includes/config.php und /includes/main/functions.php includiert werden können und auf die Forendatenbank zugegriffen werden kann.
<?php
/* Konfiguration */
// Anzahl der Themen, die ausgegeben werden sollen:
$i_threads = 5;
// Pfad des Forums, inkl. "http://" am Anfang und Slash am Ende, z.B. "http://example.com/forum/"
$u_board_l = 'http://example.com/forum/';
// Codierung der Webseite ('UTF-8' oder 'ISO-8859-1')
$charset = 'UTF-8';
/* die Dateien config.php und functions.php includen */
include('/path-to-forum/includes/config.php');
include('/path-to-forum/includes/main/functions.php');
/* ab hier muss nichts mehr geändert werden */
$dbconnect = @mysql_connect($dbhost,$dbuser,$dbpassword);
$dbselect = @mysql_select_db($dbdatabase);
if (! $dbconnect || ! $dbselect) {
echo 'Keine Datenbankverbindung';
} else {
if ($charset == 'UTF-8') {
mysql_query("SET NAMES 'utf8'");
}
if (! isset($dbprefix)) {
$dbprefix = 'jkf';
}
$r_config = mysql_query("SELECT name, content FROM " . $dbprefix . "_config WHERE name IN ('postsptp', 'b_htmlextension')");
while ($crow = mysql_fetch_array($r_config)) {
$$crow[0] = $crow[1];
}
$rext = ($b_htmlextension) ? '.html' : '';
$result = mysql_query("SELECT t.id, t.fid, t.zeit2, t.name AS tname, t.uname2, t.pzahl, f.name AS fname FROM " . $dbprefix . "_threads AS t INNER JOIN " . $dbprefix . "_foren AS f ON t.fid = f.id WHERE f.frstatus <= 1 ORDER BY t.zeit2 DESC LIMIT " . $i_threads);
echo '<table>' . "\n";
echo '<tr>' . "\n";
echo '<th>Forum</th>' . "\n";
echo '<th>Thema</th>' . "\n";
echo '<th>Beitrag</th>' . "\n";
echo '<th>von</th>' . "\n";
echo '<th>Datum</th>' . "\n";
echo '</tr>' . "\n";
while (list($tid, $fid, $i_lastpost, $tname, $uname2, $i_posts, $fname) = mysql_fetch_row($result)) {
echo '<tr>' . "\n";
echo '<td><a href="' . $u_board_l . str4url($fname) . '-f-' . $fid . '-1' . $rext . '">' . htmlspecialchars($fname) . '</a></td>' . "\n";
echo '<td><a href="' . $u_board_l . str4url($tname) . '-t-' . $tid . '-' . ceil($i_posts / $postsptp) . $rext . '#p' . $i_posts . '">' . htmlspecialchars($tname) . '</a></td>' . "\n";
echo '<td>' . $i_posts . '</td>' . "\n";
echo '<td>' . htmlspecialchars($uname2) . '</td>' . "\n";
echo '<td>' . date("d.m. H:i", $i_lastpost) . '</td>' . "\n";
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
}
?>
23.07.2010 00:53 | geändert: 23.07.2010 02:02
... 1 Jahr und 5 Monate später ...
Für JKBB 2.1 muss die SQL-Query etwas angepasst werden, das Script schaut dann so aus (Änderung fett markiert):
<?php
/* Konfiguration */
// Anzahl der Themen, die ausgegeben werden sollen:
$i_threads = 5;
// Pfad des Forums, inkl. "http://" am Anfang und Slash am Ende, z.B. "http://example.com/forum/"
$u_board_l = 'http://example.com/forum/';
// Codierung der Webseite ('UTF-8' oder 'ISO-8859-1')
$charset = 'UTF-8';
/* die Dateien config.php und functions.php includen */
include('/path-to-forum/includes/config.php');
include('/path-to-forum/includes/main/functions.php');
/* ab hier muss nichts mehr geändert werden */
$dbconnect = @mysql_connect($dbhost,$dbuser,$dbpassword);
$dbselect = @mysql_select_db($dbdatabase);
if (! $dbconnect || ! $dbselect) {
echo 'Keine Datenbankverbindung';
} else {
if ($charset == 'UTF-8') {
mysql_query("SET NAMES 'utf8'");
}
if (! isset($dbprefix)) {
$dbprefix = 'jkf';
}
$r_config = mysql_query("SELECT name, content FROM " . $dbprefix . "_config WHERE name IN ('postsptp', 'b_htmlextension')");
while ($crow = mysql_fetch_array($r_config)) {
$$crow[0] = $crow[1];
}
$rext = ($b_htmlextension) ? '.html' : '';
$result = mysql_query("SELECT t.id, t.fid, t.zeit2, t.name AS tname, t.uname2, t.pzahl, f.name AS fname FROM " . $dbprefix . "_threads AS t INNER JOIN " . $dbprefix . "_foren AS f ON t.fid = f.id WHERE f.i_read >= 7 ORDER BY t.zeit2 DESC LIMIT " . $i_threads);
echo '<table>' . "\n";
echo '<tr>' . "\n";
echo '<th>Forum</th>' . "\n";
echo '<th>Thema</th>' . "\n";
echo '<th>Beitrag</th>' . "\n";
echo '<th>von</th>' . "\n";
echo '<th>Datum</th>' . "\n";
echo '</tr>' . "\n";
while (list($tid, $fid, $i_lastpost, $tname, $uname2, $i_posts, $fname) = mysql_fetch_row($result)) {
echo '<tr>' . "\n";
echo '<td><a href="' . $u_board_l . str4url($fname) . '-f-' . $fid . '-1' . $rext . '">' . htmlspecialchars($fname) . '</a></td>' . "\n";
echo '<td><a href="' . $u_board_l . str4url($tname) . '-t-' . $tid . '-' . ceil($i_posts / $postsptp) . $rext . '#p' . $i_posts . '">' . htmlspecialchars($tname) . '</a></td>' . "\n";
echo '<td>' . $i_posts . '</td>' . "\n";
echo '<td>' . htmlspecialchars($uname2) . '</td>' . "\n";
echo '<td>' . date("d.m. H:i", $i_lastpost) . '</td>' . "\n";
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
}
?>
02.01.2012 19:23 | geändert: 02.01.2012 19:23
Nur Mitglieder können in diesem Forum Antworten schreiben.
| Thema | Autor | Forum | Beiträge | Letzter Beitrag |
|---|---|---|---|---|
| Featurevorschlag: "Unbeantwortete Beiträge" | Lionel | Feedback | 3 | 03.08.2010 15:41 |
| Letzte Themen/Beiträge im WP anzeigen | GreJan | Anpassungen | 4 | 29.03.2010 13:06 |
| Import eines phpBB-Forums (Version 2) | Jörg | Installation, Updates | 3 | 21.12.2008 13:41 |



