本文整理汇总了PHP中isCli函数的典型用法代码示例。如果您正苦于以下问题:PHP isCli函数的具体用法?PHP isCli怎么用?PHP isCli使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isCli函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printDebug
function printDebug($string)
{
if (isCli()) {
echo $string . "\n";
} else {
echo $string . '<br/>';
}
}
示例2: print_message
function print_message($text)
{
if (isCli()) {
print Console_Color2::convert("%g" . $text . "%n\n", false);
} else {
echo '<div class="alert alert-success"><img src="images/16/tick.png" align="absmiddle"> ' . $text . '</div>';
}
}
示例3: loadHelper
/**
* load functions, to help controller
*
* 裡面包裹的 help function
* 僅給 controller 使用
* 並不給予 view 使用
*/
protected function loadHelper(array $args)
{
// 目前並不是使用 controller 的方式, 所以這裡不進行以下動作
return;
if (isCli()) {
// TODO: 找時間對 console 指令的格式, 做解析
return;
}
$request = $args[0];
$response = $args[1];
$args = $args[2];
LoadHelper::init($request, $response, $args);
}
示例4: minifyJs
private static function minifyJs()
{
$sourcePathConfig = tr::config()->get("app.minify");
$minifier = new Minify\JS();
if ($sourcePathConfig['js']) {
foreach ($sourcePathConfig['js'] as $v) {
if (isCli()) {
$v = ROOT_PATH . "/public/" . $v;
}
$minifier->add($v);
}
}
$minifier->minify(ROOT_PATH . "/public/asset/global.js");
return true;
}
示例5: authUpdate
public function authUpdate()
{
if (isCli() || static::$allowUpdate) {
return true;
}
if (!static::instantiated($this)) {
return true;
}
$me = Auth::user();
if (!$me instanceof static) {
return false;
}
if ($this->is($me) || $me->isAdmin()) {
return true;
}
return false;
}
示例6: print_message
function print_message($text)
{
if (isCli()) {
c_echo("%g" . $text . "%n\n");
} else {
echo '<div class="alert alert-success"><img src="images/16/tick.png" align="absmiddle"> ' . $text . '</div>';
}
}
示例7: array_merge
}
$blti_admin_form = array_merge($blti_admin_form, array('organizationid:text:label=bl_organizationid:size=80', 'organizationurl:text:label=bl_organizationurl:size=80', 'organizationdescr:text:label=bl_organizationdescr:size=80'));
$blti_content_edit_form = array('preferheight:integer:label=bl_preferheight:size=80', 'launchinpopup:radio:label=bl_launchinpopup:choices=off,on', 'debuglaunch:radio:label=bl_debuglaunch:choices=off,on', 'sendname:radio:label=bl_sendname:choices=off,on', 'sendemailaddr:radio:label=bl_sendemailaddr:choices=off,on', 'allowroster:radio:label=bl_allowroster:choices=off,on', 'allowsetting:radio:label=bl_allowsetting:choices=off,on', 'customparameters:textarea:label=bl_customparameters:rows=5:cols=25');
if (!function_exists('isCli')) {
function isCli()
{
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
return true;
} else {
return false;
}
}
}
// If we are running from the command line - do a unit test
if (isCli()) {
function startsWith($haystack, $needle, $case = true)
{
if ($case) {
return strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
}
return strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
}
function endsWith($haystack, $needle, $case = true)
{
if ($case) {
return strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
return strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
$i18nstrings = array_merge(foorm_i18n_util($blti_instructor_form), foorm_i18n_util($blti_admin_form), foorm_i18n_util($blti_content_edit_form));
示例8: define
define('SCHEDULE_MANAGEMENTINTERVAL', 'Management_Interval');
define('SCHEDULE_MANAGEMENTCOMMAND', 'Management_Command');
define('SCHEDULE_PURGEVIDEOHOURS', 'PurgeVideo_Hours');
define('SCHEDULE_PURGEIMAGEHOURS', 'PurgeImage_Hours');
define('SCHEDULE_PURGELAPSEHOURS', 'PurgeLapse_Hours');
define('SCHEDULE_PURGESPACEMODE', 'PurgeSpace_ModeEx');
define('SCHEDULE_PURGESPACELEVEL', 'PurgeSpace_Level');
define('SCHEDULE_AUTOCAPTUREINTERVAL', 'AutoCapture_Interval');
define('SCHEDULE_COMMANDSON', 'Commands_On');
define('SCHEDULE_COMMANDSOFF', 'Commands_Off');
define('SCHEDULE_MODES', 'Modes');
define('SCHEDULE_TIMES', 'Times');
$debugString = "";
$schedulePars = array();
$schedulePars = loadPars(BASE_DIR . '/' . SCHEDULE_CONFIG);
$cliCall = isCli();
$showLog = false;
$schedulePID = getSchedulePID();
if (!$cliCall && isset($_POST['action'])) {
//Process any POST data
switch ($_POST['action']) {
case 'start':
startSchedule();
$schedulePID = getSchedulePID();
break;
case 'stop':
stopSchedule($schedulePID);
$schedulePID = getSchedulePID();
break;
case 'save':
writeLog('Saved schedule settings');
示例9: define
define('NAILS_COMMON_PATH', realpath(dirname(__FILE__) . '/../common/') . '/');
}
/**
* Setup the basic system
*/
require_once NAILS_COMMON_PATH . 'core/CORE_NAILS_Common.php';
require_once NAILS_COMMON_PATH . 'src/Startup.php';
$oStartup = new Startup();
$oStartup->init();
Factory::setup();
// Set to run indefinitely
set_time_limit(0);
// Make sure we're running on UTC
date_default_timezone_set('UTC');
// Only allow the console to run whilst on the CLI
if (!isCli()) {
echo 'This tool can only be used on the command line.';
exit(1);
}
// Setup error handling
Factory::service('ErrorHandler');
// Autoload the things
Factory::helper('app_setting');
Factory::helper('app_notification');
Factory::helper('date');
Factory::helper('tools');
Factory::helper('debug');
Factory::helper('language');
Factory::helper('text');
Factory::helper('exception');
Factory::helper('log');
示例10: isCli
class Flags
{
const ONLINE = 1;
const HONORS = 2;
const ST = 4;
const CANCELLED = 8;
}
function isCli()
{
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
return true;
} else {
return false;
}
}
define("IS_CLI", isCli());
if (IS_CLI) {
if (!isset($argv)) {
echo "Usage: <script> [fall|spring]";
return;
}
$term = $argv[1];
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
} else {
$term = $_GET["term"];
}
if (!isset($term)) {
$term = date("m") < "11" ? "fall" : "spring";
}
define("TERM", $term);
示例11: seconds2Human
/**
* Seconds to human readable
* @param int $seconds
* @return string
*/
function seconds2Human($seconds)
{
$r = '';
$_seconds = floor($seconds);
$ms = $seconds - $_seconds;
$seconds = $_seconds;
if ($hours = floor($seconds / 3600)) {
$r .= $hours . (isCli() ? ' h ' : ' час ');
$seconds = $seconds % 3600;
}
if ($minutes = floor($seconds / 60)) {
$r .= $minutes . (isCli() ? ' m ' : ' мин ');
$seconds = $seconds % 60;
}
if ($minutes < 3) {
$r .= ' ' . $seconds + ($ms > 0 ? round($ms) : 0) . (isCli() ? ' s' : ' сек');
}
return $r;
}
示例12: run
/**
* Application booting completed!
* Lets run our awesome Application
*
* @return mixed
* @throws \Exception
*/
public function run()
{
/*
| We will check if script running via console
| then we will return out from here, else application
| fall back down
*/
if (isCli()) {
return $this;
}
try {
$response = $this->handle();
if ($response instanceof ResponseInterface) {
return $response->send();
}
return $response;
} catch (\Exception $e) {
if (ENV == 'development') {
throw $e;
}
if (ENV == 'production') {
/**
* We will log exception if logger enabled
*/
if ($this['debugger']->isLoggerEnabled()) {
$this['debugger']->log($e);
}
$this['debugger']->renderErrorPage($e);
}
}
}
示例13: authCreate
/**
* Default authCreate, depends on authUpdate permission of "owning" object
* Model classes that can be created by users should implement this method...
* Top level objects which have no "owners" (like, "User" or "Project"
* should override this method without requiring a "owner" or "parent"
*/
public static function authCreate(PkModel $parent = null, User $user = null)
{
return true;
if (isCli()) {
return true;
}
if ($parent && $parent instanceof PkModel) {
return $parent->authUpdate($user);
}
return false;
}
示例14: define
\Koch\Localization\Utf8::initialize();
/**
* Constants
*
* Constants must be defined, after initialize_paths(),
* because of the automatic apc constants cache in
* define_ConstantsAndPaths().
*/
define('REWRITE_ENGINE_ON', 1);
define('TESTSUBJECT_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR);
// /../tests (trunk)
/**
* We might need some debug utils,
* when we are not in CLI mode.
*/
if (isCli() === false) {
require_once KOCH . 'Debug/Debug.php';
}
/**
* Gettext Replacement
*
* @param type $msgid
*/
if (!function_exists('_')) {
function _($msgid)
{
return $msgid;
}
}
function isCli()
{
示例15: print_message
function print_message($text)
{
if (isCli()) {
print Console_Color::convert("%g" . $text . "%n\n", false);
} else {
echo '
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
' . $text . '
</div>';
}
}