cheechm Posted January 14, 2007 Share Posted January 14, 2007 Hi,I have PHP Fetch ALl and I was wondering s it possible to have proected pages which can be visted if you log in to the forums? Or vice versa. I know PHPNuke kinda does this, but I don't want to use it. I literally want to use the PHPBB databaseWould this code work? [code] php:<?php if ($userdata['username']) { // Logged in content here } else { // Not logged in content here } ?>[/code]Thanks Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/ Share on other sites More sharing options...
Hypnos Posted January 15, 2007 Share Posted January 15, 2007 The idea will work, but just checking if username is set may not be the best way to do it. You might get positive matches on banned users.You actually don't even need PHPBB Fetchall. I do it on my site just with this:[code=php:0]define('IN_PHPBB', true);$site_root_path = ""; //<-- Modify $phpbb_root_path2 = 'forum/'; //<-- Modify $phpbb_root_path = $site_root_path . $phpbb_root_path2; 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); [/code]It should return that same array.You can var_dump($userdata) to see what each switch in the array is set to. I would try it with a banned user, a guest, and a normal user account.I'm using if($userdata['user_active'] == 1) for my user only content, and it seems to work fine. Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-160838 Share on other sites More sharing options...
cheechm Posted January 15, 2007 Author Share Posted January 15, 2007 Do I have to put the first set of code in every page I want protected? Also, if the user isn't logged in how do I redirect them to a login page? And then so if they are logged in it goes to the protected page automatically.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-161201 Share on other sites More sharing options...
Hypnos Posted January 15, 2007 Share Posted January 15, 2007 Yes. It might be easier to put it in a single file, then include it every time you need it.You can actually make your own login page that uses the phpbb login script. There's a post var that you can set to redirect to any page on your site.http://www.phpbb.com/kb/article.php?article_id=216 Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-161223 Share on other sites More sharing options...
cheechm Posted January 15, 2007 Author Share Posted January 15, 2007 Is this [code=php:0]if($userdata['user_active'] == 1)[/code] counted as a new part of the PHP code?The file with the code written in it would be called protection. Is this how I would include it?[code=php:0]<?php include("protection.php"); ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-161228 Share on other sites More sharing options...
cheechm Posted January 15, 2007 Author Share Posted January 15, 2007 I have just been playing around with it. ??? ??? ???I can't get it to work.I login into the forums and then visit the page with the include in it. I have protection.php written and saved it. But when I visit it, it doesn't seem to protect the page.The forum is located here:htdocs/forumThe protected pages are located here:htdocs/accountWhat is the problem?ThanksBTWI have done the redirect easily though. That helped a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-161318 Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 This is an old thread, so I'm not sure if you ever figured it out, but you need to define the php path vars correctly for your installation.Remeber that as soon as you go in to /account, the forum path will change to ../forum/, because you have to step down a directory.Try saving this as a file and putting it in /account.[code]<?phpdefine('IN_PHPBB', true);$site_root_path = ""; //<-- Modify $phpbb_root_path2 = '../forum/'; //<-- Modify $phpbb_root_path = $site_root_path . $phpbb_root_path2; 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); var_dump($userdata);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34173-solved-phpbb-fetch-all/#findComment-178911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.