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