I'm doing something like this now:
if (empty($_SERVER['SERVER_NAME'])) {
// the script is run by a Cron job
} else {
// the script is run by a HTTP request
}
Will it go wrong at some situation? More specifically, is $_SERVER['SERVER_NAME'] always set by Apache? I know some of the variables in $_SERVER like $_SERVER['REMOTE_ADDR'] could be tainted by the client side.
Any advice?