User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,534 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,968 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 616 | Replies: 1 | Solved
Reply
Join Date: Apr 2004
Location: Brownsville or Austin, TX or Faber, VA
Posts: 59
Reputation: world_weapon is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
world_weapon's Avatar
world_weapon world_weapon is offline Offline
Junior Poster in Training

Not Another PhpBB Integration

  #1  
Oct 7th, 2007
Hello everyone, I have an issue that I can't seem to resolve with integrating phpBB into the rest of my site so that login and session can be intact. Well, for the most part, the whole scheme seems to work at first glance. I noticed that pages that have the phpBB root path and includes and other initialization stuff works like a charm. I can pull up $userdata['username'] and what have you very nicely. I do have my own include file that has functions I use to generate menus and other things. These functions don't react to any of the $userdata.
The purpose of my existence is why I am here.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2004
Location: Brownsville or Austin, TX or Faber, VA
Posts: 59
Reputation: world_weapon is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
world_weapon's Avatar
world_weapon world_weapon is offline Offline
Junior Poster in Training

Re: Not Another PhpBB Integration

  #2  
Oct 7th, 2007
He he he he. After reading several pages about integrating phpBB into your main site through it's session capability, I came to realize that the answer was not in the actually integration code. This will solve a lot of headaches for noobs like myself, but if you have a external file of functions that need to use the $userdata that the page including the external file has already established, all you have to do is put into the function "global". This is an example of what I am talking about.
Member only page
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);
//
// End session management
//
$page_title = "Catalog";
include("misc.php"); // <---EXTERNAL FILE
?>
<html>
<head>
<title>Whatever you want</title>
<link href="./mainstyle.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript" src="mainscript.js"></script>
</head>
<body>PAGE CONTENTS GO HERE !!!!!
<?php generateSomething(); ?>
</body>
</html>
Well this is what the external include misc.php will have to look like....
<?php
$connection = mysql_connect(localhost,db_username,db_password)
    or die("Couldn't connect to database!<br>");
$database = "db_name"; //Database containing the tables for the chat logs
$db = mysql_select_db($database,$connection) 
    or die ("Database not selected!");
function generateSomething(){
global $userdata;
echo "This is all it generates!? Booo.<br />";
if ($userdata['session_logged_in']){
   echo "Well this is cool though, Your username is ".$userdata['username']."!!!!";
   }
}
?>
Well, thats the whole idea. I might have made some coding errors or something but
just so that if anyone runs into this problem there is at least something for those new to php like me to hint this, and save an hour or two of needless searching. PS. don't forget to append $userdata['session_id'] to any link that you need to have access to the login credentials. I manually echo it into the address instead of using the append_sid() which works for me, but thats just me. Thanks you all for your time.
Last edited by world_weapon : Oct 7th, 2007 at 7:24 pm. Reason: Lazy fingers
The purpose of my existence is why I am here.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC