Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Permissions on PHP script to only run locally



On Tue, 09 Mar 2010 12:16:37 +0900, Dave M G <dave@example.com> wrote:

> I wondered if there was a permission setting I could put on the file so
> that it was only accessible by the server's local cron command, and not
> accessible by anyone coming at it from the browser.

Trying to play with permissions is probably the wrong way to go about it
here. I take it this script is run by the CLI version of PHP invoked by
cron, right?

If so, have the script detect whether it is run by apache or by cron.
Detect, for example, a variable that's only present in the web-based
variant and kill the script if it is found.

For example,

if ( isset($_SERVER['REMOTE_ADDR']) ) exit(0);

-- 
G. Stewart - gstewart@example.com

Real programmers don't write in FORTRAN.  FORTRAN is for pipe stress
freaks and crystallography weenies.  FORTRAN is for wimp engineers who
wear white socks.

Attachment: pgpvA8mRKnCGm.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links