Reputation: 111
I have a PHP script that is run by a cron job once nightly. I would like to restrict users from accessing this script. Cron should be the only thing that should be able to run this.
Any ideas on how to do this?
Upvotes: 1
Views: 723
Reputation: 530
to achive that i suggset that you add a second argument to your cron instruction look like this :
/the/path/toyour/cronjob/file/cron.php -- password
Then test the argument number 3 ($argv[2]) if it is valid or not
$pass = (isset($argv[2]))?$argv[2]:"";
if ($pass != 'your password')
{
die('Password is incorrect!');
}
Then by this method you prevent any user from accessing the script directly because arguments cannot be set from other than internal jobs
Hope this is helpfull and any help needed i am here :)
Upvotes: 1