htaccess question

htaccess question

am 11.09.2009 16:46:41 von TedD

Hi gang:

Is there a way I can use a htaccess directive to require a php script
to be "included" within each file contained within that directory?

For example, let's say I have a directory with 100 scripts in it, but
I want each script within that directory to pass through an
authorization script before executing.

The hard way is for me to go through each of the 100 scripts and add
the statement "require(auth.php)", but I don't want to do that (I'm
too lazy and beside there is too great of a chance of an error). So,
is there a way for me to circumvent this problem by using a htaccess
directive?

Now, I know that I can use htaccess to require basic authorization, like so:

AuthType Basic
AuthName "admin"
AuthUserFile /home/httpd/vhosts/mydomain.com/.htpass
require valid-user

But I don't want a file containing user ids and encrypted passwords
in the file system. Instead, I want to move the user ids and
passwords into the database and out of the file system. I can do this
with an authorization script, but I don't want to alter 100 scripts
to do it.

Opinions and suggestions welcomed.

Thanks,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: htaccess question

am 11.09.2009 16:54:56 von Sudheer Satyanarayana

> Is there a way I can use a htaccess directive to require a php script
> to be "included" within each file contained within that directory?
>
> For example, let's say I have a directory with 100 scripts in it, but
> I want each script within that directory to pass through an
> authorization script before executing.
>
> The hard way is for me to go through each of the 100 scripts and add
> the statement "require(auth.php)", but I don't want to do that (I'm
> too lazy and beside there is too great of a chance of an error). So,
> is there a way for me to circumvent this problem by using a htaccess
> directive?
I don't think it is possible to include a particular script for every
request without using include or require statements.

You can solve this problem by routing all the request to one file, say
index.php and then manipulate the flow from there.


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: htaccess question

am 11.09.2009 17:11:13 von J DeBord

--0014852f5fb24152ee04734ebb68
Content-Type: text/plain; charset=UTF-8

On Fri, Sep 11, 2009 at 4:46 PM, tedd wrote:

> Hi gang:
>
> Is there a way I can use a htaccess directive to require a php script to be
> "included" within each file contained within that directory?
>
> For example, let's say I have a directory with 100 scripts in it, but I
> want each script within that directory to pass through an authorization
> script before executing.
>
> The hard way is for me to go through each of the 100 scripts and add the
> statement "require(auth.php)", but I don't want to do that (I'm too lazy and
> beside there is too great of a chance of an error). So, is there a way for
> me to circumvent this problem by using a htaccess directive?
>
> Now, I know that I can use htaccess to require basic authorization, like
> so:
>
> AuthType Basic
> AuthName "admin"
> AuthUserFile /home/httpd/vhosts/mydomain.com/.htpass
> require valid-user
>
> But I don't want a file containing user ids and encrypted passwords in the
> file system. Instead, I want to move the user ids and passwords into the
> database and out of the file system. I can do this with an authorization
> script, but I don't want to alter 100 scripts to do it.
>
> Here is a link to the manual.

http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-f ile

*PHP_INI_PERDIR* Entry can be set in php.ini, .htaccess or httpd.conf

Opinions and suggestions welcomed.
>
> Thanks,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--0014852f5fb24152ee04734ebb68--

Re: htaccess question

am 11.09.2009 17:15:44 von Shawn McKenzie

tedd wrote:
> Hi gang:
>
> Is there a way I can use a htaccess directive to require a php script to
> be "included" within each file contained within that directory?
>
> For example, let's say I have a directory with 100 scripts in it, but I
> want each script within that directory to pass through an authorization
> script before executing.
>
> The hard way is for me to go through each of the 100 scripts and add the
> statement "require(auth.php)", but I don't want to do that (I'm too lazy
> and beside there is too great of a chance of an error). So, is there a
> way for me to circumvent this problem by using a htaccess directive?
>
> Now, I know that I can use htaccess to require basic authorization, like
> so:
>
> AuthType Basic
> AuthName "admin"
> AuthUserFile /home/httpd/vhosts/mydomain.com/.htpass
> require valid-user
>
> But I don't want a file containing user ids and encrypted passwords in
> the file system. Instead, I want to move the user ids and passwords into
> the database and out of the file system. I can do this with an
> authorization script, but I don't want to alter 100 scripts to do it.
>
> Opinions and suggestions welcomed.
>
> Thanks,
>
> tedd

..htaccess

php_value auto_prepend_file "/path/to/auth.php"

--
Thanks!
-Shawn
http://www.spidean.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: htaccess question

am 11.09.2009 18:41:48 von TedD

At 10:15 AM -0500 9/11/09, Shawn McKenzie wrote:
>
>.htaccess
>
>php_value auto_prepend_file "/path/to/auth.php"
>
>Thanks!
>-Shawn


AND

At 5:11 PM +0200 9/11/09, J DeBord wrote:
>
> > Here is a link to the manual.
>
>http://www.php.net/manual/en/ini.core.php#ini.auto-prepend- file
>
>*PHP_INI_PERDIR* Entry can be set in php.ini, .htaccess or httpd.conf


Bingo!

I figured there had to be something like that.

Thanks guys.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php