Hi, this works perfect for me, but I can't seem to include the php file into my homepage.ameeck wrote:Here's a version I use, its posted in a topic somewhere here, but since this topic is a request just for this:
Code: Select all
<?php /** * newest_posts - raw dump of newest posts from forum * * @copyright (c) 2008 ameeck / Vojtech Vondra - phpBB.cz * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ define('IN_PHPBB', true); $phpbb_root_path = './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); // Number of posts and grabbing permissions // Počet příspěvků pro zobrazení a oprávnění $topic_limit = request_var('topic_limit', 5); $forums = array_unique(array_keys($auth->acl_getf('f_read', true))); // Select the last topics to which we have permissions // Vybrat poslední témata ke kterým máme oprávnění $sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u WHERE post_approved = 1 AND ' . $db->sql_in_set('forum_id', $forums) . ' AND u.user_id = p.poster_id ORDER BY post_time DESC LIMIT 0,' . $topic_limit; $result = $db->sql_query($sql); // Proper header since output not buffered // Poslat hlavičky pro správné kódování, protože výpis obsahu je postupný header('Content-Type: text/html; charset=utf-8'); // Now let's output the content // A teď vypsat obsah echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Last Topics</title></head><body><div id="post_content"><strong>Last Topics:</strong><br/><ul>'; while ($row = $db->sql_fetchrow($result)) { $url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"; echo '<li><a target="_top" href="' . $url . '">' . $row['post_subject'] . '</a> from ' . $row['username'] . ' on ' . $user->format_date($row['post_time']) . '</li>'; } echo '</ul></div></body></html>'; ?>
Code: Select all
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Code: Select all
<?php
/**
* newest_posts - raw dump of newest posts from forum
*
* @copyright (c) 2008 ameeck / Vojtech Vondra - phpBB.cz
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
define('IN_PHPBB', true);
$phpbb_root_path = 'PATH TO YOUR FORUM';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Number of posts and grabbing permissions
// Pocet príspevku pro zobrazení a oprávnení
$topic_limit = request_var('topic_limit', 5);
$forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
// Select the last topics to which we have permissions
// Vybrat poslední témata ke kterým máme oprávnení
$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
WHERE post_approved = 1
AND ' . $db->sql_in_set('forum_id', $forums) . '
AND u.user_id = p.poster_id
ORDER BY post_time DESC
LIMIT 0,' . $topic_limit;
$result = $db->sql_query($sql);
// Proper header since output not buffered
// Poslat hlavicky pro správné kódování, protože výpis obsahu je postupný
header('Content-Type: text/html; charset=utf-8');
// Now let's output the content
// A ted vypsat obsah
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Last Topics</title></head><body><div id="post_content"><strong>Last Topics:</strong><br/><ul>';
while ($row = $db->sql_fetchrow($result))
{
$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
echo '<li><a target="_top" href="' . $url . '">' . $row['post_subject'] . '</a> from ' . $row['username'] . ' on ' . $user->format_date($row['post_time']) . '</li>';
}
echo '</ul></div></body></html>';
?>
Code: Select all
<?
/*** phpBB3 - Last Active Topics System ***/
//Author: Ioan Filipov
//Email: [email protected]
//Date: 04.06.2007
//------------------------------
//Edit these parameters:
//MySQL server adress
$host="localhost";
//Username
$user="removed";
//Password
$pass="removed";
//Database
$db="removed";
//Table prefix
$table="phpbb_";
//Show last x topics
$laforums="10";
$link=mysql_connect($host, $user, $pass);
$db=mysql_select_db($db);
$query="select * from $table".topics." WHERE topic_approved = '1' order by topic_last_post_time desc limit 0,$laforums";
$query2="select config_name,config_value from $table".config." where config_name = 'server_name' limit 0,1";
$result2=mysql_query($query2);
$row2 = mysql_fetch_array($result2);
extract($row2);
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)) {
extract($row);
$date = date("F j, Y, g:i a", $topic_last_post_time );
$query3="select forum_name from $table".forums." WHERE forum_id = ".$forum_id."";
$result3=mysql_query($query3);
$row2 = mysql_fetch_array($result3);
echo "<a href='http://".$config_value."/viewforum.php?f=".$forum_id."' target='_blank'>".$row2[forum_name].":</a> <a href='http://".$config_value."/viewtopic.php?f=".$forum_id."&t=".$topic_id."' target='_blank'>".$topic_title."</a> view: ".$topic_views.", replies: ".$topic_replies.", topic first poster: ".$topic_first_poster_name.", topic last poster: ".$topic_last_poster_name.", topic last post time: ".$date."<br>\n";
}
//-------------------------- END
?>
Code: Select all
<table
style="text-align: left; width: 700px; margin-left: auto; margin-right: auto;"
border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="vertical-align: top; text-align: center; font-weight: bold;">Poster<br>
</td>
<td
style="vertical-align: top; width: 250px; text-align: center; font-weight: bold;">Topic
Title<br>
</td>
<td
style="vertical-align: top; text-align: center; font-weight: bold;">Replies<br>
</td>
<td
style="vertical-align: top; text-align: center; font-weight: bold;">Views<br>
</td>
<td
style="vertical-align: top; text-align: center; font-weight: bold;">Last
Replied<small><br>
</small></td>
</tr>
<tr>
<td style="vertical-align: top;">".$topic_first_poster_name."</td>
<td style="vertical-align: top;"><a
href="http://%22.$config_value.%22/viewtopic.php?f=%22.$forum_id.%22&t=%22.$topic_id.%22"
target="_blank">".$topic_title."</a></td>
<td style="vertical-align: top;">[".$topic_replies."]</td>
<td style="vertical-align: top;">[".$topic_views."]</td>
<td style="vertical-align: top;">".$topic_last_poster_name."</td>
</tr>
</tbody>
</table>
Demorgon wrote:I am using this code here and it works great.But I would like to contain everything into a table like I have in the code below, but how can it be coded properly to display without any errors? I am stumped on this, newb here...Code: Select all
<? /*** phpBB3 - Last Active Topics System ***/ //Author: Ioan Filipov //Email: [email protected] //Date: 04.06.2007 //------------------------------ //Edit these parameters: //MySQL server adress $host="localhost"; //Username $user="removed"; //Password $pass="removed"; //Database $db="removed"; //Table prefix $table="phpbb_"; //Show last x topics $laforums="10"; $link=mysql_connect($host, $user, $pass); $db=mysql_select_db($db); $query="select * from $table".topics." WHERE topic_approved = '1' order by topic_last_post_time desc limit 0,$laforums"; $query2="select config_name,config_value from $table".config." where config_name = 'server_name' limit 0,1"; $result2=mysql_query($query2); $row2 = mysql_fetch_array($result2); extract($row2); $result=mysql_query($query); while ($row=mysql_fetch_array($result)) { extract($row); $date = date("F j, Y, g:i a", $topic_last_post_time ); $query3="select forum_name from $table".forums." WHERE forum_id = ".$forum_id.""; $result3=mysql_query($query3); $row2 = mysql_fetch_array($result3); echo "<a href='http://".$config_value."/viewforum.php?f=".$forum_id."' target='_blank'>".$row2[forum_name].":</a> <a href='http://".$config_value."/viewtopic.php?f=".$forum_id."&t=".$topic_id."' target='_blank'>".$topic_title."</a> view: ".$topic_views.", replies: ".$topic_replies.", topic first poster: ".$topic_first_poster_name.", topic last poster: ".$topic_last_poster_name.", topic last post time: ".$date."<br>\n"; } //-------------------------- END ?>
This would be inserted in the echo command area.Code: Select all
<table style="text-align: left; width: 700px; margin-left: auto; margin-right: auto;" border="1" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="vertical-align: top; text-align: center; font-weight: bold;">Poster<br> </td> <td style="vertical-align: top; width: 250px; text-align: center; font-weight: bold;">Topic Title<br> </td> <td style="vertical-align: top; text-align: center; font-weight: bold;">Replies<br> </td> <td style="vertical-align: top; text-align: center; font-weight: bold;">Views<br> </td> <td style="vertical-align: top; text-align: center; font-weight: bold;">Last Replied<small><br> </small></td> </tr> <tr> <td style="vertical-align: top;">".$topic_first_poster_name."</td> <td style="vertical-align: top;"><a href="http://%22.$config_value.%22/viewtopic.php?f=%22.$forum_id.%22&t=%22.$topic_id.%22" target="_blank">".$topic_title."</a></td> <td style="vertical-align: top;">[".$topic_replies."]</td> <td style="vertical-align: top;">[".$topic_views."]</td> <td style="vertical-align: top;">".$topic_last_poster_name."</td> </tr> </tbody> </table>
Any help much appreciated
That's including if I try opening the lasttopic.php page by itself in a browser (therefore my issue isn't a conflict of another script trying to use the same variables or anything). So it does work in terms of pulling the information and displaying it correctly...but it still starts off with the errors every time.[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /lasttopic.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /lasttopic.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 990: Cannot modify header information - headers already sent by (output started at /lasttopic.php:1)
And then it lists all of the posts currently under these errors
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Number of posts and grabbing permissions
$topic_limit = request_var('topic_limit', 10);
$forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
// Select the last topics to which we have permissions
$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
WHERE post_approved = 1
AND ' . $db->sql_in_set('forum_id', $forums) . '
AND u.user_id = p.poster_id
ORDER BY post_time DESC
LIMIT 0,' . $topic_limit;
$result = $db->sql_query($sql);
// Now let's output the content
echo '<html><head><title>Animevortex - Latest Forum Posts</title><link rel="stylesheet" href="./ssi/styles.css" type="text/css"></head><body bgcolor="#333333"><br /><div id="post_content"><ul>';
while ($row = $db->sql_fetchrow($result))
{
$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
echo '<li><a target="_top" href="' . $url . '">' . $row['post_subject'] . '</a><br /><font size="1" color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">from ' . $row['username'] . ' on ' . $user->format_date($row['post_time']) . '</font></li>';
}
echo '</ul></div></body></html>';
?>
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
if ($user->data['user_id'] == ANONYMOUS)
{
login_box('', $user->lang['LOGIN']);
}
?>
Code: Select all
Fatal error: Cannot redeclare deregister_globals() (previously declared in /home/content/l/i/f/lifeleap99/html/toolbox/common.php:32) in /home/content/l/i/f/lifeleap99/html/toolbox/common.php on line 94