{REQUEST} - Topics Anywhere for phpBB 3.x.

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
au8ust
Translator
Posts: 11
Joined: Sun Sep 09, 2007 1:12 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by au8ust »

Nobody? :(
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by tommekemc »

http://www.phpbb.com/community/viewtopi ... 2&t=952855
here you see how to do it, just edit the script so you echo the vars in the end :)
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
au8ust
Translator
Posts: 11
Joined: Sun Sep 09, 2007 1:12 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by au8ust »

Okay, it's fixed :) Just add mysql_query("SET NAMES 'utf8'"); into the code.
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by kyo »

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>';
    ?>
Hi, this works perfect for me, but I can't seem to include the php file into my homepage.

If I put the file itself in my homepage, it generates errors, as does my PHP news section.

If I generate the file in the forum root en PHP include it on my homepage nothing happens ...

Would there be another way?
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by tommekemc »

if you include the php file, make sure you don't have these things in your other php-file yet:

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();
and make sure the "$phpbb_root_path" is defined correctly.
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by kyo »

Hi and thanks but I don't really understand.

If I include it I just use a simple include code like:

<?php

include "community/latestposts.php";

?>
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by tommekemc »

okay.
could you copy-paste the errors generated?
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by kyo »

Hi, thanks for your help.

This is the error generated when including the entire php code into my homepage:

"[phpBB Debug] PHP Notice: in file /var/www/vhosts/surfreport.be/httpdocs/surfocean/news/show_news.php on line 37: htmlspecialchars() expects parameter 1 to be string, object given
Error!
the template does not exists, note that templates are case sensetive and you must write the name exactly as it is"

This is the site:

http://www.surfocean.eu/
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by tommekemc »

ok, try this code, edit 'PATH TO YOUR FORUM' to your real path (like: ./forum).
it should work, post the error you receive after this one pls :)

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>';
    ?>
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
Demorgon
Registered User
Posts: 5
Joined: Thu Feb 09, 2006 4:37 am
Location: USA, Maine

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by Demorgon »

I am using this code here and it works great.

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
    ?>
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

<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>
This would be inserted in the echo command area.

Any help much appreciated
acctman
Registered User
Posts: 103
Joined: Thu Feb 09, 2006 5:48 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by acctman »

Do you have a demo?
Demorgon wrote:I am using this code here and it works great.

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
    ?>
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

<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>
This would be inserted in the echo command area.

Any help much appreciated
mojitoo
Registered User
Posts: 83
Joined: Sat Jul 31, 2004 1:27 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by mojitoo »

what i don´t understand is that the tittle odff the mod is ...Topics Anywhere for phpBB 3.x.

and im not able to show the posts on my index.html page ... i can in my board but not on the index.html...

can anyone help me please?
User avatar
TheSa|nt
Registered User
Posts: 127
Joined: Tue Aug 20, 2002 9:09 am
Location: Earth

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by TheSa|nt »

I cannot get any of these to work. They all result in the same issue.

I try to run this code through an iframe outside of the forums, on my site. The result I get is:
[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 error
s
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.

Of course if the user clicks to enter my forums, and then goes back to view the page...it will view just fine. However, once their session I guess ends...the errors start again. This is a problem because users will see this in an iframe on the main index page of my site before they ever get to entering my forums.

The location where I am trying to iframe it is my root dir (my site's index file) and the lasttopic.php file and forums are in "./forum" subfolder.

The script I am using is:

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>';
    ?>
User avatar
TheSa|nt
Registered User
Posts: 127
Joined: Tue Aug 20, 2002 9:09 am
Location: Earth

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by TheSa|nt »

FYI, I think I got it!


What I did was change
$phpbb_root_path = './';

to
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';


and it appears to be working. So if anyone else has that problem....there's the solution ;)
andrew55
Registered User
Posts: 236
Joined: Wed Jan 28, 2009 7:43 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by andrew55 »

Mod works great - I've been using it on a forum with no problems.

I have another forum which is password protected. For this forum, I have an off-forum php page which has the following code:

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']);
    } 
    ?>
This makes it where a user has be logged into the forum to view the page. But when I put the Topics Anywhere code in this page, I get this error:

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
I've been struggling but can't figure how to make the two codes in this page work together. Any suggestions would be greatly appreciated.

Return to “[3.0.x] MOD Requests”