]> git.mxchange.org Git - friendica.git/blob - src/App.php
7a52139d6a4176f624291272dfc9f36ef1a6bacb
[friendica.git] / src / App.php
1 <?php
2 /**
3  * @file src/App.php
4  */
5 namespace Friendica;
6
7 use Exception;
8 use Friendica\App\Arguments;
9 use Friendica\App\BaseURL;
10 use Friendica\App\Page;
11 use Friendica\App\Authentication;
12 use Friendica\Core\Config\Cache\ConfigCache;
13 use Friendica\Core\Config\Configuration;
14 use Friendica\Core\Config\PConfiguration;
15 use Friendica\Core\L10n\L10n;
16 use Friendica\Core\Session;
17 use Friendica\Core\System;
18 use Friendica\Core\Theme;
19 use Friendica\Database\Database;
20 use Friendica\Model\Profile;
21 use Friendica\Module\Login;
22 use Friendica\Module\Special\HTTPException as ModuleHTTPException;
23 use Friendica\Network\HTTPException;
24 use Friendica\Util\ConfigFileLoader;
25 use Friendica\Util\HTTPSignature;
26 use Friendica\Util\Profiler;
27 use Friendica\Util\Strings;
28 use Psr\Log\LoggerInterface;
29
30 /**
31  *
32  * class: App
33  *
34  * @brief Our main application structure for the life of this page.
35  *
36  * Primarily deals with the URL that got us here
37  * and tries to make some sense of it, and
38  * stores our page contents and config storage
39  * and anything else that might need to be passed around
40  * before we spit the page out.
41  *
42  */
43 class App
44 {
45         /** @deprecated 2019.09 - use App\Arguments->getQueryString() */
46         public $query_string;
47         /**
48          * @var Page The current page environment
49          */
50         public $page;
51         public $profile;
52         public $profile_uid;
53         public $user;
54         public $cid;
55         public $contact;
56         public $contacts;
57         public $page_contact;
58         public $content;
59         public $data = [];
60         /** @deprecated 2019.09 - use App\Arguments->getCommand() */
61         public $cmd = '';
62         /** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
63         public $argv;
64         /** @deprecated 2019.09 - use App\Arguments->getArgc() */
65         public $argc;
66         /** @deprecated 2019.09 - Use App\Module->getName() instead */
67         public $module;
68         public $timezone;
69         public $interactive = true;
70         public $identities;
71         /** @deprecated 2019.09 - Use App\Mode->isMobile() instead */
72         public $is_mobile;
73         /** @deprecated 2019.09 - Use App\Mode->isTable() instead */
74         public $is_tablet;
75         public $theme_info = [];
76         public $category;
77         // Allow themes to control internal parameters
78         // by changing App values in theme.php
79
80         public $sourcename              = '';
81         public $videowidth              = 425;
82         public $videoheight             = 350;
83         public $force_max_items         = 0;
84         public $theme_events_in_profile = true;
85         public $queue;
86
87         /**
88          * @var App\Mode The Mode of the Application
89          */
90         private $mode;
91
92         /**
93          * @var BaseURL
94          */
95         private $baseURL;
96
97         /** @var string The name of the current theme */
98         private $currentTheme;
99         /** @var string The name of the current mobile theme */
100         private $currentMobileTheme;
101
102         /**
103          * @var Configuration The config
104          */
105         private $config;
106
107         /**
108          * @var LoggerInterface The logger
109          */
110         private $logger;
111
112         /**
113          * @var Profiler The profiler of this app
114          */
115         private $profiler;
116
117         /**
118          * @var Database The Friendica database connection
119          */
120         private $database;
121
122         /**
123          * @var L10n The translator
124          */
125         private $l10n;
126
127         /**
128          * @var App\Arguments
129          */
130         private $args;
131
132         /**
133          * @var Core\Process The process methods
134          */
135         private $process;
136
137         /**
138          * Returns the current config cache of this node
139          *
140          * @return ConfigCache
141          */
142         public function getConfigCache()
143         {
144                 return $this->config->getCache();
145         }
146
147         /**
148          * Returns the current config of this node
149          *
150          * @return Configuration
151          */
152         public function getConfig()
153         {
154                 return $this->config;
155         }
156
157         /**
158          * The basepath of this app
159          *
160          * @return string
161          */
162         public function getBasePath()
163         {
164                 // Don't use the basepath of the config table for basepath (it should always be the config-file one)
165                 return $this->config->getCache()->get('system', 'basepath');
166         }
167
168         /**
169          * The Logger of this app
170          *
171          * @return LoggerInterface
172          */
173         public function getLogger()
174         {
175                 return $this->logger;
176         }
177
178         /**
179          * The profiler of this app
180          *
181          * @return Profiler
182          */
183         public function getProfiler()
184         {
185                 return $this->profiler;
186         }
187
188         /**
189          * Returns the Mode of the Application
190          *
191          * @return App\Mode The Application Mode
192          */
193         public function getMode()
194         {
195                 return $this->mode;
196         }
197
198         /**
199          * Returns the Database of the Application
200          *
201          * @return Database
202          */
203         public function getDBA()
204         {
205                 return $this->database;
206         }
207
208         /**
209          * @deprecated 2019.09 - use Page->registerStylesheet instead
210          * @see        Page::registerStylesheet()
211          */
212         public function registerStylesheet($path)
213         {
214                 $this->page->registerStylesheet($path);
215         }
216
217         /**
218          * @deprecated 2019.09 - use Page->registerFooterScript instead
219          * @see        Page::registerFooterScript()
220          */
221         public function registerFooterScript($path)
222         {
223                 $this->page->registerFooterScript($path);
224         }
225
226         /**
227          * @param Database        $database The Friendica Database
228          * @param Configuration   $config   The Configuration
229          * @param App\Mode        $mode     The mode of this Friendica app
230          * @param BaseURL         $baseURL  The full base URL of this Friendica app
231          * @param LoggerInterface $logger   The current app logger
232          * @param Profiler        $profiler The profiler of this application
233          * @param L10n            $l10n     The translator instance
234          * @param App\Arguments   $args     The Friendica Arguments of the call
235          * @param Core\Process    $process  The process methods
236          */
237         public function __construct(Database $database, Configuration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Module $module, App\Page $page, Core\Process $process)
238         {
239                 $this->database = $database;
240                 $this->config   = $config;
241                 $this->mode     = $mode;
242                 $this->baseURL  = $baseURL;
243                 $this->profiler = $profiler;
244                 $this->logger   = $logger;
245                 $this->l10n     = $l10n;
246                 $this->args     = $args;
247                 $this->process  = $process;
248
249                 $this->cmd          = $args->getCommand();
250                 $this->argv         = $args->getArgv();
251                 $this->argc         = $args->getArgc();
252                 $this->query_string = $args->getQueryString();
253                 $this->module       = $module->getName();
254                 $this->page         = $page;
255
256                 $this->is_mobile = $mode->isMobile();
257                 $this->is_tablet = $mode->isTablet();
258
259                 $this->load();
260         }
261
262         /**
263          * Load the whole app instance
264          */
265         public function load()
266         {
267                 set_time_limit(0);
268
269                 // This has to be quite large to deal with embedded private photos
270                 ini_set('pcre.backtrack_limit', 500000);
271
272                 set_include_path(
273                         get_include_path() . PATH_SEPARATOR
274                         . $this->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR
275                         . $this->getBasePath() . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR
276                         . $this->getBasePath());
277
278                 $this->profiler->reset();
279
280                 if ($this->mode->has(App\Mode::DBAVAILABLE)) {
281                         $this->profiler->update($this->config);
282
283                         Core\Hook::loadHooks();
284                         $loader = new ConfigFileLoader($this->getBasePath());
285                         Core\Hook::callAll('load_config', $loader);
286                 }
287
288                 $this->loadDefaultTimezone();
289                 // Register template engines
290                 Core\Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
291         }
292
293         /**
294          * Loads the default timezone
295          *
296          * Include support for legacy $default_timezone
297          *
298          * @global string $default_timezone
299          */
300         private function loadDefaultTimezone()
301         {
302                 if ($this->config->get('system', 'default_timezone')) {
303                         $this->timezone = $this->config->get('system', 'default_timezone');
304                 } else {
305                         global $default_timezone;
306                         $this->timezone = !empty($default_timezone) ? $default_timezone : 'UTC';
307                 }
308
309                 if ($this->timezone) {
310                         date_default_timezone_set($this->timezone);
311                 }
312         }
313
314         /**
315          * Returns the scheme of the current call
316          *
317          * @return string
318          *
319          * @deprecated 2019.06 - use BaseURL->getScheme() instead
320          */
321         public function getScheme()
322         {
323                 return $this->baseURL->getScheme();
324         }
325
326         /**
327          * Retrieves the Friendica instance base URL
328          *
329          * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
330          *
331          * @return string Friendica server base URL
332          *
333          * @deprecated 2019.09 - use BaseUrl->get($ssl) instead
334          */
335         public function getBaseURL($ssl = false)
336         {
337                 return $this->baseURL->get($ssl);
338         }
339
340         /**
341          * @brief      Initializes the baseurl components
342          *
343          * Clears the baseurl cache to prevent inconsistencies
344          *
345          * @param string $url
346          *
347          * @deprecated 2019.06 - use BaseURL->saveByURL($url) instead
348          */
349         public function setBaseURL($url)
350         {
351                 $this->baseURL->saveByURL($url);
352         }
353
354         /**
355          * Returns the current hostname
356          *
357          * @return string
358          *
359          * @deprecated 2019.06 - use BaseURL->getHostname() instead
360          */
361         public function getHostName()
362         {
363                 return $this->baseURL->getHostname();
364         }
365
366         /**
367          * Returns the sub-path of the full URL
368          *
369          * @return string
370          *
371          * @deprecated 2019.06 - use BaseURL->getUrlPath() instead
372          */
373         public function getURLPath()
374         {
375                 return $this->baseURL->getUrlPath();
376         }
377
378         /**
379          * @brief      Removes the base url from an url. This avoids some mixed content problems.
380          *
381          * @param string $origURL
382          *
383          * @return string The cleaned url
384          *
385          * @deprecated 2019.09 - Use BaseURL->remove() instead
386          * @see        BaseURL::remove()
387          */
388         public function removeBaseURL($origURL)
389         {
390                 return $this->baseURL->remove($origURL);
391         }
392
393         /**
394          * Returns the current UserAgent as a String
395          *
396          * @return string the UserAgent as a String
397          * @throws HTTPException\InternalServerErrorException
398          */
399         public function getUserAgent()
400         {
401                 return
402                         FRIENDICA_PLATFORM . " '" .
403                         FRIENDICA_CODENAME . "' " .
404                         FRIENDICA_VERSION . '-' .
405                         DB_UPDATE_VERSION . '; ' .
406                         $this->getBaseURL();
407         }
408
409         /**
410          * @deprecated 2019.09 - use Core\Process->isMaxProcessesReached() instead
411          */
412         public function isMaxProcessesReached()
413         {
414                 return $this->process->isMaxProcessesReached();
415         }
416
417         /**
418          * @deprecated 2019.09 - use Core\Process->isMinMemoryReached() instead
419          */
420         public function isMinMemoryReached()
421         {
422                 return $this->process->isMinMemoryReached();
423         }
424
425         /**
426          * @deprecated 2019.09 - use Core\Process->isMaxLoadReached() instead
427          */
428         public function isMaxLoadReached()
429         {
430                 return $this->process->isMaxLoadReached();
431         }
432
433         /**
434          * Generates the site's default sender email address
435          *
436          * @return string
437          * @throws HTTPException\InternalServerErrorException
438          */
439         public function getSenderEmailAddress()
440         {
441                 $sender_email = $this->config->get('config', 'sender_email');
442                 if (empty($sender_email)) {
443                         $hostname = $this->baseURL->getHostname();
444                         if (strpos($hostname, ':')) {
445                                 $hostname = substr($hostname, 0, strpos($hostname, ':'));
446                         }
447
448                         $sender_email = 'noreply@' . $hostname;
449                 }
450
451                 return $sender_email;
452         }
453
454         /**
455          * Returns the current theme name. May be overriden by the mobile theme name.
456          *
457          * @return string
458          * @throws Exception
459          */
460         public function getCurrentTheme()
461         {
462                 if ($this->mode->isInstall()) {
463                         return '';
464                 }
465
466                 // Specific mobile theme override
467                 if (($this->mode->isMobile() || $this->mode->isTablet()) && Core\Session::get('show-mobile', true)) {
468                         $user_mobile_theme = $this->getCurrentMobileTheme();
469
470                         // --- means same mobile theme as desktop
471                         if (!empty($user_mobile_theme) && $user_mobile_theme !== '---') {
472                                 return $user_mobile_theme;
473                         }
474                 }
475
476                 if (!$this->currentTheme) {
477                         $this->computeCurrentTheme();
478                 }
479
480                 return $this->currentTheme;
481         }
482
483         /**
484          * Returns the current mobile theme name.
485          *
486          * @return string
487          * @throws Exception
488          */
489         public function getCurrentMobileTheme()
490         {
491                 if ($this->mode->isInstall()) {
492                         return '';
493                 }
494
495                 if (is_null($this->currentMobileTheme)) {
496                         $this->computeCurrentMobileTheme();
497                 }
498
499                 return $this->currentMobileTheme;
500         }
501
502         public function setCurrentTheme($theme)
503         {
504                 $this->currentTheme = $theme;
505         }
506
507         public function setCurrentMobileTheme($theme)
508         {
509                 $this->currentMobileTheme = $theme;
510         }
511
512         /**
513          * Computes the current theme name based on the node settings, the page owner settings and the user settings
514          *
515          * @throws Exception
516          */
517         private function computeCurrentTheme()
518         {
519                 $system_theme = $this->config->get('system', 'theme');
520                 if (!$system_theme) {
521                         throw new Exception($this->l10n->t('No system theme config value set.'));
522                 }
523
524                 // Sane default
525                 $this->setCurrentTheme($system_theme);
526
527                 $page_theme = null;
528                 // Find the theme that belongs to the user whose stuff we are looking at
529                 if ($this->profile_uid && ($this->profile_uid != local_user())) {
530                         // Allow folks to override user themes and always use their own on their own site.
531                         // This works only if the user is on the same server
532                         $user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_uid]);
533                         if ($this->database->isResult($user) && !Core\PConfig::get(local_user(), 'system', 'always_my_theme')) {
534                                 $page_theme = $user['theme'];
535                         }
536                 }
537
538                 $theme_name = $page_theme ?: Core\Session::get('theme', $system_theme);
539
540                 $theme_name = Strings::sanitizeFilePathItem($theme_name);
541                 if ($theme_name
542                     && in_array($theme_name, Theme::getAllowedList())
543                     && (file_exists('view/theme/' . $theme_name . '/style.css')
544                         || file_exists('view/theme/' . $theme_name . '/style.php'))
545                 ) {
546                         $this->setCurrentTheme($theme_name);
547                 }
548         }
549
550         /**
551          * Computes the current mobile theme name based on the node settings, the page owner settings and the user settings
552          */
553         private function computeCurrentMobileTheme()
554         {
555                 $system_mobile_theme = $this->config->get('system', 'mobile-theme', '');
556
557                 // Sane default
558                 $this->setCurrentMobileTheme($system_mobile_theme);
559
560                 $page_mobile_theme = null;
561                 // Find the theme that belongs to the user whose stuff we are looking at
562                 if ($this->profile_uid && ($this->profile_uid != local_user())) {
563                         // Allow folks to override user themes and always use their own on their own site.
564                         // This works only if the user is on the same server
565                         if (!Core\PConfig::get(local_user(), 'system', 'always_my_theme')) {
566                                 $page_mobile_theme = Core\PConfig::get($this->profile_uid, 'system', 'mobile-theme');
567                         }
568                 }
569
570                 $mobile_theme_name = $page_mobile_theme ?: Core\Session::get('mobile-theme', $system_mobile_theme);
571
572                 $mobile_theme_name = Strings::sanitizeFilePathItem($mobile_theme_name);
573                 if ($mobile_theme_name == '---'
574                         ||
575                         in_array($mobile_theme_name, Theme::getAllowedList())
576                         && (file_exists('view/theme/' . $mobile_theme_name . '/style.css')
577                                 || file_exists('view/theme/' . $mobile_theme_name . '/style.php'))
578                 ) {
579                         $this->setCurrentMobileTheme($mobile_theme_name);
580                 }
581         }
582
583         /**
584          * @brief Return full URL to theme which is currently in effect.
585          *
586          * Provide a sane default if nothing is chosen or the specified theme does not exist.
587          *
588          * @return string
589          * @throws Exception
590          */
591         public function getCurrentThemeStylesheetPath()
592         {
593                 return Core\Theme::getStylesheetPath($this->getCurrentTheme());
594         }
595
596         /**
597          * @deprecated 2019.09 - use App\Mode->isAjax() instead
598          * @see        App\Mode::isAjax()
599          */
600         public function isAjax()
601         {
602                 return $this->mode->isAjax();
603         }
604
605         /**
606          * @deprecated use Arguments->get() instead
607          *
608          * @see        App\Arguments
609          */
610         public function getArgumentValue($position, $default = '')
611         {
612                 return $this->args->get($position, $default);
613         }
614
615         /**
616          * Sets the base url for use in cmdline programs which don't have
617          * $_SERVER variables
618          */
619         public function checkURL()
620         {
621                 $url = $this->config->get('system', 'url');
622
623                 // if the url isn't set or the stored url is radically different
624                 // than the currently visited url, store the current value accordingly.
625                 // "Radically different" ignores common variations such as http vs https
626                 // and www.example.com vs example.com.
627                 // We will only change the url to an ip address if there is no existing setting
628
629                 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()))) {
630                         $this->config->set('system', 'url', $this->getBaseURL());
631                 }
632         }
633
634         /**
635          * Frontend App script
636          *
637          * The App object behaves like a container and a dispatcher at the same time, including a representation of the
638          * request and a representation of the response.
639          *
640          * This probably should change to limit the size of this monster method.
641          *
642          * @param App\Module     $module The determined module
643          * @param App\Router     $router
644          * @param PConfiguration $pconfig
645          * @param Authentication $auth The Authentication backend of the node
646          * @throws HTTPException\InternalServerErrorException
647          * @throws \ImagickException
648          */
649         public function runFrontend(App\Module $module, App\Router $router, PConfiguration $pconfig, Authentication $auth)
650         {
651                 $moduleName = $module->getName();
652
653                 try {
654                         // Missing DB connection: ERROR
655                         if ($this->mode->has(App\Mode::LOCALCONFIGPRESENT) && !$this->mode->has(App\Mode::DBAVAILABLE)) {
656                                 throw new HTTPException\InternalServerErrorException('Apologies but the website is unavailable at the moment.');
657                         }
658
659                         // Max Load Average reached: ERROR
660                         if ($this->process->isMaxProcessesReached() || $this->process->isMaxLoadReached()) {
661                                 header('Retry-After: 120');
662                                 header('Refresh: 120; url=' . $this->baseURL->get() . "/" . $this->args->getQueryString());
663
664                                 throw new HTTPException\ServiceUnavailableException('The node is currently overloaded. Please try again later.');
665                         }
666
667                         if (!$this->mode->isInstall()) {
668                                 // Force SSL redirection
669                                 if ($this->baseURL->checkRedirectHttps()) {
670                                         System::externalRedirect($this->baseURL->get() . '/' . $this->args->getQueryString());
671                                 }
672
673                                 Core\Session::init();
674                                 Core\Hook::callAll('init_1');
675                         }
676
677                         // Exclude the backend processes from the session management
678                         if (!$this->mode->isBackend()) {
679                                 $stamp1 = microtime(true);
680                                 session_start();
681                                 $this->profiler->saveTimestamp($stamp1, 'parser', Core\System::callstack());
682                                 $this->l10n->setSessionVariable();
683                                 $this->l10n->setLangFromSession();
684                         } else {
685                                 $_SESSION = [];
686                                 Core\Worker::executeIfIdle();
687                         }
688
689                         if ($this->mode->isNormal()) {
690                                 $requester = HTTPSignature::getSigner('', $_SERVER);
691                                 if (!empty($requester)) {
692                                         Profile::addVisitorCookieForHandle($requester);
693                                 }
694                         }
695
696                         // ZRL
697                         if (!empty($_GET['zrl']) && $this->mode->isNormal()) {
698                                 if (!local_user()) {
699                                         // Only continue when the given profile link seems valid
700                                         // Valid profile links contain a path with "/profile/" and no query parameters
701                                         if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
702                                             strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
703                                                 if (Core\Session::get('visitor_home') != $_GET["zrl"]) {
704                                                         Core\Session::set('my_url', $_GET['zrl']);
705                                                         Core\Session::set('authenticated', 0);
706                                                 }
707
708                                                 Model\Profile::zrlInit($this);
709                                         } else {
710                                                 // Someone came with an invalid parameter, maybe as a DDoS attempt
711                                                 // We simply stop processing here
712                                                 $this->logger->debug('Invalid ZRL parameter.', ['zrl' => $_GET['zrl']]);
713                                                 throw new HTTPException\ForbiddenException();
714                                         }
715                                 }
716                         }
717
718                         if (!empty($_GET['owt']) && $this->mode->isNormal()) {
719                                 $token = $_GET['owt'];
720                                 Model\Profile::openWebAuthInit($token);
721                         }
722
723                         $auth->withSession($this);
724
725                         if (empty($_SESSION['authenticated'])) {
726                                 header('X-Account-Management-Status: none');
727                         }
728
729                         $_SESSION['sysmsg']       = Core\Session::get('sysmsg', []);
730                         $_SESSION['sysmsg_info']  = Core\Session::get('sysmsg_info', []);
731                         $_SESSION['last_updated'] = Core\Session::get('last_updated', []);
732
733                         /*
734                          * check_config() is responsible for running update scripts. These automatically
735                          * update the DB schema whenever we push a new one out. It also checks to see if
736                          * any addons have been added or removed and reacts accordingly.
737                          */
738
739                         // in install mode, any url loads install module
740                         // but we need "view" module for stylesheet
741                         if ($this->mode->isInstall() && $moduleName !== 'install') {
742                                 $this->internalRedirect('install');
743                         } elseif (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED) && $moduleName !== 'maintenance') {
744                                 $this->internalRedirect('maintenance');
745                         } else {
746                                 $this->checkURL();
747                                 Core\Update::check($this->getBasePath(), false, $this->mode);
748                                 Core\Addon::loadAddons();
749                                 Core\Hook::loadHooks();
750                         }
751
752                         // Compatibility with the Android Diaspora client
753                         if ($moduleName == 'stream') {
754                                 $this->internalRedirect('network?order=post');
755                         }
756
757                         if ($moduleName == 'conversations') {
758                                 $this->internalRedirect('message');
759                         }
760
761                         if ($moduleName == 'commented') {
762                                 $this->internalRedirect('network?order=comment');
763                         }
764
765                         if ($moduleName == 'liked') {
766                                 $this->internalRedirect('network?order=comment');
767                         }
768
769                         if ($moduleName == 'activity') {
770                                 $this->internalRedirect('network?conv=1');
771                         }
772
773                         if (($moduleName == 'status_messages') && ($this->args->getCommand() == 'status_messages/new')) {
774                                 $this->internalRedirect('bookmarklet');
775                         }
776
777                         if (($moduleName == 'user') && ($this->args->getCommand() == 'user/edit')) {
778                                 $this->internalRedirect('settings');
779                         }
780
781                         if (($moduleName == 'tag_followings') && ($this->args->getCommand() == 'tag_followings/manage')) {
782                                 $this->internalRedirect('search');
783                         }
784
785                         // Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
786                         $this->page['page_title'] = $moduleName;
787
788                         // determine the module class and save it to the module instance
789                         // @todo there's an implicit dependency due SESSION::start(), so it has to be called here (yet)
790                         $module = $module->determineClass($this->args, $router, $this->config);
791
792                         // Let the module run it's internal process (init, get, post, ...)
793                         $module->run($this->l10n, $this, $this->logger, $_SERVER, $_POST);
794                 } catch (HTTPException $e) {
795                         ModuleHTTPException::rawContent($e);
796                 }
797
798                 $this->page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->config, $pconfig);
799         }
800
801         /**
802          * @deprecated 2019.12 use BaseUrl::redirect instead
803          * @see BaseURL::redirect()
804          */
805         public function internalRedirect($toUrl = '', $ssl = false)
806         {
807                 $this->baseURL->redirect($toUrl, $ssl);
808         }
809
810         /**
811          * Automatically redirects to relative or absolute URL
812          * Should only be used if it isn't clear if the URL is either internal or external
813          *
814          * @param string $toUrl The target URL
815          *
816          * @throws HTTPException\InternalServerErrorException
817          */
818         public function redirect($toUrl)
819         {
820                 if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
821                         Core\System::externalRedirect($toUrl);
822                 } else {
823                         $this->baseURL->redirect($toUrl);
824                 }
825         }
826 }