Not Another PhpBB Integration

Thread Solved

Join Date: Apr 2004
Posts: 59
Reputation: world_weapon is an unknown quantity at this point 
Solved Threads: 2
world_weapon's Avatar
world_weapon world_weapon is offline Offline
Junior Poster in Training

Not Another PhpBB Integration

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 59
Reputation: world_weapon is an unknown quantity at this point 
Solved Threads: 2
world_weapon's Avatar
world_weapon world_weapon is offline Offline
Junior Poster in Training

Re: Not Another PhpBB Integration

 
0
  #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
  1. <?php
  2. define('IN_PHPBB', true);
  3. $phpbb_root_path = './forum/';
  4. include($phpbb_root_path . 'extension.inc');
  5. include($phpbb_root_path . 'common.'.$phpEx);
  6.  
  7. //
  8. // Start session management
  9. //
  10. $userdata = session_pagestart($user_ip, PAGE_LOGIN);
  11. init_userprefs($userdata);
  12. //
  13. // End session management
  14. //
  15. $page_title = "Catalog";
  16. include("misc.php"); // <---EXTERNAL FILE
  17. ?>
  18. <html>
  19. <head>
  20. <title>Whatever you want</title>
  21. <link href="./mainstyle.css" rel="stylesheet" type="text/css" />
  22. <script type="text/JavaScript" src="mainscript.js"></script>
  23. </head>
  24. <body>PAGE CONTENTS GO HERE !!!!!
  25. <?php generateSomething(); ?>
  26. </body>
  27. </html>
Well this is what the external include misc.php will have to look like....
  1. <?php
  2. $connection = mysql_connect(localhost,db_username,db_password)
  3. or die("Couldn't connect to database!<br>");
  4. $database = "db_name"; //Database containing the tables for the chat logs
  5. $db = mysql_select_db($database,$connection)
  6. or die ("Database not selected!");
  7. function generateSomething(){
  8. global $userdata;
  9. echo "This is all it generates!? Booo.<br />";
  10. if ($userdata['session_logged_in']){
  11. echo "Well this is cool though, Your username is ".$userdata['username']."!!!!";
  12. }
  13. }
  14. ?>
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 Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC