views:

42

answers:

2

This is my directory structure:

-st.ambulance
---public_html
---resources

My document root is public_html. I have a script in resources that I need to execute securely (meaning: normal users shouldn't be able to execute it). How would I do this?

A: 

What is the script? I guess that doesn't matter so much anyway, but what you can do is use:

require_once("/../resources/script.php);

I should add that you of course need to set up your path appropriately.

Laykes
+1  A: 

Normal users already won't be able to execute it if they can't get to it in their browser. If it's not in your document root, they shouldn't be able to get to it. So, it's already safe, unless one of the scripts in your document root is including it, or your site gets hacked.

As far as executing the script yourself, find out whether it should be run from the command line or as a web page. If it can run at the command line, just ssh in and run it. If it needs to be run as a web page, have your web server serve the resources directory to an admin (sub)domain, secured by https, and password protect it with something like basic http authentication.

no