- $content = '';
-
- try {
- $moduleClass = $module->getClassName();
-
- $arr = ['content' => $content];
- Core\Hook::callAll($moduleClass . '_mod_content', $arr);
- $content = $arr['content'];
- $arr = ['content' => call_user_func([$moduleClass, 'content'])];
- Core\Hook::callAll($moduleClass . '_mod_aftercontent', $arr);
- $content .= $arr['content'];
- } catch(HTTPException $e) {
- $content = ModuleHTTPException::content($e);
- }
-
- // initialise content region
- if ($this->getMode()->isNormal()) {
- Core\Hook::callAll('page_content_top', $this->page['content']);
- }
-
- $this->page['content'] .= $content;
-
- /* Create the page head after setting the language
- * and getting any auth credentials.
- *
- * Moved initHead() and initFooter() to after
- * all the module functions have executed so that all
- * theme choices made by the modules can take effect.
- */
- $this->initHead($module, $pconfig);
-
- /* Build the page ending -- this is stuff that goes right before
- * the closing </body> tag
- */
- $this->initFooter();
-
- if (!$this->isAjax()) {
- Core\Hook::callAll('page_end', $this->page['content']);
- }
-
- // Add the navigation (menu) template
- if ($moduleName != 'install' && $moduleName != 'maintenance') {
- $this->page['htmlhead'] .= Core\Renderer::replaceMacros(Core\Renderer::getMarkupTemplate('nav_head.tpl'), []);
- $this->page['nav'] = Content\Nav::build($this);
- }
-
- // Build the page - now that we have all the components
- if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
- $doc = new DOMDocument();
-
- $target = new DOMDocument();
- $target->loadXML("<root></root>");
-
- $content = mb_convert_encoding($this->page["content"], 'HTML-ENTITIES', "UTF-8");
-
- /// @TODO one day, kill those error-surpressing @ stuff, or PHP should ban it
- @$doc->loadHTML($content);
-
- $xpath = new DOMXPath($doc);
-
- $list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */
-
- foreach ($list as $item) {
- $item = $target->importNode($item, true);
-
- // And then append it to the target
- $target->documentElement->appendChild($item);
- }
-
- if ($_GET["mode"] == "raw") {
- header("Content-type: text/html; charset=utf-8");
-
- echo substr($target->saveHTML(), 6, -8);
-
- exit();
- }
- }
-
- $page = $this->page;
- $profile = $this->profile;
-
- header("X-Friendica-Version: " . FRIENDICA_VERSION);
- header("Content-type: text/html; charset=utf-8");
-
- if ($this->config->get('system', 'hsts') && ($this->baseURL->getSSLPolicy() == BaseUrl::SSL_POLICY_FULL)) {
- header("Strict-Transport-Security: max-age=31536000");
- }
-
- // Some security stuff
- header('X-Content-Type-Options: nosniff');
- header('X-XSS-Protection: 1; mode=block');
- header('X-Permitted-Cross-Domain-Policies: none');
- header('X-Frame-Options: sameorigin');
-
- // 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
- * to load another page template than the default one.
- * The page templates are located in /view/php/ or in the theme directory.
- */
- if (isset($_GET["mode"])) {
- $template = Core\Theme::getPathForFile($_GET["mode"] . '.php');
- }
-
- // If there is no page template use the default page template
- if (empty($template)) {
- $template = Core\Theme::getPathForFile("default.php");
- }
-
- // Theme templates expect $a as an App instance
- $a = $this;
-
- // Used as is in view/php/default.php
- $lang = $this->l10n->getCurrentLang();
-
- /// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
- require_once $template;