Make sure the php script can be only excecuted from command line (or as a cron job)

StackOverflow https://stackoverflow.com/questions/19663566

  •  01-07-2022
  •  | 
  •  

سؤال

This is the code I'm using, is it enough to make sure the script can be only run as a cron job? It sure does work but maybe there is something I have missed.

   if (php_sapi_name() !== 'cli') {
     die("You are not allwod here");
    }
هل كانت مفيدة؟

المحلول

Yes, that will work. I would also make sure the script is outside the root directory.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top