I'm running a cronjob which needs to write data to a cache. I wanted to put this cronjob in my private folder, however, even after CHMODding the cache folder in the private folder, it's not getting writing rights. This seems to be somekind of plesk feature.
So, now I've placed the cronjob in the public folder. However, I need to make sure that only the server can execute the script. What about the following at the top of the cronjob?
if ($_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']) die();
This seems to work. Is it not exploitable however, eg. can a user manipulate his remote_addr to my server's? Or is there a better way to check this?
Another issue I have is that the above code is returning 2 warnings, even though it does seem to work:
PHP Notice: Undefined index: SERVER_ADDR in ... on line 2
PHP Notice: Undefined index: REMOTE_ADDR in ... on line 2
Any idea what's the cause of that?