限制php脚本只能在客戶端命令行執行

/*限制只能在php客戶端執行*/
function drupal_is_cli() {
   return (!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0)));
}
if(!drupal_is_cli())exit;