View Full Version : Lock Script to Scheduled Task?
nick-harper
07-11-2015, 08:47 PM
I have created a custom script and added it as a scheduled task but how can I lock it so only the scheduled task can run it?
I tried to lock it to IP, but it uses the user's ip.
I tried passing a variable in the url in the task when it runs but it didn't work.
I have dumped POST and GET but nothing gets passed through when the scheduler runs it.
I'm not sure I understand. Do you mean make it so that someone can't just enter the url in their browser and run it? The scheduled tasks that come with vbulletin have this at the beginning:
if (!is_object($vbulletin->db))
{
exit;
}
so that if it's not included from a script that has already set up $vbulletin, it won't run.
MarkFL
07-11-2015, 09:40 PM
I'm not sure I understand. Do you mean make it so that someone can't just enter the url in their browser and run it? The scheduled tasks that come with vbulletin have this at the beginning:
if (!is_object($vbulletin->db))
{
exit;
}
so that if it's not included from a script that has already set up $vbulletin, it won't run.
Good to know, Kevin! :D
What I did for one of my external PHP files (called via clicking a link) is this:
if ($_SERVER['HTTP_REFERER'])
{
//script code here.
}
else
{
print_no_permission();
}
cellarius
07-15-2015, 09:07 AM
The latter is unsafe. There are several cases when $_SERVER['HTTP_REFERER'] will be empty, and it is easily faked.
squidsk
07-15-2015, 01:28 PM
Just protect the directory with the cron script in it. If it's in the default cron folder than it should not be accessible anyways as you should block all access to the includes directory.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.