- Timestamp:
- Aug 27, 2015 3:22:39 AM (9 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 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); -
trunk/lib/DB.inc.php
r546 r547 226 226 protected function _fail() 227 227 { 228 $app =& App::getInstance(); 229 228 230 if ($this->getParam('db_die_on_failure')) { 229 if (! defined('_CLI') && 'cli' !== php_sapi_name()) {231 if (!$app->cli) { 230 232 // For http requests, send a Service Unavailable header. 231 233 header(' ', true, 503); … … 323 325 $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 324 326 if ($this->getParam('db_debug')) { 325 if (! defined('_CLI') && 'cli' !== php_sapi_name()) {327 if (!$app->cli) { 326 328 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>'; 327 329 } -
trunk/lib/Prefs.inc.php
r546 r547 175 175 { 176 176 // CLI scripts can't use prefs stored in HTTP-based protocols. 177 if ( (defined('_CLI') || 'cli' === php_sapi_name())177 if ($app->cli 178 178 && isset($params['storagetype']) 179 179 && in_array($params['storagetype'], array('cookie', 'session'))) { -
trunk/lib/Utilities.inc.php
r546 r547 37 37 function dump($var, $display=false, $var_dump=false, $file='', $line='') 38 38 { 39 if ( defined('_CLI') || 'cli' === php_sapi_name()) {39 if ($app->cli) { 40 40 echo "DUMP FROM: $file $line\n"; 41 41 } else { … … 60 60 } 61 61 } 62 if ( defined('_CLI') || 'cli' === php_sapi_name()) {62 if ($app->cli) { 63 63 echo "\n"; 64 64 } else {
Note: See TracChangeset
for help on using the changeset viewer.