Forum Moderators: phranque

Message Too Old, No Replies

prepending a file for authorizations

         

flycast

11:29 pm on Jan 30, 2005 (gmt 0)

10+ Year Member



Hello esteemed webmasters...
Here is what I wish to do. I want to prepend a php file that executes before every and any other file is served from that directory regardless of the requested file type. I have explored the use of the php prepend directive but I want the file to be prepended even if the file requested is not a php file. I want to use this as a authorization method where the prepended file is a php script that checks for a cookie and if the proper cookie is there, then serves the originally requested file. If the cookie is not present then the requestor is served a login screen. Upon sucessful login the user will be directed to their originally requested file.

Any ideas?

dcrombie

10:47 am on Jan 31, 2005 (gmt 0)



I can think of two possible approaches:

1 - configure PHP to parse all file types. You probably want to disable 'short tags' if you do this otherwise your images will generate parse errors.

2 - make all non-php files only accessible through PHP (ie. instead of image.gif use showimage.php?imageid=555 or similar).

Both would increase server load.

Otherwise you might look at using PHP to generate an .htpasswd-type authentication list.

;)