use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBA;
-use Friendica\Database\DBM;
require_once 'boot.php';
require_once 'include/dba.php';
* @brief App constructor.
*
* @param string $basepath Path to the app base folder
+ *
+ * @throws Exception if the Basepath is not usable
*/
public function __construct($basepath)
{
$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' => '',
- 'content' => '',
- 'end' => '',
- 'footer' => '',
- 'htmlhead' => '',
- 'nav' => '',
- 'page_title' => '',
- 'right_aside' => '',
- 'template' => '',
- 'title' => ''
- ];
-
- $this->process_id = System::processID('log');
+ $this->reload();
set_time_limit(0);
$this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
}
+ /**
+ * Reloads the whole app instance
+ */
+ public function reload()
+ {
+ // 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' => '',
+ 'content' => '',
+ 'end' => '',
+ 'footer' => '',
+ 'htmlhead' => '',
+ 'nav' => '',
+ 'page_title' => '',
+ 'right_aside' => '',
+ 'template' => '',
+ 'title' => ''
+ ];
+
+ $this->process_id = System::processID('log');
+ }
+
/**
* Load the configuration files
*
$this->mode |= App::MODE_DBAVAILABLE;
- if (DBA::fetch_first("SHOW TABLES LIKE 'config'") === false) {
+ if (DBA::fetchFirst("SHOW TABLES LIKE 'config'") === false) {
return;
}
}
}
- $processlist = DBM::processlist();
+ $processlist = DBA::processlist();
if ($processlist['list'] != '') {
logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);
return;
}
- $cmdline = $this->getConfigValue('config', 'php_path', 'php') . $command;
+ $cmdline = $this->getConfigValue('config', 'php_path', 'php') . ' ' . escapeshellarg($command);
foreach ($args as $key => $value) {
if (!is_null($value) && is_bool($value) && !$value) {
}
}
- $cmdline = escapeshellarg($cmdline);
-
if ($this->min_memory_reached()) {
return;
}
// 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] = [];
}
// 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')) {
+ 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 !== '---') {