+ Reply to Thread
Results 1 to 10 of 10

Thread: Trying to restrict access to webpaged based on forum login? (MyBB)

  1. #1
    Fearghal's Avatar
    Fearghal is offline x10 Lieutenant Fearghal is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    286

    Trying to restrict access to webpaged based on forum login? (MyBB)

    Hi, I wonder if someone could help me out here... this tasks seems slightly advanced for my current skill set.

    I have a standard website with no forums, just pages. I then have a forums subdomain where I run a MyBB board. Can anyone advise me on how I would go about restricting a page on the standard site, based on whether or not the user is logged into the forums?

    Example, restrict access to www.example.com/vip.php to only allow access to users who are logged in to www.forums.example.com.

    Any suggestions?
    Thanks
    Last edited by Fearghal; 06-28-2010 at 06:41 AM.
    If I helped you, please rep me!
    -Fearghal

  2. #2
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Try using a plugin like this: http://mods.mybboard.net/view/custom-pages

    Restrict the pages to the usergroups of registered users.
    Last edited by techairlines; 06-28-2010 at 07:29 AM.
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  3. #3
    Fearghal's Avatar
    Fearghal is offline x10 Lieutenant Fearghal is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    286

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Thanks for the reply, sadly thats not an option for me...

    My site has a really nice layout and design and I want to keep it like that
    If I helped you, please rep me!
    -Fearghal

  4. #4
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Last edited by techairlines; 06-28-2010 at 07:40 AM.
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  5. #5
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    I think you can include forum's authorization script to normal pages for example /home/you/forums/authorize.php can be included in /home/you/public_html/hidden_treasure.php to check if user is logged in or not if not show the login form or redirect to forum.
    Liked this? Click on the icon on the bottom of post to make me .

  6. #6
    Fearghal's Avatar
    Fearghal is offline x10 Lieutenant Fearghal is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    286

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Quote Originally Posted by techairlines View Post
    I get - Parse error: syntax error, unexpected '{' in /home/standard/public_html/test.php on line 57...
    If I helped you, please rep me!
    -Fearghal

  7. #7
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Quote Originally Posted by Fearghal View Post
    I get - Parse error: syntax error, unexpected '{' in /home/standard/public_html/test.php on line 57...
    Hmm sounds like you have an unncessary { tag somewhere. If all the PHP code isn't large, could you possibly post it here so we can examine the code you used?
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  8. #8
    Fearghal's Avatar
    Fearghal is offline x10 Lieutenant Fearghal is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    286

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    I only put in the code I got from here to test it...

    Code:
    <p><?php
    $allowedgroups = array ( '4', '8' );
    if ( in_array ( $mybb->user['usergroup'], $allowedgroups )
    {
        // code here
    }
    else
    {
        die ( 'Uh oh, accessing stuff you\'re not supposed too. ;)' );
    }
    ?></p>
    Last edited by Fearghal; 06-28-2010 at 08:37 AM.
    If I helped you, please rep me!
    -Fearghal

  9. #9
    techairlines's Avatar
    techairlines is offline x10 Flyer techairlines has much to be proud oftechairlines has much to be proud of
    Join Date
    Jul 2009
    Location
    New York City
    Posts
    2,853

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    You need to include the code snippets mentioned in this thread: http://community.mybb.com/thread-6615.html then wrap that in the code in the link I mentioned above.

    Also, the error message mentions Line 57 and there doesn't appear to be a line 57 there.

    Try this slightly modified version instead:

    PHP Code:
    $allowedgroups = array ( '4''8' );
    if ( 
    in_array $mybb->user['usergroup'], $allowedgroups ) )
    {
        
    // code here
    }
    else
    {
        die ( 
    'You can\'t access this page!' );

    Put the custom page code (http://community.mybb.com/thread-6615.html) into the // code here section.
    Last edited by techairlines; 06-28-2010 at 08:45 AM.
    Best regards,
    Brian Yang - TechAirlines


    How am I doing? Click the star button at the bottom left to rate this post. Thanks.
    Terms of Service | Account Portal | Wiki

  10. #10
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: Trying to restrict access to webpaged based on forum login? (MyBB)

    Hi Fearghal,

    Based on techairlines instructions, I’m providing you with a working example.

    For this test, create a new directory in the root of your forums and call it whatever you want (I called mine “mytest”). You forums root directory is the one that has these directories: admin, archive, cache, images and others.

    Place a copy of your standard web page in this new directory.

    Add the following php code to the beginning of your page:

    PHP Code:
    <?php

    define
    ('IN_MYBB'1);
    require_once 
    "../global.php";

    $allowedgroups = array ( '4''8' );
    if (!
    in_array $mybb->user['usergroup'], $allowedgroups ))
    {
        die ( 
    'You can\'t access this page!' );
    }

    ?>
    Rename the page so that the extension is ".php" (not html)

    This is the full example of what I tested and it works fine.

    PHP Code:
    <?php

    define
    ('IN_MYBB'1);
    require_once 
    "../global.php";

    $allowedgroups = array ( '4''8' );
    if (!
    in_array $mybb->user['usergroup'], $allowedgroups ))
    {
        die ( 
    'You can\'t access this page!' );
    }

    ?>

    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <title></title>
      </head>
      <body>
        <h1>
              My site has a really nice layout
              and design and I want to keep it like that
        </h1>
      </body>
    </html>
    Finally, just let me add that this method is not very secure and quite vulnerable, so please be careful what you post.

+ Reply to Thread

Similar Threads

  1. mybb forum down
    By blazingcomputer in forum Free Hosting
    Replies: 5
    Last Post: 01-30-2010, 07:22 AM
  2. Cannot view mybb forum
    By ananth2ananth in forum Free Hosting
    Replies: 1
    Last Post: 11-04-2009, 02:00 AM
  3. restrict access to a page unless from...
    By 1erik1 in forum Programming Help
    Replies: 5
    Last Post: 04-03-2009, 09:19 PM
  4. What do you think of this MyBB forum integration?
    By tnl2k7 in forum Review My Site
    Replies: 5
    Last Post: 05-07-2008, 01:58 AM
  5. MyBB Forum Help - CHMOD
    By Pixelated-Ye in forum Free Hosting
    Replies: 0
    Last Post: 02-10-2006, 02:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers