X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp.php;h=d02ea73ca46de28dd984ef69803b36d22a19e35e;hb=d5c2c41b0289523f65dff634e3fdda3336ed6146;hp=08cf382b5467f2e3131e32d40802b18eee3a4e50;hpb=d993c8584c4c2b6023606e727ea3e0db6a6bde51;p=friendica.git diff --git a/src/App.php b/src/App.php index 08cf382b54..d02ea73ca4 100644 --- a/src/App.php +++ b/src/App.php @@ -4,16 +4,13 @@ */ namespace Friendica; +use Detection\MobileDetect; +use Exception; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\System; -use Friendica\Database\DBM; -use dba; - -use Detection\MobileDetect; - -use Exception; +use Friendica\Database\DBA; require_once 'boot.php'; require_once 'include/dba.php'; @@ -154,25 +151,6 @@ class App $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR); - // The order of the following calls is important to ensure proper initialization - $this->loadConfigFiles(); - - $this->loadDatabase(); - - $this->determineMode(); - - $this->determineUrlPath(); - - Config::load(); - - if ($this->mode & self::MODE_DBAVAILABLE) { - Core\Addon::loadHooks(); - - $this->loadAddonConfig(); - } - - $this->loadDefaultTimezone(); - $this->performance['start'] = microtime(true); $this->performance['database'] = 0; $this->performance['database_write'] = 0; @@ -194,6 +172,25 @@ class App $this->callstack['rendering'] = []; $this->callstack['parser'] = []; + // The order of the following calls is important to ensure proper initialization + $this->loadConfigFiles(); + + $this->loadDatabase(); + + $this->determineMode(); + + $this->determineUrlPath(); + + Config::load(); + + if ($this->mode & self::MODE_DBAVAILABLE) { + Core\Addon::loadHooks(); + + $this->loadAddonConfig(); + } + + $this->loadDefaultTimezone(); + $this->page = [ 'aside' => '', 'bottom' => '', @@ -492,13 +489,13 @@ class App $this->mode |= App::MODE_LOCALCONFIGPRESENT; - if (!\dba::connected()) { + if (!DBA::connected()) { return; } $this->mode |= App::MODE_DBAVAILABLE; - if (\dba::fetch_first("SHOW TABLES LIKE 'config'") === false) { + if (DBA::fetchFirst("SHOW TABLES LIKE 'config'") === false) { return; } @@ -513,7 +510,7 @@ class App public function loadDatabase() { - if (\dba::connected()) { + if (DBA::connected()) { return; } @@ -544,7 +541,7 @@ class App $stamp1 = microtime(true); - \dba::connect($db_host, $db_user, $db_pass, $db_data, $charset); + DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset); unset($db_host, $db_user, $db_pass, $db_data, $charset); $this->save_timestamp($stamp1, 'network'); @@ -1034,7 +1031,7 @@ class App } } - $processlist = DBM::processlist(); + $processlist = DBA::processlist(); if ($processlist['list'] != '') { logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG); @@ -1118,19 +1115,30 @@ class App return false; } - public function proc_run($args) + /** + * Executes a child process with 'proc_open' + * + * @param string $command The command to execute + * @param array $args Arguments to pass to the command ( [ 'key' => value, 'key2' => value2, ... ] + */ + public function proc_run($command, $args) { if (!function_exists('proc_open')) { return; } - array_unshift($args, $this->getConfigValue('config', 'php_path', 'php')); + $cmdline = $this->getConfigValue('config', 'php_path', 'php') . ' ' . escapeshellarg($command); - for ($x = 0; $x < count($args); $x ++) { - $args[$x] = escapeshellarg($args[$x]); - } + foreach ($args as $key => $value) { + if (!is_null($value) && is_bool($value) && !$value) { + continue; + } - $cmdline = implode(' ', $args); + $cmdline .= ' --' . $key; + if (!is_null($value) && !is_bool($value)) { + $cmdline .= ' ' . $value; + } + } if ($this->min_memory_reached()) { return; @@ -1299,11 +1307,11 @@ class App // Only arrays are serialized in database, so we have to unserialize sparingly $value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v; - if (!isset($this->config[$uid])) { + if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) { $this->config[$uid] = []; } - if (!isset($this->config[$uid][$cat])) { + if (!isset($this->config[$uid][$cat]) || !is_array($this->config[$uid][$cat])) { $this->config[$uid][$cat] = []; } @@ -1385,22 +1393,18 @@ class App if ($this->profile_uid && ($this->profile_uid != local_user())) { // Allow folks to override user themes and always use their own on their own site. // This works only if the user is on the same server - $user = dba::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]); - if (DBM::is_result($user) && !PConfig::get(local_user(), 'system', 'always_my_theme')) { + $user = DBA::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]); + if (DBA::isResult($user) && !PConfig::get(local_user(), 'system', 'always_my_theme')) { $page_theme = $user['theme']; } } - if (!empty($_SESSION)) { - $user_theme = defaults($_SESSION, 'theme', $system_theme); - } else { - $user_theme = $system_theme; - } + $user_theme = Core\Session::get('theme', $system_theme); // Specific mobile theme override - if (($this->is_mobile || $this->is_tablet) && defaults($_SESSION, 'show-mobile', true)) { + if (($this->is_mobile || $this->is_tablet) && Core\Session::get('show-mobile', true)) { $system_mobile_theme = Config::get('system', 'mobile-theme'); - $user_mobile_theme = defaults($_SESSION, 'mobile-theme', $system_mobile_theme); + $user_mobile_theme = Core\Session::get('mobile-theme', $system_mobile_theme); // --- means same mobile theme as desktop if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') {