How To Protect Pages Outside The Scripts Directory/Folder?

7 replies
Hi there,


I am having a problem with a php login script I downloaded from http://www.angry-frog.com. I have installed it correctly and works fine. But the problem I am having is when I am wanting to protect pages outside the folder/directory such as a sub-directory, the protected pages ain't protected.

Example:
PHP Login Script Location: http://www.mydomain.com/login/free/main.php
Wanting Pages Protected: http://www.mydomain.com/login/free/members/free.php
(and branched out from there)

The pages are only protected if they are in the folder where the script is located. When I place my protected pages within this directory it works fine, users who ain't logged in will get redirected to a page I have promoted. But I have got over 8000 web pages to protect within a sub-directory (see Wanting Pages Protected example URL above).

If I was to move them to this directory http://www.mydomain.com/login/free/... where the login script is located and where the protected pages work fine, this would not smart to put that many files in one directory/folder, if you know what I mean. This would be great if anyone knows how to fix this issue I am having or is familiar with this script produced by angry-frog.com (or even check the free script for your self there to know more about it).



Thanks kindly,
Daniel
#directory or folder #login script #pages #protect #scripts
  • Profile picture of the author David V
    Daniel, it sounds like you do not have the paths correct when you are protecting different pages in different directories.
    This part: include ("include/session.php"); which needs to be included before the first html tag will not work for every page. No matter where the page is, it must reflect the correct path back to the location of the session.php
    That snippet just assumes you have everything in the same directory.
    I suspect this is the problem.
    So, depending on where the page is, it could look like this: include ("../include/session.php");
    {{ DiscussionBoard.errors[7669437].message }}
    • Profile picture of the author daniel27lt
      Hi there David V, and thank you for your quick response and interest.

      I thought that was the problem but I'm not to sure now, this is what is at the tops of all my protected pages:

      <?php
      include("include/session.php");
      if(!$session->logged_in){ header("Location: ./main.php"); } else {
      ?> //closing php tag
      Welcome
      <? echo $session->username; ?>


      As this seems to only work on pages within the directory the login script is located. Does this seem right to you?

      Thanks kindly,
      Daniel
      Signature
      Download Free PLR Products to give away to build your list. Find all the most up-to-date PLR on the market.
      {{ DiscussionBoard.errors[7669475].message }}
      • Profile picture of the author David V
        Originally Posted by daniel27lt View Post

        Hi there David V, and thank you for your quick response and interest.

        I thought that was the problem but I'm not to sure now, this is what is at the tops of all my protected pages:

        <?php
        include("include/session.php");
        if(!){ header("Location: ./main.php"); } else {
        ?> //closing php tag
        Welcome
        <? echo ; ?>


        As this seems to only work on pages within the directory the login script is located. Does this seem right to you?

        Thanks kindly,
        Daniel
        So yes, that is the problem. The path is the same for all, which doesn't work outside the install directory.
        include("include/session.php");

        You need to modify this path depending on where the page is located.
        {{ DiscussionBoard.errors[7669533].message }}
        • Profile picture of the author daniel27lt
          Thanks for confirming that, now I realize. The only problem is that I'm not to familiar with PHP. I have only used HTML until now. I understand PHP enough to get me out of trouble (sometime), but not this case.

          I was wondering if a quick example of what this should look like and how it processes, if possible? Thanks.
          Signature
          Download Free PLR Products to give away to build your list. Find all the most up-to-date PLR on the market.
          {{ DiscussionBoard.errors[7669579].message }}
          • Profile picture of the author David V
            Originally Posted by daniel27lt View Post

            Thanks for confirming that, now I realize. The only problem is that I'm not to familiar with PHP. I have only used HTML until now. I understand PHP enough to get me out of trouble (sometime), but not this case.

            I was wondering if a quick example of what this should look like and how it processes, if possible? Thanks.
            It's ok you don't need to understand php at all, only paths/location.
            So in your example:
            PHP Login Script Location: http://www.mydomain.com/login/free/main.php
            Wanting Pages Protected: http://www.mydomain.com/login/free/members/free.php

            Obviously, everything within http://www.mydomain.com/login/free/ will work because thats the default path, but you have a "member" directory inside the "free" directory so you need to specify that.

            include("include/session.php");

            would become:

            include("../include/session.php");

            The "../" indicates stepping back a directory. Since your inside the "members" directory, you need to step back (like hitting back button) to get back to the includes directory.
            {{ DiscussionBoard.errors[7669624].message }}
            • Profile picture of the author daniel27lt
              Yes!! That worked. You are my 'genie in the bottle'. I have been pondering all day trying to work this out and to know it was just such a little mod like that to make it work, makes me laugh!!! (lol)

              Once again thanks for you time, knowledge and really do appreciate what you have taught me.
              Signature
              Download Free PLR Products to give away to build your list. Find all the most up-to-date PLR on the market.
              {{ DiscussionBoard.errors[7669708].message }}
  • Profile picture of the author David V
    Your welcome.
    {{ DiscussionBoard.errors[7669754].message }}

Trending Topics