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