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
-
// phpBB includes
-
define('IN_PHPBB', true);
-
// next one is the physical path to your forums root : CUSTOMIZE
-
$phpbb_root_path = '/home/user/you/forums/';
-
include($phpbb_root_path . 'extension.inc');
-
include($phpbb_root_path . 'common.'.$phpEx);
-
// Start session
-
$userdata = session_pagestart($user_ip, PAGE_INDEX);
-
init_userprefs($userdata);
-
// From now on, we have user infos
-
if ($userdata['session_logged_in']) {
-
echo "You are : ".$userdata['username'] ." (".$userdata['user_email'].")<br>\n";
-
echo "Userid : ".$userdata['user_id']."<br>\n";
-
} else {
-
echo "Not logged !";
-
}
-
?>
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
Pages: [3] 2 1 » Show All
commented, on 23/Apr/07 at 11:04 pm # :
Good site :) Respect for admin...
thought, on 30/Oct/06 at 7:35 am # :
Abnormal program termination.
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.
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 :)