Possible Duplicate:
PHP - how to best determine if the current invocation is from CLI or web server?
I know the obvious answer is to place the script outside the web root, but I'm hesitant to do that in my project since that complicates installation and might not even be possible in some shared hosting environments.
I know some frameworks (CodeIgniter specifically) have a framework specific way of making sure a script cannot be called by navigating to it through a web browser, but I'm wanting a way to do this via stock PHP. Specifically, my script is designed to be called by cron. How can I make it so my script errors out if called in a web browser but executes correctly when called by cron?