In: , , ,
On: 2004 / 08 / 14 Viewed: 73172 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.

PHP:
  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.

Related posts

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

    Pages: [3] 2 1 » Show All

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

    Good site :) Respect for admin...

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

    Abnormal program termination.

  3. 22
    Shawn United States »
    thought, 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.

  4. 21
    Ozh France »
    said, 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 :)

Pages: [3] 2 1 » Show All

Read more ?

Close
E-mail It