Login on main site with hiddin links

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Login on main site with hiddin links

Post by DreAdeDcoRpSE »

Okay, I was woundering, I was able to put the login to the forums onto my main website, seen HERE, but was curiouse if it was possiable to hide certian links found on my website till they log in. Once they have login there user name and password they would see all the links and also have the access to the forums. Also when they loged in that it would dump them ont the main index page of my site.

not sure if this is possiable but I am just curious, I am new to php so I dont know that much. Any insight would be helpful.
Last edited by DreAdeDcoRpSE on Sat Mar 10, 2007 4:04 am, edited 2 times in total.
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

It is possible, and fairly easy, this article will get you started: http://www.phpbb.com/kb/article.php?article_id=143
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

okay, I think I understand this a little. Just you have to figure your talking to a wall when you explain things to me. But what I am getting from this is that on ever page that I want to include the login to hide the links till there login, which I will have to say that it will just be just the main 9 pages of my site. I would have to put in

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
and I would have to alter the

Code: Select all

include($phpbb_root_path . 'common.'.$phpEx);
to match up with my phpBB path, so it would be like

Code: Select all

include($phpbb_root_path . '/phpBB2/common.'.$phpEx);


I am saying that because my root paths to the website is set up like
  • ect...
I think I am right, feel free to call me an idiot if I am wrong, tis okay to do that. But what I dont get is how would I make like the links on my site be hiddin untill they login, would that be done by adding the links into a file on the phpbb like in the session file or the common file and from there adding some sort of coding on all pages where the links would be that would be like a append_sid() or an includes or what ever.

Instead of thinking of me as a wall, cause they dont respond and are pretty lifeless, think of me as if I was 10 years old that can understand, but has to be explained on exactally what needs to be done.

But thanks for the quick responce, I believe you were one of a few that helped me get the login onto my website and I wanted to say thanks.
Last edited by DreAdeDcoRpSE on Thu Nov 08, 2007 6:16 pm, edited 1 time in total.
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

You got it this far. Then you just use this to hide stuff from guests:

Code: Select all

if( $userdata['session_logged_in'] )
   {
      [insert your HTML/PHP or whatever here]
   }
else
       {
               echo('Please Login');
       }
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

okay, I will give that a try on my test page now to see if that works. thanks for the help.
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

geocator wrote: You got it this far. Then you just use this to hide stuff from guests:

Code: Select all

if( $userdata['session_logged_in'] )
   {
      [insert your HTML/PHP or whatever here]
   }
else
       {
               echo('Please Login');
       }



you were close, I took what you said and altered it a little and it works beautifully. Thanks for the help. and for others that want to know what I had to do to make this work I did this...

Code: Select all

					<?php
					if( $userdata['session_logged_in'] )
   {
      ?>

Code: Select all

Then you put your HTML or PHP coding that you want hiddin unless they are logged in.

Code: Select all

<?php
}
else
       {
               echo('Must Login to<br>navagate this site!');
       }
	   ?>
I seperated it to show you the 3 section that make up one. You still need to have the

Code: Select all

<?php
          define('IN_PHPBB', true);
$phpbb_root_path = '/phpBB2/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
As stated above. but it works... Last question then I will say you were a god send. Is there a way to make it where ever they login will keep them at that page, if that is not possiable, is it possiable to make it so they go to the index page of the website and not the forums. mainly I just want it so if they login into the forums, they stay there, but if they log onto the site, they stay there instead of being redirected to the forums.
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

okay, I figured it would be something with this in the login.php file.

Code: Select all

if( $session_id )
					{
						$url = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : "index.$phpEx";
						redirect(append_sid($url, true));
					}
But if I edit that then the people that login on the forums that bypass the website will get sent to the main page of the website, I am looking to get around that so if login in on the forums they stay there but if they login on the website they stay on the index of the main site and not the forums, any suggestions to if this is possiable and if so how to do it?
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

In your website login form add a hidden variable called redirect.
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

Okay, I not sure on exactally how to do that, This help is greatly appreciated bigtime. This is what I am using for my login section. What would I have to add and where?

Code: Select all

<?php
          define('IN_PHPBB', true);
$phpbb_root_path = '/phpBB2/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
                                ?>
Then I have my html here all the way up to where I wanted the login box, then I used this for the login box.

Code: Select all

<?php
if( $userdata['session_logged_in'] )
   {
      echo "<b><center><font color=#00FF00 size=3><center>Welcome</font></center> ". $userdata['username'];
   }
else
       {
               echo('<font color=#00FF00><center><b>Forums login!</b></center></font>');
       
       ?>
	   <table width="100%"><center>
               </b><tr>
               <td align="center"><strong>Username:</strong></td></tr><tr>
          <td align="center"><form action="/phpBB2/login.php" method="post"><input type="text" name="username" class="textarea" size="18"></td>
               </tr>
               <tr>
               <td align="center"><strong>Password:</strong></td></tr><tr>
               <td align="center"><input type="password" name="password" class="textarea" size="18"></td>
               </tr>
			   <tr>
  <td align="center"><span class="gen"><font size="2">Log me on automatically each visit:</font></td></tr><tr><td align="center"><input type="checkbox" name="autologin" /></span></td>
   </tr>
               <tr>
               <td align="center"><input type="submit" value="login" name="login" class="textarea"></form></td>
               </tr>
			   <tr>
 <td align="center"><span class="gensmall"><a href="/phpBB2/profile.php?mode=sendpassword" class="gensmall">I forgot my password</a></span></td>
   </tr>
   <tr>
  <td align="center"><a href="/phpBB2/profile.php?mode=register" target="_blank">Click here to register</a></span></td></tr></center></table>
<?php
}
?>
So when you said add the hiddin variable I am taking a shot in the dark, but would it be like redirect=$_POST["redirect"]; or something like that, not sure... Thanks again.
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

Code: Select all

<input type="hidden" name="redirect" value="http://whatever" />
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

geocator wrote:

Code: Select all

<input type="hidden" name="redirect" value="http://whatever" />


Okay, I did that, and it worked, sortof, it sends me now to http://www.MySite.com/phpBB2/http://www ... 223c199adc
where I only wanted it to redirect me to http://www.MySite.com/indexs2.php

Am I going to have to create a second index page an put it in the phpBB so I can do this or is there a way to stop it from adding the http://www.MySite.com/phpBB2/
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

Just use the path like /index.php
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

geocator wrote: Just use the path like /index.php


but my problem is that my site is not on the same level as the phpBB2, its actually one level lower, I tried that first and it didnt work so I tried that way, I need to find a way to make it go down 1 level instead of looking on the same or greater level, if possiable.
geocator
Registered User
Posts: 16242
Joined: Fri Jan 09, 2004 11:56 pm
Location: On dry land
Contact:

Post by geocator »

DreAdeDcoRpSE wrote:
geocator wrote:Just use the path like /index.php


but my problem is that my site is not on the same level as the phpBB2, its actually one level lower, I tried that first and it didnt work so I tried that way, I need to find a way to make it go down 1 level instead of looking on the same or greater level, if possiable.


Try ../ or /../ first.
DreAdeDcoRpSE
Registered User
Posts: 196
Joined: Fri Dec 22, 2006 3:43 am

Post by DreAdeDcoRpSE »

geocator wrote:
DreAdeDcoRpSE wrote:
geocator wrote:Just use the path like /index.php


but my problem is that my site is not on the same level as the phpBB2, its actually one level lower, I tried that first and it didnt work so I tried that way, I need to find a way to make it go down 1 level instead of looking on the same or greater level, if possiable.


Try ../ or /../ first.


Thanks for the help, It worked. Something nice that should be done is a tutorial on this cause basically this thread alone explains everything on how to do this, with you answering all my pain in the butt questions. well, thanks again for your help.
Locked

Return to “2.0.x Support Forum”