944,129 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1515
  • PHP RSS
Oct 7th, 2007
0

Not Another PhpBB Integration

Expand Post »
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.
Similar Threads
Reputation Points: 21
Solved Threads: 2
Junior Poster in Training
world_weapon is offline Offline
63 posts
since Apr 2004
Oct 7th, 2007
0

Re: Not Another PhpBB Integration

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 Syntax (Toggle Plain Text)
  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....
PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 21
Solved Threads: 2
Junior Poster in Training
world_weapon is offline Offline
63 posts
since Apr 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php relocation on $_Get
Next Thread in PHP Forum Timeline: PHP Mail Scripting





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC