in reply to How to distinguish a crontab call and a web call

Going from scratch the module solution mentioned above is probably the "best" way, but if this is something legacy you can't monkey with too much you could look for the presence of $ENV{GATEWAY_INTERFACE}. Unless your cron implementation's really weird it shouldn't be set there, but mod_cgi for apache (or any CGI host environment honoring the spec) should set it in a CGI context.

The cake is a lie.
The cake is a lie.
The cake is a lie.