-1

I am using ooowebhost. I have a PHP file, which I want that normal user should not be able to run it except cron job. As this file is inside public folder so it hard to protect from normal user but let cron job executor to access it.

user8462556
  • 369
  • 6
  • 13

1 Answers1

0

you can block your script executing from browser, but run through cron/cli.

Method 1: Add below line in the start of the script,

if (php_sapi_name() !='cli') exit;

OR

Method 2:

Add in the start of the script,

if ($_SERVER['HTTP_USER_AGENT'] != 'yourSecretAgent') exit;

replace agent ,

Thanks, M.AkberKhan