471,071 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

include question

Jon
All,

I have a question regarding include files. I'm currently wanting to secure
all of the pages within a directory by having a login script that queries a
MySQL DB, and writes a session variable confirming the user is successfully
logged in.

Now, I've done this many times before, however I'm getting kind of sick of
putting the include file to check the session variable on EVERY page within
a directory. This is especially irritating if I for whatever reason want to
unsecure a directory, or change the structure of the login system - it
forces me to go into each file of the admin area and remove the call to the
file.

My question is: Is there a way to have PHP force an include file per
directory instead of just file? Maybe have a global file inside the
directory that will cascade the include to every page below? Or am I simply
forced to manually include the file on each page?

Thank you in advance.

Jon
Jan 30 '06 #1
4 1254
Jon wrote:
All,

Now, I've done this many times before, however I'm getting kind of sick of
putting the include file to check the session variable on EVERY page within
a directory. This is especially irritating if I for whatever reason want to
unsecure a directory, or change the structure of the login system - it
forces me to go into each file of the admin area and remove the call to the
file.


Wouldn'y it be easier to comment out the neccesarry lines in the include
file, this way you don't need to open every file and change it?

Jonathan
Jan 30 '06 #2
Jon
Yeah, unless I want to completely kill off the check all together (I could
leave it by commenting, but would prefer to have no code left if I were to
decide to remove it). The bigger issue is adding it to each file.

"Jonathan" <jo******@heelal.nl> wrote in message
news:43***********************@text.nova.planet.nl ...
Jon wrote:
All,

Now, I've done this many times before, however I'm getting kind of sick
of putting the include file to check the session variable on EVERY page
within a directory. This is especially irritating if I for whatever
reason want to unsecure a directory, or change the structure of the login
system - it forces me to go into each file of the admin area and remove
the call to the file.


Wouldn'y it be easier to comment out the neccesarry lines in the include
file, this way you don't need to open every file and change it?

Jonathan

Jan 30 '06 #3
d
"Jon" <jo***@netins.com> wrote in message
news:dr**********@news.netins.net...
All,

I have a question regarding include files. I'm currently wanting to secure
all of the pages within a directory by having a login script that queries
a MySQL DB, and writes a session variable confirming the user is
successfully logged in.

Now, I've done this many times before, however I'm getting kind of sick of
putting the include file to check the session variable on EVERY page
within a directory. This is especially irritating if I for whatever reason
want to unsecure a directory, or change the structure of the login
system - it forces me to go into each file of the admin area and remove
the call to the file.

My question is: Is there a way to have PHP force an include file per
directory instead of just file? Maybe have a global file inside the
directory that will cascade the include to every page below? Or am I
simply forced to manually include the file on each page?

Thank you in advance.

Jon


Have you tried using the httpd.conf to set the auto_prepend_file directive
for specific directories? You can put it in the <directory> section, so you
can set different directories to prepend your login script. That would take
it out of your code and put it in apache...

http://uk2.php.net/manual/en/configuration.changes.php

dave
Jan 30 '06 #4
Jon wrote:
Yeah, unless I want to completely kill off the check all together (I could
leave it by commenting, but would prefer to have no code left if I were to
decide to remove it). The bigger issue is adding it to each file.

"Jonathan" <jo******@heelal.nl> wrote in message
news:43***********************@text.nova.planet.nl ...
Jon wrote:
All,

Now, I've done this many times before, however I'm getting kind of sick
of putting the include file to check the session variable on EVERY page
within a directory. This is especially irritating if I for whatever
reason want to unsecure a directory, or change the structure of the login
system - it forces me to go into each file of the admin area and remove
the call to the file.


Wouldn'y it be easier to comment out the neccesarry lines in the include
file, this way you don't need to open every file and change it?

Jonathan



so just write include("includes.php") and from it include the other stuff.
Marek
Jan 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by qaz | last post: by
6 posts views Thread by Simon Elliott | last post: by
3 posts views Thread by sunnylele | last post: by
2 posts views Thread by key9 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.