Hi all,
Does anyone have the code for displaying phpbb3 latest forum posts on the frontpage? also is there a auto register code for phpbb?
thanks in advance
Scott
Hi all,
Does anyone have the code for displaying phpbb3 latest forum posts on the frontpage? also is there a auto register code for phpbb?
thanks in advance
Scott
I got my phpBB3 to support rss feeding and viewed the RSS feed in the website.
Ok so how do I get the forum to produce a RSS feed and then how do I implement it on the frontpage?
I know this an old post. I have the code if anyone needs it.
I know this an old post. I have the code if anyone needs it.
been looking for one for a while. yes please, could I have the code please?
thanks!
Me too please…that would be Great
(null)
name it recent_post.php. Replace URL to your forums with the url, leave the backslash. Upload it to your forum directory.
<?php
// Sets the number of topics to display
$topicnumber = 5;
// Change this to your PHPBB3 path (no trailing slash "/")
$urlPath = "URL to your forums/";
// Database configuration (where your PHPBB3 config.php file is located)
include 'config.php';
// Database connection and error messages
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");
// Main database query
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
/ **********************
***********************
EXCLUDE THESE FORUM IDs (if you have private forums)
***********************
********************** /
t.forum_id != 17 AND
t.forum_id != 19 AND
t.forum_id != 20 AND
/ **********************
***********************
END EXCLUSIONS
***********************
********************** /
/* Back to the query... */
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// HTML parsing
echo "<a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" class='topic_new'>" .
$row["topic_title"] .
"</a><br /><a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\">" .
$row["username"] . "</a> on " .
date('M j, Y, g:i a', $row["post_time"]) . "<br /><br />";
}
mysql_free_result($result);
mysql_close($link);
?>
<?php include("forums/latest_post.php"); ?>
Thank you very much it works great
(null)
<?php
// Sets the number of topics to display
$topicnumber = 5;
// Change this to your PHPBB3 path (no trailing slash "/")
$urlPath = "URL to your forums/";
// Database configuration (where your PHPBB3 config.php file is located)
include 'config.php';
// Database connection and error messages
$table_topics = $table_prefix. "topics";
$table_forums = $table_prefix. "forums";
$table_posts = $table_prefix. "posts";
$table_users = $table_prefix. "users";
$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");
mysql_set_charset('utf8');
// Main database query
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
/ **********************
***********************
EXCLUDE THESE FORUM IDs (if you have private forums)
***********************
********************** /
t.forum_id != 17 AND
t.forum_id != 19 AND
t.forum_id != 20 AND
/ **********************
***********************
END EXCLUSIONS
***********************
********************** /
/* Back to the query... */
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id
ORDER BY p.post_id DESC LIMIT $topicnumber";
$result = mysql_query($query) or die("Query failed");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// HTML parsing
echo "<a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&p=$row[post_id]#p$row[post_id]\" class='topic_new' target='_blank'>" .
$row["topic_title"] .
"</a><br /><a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\" target='_blank'>" .
$row["username"] . "</a> on " .
datum($row["post_time"]) . "<br /><br />";
}
mysql_free_result($result);
mysql_close($link);
function datum($time) {
$ma = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$tegnap = $ma-(60*60*24);
if($time > $ma) { $datum = "today, " . date("H:i",$time); }
elseif($ma > $time AND $time > $tegnap) { $datum = "yesterday, " . date("H:i",$time); }
elseif($time < $tegnap) { $datum = date ("M j, Y H:i",$time); }
return $datum;
}
?>
I know this is a rather old post and I thank you flyalaska for the script.
What I am wondering is can we make it so that instead of excluding private forums, can we make it check if one is an admin or moderator what ever the private forum is setup to show to? So if and admin or moderator then allow to see the recent private post and if not then continue on to the other posts?
Thanks again for this script. I like how it works and looks decent on my site.
Now I know this post is old as hell but , this old code has quit working due to mysql_connect() being deprecated. I have tried mysqli_connect() and PDO and it is a no go all the way around.
Any one still pulling posts on their site?
No one? I do have a working version on the same exact server setup as my live site but it is a WAMP server. The script on my WAMP works a treat, however, on my live server, it fails miserably.
Here is what I have. Maybe someone has better luck than I with it.
**PLEASE NOTE**
This code is to be used at your own risk. I do not know if it is secure or what. It did come right from phpBB community. I take no credit or ownership.
The WAMP server it is working on is:
Apache
php 5.6.25
mysql 5.7.14
The server it is NOT working on is:
apache
php 5.5.36
mysql:
Include this following code at the VERY TOp of every page in which you wish to call the latest posts.
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './community/'; // Path to phpbb folder
$phpEx = substr(strrchr( __FILE__ , '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
// Grab user preferences
$user->setup();
?>
Use this where you wish the latest posts to show
<?php
/ ***phpBB3 - Last Active Topics System*** /
//Show last x topics
define('TOPICS_LIMIT',10);
// Create arrays
$topics = array();
// Get forums that current user has read rights to.
$forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
// Get active topics.
$sql="SELECT *
FROM " . TOPICS_TABLE . "
WHERE topic_approved = '1' AND " . $db->sql_in_set('forum_id', $forums) . "
ORDER BY topic_last_post_time DESC";
$result = $db->sql_query_limit($sql,TOPICS_LIMIT);
while ($r = $db->sql_fetchrow($result))
{
$topics[] = $r;
}
$db->sql_freeresult($result);
?>
<div>
<?php
foreach($topics as $t)
{
// Get folder img, topic status/type related information
$topic_tracking_info = get_complete_topic_tracking($t['forum_id'], $t['topic_id']);
$unread_topic = (isset($topic_tracking_info[$t['topic_id']]) && $t['topic_last_post_time'] > $topic_tracking_info[$t['topic_id']]) ? true : false;
$folder_img = $folder_alt = $topic_type = '';
topic_status($t, $t['topic_replies'], $unread_topic, $folder_img, $folder_alt, $topic_type);
// output the link
?>
<img style="vertical-align: text-bottom" src="<?php echo $user->img($folder_img, $folder_alt, false, '', 'src');?>" title="<?php echo $user->lang[$folder_alt];?>" alt="<?php echo $user->lang[$folder_alt];?>" />
<a href="<?php echo $phpbb_root_path . 'viewtopic.php?f=' . $t['forum_id'] . '&t=' . $t['topic_id'] . '&p=' . $t['topic_last_post_id'] . '#p' . $t['topic_last_post_id'];?>"><?php echo html_entity_decode($t['topic_title']);?></a><br />
<?php
}
?>
</div>