]> git.mxchange.org Git - friendica.git/blobdiff - src/App.php
AP: Support of request messages
[friendica.git] / src / App.php
index 3e1dc147f327e84038d1fd89cda1b5495edf9c9e..9cde12499859cf5878910a87931f292374ae0725 100644 (file)
@@ -138,6 +138,16 @@ class App
                return $this->config->getCache();
        }
 
+       /**
+        * Returns the current config of this node
+        *
+        * @return Configuration
+        */
+       public function getConfig()
+       {
+               return $this->config;
+       }
+
        /**
         * The basepath of this app
         *
@@ -196,7 +206,6 @@ class App
         * @see initHead()
         *
         * @param string $path
-        * @throws InternalServerErrorException
         */
        public function registerStylesheet($path)
        {
@@ -215,7 +224,6 @@ class App
         * @see initFooter()
         *
         * @param string $path
-        * @throws InternalServerErrorException
         */
        public function registerFooterScript($path)
        {
@@ -250,7 +258,6 @@ class App
                $this->profiler = $profiler;
                $this->logger   = $logger;
 
-               $this->checkBackend($isBackend);
                $this->checkFriendicaApp();
 
                $this->profiler->reset();
@@ -320,6 +327,8 @@ class App
                        $this->module = 'home';
                }
 
+               $this->isBackend = $isBackend || $this->checkBackend($this->module);
+
                // Detect mobile devices
                $mobile_detect = new MobileDetect();
 
@@ -625,21 +634,26 @@ class App
         * This isn't a perfect solution. But we need this check very early.
         * So we cannot wait until the modules are loaded.
         *
-        * @param string $backend true, if the backend flag was set during App initialization
-        *
+        * @param string $module
+        * @return bool
         */
-       private function checkBackend($backend) {
+       private function checkBackend($module) {
                static $backends = [
                        '_well_known',
                        'api',
                        'dfrn_notify',
+                       'feed',
                        'fetch',
+                       'followers',
+                       'following',
                        'hcard',
                        'hostxrd',
+                       'inbox',
                        'manifest',
                        'nodeinfo',
                        'noscrape',
-                       'p',
+                       'objects',
+                       'outbox',
                        'poco',
                        'post',
                        'proxy',
@@ -653,7 +667,7 @@ class App
                ];
 
                // Check if current module is in backend or backend flag is set
-               $this->isBackend = (in_array($this->module, $backends) || $backend || $this->isBackend);
+               return in_array($module, $backends);
        }
 
        /**
@@ -835,7 +849,7 @@ class App
        {
                $sender_email = $this->config->get('config', 'sender_email');
                if (empty($sender_email)) {
-                       $hostname = $this->getHostName();
+                       $hostname = $this->baseURL->getHostname();
                        if (strpos($hostname, ':')) {
                                $hostname = substr($hostname, 0, strpos($hostname, ':'));
                        }
@@ -980,7 +994,7 @@ class App
                // and www.example.com vs example.com.
                // We will only change the url to an ip address if there is no existing setting
 
-               if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
+               if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) {
                        $this->config->set('system', 'url', $this->getBaseURL());
                }
        }
@@ -1014,10 +1028,7 @@ class App
 
                if (!$this->getMode()->isInstall()) {
                        // Force SSL redirection
-                       if ($this->config->get('system', 'force_ssl') && ($this->getScheme() == "http")
-                               && intval($this->config->get('system', 'ssl_policy')) == BaseURL::SSL_POLICY_FULL
-                               && strpos($this->getBaseURL(), 'https://') === 0
-                               && $_SERVER['REQUEST_METHOD'] == 'GET') {
+                       if ($this->baseURL->checkRedirectHttps()) {
                                header('HTTP/1.1 302 Moved Temporarily');
                                header('Location: ' . $this->getBaseURL() . '/' . $this->query_string);
                                exit();
@@ -1306,8 +1317,9 @@ class App
                        header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . Core\L10n::t('Permission denied.'));
                }
 
-               // Report anything which needs to be communicated in the notification area (before the main body)
-               Core\Hook::callAll('page_end', $this->page['content']);
+               if (!$this->isAjax()) {
+                       Core\Hook::callAll('page_end', $this->page['content']);
+               }
 
                // Add the navigation (menu) template
                if ($this->module != 'install' && $this->module != 'maintenance') {
@@ -1353,7 +1365,7 @@ class App
                header("X-Friendica-Version: " . FRIENDICA_VERSION);
                header("Content-type: text/html; charset=utf-8");
 
-               if ($this->config->get('system', 'hsts') && ($this->config->get('system', 'ssl_policy') == BaseUrl::SSL_POLICY_FULL)) {
+               if ($this->config->get('system', 'hsts') && ($this->baseURL->getSSLPolicy() == BaseUrl::SSL_POLICY_FULL)) {
                        header("Strict-Transport-Security: max-age=31536000");
                }