Skip to:
Content
Pages
Categories
Search
Top
Bottom

Password Protect Directory Using PHP


  • pagal
    Participant

    @pagal

    Hiya,

    I don’t want to use .htacess method, I want to use php

    Is there any way to protect a directory/folder with password using php?

    Suppose I want to protect my forums directory ( just show user/pass)

    http://www.example.com/forums

    Thanks

Viewing 15 replies - 1 through 15 (of 15 total)

  • mr_pelle
    Participant

    @mr_pelle

    Why not using .htaccess? It’s easy!

    By “I want to protect my forums directory”, do you mean you want to turn all your forums private? If so, use this plugin.


    pagal
    Participant

    @pagal

    thanks pelle :)

    I know very well .htacess really easy, but for some reasons, I don’t want to use it.

    Second your plugin also great, but need some functionalities, can you update it?

    I need following action,

    Complete protection not even show

    bb-login.php

    bb-reset-password.php

    register.php

    xmlrpc.php

    bb-admin/

    rss/

    there should just a protect.php page for asking user name and password, If i enter correct user, pass then the forums should display, then I can access the bb-login.php and other Swirl-immune pages. otherwise not!

    Thanks


    mr_pelle
    Participant

    @mr_pelle

    Just remove the pages you do not need from swirl-unknowns.php: lines 72-77. You may add pages too.

    Remember, though, that you’ll NEED bb-login.php to be swirl-immune in order to actually be able to access your forum! ;-)


    pagal
    Participant

    @pagal

    Oops! you are still confuse to understand my question :)

    I also know very well that bb-login.php need for access the forums.

    Let me tell you!

    I’ve deleted the

    bb-reset-password.php

    register.php

    xmlrpc.php

    bb-admin/

    rss/

    from swirl-unknowns.php: lines 72-77.

    Then I add this code in template’s login.php

    http://pastebin.com/raw.php?i=MdzzJc3T

    That what exactly I want :)


    kevinjohngallagher
    Member

    @kevinjohngallagher

    I’m confused, does that mean you have what you want if you can link to it?

    Or are you looking for someone to edit/duplicate a script you’ve found on the internet into a plugin for you?


    pagal
    Participant

    @pagal

    kevinjohngallagher yep exactly,

    http://pastebin.com/raw.php?i=MdzzJc3T

    this script just protect web page not whole folder/directory.

    I want to protect my whole forums directory!!

    with user name / pass without using .htacess.


    mr_pelle
    Participant

    @mr_pelle

    In the script you linked, usernames and passwords are stored in clear in the php file: why do such a bad thing when bbPress has a database and encrypts passwords for you? Just login using its login form and that’s it. =)


    kevinjohngallagher
    Member

    @kevinjohngallagher

    if (! bb_is_user_logged_in() )
    {
    header( 'Location: bb-login.php' );
    }

    Ok, so i’m guessing here, but whouldn’t those 2 lines of code work?

    btw, i used google and that solution was the first one, i’m just copy and pasting


    mr_pelle
    Participant

    @mr_pelle

    You would get into a redirection loop with that. Add a filter to ignore bb-login.php in the if and it should work.


    kevinjohngallagher
    Member

    @kevinjohngallagher

    OFC!

    Thats daft of me.

    if (! bb_is_user_logged_in() && basename($_SERVER['PHP_SELF'] != "bb-login.php")
    {
    header( 'Location: bb-login.php' );
    }

    Pagal, please mate, i beg of you.

    Google for 5 minutes before posting these requests and telling everyone they don’t understand what you want, and never saying please or thank you.

    We want to help bro, help us by using Google first :)


    pagal
    Participant

    @pagal

    @kevinjohngallagher which keyword you’ve used for google to find this solution?

    Why are you begging? I did not send you invitation to help me!

    Sorry I don’t want to say any more, otherwise cris will close this topic. :-)


    chrishajer
    Participant

    @chrishajer

    pagal and Kevinjohn – please take your personal discussion off list. It really doesn’t belong here.


    pagal
    Participant

    @pagal

    May be my style of talking is different because of my bad English, Or My question presentation is not clear, but I don’t want to hurt anyone or want to use bad words, that’s why I always said “Please try to understand me”

    The easiest way to protect with .htaccess


    pagal
    Participant

    @pagal

    @gordonsa thanks dear,

    I definitely know that the easiest way to protect with .htacess. but again

    I don’t want to use .htacess method, I want to use php

    Because sometime some scripts works with open directories. If I protect a directory via .htacess then this script or plugin will not work with this…

    e.g. This wordpress plugin

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.
Skip to toolbar