From 164acb2d8e549e659a2221a404e342662b821036 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 22 Aug 2019 10:55:32 -0600 Subject: [PATCH] Update functions.php --- resources/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/functions.php b/resources/functions.php index 35230a7b9c..95cb10b15a 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1623,6 +1623,19 @@ function number_pad($number,$n) { } } +//detect if php is running as command line interface + if (!function_exists('is_cli')) { + function is_cli() { + if (defined('STDIN')) { + return true; + } + if (php_sapi_name() == 'cli' && !isset($_SERVER['HTTP_USER_AGENT']) && is_numeric($_SERVER['argc']) { + return true; + } + return false; + } + } + //format mac address if (!function_exists('format_mac')) { function format_mac($str, $delim = '-', $case = 'lower') {