Hello and welcome to our community! Is this your first visit?
Register
Results 1 to 8 of 8
  1. #1
    Insanity Skype's Avatar



    Join Date
    Apr 2007
    Location
    England
    Posts
    27,397

    Using the PHPBB3 log in for 'premium' features.

    What I'd like to do is have a log in box in say the, top left hand corner of my site, a username and password box. Where they log in with forum details.

    On a page full of website templates there are links that say "Log in to download". So the user uses their username and pass from the FORUMS to log in, and once logged in, the link changes to "Download" and they can download it when logged in.

    How would I go about doing this? ViciousDuck said something about making a new page in the forums, but I wanted to know if there's a simpler way I can do this.

    Thanks.

  2. #2
    Fanatic Enthusiast The Inzuki's Avatar

    Join Date
    Oct 2006
    Location
    ???
    Posts
    4,690

    Re: Using the PHPBB3 log in for 'premium' features.

    Well, I only know how to make certain pages premium, not download links.
    Code:
    if(!session_is_registered("username")){
    	header("location:login.php");
    }
    That dandy script makes it so if there is no session logged, it redirects the guest to the login page. I'm not sure how it'll help, but you could try to devise a plan.

    EDIT: Yea, my helping sucks. Adam probably knows how than me.
    hi.

  3. #3
    Obsessed Veteran Adam's Avatar



    Join Date
    Nov 2004
    Location
    UK / England
    Posts
    17,271

    Re: Using the PHPBB3 log in for 'premium' features.

    There are lots of PHPBB login scripts over at phpbb.com. To ensure people are actually logged in before trying to get a file, just place a htaccess file inside the files folder which redirects to a php script. So everytime there is a request to files/foobar.png it for example checks a script like checker.php?f=foobar.png. The php script can then check if a PHPBB session exists if so just allow the download. Simple.

  4. #4
    Senior Member
    Join Date
    Apr 2008
    Location
    {postrow.POSTER_FROM}
    Posts
    424

    Re: Using the PHPBB3 log in for 'premium' features.

    Urgh...you suck.

    Ok, I'm going to tell you the simplest and easiest way to do this.

    1. Login to the phpbb3 admin section and change the cookies path to /.
    2. Assuming you already have your page written and you just want to integrate the phpbb3 sessions, just change the file extension to .php.

    3. Now add this to the VERY TOP of the file.
    Code:
    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
    ?>
    
    Your existing page goes here (starting with the doctype and whatnot)
    4. Ok, so you said you wanted to check to see if they're logged in or not. Well just use this code whereever you want to check it. (So like on a download page for the template)
    Code:
    <?php
    if ($user->data['user_id'] == ANONYMOUS)
    {
       echo 'Please login!';
    }
    
    else
    {
       echo 'Hello, ' . $user->data['username_clean'] 'WHATEVER YOU WANT DISPLAYED TO LOGGED IN USERS SHOULD GO HERE OR SOMEWHERE AFTER THE ELSE!!!';
    }
    ?>
    If you want to display an actual login form anyway, just make sure you follow steps 1-3 for each page that will have the login form, and then just use the same code for the login form you have on your forums...

    If that doesn't work then I don't know what to tell ya.
    [center:5vxp2rwi][/center:5vxp2rwi]

    See, the problem is that God gives men a brain and a penis, and only enough blood to run one at a time.
    -Robin Williams
    The VIP Store | Net-Cake (Coming Soon)

  5. #5
    Insanity Skype's Avatar



    Join Date
    Apr 2007
    Location
    England
    Posts
    27,397

    Re: Using the PHPBB3 log in for 'premium' features.

    Ok 'nother question.

    How do I log into the forums from another page?

  6. #6
    Fanatic Enthusiast The Inzuki's Avatar

    Join Date
    Oct 2006
    Location
    ???
    Posts
    4,690

    Re: Using the PHPBB3 log in for 'premium' features.

    Quote Originally Posted by Skype
    Ok 'nother question.

    How do I log into the forums from another page?
    You would just create a log-in form and create a code in PHP that collects all the user's data that you can use to log in with, and if the username and password match then your re-direct the user to the page you want.

    I could post scripts, but I'm too lazy, and you said you didn't wont scripts D:
    hi.

  7. #7
    Senior Member
    Join Date
    Apr 2008
    Location
    {postrow.POSTER_FROM}
    Posts
    424

    Re: Using the PHPBB3 log in for 'premium' features.

    Try this. If it doesn't work, fuck phpbb.
    Code:
    <form action="ucp.php?mode=login" method="post" enctype="multipart/form-data">
    <input type="text" name="username">
    
    <input type="password" name="password">
    
    <input type="hidden" name="redirect" value="../">
    <input type="submit" value="login" name="login">
    </form>
    [center:5vxp2rwi][/center:5vxp2rwi]

    See, the problem is that God gives men a brain and a penis, and only enough blood to run one at a time.
    -Robin Williams
    The VIP Store | Net-Cake (Coming Soon)

  8. #8
    Insanity Skype's Avatar



    Join Date
    Apr 2007
    Location
    England
    Posts
    27,397

    Re: Using the PHPBB3 log in for 'premium' features.

    Fixed again, thanks VD.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •