Jump to content

Recommended Posts

Posted

Well, I didn't upload phpBB3 to my host, I got a phpBB3 forum from here. But then, I didn't do anything to get rss feed, I just went to www.yourname.com/rss and it was there. :lol:

  • 6 months later...
  • Moderators
Posted

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! :D

Posted

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"); ?>

  • 4 weeks later...
Posted
<?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;
}
?>

  • 1 year later...
Posted

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.

  • 2 years later...
Posted

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?

Posted

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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...