Feb 142010
How to prevent PHP script from running in Apache
Answer:
If you have a PHP script and want it run under in command line only, not in the web server context, you can use the following method.
<?php
if ( php_sapi_name() != "cli" ) {
print "This script must be run from the command line\n";
exit();
}