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