Ich habe das Forum unter /forum/ installiert. Läuft auch.
Hab das Modul angelegt:
Eingabe:
Code: Alles auswählen
<?php
/*
Konfiguration
*/
$phpbb_root_path = '/forum/';
/*
Ende der Konfiguration
*/
define('IN_PHPBB', true);
$phpbb_root_path = (preg_match("/\/$/i", $phpbb_root_path)) ? $phpbb_root_path : $phpbb_root_path . '/';
/*
Lade die benötigten phpBB Dateien
*/
if (!@include_once($phpbb_root_path . 'extension.inc')) {
die('Unable to open extension.inc. Feeling helpful? Send an email to the webmaster.');
}
if (!@include_once($phpbb_root_path . 'common.' . $phpEx)) {
die('Unable to open config file. Feeling helpful? Send an email to the webmaster.');
}
/*
Forenliste erstellen
*/
$sql = "SELECT forum_id, forum_name FROM " . FORUMS_TABLE . " ORDER BY forum_name";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not query table information", "", __LINE__, __FILE__, $sql);
}
else {
echo '<p>';
echo '<label for="VALUE[1]">Forum</label>' . "\n";
echo '<select name="VALUE[1]" id="VALUE[1]">';
while ( $row = $db->sql_fetchrow($result) )
{
echo '<option value="' . $row['forum_id'] . '"' . ("REX_VALUE[1]" == $row['forum_id'] ? ' selected="selected"' : '') . '>' . $row['forum_name'] . ' (' . $row['forum_id'] .')</option>';
}
echo '</select>';
echo '</p>';
}
?>
<p>
<label for="VALUE[2]">Anzahl der Posts</label>
<input type="text" value="REX_VALUE[2]" name="VALUE[2]" id="VALUE[2]" />
</p>
<p>
<label for="VALUE[3]">Postlänge</label>
<input type="text" value="REX_VALUE[3]" name="VALUE[3]" id="VALUE[3]" />
</p>
<p>
<input type="checkbox"<?php if("REX_VALUE[4]") echo 'checked="checked"'; ?> value="true" name="VALUE[4]" id="VALUE[4]" />
<label for="VALUE[4]">"Sticky"-Posts anzeigen</label>
</p>
<p>
<input type="checkbox"<?php if("REX_VALUE[5]") echo 'checked="checked"'; ?> value="true" name="VALUE[5]" id="VALUE[5]" />
<label for="VALUE[5]">Attachments anzeigen</label>
</p>
Code: Alles auswählen
<?php
/*
Konfiguration
*/
$phpbb_root_path = '/forum/';
$phpbb_url = 'http://www.briefmarken-jugend.de/forum/';
/*
Ende der Konfiguration
*/
define('IN_PHPBB', true);
$phpbb_root_path = (preg_match("/\/$/i", $phpbb_root_path)) ? $phpbb_root_path : $phpbb_root_path . '/';
$phpbb_url = (preg_match("/\/$/i", $phpbb_url)) ? $phpbb_url : $phpbb_url . '/';
/*
Thanks to geniusdex & hwlab for posting sample code to php.net.
*/
function shorten($str, $max_chars, $substitution = '...') {
if (strlen($str) > $max_chars) {
$str = substr($str, 0, ($max_chars - 3));
$last_space = strrpos($str, ' ');
$str = substr($str, 0, $last_space);
/*
Here we check to see if we just truncated right in the middle of a tag,
like "<a " (if that happens, adding the ">" character will at least
keep the page from crashing & burning)!
*/
if (strrpos($str, '>') < strrpos($str, '<')) {
$str .= '>';
}
$str .= $substitution;
}
return $str;
}
/*
Lade die benötigten phpBB Dateien
*/
if (!@include_once($phpbb_root_path . 'extension.inc')) {
die('Unable to open extension.inc. Feeling helpful? Send an email to the webmaster.');
}
if (!@include_once($phpbb_root_path . 'common.' . $phpEx)) {
die('Unable to open config file. Feeling helpful? Send an email to the webmaster.');
}
if (!@include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx)) {
die('Unable to open bbcode file. Feeling helpful? Send an email to the webmaster.');
}
/*
Variablen setzen
*/
$count = 0;
$more_url = $phpbb_url . 'viewforum.' . $phpEx . '?f=REX_VALUE[1]';
$GLOBALS['HTTP_COOKIE_VARS'] = & $HTTP_COOKIE_VARS;
$GLOBALS['HTTP_GET_VARS'] = & $HTTP_GET_VARS;
$GLOBALS['SID'] = & $SID;
$GLOBALS['board_config'] = & $board_config;
$GLOBALS['db'] = & $db;
$GLOBALS['gen_simple_header'] = & $gen_simple_header;
$GLOBALS['images'] = & $images;
$GLOBALS['lang'] = & $lang;
$GLOBALS['nav_links'] = & $nav_links;
$GLOBALS['phpbb_root_path'] = & $phpbb_root_path;
$GLOBALS['phpEx'] = & $phpEx;
$GLOBALS['session_length'] = & $session_length;
$GLOBALS['starttime'] = & $starttime;
$GLOBALS['template'] = & $template;
$GLOBALS['theme'] = & $theme;
$GLOBALS['user_ip'] = & $user_ip;
$GLOBALS['userdata'] = & $userdata;
/*
I need to run a SESSION just to have the bbcode file work!
*/
$userdata = session_pagestart($user_ip, $forum);
init_userprefs($userdata);
/*
Posts aus der Datenbank lesen
*/
$sql = 'SELECT t.topic_id, t.topic_poster, t.topic_time, t.topic_replies, u.username, p.post_id, p.bbcode_uid, p.post_subject, p.post_text ';
$sql .= 'FROM ' . TOPICS_TABLE . ' as t, ' . USERS_TABLE . ' as u, ' . POSTS_TEXT_TABLE . ' as p ';
$sql .= 'WHERE t.forum_id=REX_VALUE[1] AND t.topic_poster=u.user_id AND t.topic_first_post_id=p.post_id ';
if (!"REX_VALUE[4]") {
$sql .= 'AND t.topic_type=0 ';
}
$sql .= 'ORDER BY t.topic_time DESC ';
$sql .= 'LIMIT REX_VALUE[2]';
if (!$result = $db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Querying the database didn\'t work. Feeling helpful? Email the webmaster.');
}
/*
Ergebnisse durchlaufen und ausgeben
*/
while ($row = $db->sql_fetchrow($result)) {
$topic_id = $row['topic_id'];
$userid = $row['topic_poster'];
$topic_time = $row['topic_time'];
$replies = $row['topic_replies'];
$username = $row['username'];
$bid = $row['bbcode_uid'];
$post_id = $row['post_id'];
$subject = $row['post_subject'];
$text = $row['post_text'];
$topic_url = $phpbb_url . 'viewtopic.' . $phpEx . '?t=' . $topic_id;
/*
Attachments aus der Datenbank lesen
*/
$sql = 'SELECT d.attach_id, IFNULL(d.comment, d.real_filename) as label, d.mimetype, d.filesize';
$sql .= ' FROM ' . ATTACHMENTS_TABLE . ' as a';
$sql .= ' INNER JOIN ' . ATTACHMENTS_DESC_TABLE . ' as d ON a.attach_id = d.attach_id';
$sql .= ' WHERE a.post_id = ' . $post_id;
if (!$attachments = $db->sql_query($sql)) {
message_die(GENERAL_ERROR, 'Querying the database didn\'t work. Feeling helpful? Email the webmaster.');
}
if ($count < "REX_VALUE[2]") {
if ($bid != '') {
$text = ($board_config['allow_bbcode']) ? bbencode_second_pass($text, $bid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $text);
}
$text = make_clickable($text);
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if (count($orig_word)) {
$subject = preg_replace($orig_word, $replacement_word, $subject);
$text = preg_replace($orig_word, $replacement_word, $text);
}
$text = ($board_config['allow_smilies']) ? smilies_pass($text) : $text;
$text = str_replace("\n", '<br />', $text);
$text = preg_replace('/src ?= ?"images\/smiles\//', 'src="' . $phpbb_url . 'images/smiles/', $text);
$text = ("REX_VALUE[3]") ? shorten($text, "REX_VALUE[3]", '... <a href="' . $topic_url . '">weiter</a>') : $text;
$profile_url = $phpbb_url . 'profile.' . $phpEx . '?mode=viewprofile&u=' . $userid;
$profile_link_start = '<a href="' . $profile_url . '">';
$profile_link_end = '</a>';
$topic_time = gmdate($board_config['default_dateformat'], $topic_time + (3600 * $board_config['board_timezone']));
}
?>
<div class="forum_entry">
<h2 class="subject"><a href="<?php echo $topic_url; ?>"><?php echo $subject; ?></a></h2>
<p class="tagline"><?php echo $profile_link_start,$username,$profile_link_end . ' - ' . $topic_time; ?></p>
<p class="text"><?php echo $text; ?></p>
<?php
/*
Attachments durchlaufen und ausgeben
*/
if("REX_VALUE[5]" && isset($attachments) && $db->sql_numrows($attachments) > 0) {
echo '<h3>Anhang</h3>';
echo '<ul>';
while($attachment = $db->sql_fetchrow($attachments)) {
$size_lang = ($attachment['filesize'] >= 1048576) ? 'MB' : ( ($attachment['filesize'] >= 1024) ? 'KB' : 'Bytes' );
if ($attachment['filesize'] >= 1048576)
{
$attachment['filesize'] = (round((round($attachment['filesize'] / 1048576 * 100) / 100), 2));
}
else if ($attachment['filesize'] >= 1024)
{
$attachment['filesize'] = (round((round($attachment['filesize'] / 1024 * 100) / 100), 2));
}
echo '<li><a href=" ' . $phpbb_url . 'download.' . $phpEx . '?id=' . $attachment['attach_id'] . '">' . $attachment['label'] . ' (' . $attachment['filesize'] . ' ' . $size_lang . ')</a></li>';
}
echo '</ul>';
}
?>
<p class="comments"><a href="<?php echo $topic_url; ?>">Kommentare</a> (<?php echo $replies; ?>)</p>
</div>
<?php
$count++;
}
$db->sql_freeresult($result);
?>
<p><a href="<?php echo $more_url; ?>">Alle Einträge anzeigen.</a></p>
Unable to open extension.inc. Feeling helpful? Send an email to the webmaster.
Was nun? Was ist falsch konfiguriert? Ist noch etwas mehr nötig als Modul und phpBB-Forum??