public $argv;
public $argc;
public $module;
- public $strings;
- public $hooks = [];
public $timezone;
public $interactive = true;
- public $addons;
- public $addons_admin = [];
- public $apps = [];
public $identities;
public $is_mobile = false;
public $is_tablet = false;
public $performance = [];
public $callstack = [];
public $theme_info = [];
- public $nav_sel;
public $category;
// Allow themes to control internal parameters
// by changing App values in theme.php
Core\Config::load();
if ($this->getMode()->has(App\Mode::DBAVAILABLE)) {
- Core\Addon::loadHooks();
+ Core\Hook::loadHooks();
$this->loadAddonConfig();
}
$this->loadDefaultTimezone();
- $this->page = [
- 'aside' => '',
- 'bottom' => '',
- 'content' => '',
- 'footer' => '',
- 'htmlhead' => '',
- 'nav' => '',
- 'page_title' => '',
- 'right_aside' => '',
- 'template' => '',
- 'title' => ''
- ];
+ Core\L10n::init();
$this->process_id = Core\System::processID('log');
}
$stamp1 = microtime(true);
- DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset);
+ if (DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset)) {
+ // Loads DB_UPDATE_VERSION constant
+ Database\DBStructure::definition();
+ }
+
unset($db_host, $db_user, $db_pass, $db_data, $charset);
$this->saveTimestamp($stamp1, 'network');
Core\Addon::callHooks('init_1');
}
- $lang = Core\L10n::getBrowserLanguage();
-
- Core\L10n::loadTranslationTable($lang);
-
-
// Exclude the backend processes from the session management
if (!$this->isBackend()) {
$stamp1 = microtime(true);
session_start();
- $this->saveTimestamp($stamp1, "parser");
+ $this->saveTimestamp($stamp1, 'parser');
+ Core\L10n::setSessionVariable();
+ Core\L10n::setLangFromSession();
} else {
$_SESSION = [];
Core\Worker::executeIfIdle();
}
- /**
- * Language was set earlier, but we can over-ride it in the session.
- * We have to do it here because the session was just now opened.
- */
- if (!empty($_SESSION['authenticated']) && empty($_SESSION['language'])) {
- $_SESSION['language'] = $lang;
- // we haven't loaded user data yet, but we need user language
- if (!empty($_SESSION['uid'])) {
- $user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
- if (DBA::isResult($user)) {
- $_SESSION['language'] = $user['language'];
- }
- }
- }
-
- if (!empty($_SESSION['language']) && $_SESSION['language'] !== $lang) {
- $lang = $_SESSION['language'];
- Core\L10n::loadTranslationTable($lang);
- }
-
// ZRL
if (!empty($_GET['zrl']) && $this->getMode()->isNormal()) {
$this->query_string = Model\Profile::stripZrls($this->query_string);
// Someone came with an invalid parameter, maybe as a DDoS attempt
// We simply stop processing here
logger("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG);
- header('HTTP/1.1 403 Forbidden');
- echo "<h1>403 Forbidden</h1>";
- exit();
+ Core\System::httpExit(403, ['title' => '403 Forbidden']);
}
}
}
Core\Addon::check();
}
- Content\Nav::setSelected('nothing');
-
- //Don't populate apps_menu if apps are private
- $privateapps = Core\Config::get('config', 'private_addons');
- if ((local_user()) || (! $privateapps === "1")) {
- $arr = ['app_menu' => $this->apps];
-
- Core\Addon::callHooks('app_menu', $arr);
-
- $this->apps = $arr['app_menu'];
- }
+ $this->page = [
+ 'aside' => '',
+ 'bottom' => '',
+ 'content' => '',
+ 'footer' => '',
+ 'htmlhead' => '',
+ 'nav' => '',
+ 'page_title' => '',
+ 'right_aside' => '',
+ 'template' => '',
+ 'title' => ''
+ ];
if (strlen($this->module)) {
// Compatibility with the Android Diaspora client
if ($this->module == 'stream') {
- goaway('network?f=&order=post');
+ $this->internalRedirect('network?f=&order=post');
}
if ($this->module == 'conversations') {
- goaway('message');
+ $this->internalRedirect('message');
}
if ($this->module == 'commented') {
- goaway('network?f=&order=comment');
+ $this->internalRedirect('network?f=&order=comment');
}
if ($this->module == 'liked') {
- goaway('network?f=&order=comment');
+ $this->internalRedirect('network?f=&order=comment');
}
if ($this->module == 'activity') {
- goaway('network/?f=&conv=1');
+ $this->internalRedirect('network/?f=&conv=1');
}
if (($this->module == 'status_messages') && ($this->cmd == 'status_messages/new')) {
- goaway('bookmarklet');
+ $this->internalRedirect('bookmarklet');
}
if (($this->module == 'user') && ($this->cmd == 'user/edit')) {
- goaway('settings');
+ $this->internalRedirect('settings');
}
if (($this->module == 'tag_followings') && ($this->cmd == 'tag_followings/manage')) {
- goaway('search');
+ $this->internalRedirect('search');
}
// Compatibility with the Firefox App
if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
- goaway($this->getBaseURL() . $_SERVER['REQUEST_URI']);
+ $this->internalRedirect($_SERVER['REQUEST_URI']);
}
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
}
}
- /**
- * Load current theme info
- */
+ // Load current theme info
$theme_info_file = 'view/theme/' . $this->getCurrentTheme() . '/theme.php';
if (file_exists($theme_info_file)) {
require_once $theme_info_file;
}
-
- /* initialise content region */
-
+ // initialise content region
if ($this->getMode()->isNormal()) {
Core\Addon::callHooks('page_content_top', $this->page['content']);
}
- /**
- * Call module functions
- */
-
+ // Call module functions
if ($this->module_loaded) {
$this->page['page_title'] = $this->module;
$placeholder = '';
// Add the navigation (menu) template
if ($this->module != 'install' && $this->module != 'maintenance') {
- Content\Nav::build($this);
+ $this->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
+ $this->page['nav'] = Content\Nav::build($this);
}
// Build the page - now that we have all the components
// Things like embedded OSM maps don't work, when this is enabled
// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https: data:; media-src 'self' https:; child-src 'self' https:; object-src 'none'");
- /*
- * We use $_GET["mode"] for special page templates. So we will check if we have
+ /* We use $_GET["mode"] for special page templates. So we will check if we have
* to load another page template than the default one.
* The page templates are located in /view/php/ or in the theme directory.
*/
/// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
require_once $template;
}
+
+ /**
+ * Redirects to another module relative to the current Friendica base.
+ * If you want to redirect to a external URL, use System::externalRedirectTo()
+ *
+ * @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
+ * @param bool $ssl if true, base URL will try to get called with https:// (works just for relative paths)
+ *
+ * @throws InternalServerErrorException In Case the given URL is not relative to the Friendica node
+ */
+ public function internalRedirect($toUrl = '', $ssl = false)
+ {
+ if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
+ throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo');
+ }
+
+ $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
+ System::externalRedirect($redirectTo);
+ }
}