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