In: , , ,
On: 2004 / 08 / 14 Viewed: 90251 times
Shorter URL for this post: http://ozh.in/1j

I run a community site that uses a phpBB2 forum, and I was wondering how to fetch informations from the forum into other pages (without messing with phpBB2 code, which is something I don't want to even hear about)
Here are some tips that may help you make your existing pages and phpBB2 communicate.

phpBB Fetch All

phpBB Fetch All : This project is a collection of functions you can easily use on any pages. Simple installation (5 or 6 pages in a forum sub-directory) and you have ready-to-use functions about posts (last posts, last topics, ongoing thread…), users (top posters, info about a random user…), polls and a lot of things. The doc pages are clear and list every function available.

This package contains almost everything I needed… Almost only, since there is no function to dectect informations from a login cookie, if any. It retrieves infos from the forum, but not from a user currently viewing a page.

Reading phpBB2's cookie

Hopefully, reading the login cookie is not difficult, I was real glad after a short googlage to realize how easy it was :) The following quick example just displays if the user has an ongoing session or cookie in your forums, you'll need to edit only line 5.

  1. <?php
  2. // phpBB includes
  3. define('IN_PHPBB', true);
  4. // next one is the physical path to your forums root : CUSTOMIZE
  5. $phpbb_root_path = '/home/user/you/forums/';
  6. include($phpbb_root_path . 'extension.inc');
  7. include($phpbb_root_path . 'common.'.$phpEx);
  8. // Start session
  9. $userdata = session_pagestart($user_ip, PAGE_INDEX);
  10. init_userprefs($userdata);
  11. // From now on, we have user infos
  12. if ($userdata['session_logged_in']) {
  13.         echo "You are : ".$userdata['username'] ." (".$userdata['user_email'].")<br>\n";
  14.         echo "Userid : ".$userdata['user_id']."<br>\n";
  15. } else {
  16.         echo "Not logged !";
  17. }
  18. ?>

The informations fetched can be any $userdata[thing] where thing is a field from phpbb2_users table : user_id, username, user_regdate, user_password, user_email, etc …

You can now use this informations into your existing site, for example auto-fill the comments form fields with username, user_url and user_email.

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/1j

Metastuff

This entry "Integration of phpBB2 into a site" was posted on 14/08/2004 at 11:38 pm and is tagged with , , ,

24 Blablas

  1. 1
    rail-flex France »
    wrote, on 15/Aug/04 at 12:27 am # :

    Nice hints :)

    But let's recognize Invision is much better :)

  2. 2
    David's Access United States »
    trackback on 18/Aug/04 at 3:33 pm # :

    Integrating phpBB with WordPress
    My prayers have been answered!

    For quite a while now, I have been trying to figure out how to integrate phpBB with WordPress. I have known and used the phpbb_fetch_all mod for quite a while, but I had not figured out how to handle merging the two c…

  3. 3
    david clark United States »
    replied, on 25/Aug/04 at 10:20 pm # :

    How did you work around both applications having funcs named get_userdata()?

  4. 4
    Ozh France »
    thought, on 25/Aug/04 at 11:07 pm # :

    The easiest way is to rename fetch_all's func to something else, like prefix them with "fa_" (this is quite quick as there arent so many functions)

  5. 5
    John United States »
    said, on 24/Feb/05 at 9:25 pm # :

    Nice hints :)

    But let's recognize Invision is much better :)

    It has more features for sure, but it also costs a lot more. I don't think it's fair to look at these things from a simple this one is better than that one standpoint. The right tool for the job, in other words. It's also important to note that phpBB 3.0 is bringing many new features to the table.

  6. 6
    Sam United States »
    said, on 28/Mar/05 at 2:10 am # :

    >

    I'm trying to implement this as you say and have done so with all of my fetch_all functions. But it seems as if the same fix is required throughout all of phpbb (not just phpbb fetch all). Does that make sense? I'm a little nervous to make those changes, because I don't want to mess with my boards, but it would be great to integrate the boards with my WordPress.

    Thanks!

    Sam

  7. 7
    Ozh France »
    thought, on 29/Mar/05 at 9:14 pm # :

    Why would you need to modify original phpBB functions ? fetch_all functions retrieve stuff from the phpbb tables, no matter their name is do_something or fa_do_something …

  8. 8
    Sam United States »
    commented, on 05/Apr/05 at 9:44 pm # :

    I'm getting this error

    Fatal error: Cannot redeclare get_userdata() (previously declared in /home/content/m/y/s/mysportsradio/html/wp-includes/functions.php:184) in /home/content/m/y/s/mysportsradio/html/boards/includes/functions.php on line 116

    I think may have something to do with common.php here:
    include_once ($phpbb_root_path . 'common.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);

    I'm very novice at php so I'm pulling my hair out but want to get this solved. Thanks for your help!

  9. 9
    Ozh France »
    replied, on 05/Apr/05 at 10:07 pm # :

    Yes, that's why you have to rename fetch_all's functions. But leave those in phpbb intact.

  10. 10
    Sam United States »
    thought, on 06/Apr/05 at 5:07 am # :

    >

    This is what I have intended to do, yet I get this error. As mentioned, I'm a newb so I'm not at all clear what's going on with this.

  11. 11
    WDuluoz United States »
    commented, on 08/Jun/05 at 8:05 am # :

    Ok, I have fooled with this again and again. The only place that get_userdata is being called is within wordpress and within phpbb. Fetch all does not have a get_userdata. The conflict is between wordpress and phpbb. The only way you could have managed to make this work is renaming the functions in wordpress. Is that the case?
    After changing the wordpress function names, I get this error when trying to call common.php
    Call to a member function on a non-object
    Any ideas?

  12. 12
    duncan United Kingdom »
    replied, on 12/Jun/05 at 6:26 pm # :

    If you're interested in logging in users to both your site and phpBB (if you have your own login code and want to have a single-sign-on), then look no further!

    I wrote a PHP class to take care of this:

    http://www.phpclasses.org/browse/package/1532.html

  13. 13
    Luke United Kingdom »
    thought, on 30/Oct/05 at 5:42 am # :

    Like WDuluoz, I also cannot find any get_userdata vars to change in the phpBB Fetch All functions. The variable is within phpBB itself. How did you get around this?

  14. 14
    Jake United States »
    commented, on 16/Dec/05 at 7:44 pm # :

    I'm getting the following warning at the top of the page when I use this code. Any ideas on fixing it?

    Warning: Cannot modify header information – headers already sent by (output started at /home/path/roster.php:9) in /home/path/sessions.php on line 258

    Warning: Cannot modify header information – headers already sent by (output started at /home/path/roster.php:9) in /home/path/sessions.php on line 259

  15. 15
    Ozh France »
    commented, on 16/Dec/05 at 9:23 pm # :

    you badly edited roster.php and it's outputting white spaces before sending the header. Probably blank spaces or lines before or after PHP tags.

  16. 16
    Jake United States »
    wrote, on 16/Dec/05 at 10:53 pm # :

    Sorry, but I'm still not sure what I need to fix.

  17. 17
    Ozh France »
    wrote, on 17/Dec/05 at 12:08 am # :

    One of your files is beginning or ending with spaces or new lines. Remove them.

  18. 18
    Jake United States »
    replied, on 17/Dec/05 at 12:26 am # :

    I deleted " Title " and just started with "

  19. 19
    Jake United States »
    said, on 17/Dec/05 at 12:28 am # :

    That last comment didn't work. I deleted the HTML, HEAD, and TITLE opening and closing tags and just started with the php tag and it got rid of the error.

    Thanks.

  20. 20
    CoolGuy India »
    replied, on 29/Apr/06 at 8:31 pm # :

    Hello,
    Greetings! I am trying to integrate PhpbBB script with a HTML page. How can i do it? I look forward to hear a earlier reply. Thank you very much for your time.
    Good regards.

  21. 21
    Ozh France »
    wrote, on 30/Apr/06 at 7:34 pm # :

    To the whole world » I loathe PHPBB2 and I ditched it months ago. Ask for support on phpbb2 sites, thanks :)

  22. 22
    Shawn United States »
    replied, on 18/Oct/06 at 12:00 am # :

    Yeah, just thought I would leave a comment.
    I've used both IPB and phpBB, but the website I am updating is in a phpBB database…I'm finding myself pretty much re-writing the entire forums!

    Once I'm done it might be real nice to see since I'm implementing tons of ajax.

  23. 23
    XRumer255 Germany »
    replied, on 30/Oct/06 at 7:35 am # :

    Abnormal program termination.

  24. 24
    usedggues Russia »
    commented, on 23/Apr/07 at 11:04 pm # :

    Good site :) Respect for admin…

Read more ?