Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a website which I run a PHP script for updating its Database. What is considered to be an acceptable location on the server to store such scripts? Obviously only the root (running a cronjob to start the script) should have access to it.

Thanks,

Joel

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you are worried about access to this script you can add a random string to the command line argument of the cron job string e.g.

php /path/to/script.php random_string

Then in your script.php you check argv0 to see if that string is exists and is correct before running the rest of your code.

Another way is to put the cron script in a folder and restrict its access using a .htaccess file. Here is an answer on how to do this: http://serverfault.com/questions/92192/apache-htaccess-file-to-restrict-access-to-all-files-unless-local-ip

share|improve this answer
4  
Why not just put the script outside of your web root directory? –  Lèse majesté Nov 18 '10 at 11:45
    
Yes that is a very valid point! –  mar10 Nov 18 '10 at 12:12
    
Actually I was aiming to that point. I was wondering if there is a directory outside of the web root directory, that it is common to put scripts within. –  Joel Nov 18 '10 at 12:32
    
@Joel: AFAIK, there is no common directory that such scripts are put in. I normally group these types of scripts with the application that it belongs to, so it just depends on their directory structure. As long as it's outside of your web root and inside your home directory (for shared hosting), then it's equally safe wherever you put it. –  Lèse majesté Nov 18 '10 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.