Changeset 547 for trunk/lib/App.inc.php
- Timestamp:
- Aug 27, 2015 3:22:39 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r546 r547 64 64 protected $_raised_msg_counter = array(MSG_NOTICE => 0, MSG_SUCCESS => 0, MSG_WARNING => 0, MSG_ERR => 0); 65 65 66 // We're running as CLI. Public becuase we must force this as false when testing sessions via CLI. 67 public $cli = false; 68 66 69 // Dictionary of global application parameters. 67 70 protected $_params = array(); … … 206 209 $this->timer = new ScriptTimer(); 207 210 $this->timer->start('_app'); 211 212 // Are we running as a CLI? 213 $this->cli = ('cli' === php_sapi_name() || defined('_CLI')); 208 214 } 209 215 … … 351 357 // DB credentials for CLI scripts stored in a JSON file with read rights given only to the user who will be executing the scripts: -r-------- 352 358 // But not if all DB credentials have been defined already by other means. 353 if ( ('cli' === php_sapi_name() || defined('_CLI'))&& (!$this->getParam('db_server') || !$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass'))) {359 if ($this->cli && (!$this->getParam('db_server') || !$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass'))) { 354 360 if (false !== $db_auth_file = stream_resolve_include_path($this->getParam('db_auth_file'))) { 355 361 if (is_readable($db_auth_file)) { … … 385 391 */ 386 392 387 // Skip sessions if disabled or automatically skip if run ina CLI script.388 if (true === $this->getParam('enable_session') && ! defined('_CLI') && 'cli' !== php_sapi_name()) {393 // Use sessions if enabled and not a CLI script. 394 if (true === $this->getParam('enable_session') && !$this->cli) { 389 395 390 396 // Session parameters. … … 450 456 451 457 // Character set. This should also be printed in the html header template. 452 if (! defined('_CLI') && 'cli' !== php_sapi_name()) {458 if (!$this->cli) { 453 459 if (!headers_sent($h_file, $h_line)) { 454 460 header('Content-type: text/html; charset=' . $this->getParam('character_set')); … … 464 470 $codebase_version = trim(file_get_contents($codebase_version_file)); 465 471 $this->setParam(array('codebase_version' => $codebase_version)); 466 if (! defined('_CLI') && 'cli' !== php_sapi_name()) {472 if (!$this->cli) { 467 473 if (!headers_sent($h_file, $h_line)) { 468 474 header('X-Codebase-Version: ' . $codebase_version); … … 487 493 $this->setParam(array('site_version' => $site_version)); 488 494 } 489 if (! defined('_CLI') && 'cli' !== php_sapi_name()&& $this->getParam('site_version')) {495 if (!$this->cli && $this->getParam('site_version')) { 490 496 if (!headers_sent($h_file, $h_line)) { 491 497 header('X-Site-Version: ' . $site_version);
Note: See TracChangeset
for help on using the changeset viewer.