So I need to make a cron job that runs every 24 hours and sends out some emails. I need to do it in a way, that only server is able to run it, and it needs to be in CodeIgniter.
So lets suppose that I have it in controller called cron.php
, how do I make it that only server can execute it. So far i have thought of putting something like this in the constructor:
if($_SERVER['SERVER_ADDR'] != $SERVER['REMOTE_ADDR']){
//kill the script, do not send emails
}
So my question is, this seems too simple, Can these values be spoofed/manipulated somehow? Is it hard to do?
Is there any better ways to approach this (Short of making this as a standalone program hidden somewhere outside the public web-root?