| |
Welcome to Webmaster Forums 101!
You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact support.
|
 |
19th July 2003, 02:50 PM
|
#1
|
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
|
phpbb integration
hi mr.tech i need some help i want to use the login and private messages and who's online stuff from phpbb 2.0.4 on my main site so i want to intergate them together. But the way they tell to do it on phpbb.com doesn't work with my template system i am using for my main site.
It won't let me include both common.php from the forums and my template.php class file for my template system but i have to use my template.php class or my templates won't work and i have to have common.php from the forums or the sessions won't call from the forums.
I was wondering how to do this without using the common.php file from the forums.
any help would be appreciated
Thanks.
__________________
|
|
|
21st July 2003, 10:17 AM
|
#2
|
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
|
Re: phpbb integration
This is how I do it:
Page that shows whos online
Code:
<?php
define('IN_PHPBB', true);
// Path to forum
$phpbb_root_path = 'forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'config.php');
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
// Page which gets the data
include("online.php");
echo "$onlinet";
?>
online.php
Code:
<?php
$user_forum_sql = ( !empty($forum_id) ) ? "AND ( u.user_session_page = $forum_id
OR s.session_page = $forum_id)" : "";
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND ( s.session_time >= ".( time() - 300 ) . "
OR u.user_session_time >= " . ( time() - 300 ) . " )
$user_forum_sql
ORDER BY u.username ASC";
$result = $db->sql_query($sql);
if(!$result)
{
message_die(GENERAL_ERROR, "Couldn't obtain user/online information.", "", __LINE__, __FILE__, $sql);
}
$userlist_ary = array();
$userlist_visible = array();
$logged_visible_online = 0;
$logged_hidden_online = 0;
$guests_online = 0;
$online_userlist = "";
$prev_user_id = 0;
$prev_session_ip = 0;
while( $row = $db->sql_fetchrow($result) )
{
// User is logged in and therefor not a guest
if( $row['session_logged_in'] )
{
// Skip multiple sessions for one user
if( $row['user_id'] != $prev_user_id )
{
$style_color = "";
if( $row['user_level'] == ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
}
else if( $row['user_level'] == MOD )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
}
if( $row['user_allow_viewonline'] )
{
$user_online_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
$logged_visible_online++;
}
else
{
$user_online_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
$logged_hidden_online++;
}
if( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
{
$online_userlist .= ( $online_userlist != "" ) ? ", " . $user_online_link : $user_online_link;
}
}
}
else
{
if( $row['session_ip'] != $prev_session_ip ){
$guests_online++;
}
}
$prev_user_id = $row['user_id'];
$prev_session_ip = $row['session_ip'];
}
if( empty($online_userlist) )
{
$online_userlist = $lang['None'];
}
$online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . " " . $online_userlist;
$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
if($total_online_users > $board_config['record_online_users'])
{
$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '$total_online_users'
WHERE config_name = 'record_online_users'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update online user record (nr of users)", "", __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '" . time() . "'
WHERE config_name = 'record_online_date'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update online user record (date)", "", __LINE__, __FILE__, $sql);
}
$board_config['record_online_users'] = $total_online_users;
$board_config['record_online_date'] = time();
}
if( $total_online_users == 0 )
{
$l_t_user_s = $lang['Online_users_zero_total'];
}
else if( $total_online_users == 1 )
{
$l_t_user_s = $lang['Online_user_total'];
}
else
{
$l_t_user_s = $lang['Online_users_total'];
}
if( $logged_visible_online == 0 )
{
$l_r_user_s = $lang['Reg_users_zero_total'];
}
else if( $logged_visible_online == 1 )
{
$l_r_user_s = $lang['Reg_user_total'];
}
else
{
$l_r_user_s = $lang['Reg_users_total'];
}
if( $logged_hidden_online == 0 )
{
$l_h_user_s = $lang['Hidden_users_zero_total'];
}
else if( $logged_hidden_online == 1 )
{
$l_h_user_s = $lang['Hidden_user_total'];
}
else
{
$l_h_user_s = $lang['Hidden_users_total'];
}
if( $guests_online == 0 )
{
$l_g_user_s = $lang['Guest_users_zero_total'];
}
else if( $guests_online == 1 )
{
$l_g_user_s = $lang['Guest_user_total'];
}
else
{
$l_g_user_s = $lang['Guest_users_total'];
}
$l_online_users = sprintf($l_t_user_s, $total_online_users);
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
$l_online_users .= sprintf($l_g_user_s, $guests_online);
$onlinet="<hr size=\"1\"><br>$l_online_users<br><br>$online_userlist<br>";
?>
And that should do it. You'll have to find a MOD which will aloow you to show PM's but what I have shown you will show whos online.
Hope that helps!
|
|
|
21st July 2003, 10:23 AM
|
#3
|
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
|
well that should help with the whosonline part but how about the login part.
what i want is to be able to use phpbb's login stuff on my main site so it log's them in to my site and the forums.
and the pm thing i'm sure i can figure that out on my own trying to get support on phpbb.com isn't that easy lol.
Thanks for the help Mr.Tech.
__________________
|
|
|
21st July 2003, 10:35 AM
|
#4
|
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
|
Just use this code:
Code:
<form action="forum/login.php" method="post">
<input type="hidden" name="autologin">
<input type="hidden" name="redirect" value="">
<b>Username:</b><br>
<input type="text" name="username" size="15" maxlength="40" value=""><br>
<b>Password:</b><br>
<input type="password" name="password" size="15" maxlength="25"><br>
<input type="submit" name="login" value="Log in">
</form>
|
|
|
29th July 2003, 12:29 PM
|
#5
|
Join Date: Jan 2003
Location: California
Posts: 189
Points: 0.00
|
Code:
<?php
define('IN_PHPBB', true);
// Path to forum
$phpbb_root_path = 'forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');
include($phpbb_root_path . 'config.php');
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
// Page which gets the data
include("online.php");
echo "$onlinet";
?>
Mr. Tech. I was just wondering what does echo "$onlinet" does and where does it come from?
I don't get it?
__________________
When the Bitterness is gone, Sweetness will follow.
|
|
|
29th July 2003, 01:05 PM
|
#6
|
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
|
Quote:
|
Originally Posted by online.php
$onlinet="<hr size=\"1\"><br>$l_online_users<br><br>$on line_userlist<br>";
|
online.php :cheesygr:
|
|
|
29th July 2003, 04:44 PM
|
#7
|
Join Date: Jan 2003
Location: California
Posts: 189
Points: 0.00
|
Kewl! Thanks.
Looks I learn something new again today. Great work Mr. Tech for informing me.
__________________
When the Bitterness is gone, Sweetness will follow.
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
| Useful Resources |
| Webmaster Resources |
| |
| Developers Tools |
| |
| Developer Tutorials |
| |
|
All times are GMT +10. The time now is 10:42 PM.
|
|