当前位置: 首页>>代码示例>>PHP>>正文


PHP Common::isPhpCliMode方法代码示例

本文整理汇总了PHP中Piwik\Common::isPhpCliMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::isPhpCliMode方法的具体用法?PHP Common::isPhpCliMode怎么用?PHP Common::isPhpCliMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Common的用法示例。


在下文中一共展示了Common::isPhpCliMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleException

 public static function handleException(Exception $exception)
 {
     if (Common::isPhpCliMode()) {
         self::dieWithCliError($exception);
     }
     self::dieWithHtmlErrorPage($exception);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:ExceptionHandler.php

示例2: findPhpBinary

 public function findPhpBinary()
 {
     if (defined('PHP_BINARY')) {
         if ($this->isValidPhpType(PHP_BINARY)) {
             return PHP_BINARY . ' -q';
         }
         if ($this->isHhvmBinary(PHP_BINARY)) {
             return PHP_BINARY . ' --php';
         }
     }
     $bin = '';
     if (!empty($_SERVER['_']) && Common::isPhpCliMode()) {
         $bin = $this->getPhpCommandIfValid($_SERVER['_']);
     }
     if (empty($bin) && !empty($_SERVER['argv'][0]) && Common::isPhpCliMode()) {
         $bin = $this->getPhpCommandIfValid($_SERVER['argv'][0]);
     }
     if (!$this->isValidPhpType($bin)) {
         $bin = shell_exec('which php');
     }
     if (!$this->isValidPhpType($bin)) {
         $bin = shell_exec('which php5');
     }
     if (!$this->isValidPhpType($bin)) {
         return false;
     }
     $bin = trim($bin);
     if (!$this->isValidPhpVersion($bin)) {
         return false;
     }
     $bin .= ' -q';
     return $bin;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:33,代码来源:CliPhp.php

示例3: __construct

 /**
  * Constructor.
  * 
  * @param string|null $name The name of the command, eg, `'generate:api'`.
  */
 public function __construct($name = null)
 {
     if (!Common::isPhpCliMode()) {
         throw new \RuntimeException('Only executable in CLI mode');
     }
     parent::__construct($name);
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:12,代码来源:ConsoleCommand.php

示例4: __construct

 /**
  * @param string $namespace
  * @param bool $singleInstance
  */
 public function __construct($namespace = 'Default', $singleInstance = false)
 {
     if (Common::isPhpCliMode()) {
         self::$_readable = true;
         return;
     }
     parent::__construct($namespace, $singleInstance);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:12,代码来源:SessionNamespace.php

示例5: exitWithErrorMessage

 /**
  * Display the message in a nice red font with a nice icon
  * ... and dies
  *
  * @param string $message
  */
 public static function exitWithErrorMessage($message)
 {
     if (!Common::isPhpCliMode()) {
         @header('Content-Type: text/html; charset=utf-8');
     }
     $output = "<style>a{color:red;}</style>\n" . "<div style='color:red;font-family:Georgia;font-size:120%'>" . "<p><img src='plugins/Morpheus/images/error_medium.png' style='vertical-align:middle; float:left;padding:20 20 20 20' />" . $message . "</p></div>";
     print $output;
     exit;
 }
开发者ID:Abine,项目名称:piwik,代码行数:15,代码来源:Piwik.php

示例6: shouldRun

 public function shouldRun(Tracker $tracker)
 {
     if (Common::isPhpCliMode()) {
         // don't run scheduled tasks in CLI mode from Tracker, this is the case
         // where we bulk load logs & don't want to lose time with tasks
         return false;
     }
     return $tracker->shouldRecordStatistics();
 }
开发者ID:cemo,项目名称:piwik,代码行数:9,代码来源:ScheduledTasksRunner.php

示例7: __invoke

 public function __invoke(array $record)
 {
     if (Common::isPhpCliMode()) {
         return $record;
     }
     if (empty($this->currentRequestKey)) {
         $this->currentRequestKey = substr(Common::generateUniqId(), 0, 5);
     }
     $record['extra']['request_id'] = $this->currentRequestKey;
     return $record;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:RequestIdProcessor.php

示例8: formatScreenMessage

 public static function formatScreenMessage(&$message, $level, $tag, $datetime, $log)
 {
     if ($message instanceof \Exception) {
         if (!Common::isPhpCliMode()) {
             @header('Content-Type: text/html; charset=utf-8');
         }
         $outputFormat = strtolower(Common::getRequestVar('format', 'html', 'string'));
         $response = new ResponseBuilder($outputFormat);
         $message = $response->getResponseException(new \Exception($message->getMessage()));
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:11,代码来源:ExceptionHandler.php

示例9: checkConfigFileExists

 /**
  * @param $path
  * @param bool $startInstaller
  * @throws \Exception
  */
 private function checkConfigFileExists($path, $startInstaller = false)
 {
     if (is_readable($path)) {
         return;
     }
     $message = $this->translator->translate('General_ExceptionConfigurationFileNotFound', array($path));
     if (Common::isPhpCliMode()) {
         $message .= "\n" . $this->translator->translate('General_ExceptionConfigurationFileNotFound2', array($path, get_current_user()));
     }
     $exception = new \Exception($message);
     if ($startInstaller) {
         /**
          * Triggered when the configuration file cannot be found or read, which usually
          * means Piwik is not installed yet.
          *
          * This event can be used to start the installation process or to display a custom error message.
          *
          * @param \Exception $exception The exception that was thrown by `Config::getInstance()`.
          */
         Piwik::postEvent('Config.NoConfigurationFile', array($exception), $pending = true);
     } else {
         throw $exception;
     }
 }
开发者ID:JoeHorn,项目名称:piwik,代码行数:29,代码来源:EnvironmentValidator.php

示例10: getMessageFromException

 /**
  * Gets the error message to output when a tracking request fails.
  *
  * @param Exception $e
  * @return string
  */
 protected function getMessageFromException($e)
 {
     // Note: duplicated from FormDatabaseSetup.isAccessDenied
     // Avoid leaking the username/db name when access denied
     if ($e->getCode() == 1044 || $e->getCode() == 42000) {
         return "Error while connecting to the Piwik database - please check your credentials in config/config.ini.php file";
     }
     if (Common::isPhpCliMode()) {
         return $e->getMessage() . "\n" . $e->getTraceAsString();
     }
     return $e->getMessage();
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:18,代码来源:Response.php

示例11: runUpdaterAndExit

 protected function runUpdaterAndExit()
 {
     $updater = new Updater();
     $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
     if (empty($componentsWithUpdateFile)) {
         Piwik::redirectToModule('CoreHome');
     }
     SettingsServer::setMaxExecutionTime(0);
     $cli = Common::isPhpCliMode() ? '_cli' : '';
     $welcomeTemplate = '@CoreUpdater/runUpdaterAndExit_welcome' . $cli;
     $doneTemplate = '@CoreUpdater/runUpdaterAndExit_done' . $cli;
     $viewWelcome = new View($welcomeTemplate);
     $viewDone = new View($doneTemplate);
     if (Common::isPhpCliMode()) {
         $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
         $output = $viewWelcome->render();
         if (!$this->coreError && Piwik::getModule() == 'CoreUpdater') {
             $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
             $output .= $viewDone->render();
         }
         return $output;
     } else {
         if (Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1) {
             $this->warningMessages = array();
             $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
             $this->redirectToDashboardWhenNoError($updater);
             return $viewDone->render();
         } else {
             $viewWelcome->queries = $updater->getSqlQueriesToExecute();
             $viewWelcome->isMajor = $updater->hasMajorDbUpdate();
             $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
             return $viewWelcome->render();
         }
     }
     exit;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:36,代码来源:Controller.php

示例12: executeDataPurge

 /**
  * Executes a data purge, deleting log data and report data using the current config
  * options. Echo's the result of getDatabaseSize after purging.
  */
 public function executeDataPurge()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->checkTokenInUrl();
     // if the request isn't a POST, redirect to index
     if ($_SERVER["REQUEST_METHOD"] != "POST" && !Common::isPhpCliMode()) {
         $this->redirectToIndex('PrivacyManager', 'privacySettings');
         return;
     }
     $settings = PrivacyManager::getPurgeDataSettings();
     if ($settings['delete_logs_enable']) {
         $logDataPurger = LogDataPurger::make($settings);
         $logDataPurger->purgeData();
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = ReportsPurger::make($settings, PrivacyManager::getAllMetricsToKeep());
         $reportsPurger->purgeData(true);
     }
 }
开发者ID:emersonmatsumoto,项目名称:piwik,代码行数:23,代码来源:Controller.php

示例13: disableLoggingBasedOnConfig

 private function disableLoggingBasedOnConfig($logConfig)
 {
     $disableLogging = false;
     if (!empty($logConfig['log_only_when_cli']) && !Common::isPhpCliMode()) {
         $disableLogging = true;
     }
     if (!empty($logConfig['log_only_when_debug_parameter']) && !isset($_REQUEST['debug'])) {
         $disableLogging = true;
     }
     if ($disableLogging) {
         $this->currentLogLevel = self::NONE;
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:13,代码来源:Log.php

示例14: runUpdaterAndExit

 public function runUpdaterAndExit($doDryRun = null)
 {
     $updater = new Updater();
     $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
     if (empty($componentsWithUpdateFile)) {
         throw new NoUpdatesFoundException("Everything is already up to date.");
     }
     SettingsServer::setMaxExecutionTime(0);
     $cli = Common::isPhpCliMode() ? '_cli' : '';
     $welcomeTemplate = '@CoreUpdater/runUpdaterAndExit_welcome' . $cli;
     $doneTemplate = '@CoreUpdater/runUpdaterAndExit_done' . $cli;
     $viewWelcome = new View($welcomeTemplate);
     $this->addCustomLogoInfo($viewWelcome);
     $viewDone = new View($doneTemplate);
     $this->addCustomLogoInfo($viewDone);
     $doExecuteUpdates = Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1;
     if (is_null($doDryRun)) {
         $doDryRun = !$doExecuteUpdates;
     }
     if ($doDryRun) {
         $viewWelcome->queries = $updater->getSqlQueriesToExecute();
         $viewWelcome->isMajor = $updater->hasMajorDbUpdate();
         $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
         return $viewWelcome->render();
     }
     // CLI
     if (Common::isPhpCliMode()) {
         $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
         $output = $viewWelcome->render();
         // Proceed with upgrade in CLI only if user specifically asked for it, or if running console command
         $isUpdateRequested = Common::isRunningConsoleCommand() || Piwik::getModule() == 'CoreUpdater';
         if (!$this->coreError && $isUpdateRequested) {
             $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
             $output .= $viewDone->render();
         }
         return $output;
     }
     // Web
     if ($doExecuteUpdates) {
         $this->warningMessages = array();
         $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
         $this->redirectToDashboardWhenNoError($updater);
         return $viewDone->render();
     }
     exit;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:46,代码来源:Controller.php

示例15: shouldRunScheduledTasks

 protected function shouldRunScheduledTasks()
 {
     // don't run scheduled tasks in CLI mode from Tracker, this is the case
     // where we bulk load logs & don't want to lose time with tasks
     return !Common::isPhpCliMode() && $this->getState() != self::STATE_LOGGING_DISABLE;
 }
开发者ID:Abine,项目名称:piwik,代码行数:6,代码来源:Tracker.php


注:本文中的Piwik\Common::isPhpCliMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。