vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Lock Script to Scheduled Task? (https://vborg.vbsupport.ru/showthread.php?t=319433)

nick-harper 07-11-2015 08:47 PM

Lock Script to Scheduled Task?
 
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.

kh99 07-11-2015 09:32 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:
PHP Code:

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

Quote:

Originally Posted by kh99 (Post 2549981)
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:
PHP Code:

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:

PHP Code:

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.


All times are GMT. The time now is 02:37 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01080 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete