[BUGFIX] Ignore non-integer values for type in redirects
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Controller / TypoScriptFrontendController.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Controller;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Core\Utility\HttpUtility;
19 use TYPO3\CMS\Core\Utility\MathUtility;
20
21 /**
22 * Class for the built TypoScript based frontend. Instantiated in
23 * index_ts.php script as the global object TSFE.
24 *
25 * Main frontend class, instantiated in the index_ts.php script as the global
26 * object TSFE.
27 *
28 * This class has a lot of functions and internal variable which are used from
29 * index_ts.php.
30 *
31 * The class is instantiated as $GLOBALS['TSFE'] in index_ts.php.
32 *
33 * The use of this class should be inspired by the order of function calls as
34 * found in index_ts.php.
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 */
38 class TypoScriptFrontendController {
39
40 // CURRENT PAGE
41
42 /**
43 * The page id (int)
44 * @var string
45 * @todo Define visibility
46 */
47 public $id = '';
48
49 /**
50 * The type (read-only)
51 * @var int
52 * @todo Define visibility
53 */
54 public $type = '';
55
56 /**
57 * The submitted cHash
58 * @var string
59 * @todo Define visibility
60 */
61 public $cHash = '';
62
63 /**
64 * Page will not be cached. Write only TRUE. Never clear value (some other
65 * code might have reasons to set it TRUE).
66 * @var bool
67 * @todo Define visibility
68 */
69 public $no_cache = FALSE;
70
71 /**
72 * The rootLine (all the way to tree root, not only the current site!)
73 * @var array
74 * @todo Define visibility
75 */
76 public $rootLine = '';
77
78 /**
79 * The pagerecord
80 * @var array
81 */
82 public $page = '';
83
84 /**
85 * This will normally point to the same value as id, but can be changed to
86 * point to another page from which content will then be displayed instead.
87 * @var int
88 * @todo Define visibility
89 */
90 public $contentPid = 0;
91
92 /**
93 * Gets set when we are processing a page of type shortcut in the early stages
94 * opf init.php when we do not know about languages yet, used later in init.php
95 * to determine the correct shortcut in case a translation changes the shortcut
96 * target
97 * @var array|NULL
98 */
99 protected $originalShortcutPage = NULL;
100
101 /**
102 * sys_page-object, pagefunctions
103 *
104 * @var \TYPO3\CMS\Frontend\Page\PageRepository
105 * @todo Define visibility
106 */
107 public $sys_page = '';
108
109 /**
110 * @var string
111 * @todo Define visibility
112 */
113 public $jumpurl = '';
114
115 /**
116 * Is set to 1 if a pageNotFound handler could have been called.
117 * @var int
118 * @todo Define visibility
119 */
120 public $pageNotFound = 0;
121
122 /**
123 * Domain start page
124 * @var int
125 * @todo Define visibility
126 */
127 public $domainStartPage = 0;
128
129 /**
130 * Array containing a history of why a requested page was not accessible.
131 * @var array
132 * @todo Define visibility
133 */
134 public $pageAccessFailureHistory = array();
135
136 /**
137 * @var string
138 * @todo Define visibility
139 */
140 public $MP = '';
141
142 /**
143 * @var string
144 * @todo Define visibility
145 */
146 public $RDCT = '';
147
148 /**
149 * This can be set from applications as a way to tag cached versions of a page
150 * and later perform some external cache management, like clearing only a part
151 * of the cache of a page...
152 * @var int
153 * @todo Define visibility
154 */
155 public $page_cache_reg1 = 0;
156
157 /**
158 * Contains the value of the current script path that activated the frontend.
159 * Typically "index.php" but by rewrite rules it could be something else! Used
160 * for Speaking Urls / Simulate Static Documents.
161 * @var string
162 * @todo Define visibility
163 */
164 public $siteScript = '';
165
166 /**
167 * The frontend user
168 *
169 * @var \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
170 * @todo Define visibility
171 */
172 public $fe_user = '';
173
174 /**
175 * Global flag indicating that a frontend user is logged in. This is set only if
176 * a user really IS logged in. The group-list may show other groups (like added
177 * by IP filter or so) even though there is no user.
178 * @var bool
179 * @todo Define visibility
180 */
181 public $loginUser = FALSE;
182
183 /**
184 * (RO=readonly) The group list, sorted numerically. Group '0,-1' is the default
185 * group, but other groups may be added by other means than a user being logged
186 * in though...
187 * @var string
188 * @todo Define visibility
189 */
190 public $gr_list = '';
191
192 /**
193 * Flag that indicates if a backend user is logged in!
194 * @var bool
195 */
196 public $beUserLogin = FALSE;
197
198 /**
199 * Integer, that indicates which workspace is being previewed.
200 * @var int
201 * @todo Define visibility
202 */
203 public $workspacePreview = 0;
204
205 /**
206 * Shows whether logins are allowed in branch
207 * @var bool
208 * @todo Define visibility
209 */
210 public $loginAllowedInBranch = TRUE;
211
212 /**
213 * Shows specific mode (all or groups)
214 * @var string
215 * @todo Define visibility
216 */
217 public $loginAllowedInBranch_mode = '';
218
219 /**
220 * Set to backend user ID to initialize when keyword-based preview is used
221 * @var int
222 * @todo Define visibility
223 */
224 public $ADMCMD_preview_BEUSER_uid = 0;
225
226 // PREVIEW
227
228 /**
229 * Flag indication that preview is active. This is based on the login of a
230 * backend user and whether the backend user has read access to the current
231 * page. A value of 1 means ordinary preview, 2 means preview of a non-live
232 * workspace
233 * @var int
234 * @todo Define visibility
235 */
236 public $fePreview = 0;
237
238 /**
239 * Flag indicating that hidden pages should be shown, selected and so on. This
240 * goes for almost all selection of pages!
241 * @var bool
242 * @todo Define visibility
243 */
244 public $showHiddenPage = FALSE;
245
246 /**
247 * Flag indicating that hidden records should be shown. This includes
248 * sys_template, pages_language_overlay and even fe_groups in addition to all
249 * other regular content. So in effect, this includes everything except pages.
250 * @var bool
251 * @todo Define visibility
252 */
253 public $showHiddenRecords = FALSE;
254
255 /**
256 * Value that contains the simulated usergroup if any
257 * @var int
258 * @todo Define visibility
259 */
260 public $simUserGroup = 0;
261
262 // CONFIGURATION
263
264 /**
265 * Copy of $GLOBALS['TYPO3_CONF_VARS']
266 *
267 * @var array
268 */
269 public $TYPO3_CONF_VARS = array();
270
271 /**
272 * "CONFIG" object from TypoScript. Array generated based on the TypoScript
273 * configuration of the current page. Saved with the cached pages.
274 * @var array
275 */
276 public $config = '';
277
278 // TEMPLATE / CACHE
279
280 /**
281 * The TypoScript template object. Used to parse the TypoScript template
282 *
283 * @var \TYPO3\CMS\Core\TypoScript\TemplateService
284 * @todo Define visibility
285 */
286 public $tmpl = NULL;
287
288 /**
289 * Is set to the time-to-live time of cached pages. If FALSE, default is
290 * 60*60*24, which is 24 hours.
291 * @var bool|int
292 * @todo Define visibility
293 */
294 public $cacheTimeOutDefault = FALSE;
295
296 /**
297 * Set internally if cached content is fetched from the database
298 * @var bool
299 * @internal
300 * @todo Define visibility
301 */
302 public $cacheContentFlag = FALSE;
303
304 /**
305 * Set to the expire time of cached content
306 * @var int
307 * @todo Define visibility
308 */
309 public $cacheExpires = 0;
310
311 /**
312 * Set if cache headers allowing caching are sent.
313 * @var bool
314 * @todo Define visibility
315 */
316 public $isClientCachable = FALSE;
317
318 /**
319 * Used by template fetching system. This array is an identification of
320 * the template. If $this->all is empty it's because the template-data is not
321 * cached, which it must be.
322 * @var array
323 * @todo Define visibility
324 */
325 public $all = array();
326
327 /**
328 * Toplevel - objArrayName, eg 'page'
329 * @var string
330 * @todo Define visibility
331 */
332 public $sPre = '';
333
334 /**
335 * TypoScript configuration of the page-object pointed to by sPre.
336 * $this->tmpl->setup[$this->sPre.'.']
337 * @var array
338 * @todo Define visibility
339 */
340 public $pSetup = '';
341
342 /**
343 * This hash is unique to the template, the $this->id and $this->type vars and
344 * the gr_list (list of groups). Used to get and later store the cached data
345 * @var string
346 * @todo Define visibility
347 */
348 public $newHash = '';
349
350 /**
351 * If config.ftu (Frontend Track User) is set in TypoScript for the current
352 * page, the string value of this var is substituted in the rendered source-code
353 * with the string, '&ftu=[token...]' which enables GET-method usertracking as
354 * opposed to cookie based
355 * @var string
356 * @todo Define visibility
357 */
358 public $getMethodUrlIdToken = '';
359
360 /**
361 * This flag is set before inclusion of pagegen.php IF no_cache is set. If this
362 * flag is set after the inclusion of pagegen.php, no_cache is forced to be set.
363 * This is done in order to make sure that php-code from pagegen does not falsely
364 * clear the no_cache flag.
365 * @var bool
366 * @todo Define visibility
367 */
368 public $no_cacheBeforePageGen = FALSE;
369
370 /**
371 * This flag indicates if temporary content went into the cache during
372 * page-generation.
373 * @var mixed
374 * @todo Define visibility
375 */
376 public $tempContent = FALSE;
377
378 /**
379 * Passed to TypoScript template class and tells it to force template rendering
380 * @var bool
381 * @todo Define visibility
382 */
383 public $forceTemplateParsing = FALSE;
384
385 /**
386 * The array which cHash_calc is based on, see ->makeCacheHash().
387 * @var array
388 * @todo Define visibility
389 */
390 public $cHash_array = array();
391
392 /**
393 * May be set to the pagesTSconfig
394 * @var array
395 * @todo Define visibility
396 */
397 public $pagesTSconfig = '';
398
399 // PAGE-GENERATION / cOBJ
400
401 /**
402 * Eg. insert JS-functions in this array ($additionalHeaderData) to include them
403 * once. Use associative keys.
404 *
405 * Keys in use:
406 *
407 * JSFormValidate: <script type="text/javascript" src="'.$GLOBALS["TSFE"]->absRefPrefix.'typo3/sysext/frontend/Resources/Public/JavaScript/jsfunc.validateform.js"></script>
408 * JSincludeFormupdate: <script type="text/javascript" src="typo3/js/jsfunc.updateform.js"></script>
409 * JSMenuCode, JSMenuCode_menu: JavaScript for the JavaScript menu
410 * JSCode: reserved
411 * JSImgCode: reserved
412 *
413 * used to accumulate additional HTML-code for the header-section,
414 * <head>...</head>. Insert either associative keys (like
415 * additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys
416 * (like additionalHeaderData[] = '...')
417 *
418 * @var array
419 * @todo Define visibility
420 */
421 public $additionalHeaderData = array();
422
423 /**
424 * Used to accumulate additional HTML-code for the footer-section of the template
425 * @var array
426 */
427 public $additionalFooterData = array();
428
429 /**
430 * Used to accumulate additional JavaScript-code. Works like
431 * additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
432 *
433 * @var array
434 * @todo Define visibility
435 */
436 public $additionalJavaScript = array();
437
438 /**
439 * Used to accumulate additional Style code. Works like additionalHeaderData.
440 *
441 * @var array
442 * @todo Define visibility
443 */
444 public $additionalCSS = array();
445
446 /**
447 * You can add JavaScript functions to each entry in these arrays. Please see
448 * how this is done in the GMENU_LAYERS script. The point is that many
449 * applications on a page can set handlers for onload, onmouseover and onmouseup
450 *
451 * @var array
452 * @todo Define visibility
453 */
454 public $JSeventFuncCalls = array(
455 'onmousemove' => array(),
456 'onmouseup' => array(),
457 'onkeydown' => array(),
458 'onkeyup' => array(),
459 'onkeypress' => array(),
460 'onload' => array(),
461 'onunload' => array()
462 );
463
464 /**
465 * Used to accumulate JavaScript loaded images (by menus)
466 * @var string
467 * @todo Define visibility
468 */
469 public $JSImgCode = '';
470
471 /**
472 * Used to accumulate DHTML-layers.
473 * @var string
474 * @todo Define visibility
475 */
476 public $divSection = '';
477
478 /**
479 * Default bodytag, if nothing else is set. This can be overridden by
480 * applications like TemplaVoila.
481 * @var string
482 * @todo Define visibility
483 */
484 public $defaultBodyTag = '<body>';
485
486 // RENDERING configuration, settings from TypoScript is loaded into these
487 // vars. See pagegen.php
488
489 /**
490 * Debug flag, may output special debug html-code.
491 * @var string
492 * @todo Define visibility
493 */
494 public $debug = '';
495
496 /**
497 * Default internal target
498 * @var string
499 * @todo Define visibility
500 */
501 public $intTarget = '';
502
503 /**
504 * Default external target
505 * @var string
506 * @todo Define visibility
507 */
508 public $extTarget = '';
509
510 /**
511 * Default file link target
512 * @var string
513 * @todo Define visibility
514 */
515 public $fileTarget = '';
516
517 /**
518 * Keys are page ids and values are default &MP (mount point) values to set
519 * when using the linking features...)
520 * @var array
521 * @todo Define visibility
522 */
523 public $MP_defaults = array();
524
525 /**
526 * If set, typolink() function encrypts email addresses. Is set in pagegen-class.
527 * @var string|int
528 * @todo Define visibility
529 */
530 public $spamProtectEmailAddresses = 0;
531
532 /**
533 * Absolute Reference prefix
534 * @var string
535 * @todo Define visibility
536 */
537 public $absRefPrefix = '';
538
539 /**
540 * Absolute Reference prefix force flag. This is set, if the type and id is
541 * retrieve from PATH_INFO and thus we NEED to prefix urls with at least '/'
542 * UNUSED in Core
543 *
544 * @var bool
545 * @deprecated since 6.2; will be removed two versions later
546 */
547 public $absRefPrefix_force = FALSE;
548
549 /**
550 * Factor for form-field widths compensation
551 * @var string
552 * @todo Define visibility
553 */
554 public $compensateFieldWidth = '';
555
556 /**
557 * Lock file path
558 * @var string
559 * @todo Define visibility
560 */
561 public $lockFilePath = '';
562
563 /**
564 * <A>-tag parameters
565 * @var string
566 * @todo Define visibility
567 */
568 public $ATagParams = '';
569
570 /**
571 * Search word regex, calculated if there has been search-words send. This is
572 * used to mark up the found search words on a page when jumped to from a link
573 * in a search-result.
574 * @var string
575 * @todo Define visibility
576 */
577 public $sWordRegEx = '';
578
579 /**
580 * Is set to the incoming array sword_list in case of a page-view jumped to from
581 * a search-result.
582 * @var string
583 * @todo Define visibility
584 */
585 public $sWordList = '';
586
587 /**
588 * A string prepared for insertion in all links on the page as url-parameters.
589 * Based on configuration in TypoScript where you defined which GET_VARS you
590 * would like to pass on.
591 * @var string
592 * @todo Define visibility
593 */
594 public $linkVars = '';
595
596 /**
597 * A string set with a comma list of additional GET vars which should NOT be
598 * included in the cHash calculation. These vars should otherwise be detected
599 * and involved in caching, eg. through a condition in TypoScript.
600 * @var string
601 * @todo Define visibility
602 */
603 public $excludeCHashVars = '';
604
605 /**
606 * If set, edit icons are rendered aside content records. Must be set only if
607 * the ->beUserLogin flag is set and set_no_cache() must be called as well.
608 * @var string
609 * @todo Define visibility
610 */
611 public $displayEditIcons = '';
612
613 /**
614 * If set, edit icons are rendered aside individual fields of content. Must be
615 * set only if the ->beUserLogin flag is set and set_no_cache() must be called as
616 * well.
617 * @var string
618 * @todo Define visibility
619 */
620 public $displayFieldEditIcons = '';
621
622 /**
623 * Site language, 0 (zero) is default, int+ is uid pointing to a sys_language
624 * record. Should reflect which language menus, templates etc is displayed in
625 * (master language) - but not necessarily the content which could be falling
626 * back to default (see sys_language_content)
627 * @var int
628 * @todo Define visibility
629 */
630 public $sys_language_uid = 0;
631
632 /**
633 * Site language mode for content fall back.
634 * @var string
635 * @todo Define visibility
636 */
637 public $sys_language_mode = '';
638
639 /**
640 * Site content selection uid (can be different from sys_language_uid if content
641 * is to be selected from a fall-back language. Depends on sys_language_mode)
642 * @var int
643 * @todo Define visibility
644 */
645 public $sys_language_content = 0;
646
647 /**
648 * Site content overlay flag; If set - and sys_language_content is > 0 - ,
649 * records selected will try to look for a translation pointing to their uid. (If
650 * configured in [ctrl][languageField] / [ctrl][transOrigP...]
651 * @var int
652 * @todo Define visibility
653 */
654 public $sys_language_contentOL = 0;
655
656 /**
657 * Is set to the iso code of the sys_language_content if that is properly defined
658 * by the sys_language record representing the sys_language_uid. (Requires the
659 * extension "static_info_tables")
660 * @var string
661 * @todo Define visibility
662 */
663 public $sys_language_isocode = '';
664
665 // RENDERING data
666
667 /**
668 * 'Global' Storage for various applications. Keys should be 'tx_'.extKey for
669 * extensions.
670 * @var array
671 * @todo Define visibility
672 */
673 public $applicationData = array();
674
675 /**
676 * @var array
677 * @todo Define visibility
678 */
679 public $register = array();
680
681 /**
682 * Stack used for storing array and retrieving register arrays (see
683 * LOAD_REGISTER and RESTORE_REGISTER)
684 * @var array
685 * @todo Define visibility
686 */
687 public $registerStack = array();
688
689 /**
690 * Checking that the function is not called eternally. This is done by
691 * interrupting at a depth of 50
692 * @var int
693 * @todo Define visibility
694 */
695 public $cObjectDepthCounter = 50;
696
697 /**
698 * Used by cObj->RECORDS and cObj->CONTENT to ensure the a records is NOT
699 * rendered twice through it!
700 * @var array
701 * @todo Define visibility
702 */
703 public $recordRegister = array();
704
705 /**
706 * This is set to the [table]:[uid] of the latest record rendered. Note that
707 * class ContentObjectRenderer has an equal value, but that is pointing to the
708 * record delivered in the $data-array of the ContentObjectRenderer instance, if
709 * the cObjects CONTENT or RECORD created that instance
710 * @var string
711 * @todo Define visibility
712 */
713 public $currentRecord = '';
714
715 /**
716 * Used by class \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
717 * to keep track of access-keys.
718 * @var array
719 * @todo Define visibility
720 */
721 public $accessKey = array();
722
723 /**
724 * Numerical array where image filenames are added if they are referenced in the
725 * rendered document. This includes only TYPO3 generated/inserted images.
726 * @var array
727 * @todo Define visibility
728 */
729 public $imagesOnPage = array();
730
731 /**
732 * Is set in ContentObjectRenderer->cImage() function to the info-array of the
733 * most recent rendered image. The information is used in
734 * ContentObjectRenderer->IMGTEXT
735 * @var array
736 * @todo Define visibility
737 */
738 public $lastImageInfo = array();
739
740 /**
741 * Used to generate page-unique keys. Point is that uniqid() functions is very
742 * slow, so a unikey key is made based on this, see function uniqueHash()
743 * @var int
744 * @todo Define visibility
745 */
746 public $uniqueCounter = 0;
747
748 /**
749 * @var string
750 * @todo Define visibility
751 */
752 public $uniqueString = '';
753
754 /**
755 * This value will be used as the title for the page in the indexer (if
756 * indexing happens)
757 * @var string
758 * @todo Define visibility
759 */
760 public $indexedDocTitle = '';
761
762 /**
763 * Alternative page title (normally the title of the page record). Can be set
764 * from applications you make.
765 * @var string
766 * @todo Define visibility
767 */
768 public $altPageTitle = '';
769
770 /**
771 * The base URL set for the page header.
772 * @var string
773 * @todo Define visibility
774 */
775 public $baseUrl = '';
776
777 /**
778 * The proper anchor prefix needed when using speaking urls. (only set if
779 * baseUrl is set)
780 * @var string
781 * @todo Define visibility
782 */
783 public $anchorPrefix = '';
784
785 /**
786 * IDs we already rendered for this page (to make sure they are unique)
787 * @var array
788 */
789 private $usedUniqueIds = array();
790
791 /**
792 * Page content render object
793 *
794 * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
795 * @todo Define visibility
796 */
797 public $cObj = '';
798
799 // CONTENT accumulation
800
801 /**
802 * All page content is accumulated in this variable. See pagegen.php
803 * @var string
804 */
805 public $content = '';
806
807 // GENERAL
808
809 /**
810 * Set to the browser: net / msie if 4+ browsers
811 * @var string
812 * @todo Define visibility
813 */
814 public $clientInfo = '';
815
816 /**
817 * @var int
818 * @todo Define visibility
819 */
820 public $scriptParseTime = 0;
821
822 /**
823 * Character set (charset) conversion object:
824 * charset conversion class. May be used by any application.
825 *
826 * @var \TYPO3\CMS\Core\Charset\CharsetConverter
827 * @todo Define visibility
828 */
829 public $csConvObj;
830
831 /**
832 * The default charset used in the frontend if nothing else is set.
833 * @var string
834 * @todo Define visibility
835 */
836 public $defaultCharSet = 'utf-8';
837
838 /**
839 * Internal charset of the frontend during rendering. (Default: UTF-8)
840 * @var string
841 * @todo Define visibility
842 */
843 public $renderCharset = '';
844
845 /**
846 * Output charset of the websites content. This is the charset found in the
847 * header, meta tag etc. If different from $renderCharset a conversion
848 * happens before output to browser. Defaults to ->renderCharset if not set.
849 * @var string
850 * @todo Define visibility
851 */
852 public $metaCharset = '';
853
854 /**
855 * Assumed charset of locale strings.
856 * @var string
857 * @todo Define visibility
858 */
859 public $localeCharset = '';
860
861 // LANG
862
863 /**
864 * Set to the system language key (used on the site)
865 * @var string
866 * @todo Define visibility
867 */
868 public $lang = '';
869
870 /**
871 * @var array
872 * @todo Define visibility
873 */
874 public $LL_labels_cache = array();
875
876 /**
877 * @var array
878 * @todo Define visibility
879 */
880 public $LL_files_cache = array();
881
882 /**
883 * List of language dependencies for actual language. This is used for local
884 * variants of a language that depend on their "main" language, like Brazilian,
885 * Portuguese or Canadian French.
886 *
887 * @var array
888 */
889 protected $languageDependencies = array();
890
891 /**
892 * Locking object for accessing "cache_pagesection"
893 *
894 * @var \TYPO3\CMS\Core\Locking\Locker
895 * @todo Define visibility
896 */
897 public $pagesection_lockObj;
898
899 /**
900 * Locking object for accessing "cache_pages"
901 *
902 * @var \TYPO3\CMS\Core\Locking\Locker
903 * @todo Define visibility
904 */
905 public $pages_lockObj;
906
907 /**
908 * @var \TYPO3\CMS\Core\Page\PageRenderer
909 */
910 protected $pageRenderer;
911
912 /**
913 * The page cache object, use this to save pages to the cache and to
914 * retrieve them again
915 *
916 * @var \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
917 */
918 protected $pageCache;
919
920 /**
921 * @var array
922 */
923 protected $pageCacheTags = array();
924
925 /**
926 * @var \TYPO3\CMS\Frontend\Page\CacheHashCalculator The cHash Service class used for cHash related functionality
927 */
928 protected $cacheHash;
929
930 /**
931 * Runtime cache of domains per processed page ids.
932 *
933 * @var array
934 */
935 protected $domainDataCache = array();
936
937 /**
938 * Class constructor
939 * Takes a number of GET/POST input variable as arguments and stores them internally.
940 * The processing of these variables goes on later in this class.
941 * Also sets internal clientInfo array (browser information) and a unique string (->uniqueString) for this script instance; A md5 hash of the microtime()
942 *
943 * @param array $TYPO3_CONF_VARS The global $TYPO3_CONF_VARS array. Will be set internally in ->TYPO3_CONF_VARS
944 * @param mixed $id The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id')
945 * @param integer $type The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type')
946 * @param bool|string $no_cache The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('no_cache'), evaluated to 1/0
947 * @param string $cHash The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cHash')
948 * @param string $jumpurl The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('jumpurl')
949 * @param string $MP The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('MP')
950 * @param string $RDCT The value of \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RDCT')
951 * @see index_ts.php
952 * @todo Define visibility
953 */
954 public function __construct($TYPO3_CONF_VARS, $id, $type, $no_cache = '', $cHash = '', $jumpurl = '', $MP = '', $RDCT = '') {
955 // Setting some variables:
956 $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
957 $this->id = $id;
958 $this->type = $type;
959 if ($no_cache) {
960 if ($this->TYPO3_CONF_VARS['FE']['disableNoCacheParameter']) {
961 $warning = '&no_cache=1 has been ignored because $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set!';
962 $GLOBALS['TT']->setTSlogMessage($warning, 2);
963 } else {
964 $warning = '&no_cache=1 has been supplied, so caching is disabled! URL: "' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '"';
965 $this->disableCache();
966 }
967 GeneralUtility::sysLog($warning, 'cms', GeneralUtility::SYSLOG_SEVERITY_WARNING);
968 }
969 $this->cHash = $cHash;
970 $this->jumpurl = $jumpurl;
971 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? (string) $MP : '';
972 $this->RDCT = $RDCT;
973 $this->clientInfo = GeneralUtility::clientInfo();
974 $this->uniqueString = md5(microtime());
975 $this->csConvObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
976 // Call post processing function for constructor:
977 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) {
978 $_params = array('pObj' => &$this);
979 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef) {
980 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
981 }
982 }
983 $this->cacheHash = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator');
984 $this->initCaches();
985 }
986
987 /**
988 * Connect to SQL database. May exit after outputting an error message
989 * or some JavaScript redirecting to the install tool.
990 *
991 * @throws \RuntimeException
992 * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
993 * @return void
994 */
995 public function connectToDB() {
996 try {
997 $GLOBALS['TYPO3_DB']->connectDB();
998 } catch (\RuntimeException $exception) {
999 switch ($exception->getCode()) {
1000 case 1270853883:
1001 // Cannot connect to current database
1002 $message = 'Cannot connect to the configured database "' . TYPO3_db . '"';
1003 if ($this->checkPageUnavailableHandler()) {
1004 $this->pageUnavailableAndExit($message);
1005 } else {
1006 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1007 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1301648782);
1008 }
1009 break;
1010 case 1270853884:
1011 // Username / password not accepted
1012 $message = 'The current username, password or host was not accepted when' . ' the connection to the database was attempted to be established!';
1013 if ($this->checkPageUnavailableHandler()) {
1014 $this->pageUnavailableAndExit($message);
1015 } else {
1016 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1017 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException('Database Error: ' . $message, 1301648945);
1018 }
1019 break;
1020 default:
1021 throw $exception;
1022 }
1023 }
1024 // Call post processing function for DB connection:
1025 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'])) {
1026 $_params = array('pObj' => &$this);
1027 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['connectToDB'] as $_funcRef) {
1028 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1029 }
1030 }
1031 }
1032
1033 /**
1034 * Looks up the value of $this->RDCT in the database and if it is
1035 * found to be associated with a redirect URL then the redirection
1036 * is carried out with a 'Location:' header
1037 * May exit after sending a location-header.
1038 *
1039 * @return void
1040 */
1041 public function sendRedirect() {
1042 if ($this->RDCT) {
1043 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->RDCT, 'cache_md5params'));
1044 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1045 $this->updateMD5paramsRecord($this->RDCT);
1046 header('Location: ' . $row['params']);
1047 die;
1048 }
1049 }
1050 }
1051
1052 /**
1053 * Gets instance of PageRenderer
1054 *
1055 * @return \TYPO3\CMS\Core\Page\PageRenderer
1056 */
1057 public function getPageRenderer() {
1058 if (!isset($this->pageRenderer)) {
1059 $this->pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
1060 $this->pageRenderer->setTemplateFile(PATH_tslib . 'templates/tslib_page_frontend.html');
1061 $this->pageRenderer->setBackPath(TYPO3_mainDir);
1062 }
1063 return $this->pageRenderer;
1064 }
1065
1066 /**
1067 * This is needed for USER_INT processing
1068 *
1069 * @param \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer
1070 */
1071 protected function setPageRenderer(\TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) {
1072 $this->pageRenderer = $pageRenderer;
1073 }
1074
1075 /********************************************
1076 *
1077 * Initializing, resolving page id
1078 *
1079 ********************************************/
1080 /**
1081 * Initializes the caching system.
1082 *
1083 * @return void
1084 */
1085 protected function initCaches() {
1086 $this->pageCache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_pages');
1087 }
1088
1089 /**
1090 * Initializes the front-end login user.
1091 *
1092 * @return void
1093 */
1094 public function initFEuser() {
1095 $this->fe_user = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
1096 $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP'];
1097 $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid'];
1098 $this->fe_user->lifetime = (int)$this->TYPO3_CONF_VARS['FE']['lifetime'];
1099 // List of pid's acceptable
1100 $pid = GeneralUtility::_GP('pid');
1101 $this->fe_user->checkPid_value = $pid ? $GLOBALS['TYPO3_DB']->cleanIntList($pid) : 0;
1102 // Check if a session is transferred:
1103 if (GeneralUtility::_GP('FE_SESSION_KEY')) {
1104 $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
1105 // If the session key hash check is OK:
1106 if (md5(($fe_sParts[0] . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey'])) === (string)$fe_sParts[1]) {
1107 $cookieName = \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication::getCookieName();
1108 $_COOKIE[$cookieName] = $fe_sParts[0];
1109 if (isset($_SERVER['HTTP_COOKIE'])) {
1110 // See http://forge.typo3.org/issues/27740
1111 $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
1112 }
1113 $this->fe_user->forceSetCookie = 1;
1114 unset($cookieName);
1115 }
1116 }
1117 $this->fe_user->start();
1118 $this->fe_user->unpack_uc('');
1119 // Gets session data
1120 $this->fe_user->fetchSessionData();
1121 $recs = GeneralUtility::_GP('recs');
1122 // If any record registration is submitted, register the record.
1123 if (is_array($recs)) {
1124 $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']);
1125 }
1126 // Call hook for possible manipulation of frontend user object
1127 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
1128 $_params = array('pObj' => &$this);
1129 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
1130 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1131 }
1132 }
1133 // For every 60 seconds the is_online timestamp is updated.
1134 if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online'] < $GLOBALS['EXEC_TIME'] - 60) {
1135 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid=' . (int)$this->fe_user->user['uid'], array('is_online' => $GLOBALS['EXEC_TIME']));
1136 }
1137 }
1138
1139 /**
1140 * Initializes the front-end user groups.
1141 * Sets ->loginUser and ->gr_list based on front-end user status.
1142 *
1143 * @return void
1144 * @todo Define visibility
1145 */
1146 public function initUserGroups() {
1147 // This affects the hidden-flag selecting the fe_groups for the user!
1148 $this->fe_user->showHiddenRecords = $this->showHiddenRecords;
1149 // no matter if we have an active user we try to fetch matching groups which can be set without an user (simulation for instance!)
1150 $this->fe_user->fetchGroupData();
1151 if (is_array($this->fe_user->user) && count($this->fe_user->groupData['uid'])) {
1152 // global flag!
1153 $this->loginUser = TRUE;
1154 // group -2 is not an existing group, but denotes a 'default' group when a user IS logged in. This is used to let elements be shown for all logged in users!
1155 $this->gr_list = '0,-2';
1156 $gr_array = $this->fe_user->groupData['uid'];
1157 } else {
1158 $this->loginUser = FALSE;
1159 // group -1 is not an existing group, but denotes a 'default' group when not logged in. This is used to let elements be hidden, when a user is logged in!
1160 $this->gr_list = '0,-1';
1161 if ($this->loginAllowedInBranch) {
1162 // For cases where logins are not banned from a branch usergroups can be set based on IP masks so we should add the usergroups uids.
1163 $gr_array = $this->fe_user->groupData['uid'];
1164 } else {
1165 // Set to blank since we will NOT risk any groups being set when no logins are allowed!
1166 $gr_array = array();
1167 }
1168 }
1169 // Clean up.
1170 // Make unique...
1171 $gr_array = array_unique($gr_array);
1172 // sort
1173 sort($gr_array);
1174 if (count($gr_array) && !$this->loginAllowedInBranch_mode) {
1175 $this->gr_list .= ',' . implode(',', $gr_array);
1176 }
1177 if ($this->fe_user->writeDevLog) {
1178 GeneralUtility::devLog('Valid usergroups for TSFE: ' . $this->gr_list, 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController');
1179 }
1180 }
1181
1182 /**
1183 * Checking if a user is logged in or a group constellation different from "0,-1"
1184 *
1185 * @return boolean TRUE if either a login user is found (array fe_user->user) OR if the gr_list is set to something else than '0,-1' (could be done even without a user being logged in!)
1186 * @todo Define visibility
1187 */
1188 public function isUserOrGroupSet() {
1189 return is_array($this->fe_user->user) || $this->gr_list !== '0,-1';
1190 }
1191
1192 /**
1193 * Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
1194 *
1195 * Two options:
1196 * 1) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
1197 * 2) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
1198 *
1199 * @return void
1200 */
1201 public function checkAlternativeIdMethods() {
1202 $this->siteScript = GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT');
1203 // Call post processing function for custom URL methods.
1204 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
1205 $_params = array('pObj' => &$this);
1206 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
1207 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1208 }
1209 }
1210 }
1211
1212 /**
1213 * Clears the preview-flags, sets sim_exec_time to current time.
1214 * Hidden pages must be hidden as default, $GLOBALS['SIM_EXEC_TIME'] is set to $GLOBALS['EXEC_TIME']
1215 * in bootstrap initializeGlobalTimeVariables(). Alter it by adding or subtracting seconds.
1216 *
1217 * @return void
1218 */
1219 public function clear_preview() {
1220 $this->showHiddenPage = FALSE;
1221 $this->showHiddenRecords = FALSE;
1222 $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
1223 $GLOBALS['SIM_ACCESS_TIME'] = $GLOBALS['ACCESS_TIME'];
1224 $this->fePreview = 0;
1225 }
1226
1227 /**
1228 * Checks if a backend user is logged in
1229 *
1230 * @return boolean whether a backend user is logged in
1231 */
1232 public function isBackendUserLoggedIn() {
1233 return (bool)$this->beUserLogin;
1234 }
1235
1236 /**
1237 * Creates the backend user object and returns it.
1238 *
1239 * @return \TYPO3\CMS\Backend\FrontendBackendUserAuthentication the backend user object
1240 */
1241 public function initializeBackendUser() {
1242 // PRE BE_USER HOOK
1243 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'])) {
1244 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preBeUser'] as $_funcRef) {
1245 $_params = array();
1246 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1247 }
1248 }
1249 /** @var $BE_USER \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */
1250 $BE_USER = NULL;
1251 // If the backend cookie is set,
1252 // we proceed and check if a backend user is logged in.
1253 if ($_COOKIE[\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName()]) {
1254 $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = microtime(TRUE);
1255 $GLOBALS['TT']->push('Back End user initialized', '');
1256 // TODO: validate the comment below: is this necessary? if so,
1257 // formfield_status should be set to "" in \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
1258 // which is a subclass of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
1259 // ----
1260 // the value this->formfield_status is set to empty in order to
1261 // disable login-attempts to the backend account through this script
1262 // New backend user object
1263 $BE_USER = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\FrontendBackendUserAuthentication');
1264 $BE_USER->OS = TYPO3_OS;
1265 $BE_USER->lockIP = $this->TYPO3_CONF_VARS['BE']['lockIP'];
1266 // Object is initialized
1267 $BE_USER->start();
1268 $BE_USER->unpack_uc('');
1269 if (!empty($BE_USER->user['uid'])) {
1270 $BE_USER->fetchGroupData();
1271 $this->beUserLogin = TRUE;
1272 }
1273 // Unset the user initialization.
1274 if (!$BE_USER->checkLockToIP() || !$BE_USER->checkBackendAccessSettingsFromInitPhp() || empty($BE_USER->user['uid'])) {
1275 $BE_USER = NULL;
1276 $this->beUserLogin = FALSE;
1277 $_SESSION['TYPO3-TT-start'] = FALSE;
1278 }
1279 $GLOBALS['TT']->pull();
1280 $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = microtime(TRUE);
1281 }
1282 // POST BE_USER HOOK
1283 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'])) {
1284 $_params = array(
1285 'BE_USER' => &$BE_USER
1286 );
1287 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['postBeUser'] as $_funcRef) {
1288 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1289 }
1290 }
1291 return $BE_USER;
1292 }
1293
1294 /**
1295 * Determines the id and evaluates any preview settings
1296 * Basically this function is about determining whether a backend user is logged in, if he has read access to the page and if he's previewing the page. That all determines which id to show and how to initialize the id.
1297 *
1298 * @return void
1299 */
1300 public function determineId() {
1301 // Call pre processing function for id determination
1302 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'])) {
1303 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'] as $functionReference) {
1304 $parameters = array('parentObject' => $this);
1305 GeneralUtility::callUserFunction($functionReference, $parameters, $this);
1306 }
1307 }
1308 // Getting ARG-v values if some
1309 $this->setIDfromArgV();
1310 // If there is a Backend login we are going to check for any preview settings:
1311 $GLOBALS['TT']->push('beUserLogin', '');
1312 $originalFrontendUser = NULL;
1313 if ($this->beUserLogin || $this->doWorkspacePreview()) {
1314 // Backend user preview features:
1315 if ($this->beUserLogin && $GLOBALS['BE_USER']->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView) {
1316 $this->fePreview = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview');
1317 // If admin panel preview is enabled...
1318 if ($this->fePreview) {
1319 if ($this->fe_user->user) {
1320 $originalFrontendUser = $this->fe_user->user;
1321 }
1322 $this->showHiddenPage = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'showHiddenPages');
1323 $this->showHiddenRecords = (bool)$GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'showHiddenRecords');
1324 // Simulate date
1325 $simTime = $GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'simulateDate');
1326 if ($simTime) {
1327 $GLOBALS['SIM_EXEC_TIME'] = $simTime;
1328 $GLOBALS['SIM_ACCESS_TIME'] = $simTime - $simTime % 60;
1329 }
1330 // simulate user
1331 $simUserGroup = $GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview', 'simulateUserGroup');
1332 $this->simUserGroup = $simUserGroup;
1333 if ($simUserGroup) {
1334 if ($this->fe_user->user) {
1335 $this->fe_user->user[$this->fe_user->usergroup_column] = $simUserGroup;
1336 } else {
1337 $this->fe_user->user = array(
1338 $this->fe_user->usergroup_column => $simUserGroup
1339 );
1340 }
1341 }
1342 if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
1343 $this->fePreview = 0;
1344 }
1345 }
1346 }
1347 if ($this->id) {
1348 if ($this->determineIdIsHiddenPage()) {
1349 // The preview flag is set only if the current page turns out to actually be hidden!
1350 $this->fePreview = 1;
1351 $this->showHiddenPage = TRUE;
1352 }
1353 // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions)
1354 if (!$this->fePreview && $this->whichWorkspace() === 0) {
1355 // Initialize the page-select functions to check rootline:
1356 $temp_sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
1357 $temp_sys_page->init($this->showHiddenPage);
1358 // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...:
1359 if (!count($temp_sys_page->getRootLine($this->id, $this->MP)) && $temp_sys_page->error_getRootLine_failPid == -1) {
1360 // Setting versioningPreview flag and try again:
1361 $temp_sys_page->versioningPreview = TRUE;
1362 if (count($temp_sys_page->getRootLine($this->id, $this->MP))) {
1363 // Finally, we got a root line (meaning that it WAS due to versioning preview of a page somewhere) and we set the fePreview flag which in itself will allow sys_page class to display previews of versionized records.
1364 $this->fePreview = 1;
1365 }
1366 }
1367 }
1368 }
1369 // The preview flag will be set if a backend user is in an offline workspace
1370 if (($GLOBALS['BE_USER']->user['workspace_preview'] || GeneralUtility::_GP('ADMCMD_view') || $this->doWorkspacePreview()) && ($this->whichWorkspace() === -1 || $this->whichWorkspace() > 0)) {
1371 // Will show special preview message.
1372 $this->fePreview = 2;
1373 }
1374 // If the front-end is showing a preview, caching MUST be disabled.
1375 if ($this->fePreview) {
1376 $this->disableCache();
1377 }
1378 }
1379 $GLOBALS['TT']->pull();
1380 // Now, get the id, validate access etc:
1381 $this->fetch_the_id();
1382 // Check if backend user has read access to this page. If not, recalculate the id.
1383 if ($this->beUserLogin && $this->fePreview) {
1384 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->page, 1)) {
1385 // Resetting
1386 $this->clear_preview();
1387 $this->fe_user->user = $originalFrontendUser;
1388 // Fetching the id again, now with the preview settings reset.
1389 $this->fetch_the_id();
1390 }
1391 }
1392 // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID.
1393 $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch();
1394 // Logins are not allowed:
1395 if (!$this->loginAllowedInBranch) {
1396 // Only if there is a login will we run this...
1397 if ($this->isUserOrGroupSet()) {
1398 if ($this->loginAllowedInBranch_mode == 'all') {
1399 // Clear out user and group:
1400 unset($this->fe_user->user);
1401 $this->gr_list = '0,-1';
1402 } else {
1403 $this->gr_list = '0,-2';
1404 }
1405 // Fetching the id again, now with the preview settings reset.
1406 $this->fetch_the_id();
1407 }
1408 }
1409 // Final cleaning.
1410 // Make sure it's an integer
1411 $this->id = ($this->contentPid = (int)$this->id);
1412 // Make sure it's an integer
1413 $this->type = (int)$this->type;
1414 // Call post processing function for id determination:
1415 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
1416 $_params = array('pObj' => &$this);
1417 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) {
1418 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1419 }
1420 }
1421 }
1422
1423 /**
1424 * Checks if the page is hidden in the active workspace.
1425 * If it is hidden, preview flags will be set.
1426 *
1427 * @return boolean
1428 */
1429 protected function determineIdIsHiddenPage() {
1430 $field = \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->id) ? 'uid' : 'alias';
1431 $pageSelectCondition = $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages');
1432 $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid,hidden,starttime,endtime', 'pages', $pageSelectCondition . ' AND pid>=0 AND deleted=0');
1433 $workspace = $this->whichWorkspace();
1434 if ($workspace !== 0 && $workspace !== FALSE) {
1435 // Fetch overlay of page if in workspace and check if it is hidden
1436 $pageSelectObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
1437 $pageSelectObject->versioningPreview = TRUE;
1438 $pageSelectObject->init(FALSE);
1439 $targetPage = $pageSelectObject->getWorkspaceVersionOfRecord($this->whichWorkspace(), 'pages', $page['uid']);
1440 $result = $targetPage === -1 || $targetPage === -2;
1441 } else {
1442 $result = is_array($page) && ($page['hidden'] || $page['starttime'] > $GLOBALS['SIM_EXEC_TIME'] || $page['endtime'] != 0 && $page['endtime'] <= $GLOBALS['SIM_EXEC_TIME']);
1443 }
1444 return $result;
1445 }
1446
1447 /**
1448 * Get The Page ID
1449 * This gets the id of the page, checks if the page is in the domain and if the page is accessible
1450 * Sets variables such as $this->sys_page, $this->loginUser, $this->gr_list, $this->id, $this->type, $this->domainStartPage
1451 *
1452 * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
1453 * @return void
1454 * @access private
1455 * @todo Define visibility
1456 */
1457 public function fetch_the_id() {
1458 $GLOBALS['TT']->push('fetch_the_id initialize/', '');
1459 // Initialize the page-select functions.
1460 $this->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
1461 $this->sys_page->versioningPreview = $this->fePreview === 2 || (int)$this->workspacePreview || (bool)GeneralUtility::_GP('ADMCMD_view');
1462 $this->sys_page->versioningWorkspaceId = $this->whichWorkspace();
1463 $this->sys_page->init($this->showHiddenPage);
1464 // Set the valid usergroups for FE
1465 $this->initUserGroups();
1466 // Sets sys_page where-clause
1467 $this->setSysPageWhereClause();
1468 // Splitting $this->id by a period (.).
1469 // First part is 'id' and second part (if exists) will overrule the &type param
1470 $idParts = explode('.', $this->id, 2);
1471 $this->id = $idParts[0];
1472 if (isset($idParts[1])) {
1473 $this->type = $idParts[1];
1474 }
1475
1476 // If $this->id is a string, it's an alias
1477 $this->checkAndSetAlias();
1478 // The id and type is set to the integer-value - just to be sure...
1479 $this->id = (int)$this->id;
1480 $this->type = (int)$this->type;
1481 $GLOBALS['TT']->pull();
1482 // We find the first page belonging to the current domain
1483 $GLOBALS['TT']->push('fetch_the_id domain/', '');
1484 // The page_id of the current domain
1485 $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);
1486 if (!$this->id) {
1487 if ($this->domainStartPage) {
1488 // If the id was not previously set, set it to the id of the domain.
1489 $this->id = $this->domainStartPage;
1490 } else {
1491 // Find the first 'visible' page in that domain
1492 $theFirstPage = $this->sys_page->getFirstWebPage($this->id);
1493 if ($theFirstPage) {
1494 $this->id = $theFirstPage['uid'];
1495 } else {
1496 $message = 'No pages are found on the rootlevel!';
1497 if ($this->checkPageUnavailableHandler()) {
1498 $this->pageUnavailableAndExit($message);
1499 } else {
1500 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1501 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1301648975);
1502 }
1503 }
1504 }
1505 }
1506 $GLOBALS['TT']->pull();
1507 $GLOBALS['TT']->push('fetch_the_id rootLine/', '');
1508 // We store the originally requested id
1509 $requestedId = $this->id;
1510 $this->getPageAndRootlineWithDomain($this->domainStartPage);
1511 $GLOBALS['TT']->pull();
1512 if ($this->pageNotFound && $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
1513 $pNotFoundMsg = array(
1514 1 => 'ID was not an accessible page',
1515 2 => 'Subsection was found and not accessible',
1516 3 => 'ID was outside the domain',
1517 4 => 'The requested page alias does not exist'
1518 );
1519 $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
1520 }
1521 if ($this->page['url_scheme'] > 0) {
1522 $newUrl = '';
1523 $requestUrlScheme = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
1524 if ((int)$this->page['url_scheme'] === HttpUtility::SCHEME_HTTP && $requestUrlScheme == 'https') {
1525 $newUrl = 'http://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 8);
1526 } elseif ((int)$this->page['url_scheme'] === HttpUtility::SCHEME_HTTPS && $requestUrlScheme == 'http') {
1527 $newUrl = 'https://' . substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 7);
1528 }
1529 if ($newUrl !== '') {
1530 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
1531 $headerCode = HttpUtility::HTTP_STATUS_303;
1532 } else {
1533 $headerCode = HttpUtility::HTTP_STATUS_301;
1534 }
1535 HttpUtility::redirect($newUrl, $headerCode);
1536 }
1537 }
1538 // Set no_cache if set
1539 if ($this->page['no_cache']) {
1540 $this->set_no_cache('no_cache is set in page properties');
1541 }
1542 // Init SYS_LASTCHANGED
1543 $this->register['SYS_LASTCHANGED'] = (int)$this->page['tstamp'];
1544 if ($this->register['SYS_LASTCHANGED'] < (int)$this->page['SYS_LASTCHANGED']) {
1545 $this->register['SYS_LASTCHANGED'] = (int)$this->page['SYS_LASTCHANGED'];
1546 }
1547 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'])) {
1548 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['fetchPageId-PostProcessing'] as $functionReference) {
1549 $parameters = array('parentObject' => $this);
1550 GeneralUtility::callUserFunction($functionReference, $parameters, $this);
1551 }
1552 }
1553 }
1554
1555 /**
1556 * Gets the page and rootline arrays based on the id, $this->id
1557 *
1558 * If the id does not correspond to a proper page, the 'previous' valid page in the rootline is found
1559 * If the page is a shortcut (doktype=4), the ->id is loaded with that id
1560 *
1561 * Whether or not the ->id is changed to the shortcut id or the previous id in rootline (eg if a page is hidden), the ->page-array and ->rootline is found and must also be valid.
1562 *
1563 * Sets or manipulates internal variables such as: $this->id, $this->page, $this->rootLine, $this->MP, $this->pageNotFound
1564 *
1565 * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
1566 * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
1567 * @return void
1568 * @access private
1569 * @todo Define visibility
1570 */
1571 public function getPageAndRootline() {
1572 $this->page = $this->sys_page->getPage($this->id);
1573 if (!count($this->page)) {
1574 // If no page, we try to find the page before in the rootLine.
1575 // Page is 'not found' in case the id itself was not an accessible page. code 1
1576 $this->pageNotFound = 1;
1577 $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
1578 if (count($this->rootLine)) {
1579 $c = count($this->rootLine) - 1;
1580 while ($c > 0) {
1581 // Add to page access failure history:
1582 $this->pageAccessFailureHistory['direct_access'][] = $this->rootLine[$c];
1583 // Decrease to next page in rootline and check the access to that, if OK, set as page record and ID value.
1584 $c--;
1585 $this->id = $this->rootLine[$c]['uid'];
1586 $this->page = $this->sys_page->getPage($this->id);
1587 if (count($this->page)) {
1588 break;
1589 }
1590 }
1591 }
1592 // If still no page...
1593 if (!count($this->page)) {
1594 $message = 'The requested page does not exist!';
1595 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
1596 $this->pageNotFoundAndExit($message);
1597 } else {
1598 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1599 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648780);
1600 }
1601 }
1602 }
1603 // Spacer is not accessible in frontend
1604 if ($this->page['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SPACER) {
1605 $message = 'The requested page does not exist!';
1606 if ($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling']) {
1607 $this->pageNotFoundAndExit($message);
1608 } else {
1609 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1610 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648781);
1611 }
1612 }
1613 // Is the ID a link to another page??
1614 if ($this->page['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
1615 // We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.
1616 $this->MP = '';
1617 // saving the page so that we can check later - when we know
1618 // about languages - whether we took the correct shortcut or
1619 // whether a translation of the page overwrites the shortcut
1620 // target and we need to follow the new target
1621 $this->originalShortcutPage = $this->page;
1622 $this->page = $this->getPageShortcut($this->page['shortcut'], $this->page['shortcut_mode'], $this->page['uid']);
1623 $this->id = $this->page['uid'];
1624 }
1625 // Gets the rootLine
1626 $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
1627 // If not rootline we're off...
1628 if (!count($this->rootLine)) {
1629 $ws = $this->whichWorkspace();
1630 if ($this->sys_page->error_getRootLine_failPid == -1 && $ws) {
1631 $this->sys_page->versioningPreview = TRUE;
1632 $this->versioningWorkspaceId = $ws;
1633 $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
1634 }
1635 if (!count($this->rootLine)) {
1636 $message = 'The requested page didn\'t have a proper connection to the tree-root!';
1637 if ($this->checkPageUnavailableHandler()) {
1638 $this->pageUnavailableAndExit($message);
1639 } else {
1640 $rootline = '(' . $this->sys_page->error_getRootLine . ')';
1641 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1642 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message . '<br /><br />' . $rootline, 1301648167);
1643 }
1644 }
1645 $this->fePreview = 1;
1646 }
1647 // Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
1648 if ($this->checkRootlineForIncludeSection()) {
1649 if (!count($this->rootLine)) {
1650 $message = 'The requested page was not accessible!';
1651 if ($this->checkPageUnavailableHandler()) {
1652 $this->pageUnavailableAndExit($message);
1653 } else {
1654 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1655 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1301648234);
1656 }
1657 } else {
1658 $el = reset($this->rootLine);
1659 $this->id = $el['uid'];
1660 $this->page = $this->sys_page->getPage($this->id);
1661 $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
1662 }
1663 }
1664 }
1665
1666 /**
1667 * Get page shortcut; Finds the records pointed to by input value $SC (the shortcut value)
1668 *
1669 * @param integer $SC The value of the "shortcut" field from the pages record
1670 * @param integer $mode The shortcut mode: 1 will select first subpage, 2 a random subpage, 3 the parent page; default is the page pointed to by $SC
1671 * @param integer $thisUid The current page UID of the page which is a shortcut
1672 * @param integer $itera Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
1673 * @param array $pageLog An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
1674 * @param bool $disableGroupCheck If true, the group check is disabled when fetching the target page (needed e.g. for menu generation)
1675 * @throws \RuntimeException
1676 * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
1677 * @return mixed Returns the page record of the page that the shortcut pointed to.
1678 * @access private
1679 * @see getPageAndRootline()
1680 * @todo Define visibility
1681 */
1682 public function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = array(), $disableGroupCheck = FALSE) {
1683 $idArray = GeneralUtility::intExplode(',', $SC);
1684 // Find $page record depending on shortcut mode:
1685 switch ($mode) {
1686 case \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE:
1687
1688 case \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE:
1689 $pageArray = $this->sys_page->getMenu($idArray[0] ? $idArray[0] : $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_BE_USER_SECTION);
1690 $pO = 0;
1691 if ($mode == \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE && count($pageArray)) {
1692 $randval = (int)rand(0, count($pageArray) - 1);
1693 $pO = $randval;
1694 }
1695 $c = 0;
1696 foreach ($pageArray as $pV) {
1697 if ($c == $pO) {
1698 $page = $pV;
1699 break;
1700 }
1701 $c++;
1702 }
1703 if (count($page) == 0) {
1704 $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a subpage. ' . 'However, this page has no accessible subpages.';
1705 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648328);
1706 }
1707 break;
1708 case \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_PARENT_PAGE:
1709 $parent = $this->sys_page->getPage($thisUid, $disableGroupCheck);
1710 $page = $this->sys_page->getPage($parent['pid'], $disableGroupCheck);
1711 if (count($page) == 0) {
1712 $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to its parent page. ' . 'However, the parent page is not accessible.';
1713 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648358);
1714 }
1715 break;
1716 default:
1717 $page = $this->sys_page->getPage($idArray[0], $disableGroupCheck);
1718 if (count($page) == 0) {
1719 $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a page, which is not accessible (ID ' . $idArray[0] . ').';
1720 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648404);
1721 }
1722 }
1723 // Check if short cut page was a shortcut itself, if so look up recursively:
1724 if ($page['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
1725 if (!in_array($page['uid'], $pageLog) && $itera > 0) {
1726 $pageLog[] = $page['uid'];
1727 $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog, $disableGroupCheck);
1728 } else {
1729 $pageLog[] = $page['uid'];
1730 $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!';
1731 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
1732 throw new \RuntimeException($message, 1294587212);
1733 }
1734 }
1735 // Return resulting page:
1736 return $page;
1737 }
1738
1739 /**
1740 * Checks the current rootline for defined sections.
1741 *
1742 * @return boolean
1743 * @access private
1744 * @todo Define visibility
1745 */
1746 public function checkRootlineForIncludeSection() {
1747 $c = count($this->rootLine);
1748 $removeTheRestFlag = 0;
1749 for ($a = 0; $a < $c; $a++) {
1750 if (!$this->checkPagerecordForIncludeSection($this->rootLine[$a])) {
1751 // Add to page access failure history:
1752 $this->pageAccessFailureHistory['sub_section'][] = $this->rootLine[$a];
1753 $removeTheRestFlag = 1;
1754 }
1755 if ($this->rootLine[$a]['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_BE_USER_SECTION) {
1756 // If there is a backend user logged in, check if he has read access to the page:
1757 if ($this->beUserLogin) {
1758 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid=' . (int)$this->id . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
1759 // versionOL()?
1760 list($isPage) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1761 if (!$isPage) {
1762 // If there was no page selected, the user apparently did not have read access to the current PAGE (not position in rootline) and we set the remove-flag...
1763 $removeTheRestFlag = 1;
1764 }
1765 } else {
1766 // Dont go here, if there is no backend user logged in.
1767 $removeTheRestFlag = 1;
1768 }
1769 }
1770 if ($removeTheRestFlag) {
1771 // Page is 'not found' in case a subsection was found and not accessible, code 2
1772 $this->pageNotFound = 2;
1773 unset($this->rootLine[$a]);
1774 }
1775 }
1776 return $removeTheRestFlag;
1777 }
1778
1779 /**
1780 * Checks page record for enableFields
1781 * Returns TRUE if enableFields does not disable the page record.
1782 * Takes notice of the ->showHiddenPage flag and uses SIM_ACCESS_TIME for start/endtime evaluation
1783 *
1784 * @param array $row The page record to evaluate (needs fields: hidden, starttime, endtime, fe_group)
1785 * @param boolean $bypassGroupCheck Bypass group-check
1786 * @return boolean TRUE, if record is viewable.
1787 * @see TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer::getTreeList(), checkPagerecordForIncludeSection()
1788 * @todo Define visibility
1789 */
1790 public function checkEnableFields($row, $bypassGroupCheck = FALSE) {
1791 if (isset($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields']) && is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'])) {
1792 $_params = array('pObj' => $this, 'row' => &$row, 'bypassGroupCheck' => &$bypassGroupCheck);
1793 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'] as $_funcRef) {
1794 // Call hooks: If one returns FALSE, method execution is aborted with result "This record is not available"
1795 $return = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1796 if ($return === FALSE) {
1797 return FALSE;
1798 }
1799 }
1800 }
1801 if ((!$row['hidden'] || $this->showHiddenPage) && $row['starttime'] <= $GLOBALS['SIM_ACCESS_TIME'] && ($row['endtime'] == 0 || $row['endtime'] > $GLOBALS['SIM_ACCESS_TIME']) && ($bypassGroupCheck || $this->checkPageGroupAccess($row))) {
1802 return TRUE;
1803 }
1804 }
1805
1806 /**
1807 * Check group access against a page record
1808 *
1809 * @param array $row The page record to evaluate (needs field: fe_group)
1810 * @param mixed $groupList List of group id's (comma list or array). Default is $this->gr_list
1811 * @return boolean TRUE, if group access is granted.
1812 * @access private
1813 * @todo Define visibility
1814 */
1815 public function checkPageGroupAccess($row, $groupList = NULL) {
1816 if (is_null($groupList)) {
1817 $groupList = $this->gr_list;
1818 }
1819 if (!is_array($groupList)) {
1820 $groupList = explode(',', $groupList);
1821 }
1822 $pageGroupList = explode(',', $row['fe_group'] ?: 0);
1823 return count(array_intersect($groupList, $pageGroupList)) > 0;
1824 }
1825
1826 /**
1827 * Checks page record for include section
1828 *
1829 * @param array $row The page record to evaluate (needs fields: extendToSubpages + hidden, starttime, endtime, fe_group)
1830 * @return boolean Returns TRUE if either extendToSubpages is not checked or if the enableFields does not disable the page record.
1831 * @access private
1832 * @see checkEnableFields(), TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer::getTreeList(), checkRootlineForIncludeSection()
1833 * @todo Define visibility
1834 */
1835 public function checkPagerecordForIncludeSection($row) {
1836 return !$row['extendToSubpages'] || $this->checkEnableFields($row) ? 1 : 0;
1837 }
1838
1839 /**
1840 * Checks if logins are allowed in the current branch of the page tree. Traverses the full root line and returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
1841 *
1842 * @return boolean returns TRUE if logins are OK, otherwise FALSE (and then the login user must be unset!)
1843 * @todo Define visibility
1844 */
1845 public function checkIfLoginAllowedInBranch() {
1846 // Initialize:
1847 $c = count($this->rootLine);
1848 $disable = FALSE;
1849 // Traverse root line from root and outwards:
1850 for ($a = 0; $a < $c; $a++) {
1851 // If a value is set for login state:
1852 if ($this->rootLine[$a]['fe_login_mode'] > 0) {
1853 // Determine state from value:
1854 if ((int)$this->rootLine[$a]['fe_login_mode'] === 1) {
1855 $disable = TRUE;
1856 $this->loginAllowedInBranch_mode = 'all';
1857 } elseif ((int)$this->rootLine[$a]['fe_login_mode'] === 3) {
1858 $disable = TRUE;
1859 $this->loginAllowedInBranch_mode = 'groups';
1860 } else {
1861 $disable = FALSE;
1862 }
1863 }
1864 }
1865 return !$disable;
1866 }
1867
1868 /**
1869 * Analysing $this->pageAccessFailureHistory into a summary array telling which features disabled display and on which pages and conditions. That data can be used inside a page-not-found handler
1870 *
1871 * @return array Summary of why page access was not allowed.
1872 * @todo Define visibility
1873 */
1874 public function getPageAccessFailureReasons() {
1875 $output = array();
1876 $combinedRecords = array_merge(is_array($this->pageAccessFailureHistory['direct_access']) ? $this->pageAccessFailureHistory['direct_access'] : array(array('fe_group' => 0)), is_array($this->pageAccessFailureHistory['sub_section']) ? $this->pageAccessFailureHistory['sub_section'] : array());
1877 if (count($combinedRecords)) {
1878 foreach ($combinedRecords as $k => $pagerec) {
1879 // If $k=0 then it is the very first page the original ID was pointing at and that will get a full check of course
1880 // If $k>0 it is parent pages being tested. They are only significant for the access to the first page IF they had the extendToSubpages flag set, hence checked only then!
1881 if (!$k || $pagerec['extendToSubpages']) {
1882 if ($pagerec['hidden']) {
1883 $output['hidden'][$pagerec['uid']] = TRUE;
1884 }
1885 if ($pagerec['starttime'] > $GLOBALS['SIM_ACCESS_TIME']) {
1886 $output['starttime'][$pagerec['uid']] = $pagerec['starttime'];
1887 }
1888 if ($pagerec['endtime'] != 0 && $pagerec['endtime'] <= $GLOBALS['SIM_ACCESS_TIME']) {
1889 $output['endtime'][$pagerec['uid']] = $pagerec['endtime'];
1890 }
1891 if (!$this->checkPageGroupAccess($pagerec)) {
1892 $output['fe_group'][$pagerec['uid']] = $pagerec['fe_group'];
1893 }
1894 }
1895 }
1896 }
1897 return $output;
1898 }
1899
1900 /**
1901 * This checks if there are ARGV-parameters in the QUERY_STRING and if so, those are used for the id
1902 * $this->id must be 'FALSE' in order for any processing to happen in here
1903 * If an id/alias value is extracted from the QUERY_STRING it is set in $this->id
1904 *
1905 * @return void
1906 * @access private
1907 * @todo Define visibility
1908 */
1909 public function setIDfromArgV() {
1910 if (!$this->id) {
1911 list($theAlias) = explode('&', GeneralUtility::getIndpEnv('QUERY_STRING'));
1912 $theAlias = trim($theAlias);
1913 $this->id = $theAlias != '' && strpos($theAlias, '=') === FALSE ? $theAlias : 0;
1914 }
1915 }
1916
1917 /**
1918 * Gets ->page and ->rootline information based on ->id. ->id may change during this operation.
1919 * If not inside domain, then default to first page in domain.
1920 *
1921 * @param integer $domainStartPage Page uid of the page where the found domain record is (pid of the domain record)
1922 * @return void
1923 * @access private
1924 * @todo Define visibility
1925 */
1926 public function getPageAndRootlineWithDomain($domainStartPage) {
1927 $this->getPageAndRootline();
1928 // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
1929 if ($domainStartPage && is_array($this->rootLine)) {
1930 $idFound = 0;
1931 foreach ($this->rootLine as $key => $val) {
1932 if ($val['uid'] == $domainStartPage) {
1933 $idFound = 1;
1934 break;
1935 }
1936 }
1937 if (!$idFound) {
1938 // Page is 'not found' in case the id was outside the domain, code 3
1939 $this->pageNotFound = 3;
1940 $this->id = $domainStartPage;
1941 // re-get the page and rootline if the id was not found.
1942 $this->getPageAndRootline();
1943 }
1944 }
1945 }
1946
1947 /**
1948 * Sets sys_page where-clause
1949 *
1950 * @return void
1951 * @access private
1952 * @todo Define visibility
1953 */
1954 public function setSysPageWhereClause() {
1955 $this->sys_page->where_hid_del .= ' AND pages.doktype<200';
1956 $this->sys_page->where_groupAccess = $this->sys_page->getMultipleGroupsWhereClause('pages.fe_group', 'pages');
1957 }
1958
1959 /**
1960 * Looking up a domain record based on HTTP_HOST
1961 *
1962 * @param boolean $recursive If set, it looks "recursively" meaning that a domain like "123.456.typo3.com" would find a domain record like "typo3.com" if "123.456.typo3.com" or "456.typo3.com" did not exist.
1963 * @return integer Returns the page id of the page where the domain record was found.
1964 * @access private
1965 * @todo Define visibility
1966 */
1967 public function findDomainRecord($recursive = FALSE) {
1968 if ($recursive) {
1969 $host = explode('.', GeneralUtility::getIndpEnv('HTTP_HOST'));
1970 while (count($host)) {
1971 $pageUid = $this->sys_page->getDomainStartPage(implode('.', $host), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
1972 if ($pageUid) {
1973 return $pageUid;
1974 } else {
1975 array_shift($host);
1976 }
1977 }
1978 return $pageUid;
1979 } else {
1980 return $this->sys_page->getDomainStartPage(GeneralUtility::getIndpEnv('HTTP_HOST'), GeneralUtility::getIndpEnv('SCRIPT_NAME'), GeneralUtility::getIndpEnv('REQUEST_URI'));
1981 }
1982 }
1983
1984 /**
1985 * Page unavailable handler for use in frontend plugins from extensions.
1986 *
1987 * @param string $reason Reason text
1988 * @param string $header HTTP header to send
1989 * @return void Function exits.
1990 */
1991 public function pageUnavailableAndExit($reason = '', $header = '') {
1992 $header = $header ?: $this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling_statheader'];
1993 $this->pageUnavailableHandler($this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling'], $header, $reason);
1994 die;
1995 }
1996
1997 /**
1998 * Page-not-found handler for use in frontend plugins from extensions.
1999 *
2000 * @param string $reason Reason text
2001 * @param string $header HTTP header to send
2002 * @return void Function exits.
2003 * @todo Define visibility
2004 */
2005 public function pageNotFoundAndExit($reason = '', $header = '') {
2006 $header = $header ?: $this->TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'];
2007 $this->pageNotFoundHandler($this->TYPO3_CONF_VARS['FE']['pageNotFound_handling'], $header, $reason);
2008 die;
2009 }
2010
2011 /**
2012 * Checks whether the pageUnavailableHandler should be used. To be used, pageUnavailable_handling must be set
2013 * and devIPMask must not match the current visitor's IP address.
2014 *
2015 * @return boolean TRUE/FALSE whether the pageUnavailable_handler should be used.
2016 * @todo Define visibility
2017 */
2018 public function checkPageUnavailableHandler() {
2019 if (
2020 $this->TYPO3_CONF_VARS['FE']['pageUnavailable_handling']
2021 && !GeneralUtility::cmpIP(
2022 GeneralUtility::getIndpEnv('REMOTE_ADDR'),
2023 $this->TYPO3_CONF_VARS['SYS']['devIPmask']
2024 )
2025 ) {
2026 $checkPageUnavailableHandler = TRUE;
2027 } else {
2028 $checkPageUnavailableHandler = FALSE;
2029 }
2030 return $checkPageUnavailableHandler;
2031 }
2032
2033 /**
2034 * Page unavailable handler. Acts a wrapper for the pageErrorHandler method.
2035 *
2036 * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
2037 * @param string $header If set, this is passed directly to the PHP function, header()
2038 * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
2039 * @return void (The function exits!)
2040 * @todo Define visibility
2041 */
2042 public function pageUnavailableHandler($code, $header, $reason) {
2043 $this->pageErrorHandler($code, $header, $reason);
2044 }
2045
2046 /**
2047 * Page not found handler. Acts a wrapper for the pageErrorHandler method.
2048 *
2049 * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
2050 * @param string $header If set, this is passed directly to the PHP function, header()
2051 * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
2052 * @return void (The function exits!)
2053 * @todo Define visibility
2054 */
2055 public function pageNotFoundHandler($code, $header = '', $reason = '') {
2056 $this->pageErrorHandler($code, $header, $reason);
2057 }
2058
2059 /**
2060 * Generic error page handler.
2061 * Exits.
2062 *
2063 * @param mixed $code Which type of handling; If a true PHP-boolean or TRUE then a \TYPO3\CMS\Core\Messaging\ErrorpageMessage is outputted. If integer an error message with that number is shown. Otherwise the $code value is expected to be a "Location:" header value.
2064 * @param string $header If set, this is passed directly to the PHP function, header()
2065 * @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
2066 * @throws \RuntimeException
2067 * @return void (The function exits!)
2068 * @todo Define visibility
2069 */
2070 public function pageErrorHandler($code, $header = '', $reason = '') {
2071 // Issue header in any case:
2072 if ($header) {
2073 $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
2074 foreach ($headerArr as $header) {
2075 header($header);
2076 }
2077 }
2078 // Create response:
2079 // Simply boolean; Just shows TYPO3 error page with reason:
2080 if (gettype($code) == 'boolean' || (string)$code === '1') {
2081 $title = 'Page Not Found';
2082 $message = 'The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . htmlspecialchars($reason) : '');
2083 $messagePage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage', $message, $title);
2084 $messagePage->output();
2085 die;
2086 } elseif (GeneralUtility::isFirstPartOfStr($code, 'USER_FUNCTION:')) {
2087 $funcRef = trim(substr($code, 14));
2088 $params = array(
2089 'currentUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
2090 'reasonText' => $reason,
2091 'pageAccessFailureReasons' => $this->getPageAccessFailureReasons()
2092 );
2093 echo GeneralUtility::callUserFunction($funcRef, $params, $this);
2094 } elseif (GeneralUtility::isFirstPartOfStr($code, 'READFILE:')) {
2095 $readFile = GeneralUtility::getFileAbsFileName(trim(substr($code, 9)));
2096 if (@is_file($readFile)) {
2097 echo str_replace(
2098 array(
2099 '###CURRENT_URL###',
2100 '###REASON###'
2101 ),
2102 array(
2103 GeneralUtility::getIndpEnv('REQUEST_URI'),
2104 htmlspecialchars($reason)
2105 ),
2106 GeneralUtility::getUrl($readFile)
2107 );
2108 } else {
2109 throw new \RuntimeException('Configuration Error: 404 page "' . $readFile . '" could not be found.', 1294587214);
2110 }
2111 } elseif (GeneralUtility::isFirstPartOfStr($code, 'REDIRECT:')) {
2112 HttpUtility::redirect(substr($code, 9));
2113 } elseif (strlen($code)) {
2114 // Check if URL is relative
2115 $url_parts = parse_url($code);
2116 if ($url_parts['host'] == '') {
2117 $url_parts['host'] = GeneralUtility::getIndpEnv('HTTP_HOST');
2118 if ($code[0] === '/') {
2119 $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . $code;
2120 } else {
2121 $code = GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . $code;
2122 }
2123 $checkBaseTag = FALSE;
2124 } else {
2125 $checkBaseTag = TRUE;
2126 }
2127 // Check recursion
2128 if ($code == GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) {
2129 if ($reason == '') {
2130 $reason = 'Page cannot be found.';
2131 }
2132 $reason .= LF . LF . 'Additionally, ' . $code . ' was not found while trying to retrieve the error document.';
2133 throw new \RuntimeException(nl2br(htmlspecialchars($reason)), 1294587215);
2134 }
2135 // Prepare headers
2136 $headerArr = array(
2137 'User-agent: ' . GeneralUtility::getIndpEnv('HTTP_USER_AGENT'),
2138 'Referer: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')
2139 );
2140 $res = GeneralUtility::getUrl($code, 1, $headerArr);
2141 // Header and content are separated by an empty line
2142 list($header, $content) = explode(CRLF . CRLF, $res, 2);
2143 $content .= CRLF;
2144 if (FALSE === $res) {
2145 // Last chance -- redirect
2146 HttpUtility::redirect($code);
2147 } else {
2148 // Forward these response headers to the client
2149 $forwardHeaders = array(
2150 'Content-Type:'
2151 );
2152 $headerArr = preg_split('/\\r|\\n/', $header, -1, PREG_SPLIT_NO_EMPTY);
2153 foreach ($headerArr as $header) {
2154 foreach ($forwardHeaders as $h) {
2155 if (preg_match('/^' . $h . '/', $header)) {
2156 header($header);
2157 }
2158 }
2159 }
2160 // Put <base> if necesary
2161 if ($checkBaseTag) {
2162 // If content already has <base> tag, we do not need to do anything
2163 if (FALSE === stristr($content, '<base ')) {
2164 // Generate href for base tag
2165 $base = $url_parts['scheme'] . '://';
2166 if ($url_parts['user'] != '') {
2167 $base .= $url_parts['user'];
2168 if ($url_parts['pass'] != '') {
2169 $base .= ':' . $url_parts['pass'];
2170 }
2171 $base .= '@';
2172 }
2173 $base .= $url_parts['host'];
2174 // Add path portion skipping possible file name
2175 $base .= preg_replace('/(.*\\/)[^\\/]*/', '${1}', $url_parts['path']);
2176 // Put it into content (generate also <head> if necessary)
2177 $replacement = LF . '<base href="' . htmlentities($base) . '" />' . LF;
2178 if (stristr($content, '<head>')) {
2179 $content = preg_replace('/(<head>)/i', '\\1' . $replacement, $content);
2180 } else {
2181 $content = preg_replace('/(<html[^>]*>)/i', '\\1<head>' . $replacement . '</head>', $content);
2182 }
2183 }
2184 }
2185 // Output the content
2186 echo $content;
2187 }
2188 } else {
2189 $title = 'Page Not Found';
2190 $message = $reason ? 'Reason: ' . htmlspecialchars($reason) : 'Page cannot be found.';
2191 $messagePage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage', $message, $title);
2192 $messagePage->output();
2193 }
2194 die;
2195 }
2196
2197 /**
2198 * Fetches the integer page id for a page alias.
2199 * Looks if ->id is not an integer and if so it will search for a page alias and if found the page uid of that page is stored in $this->id
2200 *
2201 * @return void
2202 * @access private
2203 * @todo Define visibility
2204 */
2205 public function checkAndSetAlias() {
2206 if ($this->id && !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->id)) {
2207 $aid = $this->sys_page->getPageIdFromAlias($this->id);
2208 if ($aid) {
2209 $this->id = $aid;
2210 } else {
2211 $this->pageNotFound = 4;
2212 }
2213 }
2214 }
2215
2216 /**
2217 * Merging values into the global $_GET
2218 *
2219 * @param array $GET_VARS Array of key/value pairs that will be merged into the current GET-vars. (Non-escaped values)
2220 * @return void
2221 * @todo Define visibility
2222 */
2223 public function mergingWithGetVars($GET_VARS) {
2224 if (is_array($GET_VARS)) {
2225 // Getting $_GET var, unescaped.
2226 $realGet = GeneralUtility::_GET();
2227 if (!is_array($realGet)) {
2228 $realGet = array();
2229 }
2230 // Merge new values on top:
2231 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($realGet, $GET_VARS);
2232 // Write values back to $_GET:
2233 GeneralUtility::_GETset($realGet);
2234 // Setting these specifically (like in the init-function):
2235 if (isset($GET_VARS['type'])) {
2236 $this->type = (int)$GET_VARS['type'];
2237 }
2238 if (isset($GET_VARS['cHash'])) {
2239 $this->cHash = $GET_VARS['cHash'];
2240 }
2241 if (isset($GET_VARS['jumpurl'])) {
2242 $this->jumpurl = $GET_VARS['jumpurl'];
2243 }
2244 if (isset($GET_VARS['MP'])) {
2245 $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $GET_VARS['MP'] : '';
2246 }
2247 if (isset($GET_VARS['no_cache']) && $GET_VARS['no_cache']) {
2248 $this->set_no_cache('no_cache is requested via GET parameter');
2249 }
2250 }
2251 }
2252
2253 /********************************************
2254 *
2255 * Template and caching related functions.
2256 *
2257 *******************************************/
2258 /**
2259 * Calculates a hash string based on additional parameters in the url.
2260 *
2261 * Calculated hash is stored in $this->cHash_array.
2262 * This is used to cache pages with more parameters than just id and type.
2263 *
2264 * @return void
2265 * @see reqCHash()
2266 */
2267 public function makeCacheHash() {
2268 // No need to test anything if caching was already disabled.
2269 if ($this->no_cache && !$this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
2270 return;
2271 }
2272 $GET = GeneralUtility::_GET();
2273 if ($this->cHash && is_array($GET)) {
2274 $this->cHash_array = $this->cacheHash->getRelevantParameters(GeneralUtility::implodeArrayForUrl('', $GET));
2275 $cHash_calc = $this->cacheHash->calculateCacheHash($this->cHash_array);
2276 if ($cHash_calc != $this->cHash) {
2277 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
2278 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)');
2279 } else {
2280 $this->disableCache();
2281 $GLOBALS['TT']->setTSlogMessage('The incoming cHash "' . $this->cHash . '" and calculated cHash "' . $cHash_calc . '" did not match, so caching was disabled. The fieldlist used was "' . implode(',', array_keys($this->cHash_array)) . '"', 2);
2282 }
2283 }
2284 } elseif (is_array($GET)) {
2285 // No cHash is set, check if that is correct
2286 if ($this->cacheHash->doParametersRequireCacheHash(GeneralUtility::implodeArrayForUrl('', $GET))) {
2287 $this->reqCHash();
2288 }
2289 }
2290 }
2291
2292 /**
2293 * Will disable caching if the cHash value was not set.
2294 * This function should be called to check the _existence_ of "&cHash" whenever a plugin generating cachable output is using extra GET variables. If there _is_ a cHash value the validation of it automatically takes place in makeCacheHash() (see above)
2295 *
2296 * @return void
2297 * @see makeCacheHash(), \TYPO3\CMS\Frontend\Plugin\AbstractPlugin::pi_cHashCheck()
2298 * @todo Define visibility
2299 */
2300 public function reqCHash() {
2301 if (!$this->cHash) {
2302 if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
2303 if ($this->tempContent) {
2304 $this->clearPageCacheContent();
2305 }
2306 $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash empty)');
2307 } else {
2308 $this->disableCache();
2309 $GLOBALS['TT']->setTSlogMessage('TSFE->reqCHash(): No &cHash parameter was sent for GET vars though required so caching is disabled', 2);
2310 }
2311 }
2312 }
2313
2314 /**
2315 * Initialize the TypoScript template parser
2316 *
2317 * @return void
2318 */
2319 public function initTemplate() {
2320 $this->tmpl = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
2321 $this->tmpl->init();
2322 $this->tmpl->tt_track = (bool)$this->beUserLogin;
2323 }
2324
2325 /**
2326 * See if page is in cache and get it if so
2327 * Stores the page content in $this->content if something is found.
2328 *
2329 * @return void
2330 */
2331 public function getFromCache() {
2332 if (!$this->no_cache) {
2333 $cc = $this->tmpl->getCurrentPageData();
2334 if (!is_array($cc)) {
2335 $key = $this->id . '::' . $this->MP;
2336 // Returns TRUE if the lock is active now
2337 $isLocked = $this->acquirePageGenerationLock($this->pagesection_lockObj, $key);
2338 if (!$isLocked) {
2339 // Lock is no longer active, the data in "cache_pagesection" is now ready
2340 $cc = $this->tmpl->getCurrentPageData();
2341 if (is_array($cc)) {
2342 // Release the lock
2343 $this->releasePageGenerationLock($this->pagesection_lockObj);
2344 }
2345 }
2346 }
2347 if (is_array($cc)) {
2348 // BE CAREFUL to change the content of the cc-array. This array is serialized and an md5-hash based on this is used for caching the page.
2349 // If this hash is not the same in here in this section and after page-generation, then the page will not be properly cached!
2350 // This array is an identification of the template. If $this->all is empty it's because the template-data is not cached, which it must be.
2351 $cc = $this->tmpl->matching($cc);
2352 ksort($cc);
2353 $this->all = $cc;
2354 }
2355 unset($cc);
2356 }
2357 // clearing the content-variable, which will hold the pagecontent
2358 $this->content = '';
2359 // Unsetting the lowlevel config
2360 unset($this->config);
2361 $this->cacheContentFlag = FALSE;
2362 // Look for page in cache only if caching is not disabled and if a shift-reload is not sent to the server.
2363 if (!$this->no_cache && !$this->headerNoCache()) {
2364 $lockHash = $this->getLockHash();
2365 if ($this->all) {
2366 $this->newHash = $this->getHash();
2367 $GLOBALS['TT']->push('Cache Row', '');
2368 $row = $this->getFromCache_queryRow();
2369 if (!is_array($row)) {
2370 $isLocked = $this->acquirePageGenerationLock($this->pages_lockObj, $lockHash);
2371 if (!$isLocked) {
2372 // Lock is no longer active, the data in "cache_pages" is now ready
2373 $row = $this->getFromCache_queryRow();
2374 if (is_array($row)) {
2375 // Release the lock
2376 $this->releasePageGenerationLock($this->pages_lockObj);
2377 }
2378 }
2379 }
2380 if (is_array($row)) {
2381 // Release this lock
2382 $this->releasePageGenerationLock($this->pages_lockObj);
2383 // Call hook when a page is retrieved from cache:
2384 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'])) {
2385 $_params = array('pObj' => &$this, 'cache_pages_row' => &$row);
2386 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] as $_funcRef) {
2387 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2388 }
2389 }
2390 // Fetches the lowlevel config stored with the cached data
2391 $this->config = $row['cache_data'];
2392 // Getting the content
2393 $this->content = $row['content'];
2394 // Flag for temp content
2395 $this->tempContent = $row['temp_content'];
2396 // Setting flag, so we know, that some cached content has been loaded
2397 $this->cacheContentFlag = TRUE;
2398 $this->cacheExpires = $row['expires'];
2399
2400 if (isset($this->config['config']['debug'])) {
2401 $debugCacheTime = (bool)$this->config['config']['debug'];
2402 } else {
2403 $debugCacheTime = !empty($this->TYPO3_CONF_VARS['FE']['debug']);
2404 }
2405 if ($debugCacheTime) {
2406 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
2407 $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
2408 $this->content .= LF . '<!-- Cached page generated ' . date(($dateFormat . ' ' . $timeFormat), $row['tstamp']) . '. Expires ' . Date(($dateFormat . ' ' . $timeFormat), $row['expires']) . ' -->';
2409 }
2410 }
2411 $GLOBALS['TT']->pull();
2412 } else {
2413 $this->acquirePageGenerationLock($this->pages_lockObj, $lockHash);
2414 }
2415 }
2416 }
2417
2418 /**
2419 * Returning the cached version of page with hash = newHash
2420 *
2421 * @return array Cached row, if any. Otherwise void.
2422 * @todo Define visibility
2423 */
2424 public function getFromCache_queryRow() {
2425 $GLOBALS['TT']->push('Cache Query', '');
2426 $row = $this->pageCache->get($this->newHash);
2427 $GLOBALS['TT']->pull();
2428 return $row;
2429 }
2430
2431 /**
2432 * Detecting if shift-reload has been clicked
2433 * Will not be called if re-generation of page happens by other reasons (for instance that the page is not in cache yet!)
2434 * Also, a backend user MUST be logged in for the shift-reload to be detected due to DoS-attack-security reasons.
2435 *
2436 * @return boolean If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it).
2437 * @todo Define visibility
2438 */
2439 public function headerNoCache() {
2440 $disableAcquireCacheData = FALSE;
2441 if ($this->beUserLogin) {
2442 if (strtolower($_SERVER['HTTP_CACHE_CONTROL']) === 'no-cache' || strtolower($_SERVER['HTTP_PRAGMA']) === 'no-cache') {
2443 $disableAcquireCacheData = TRUE;
2444 }
2445 }
2446 // Call hook for possible by-pass of requiring of page cache (for recaching purpose)
2447 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'])) {
2448 $_params = array('pObj' => &$this, 'disableAcquireCacheData' => &$disableAcquireCacheData);
2449 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'] as $_funcRef) {
2450 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2451 }
2452 }
2453 return $disableAcquireCacheData;
2454 }
2455
2456 /**
2457 * Calculates the cache-hash
2458 * This hash is unique to the template, the variables ->id, ->type, ->gr_list (list of groups), ->MP (Mount Points) and cHash array
2459 * Used to get and later store the cached data.
2460 *
2461 * @return string MD5 hash of serialized hash base from createHashBase()
2462 * @access private
2463 * @see getFromCache(), getLockHash()
2464 * @todo Define visibility
2465 */
2466 public function getHash() {
2467 return md5($this->createHashBase(FALSE));
2468 }
2469
2470 /**
2471 * Calculates the lock-hash
2472 * This hash is unique to the above hash, except that it doesn't contain the template information in $this->all.
2473 *
2474 * @return string MD5 hash
2475 * @access private
2476 * @see getFromCache(), getHash()
2477 * @todo Define visibility
2478 */
2479 public function getLockHash() {
2480 $lockHash = $this->createHashBase(TRUE);
2481 return md5($lockHash);
2482 }
2483
2484 /**
2485 * Calculates the cache-hash (or the lock-hash)
2486 * This hash is unique to the template,
2487 * the variables ->id, ->type, ->gr_list (list of groups),
2488 * ->MP (Mount Points) and cHash array
2489 * Used to get and later store the cached data.
2490 *
2491 * @param boolean $createLockHashBase Whether to create the lock hash, which doesn't contain the "this->all" (the template information)
2492 * @return string the serialized hash base
2493 */
2494 protected function createHashBase($createLockHashBase = FALSE) {
2495 $hashParameters = array(
2496 'id' => (int)$this->id,
2497 'type' => (int)$this->type,
2498 'gr_list' => (string) $this->gr_list,
2499 'MP' => (string) $this->MP,
2500 'cHash' => $this->cHash_array,
2501 'domainStartPage' => $this->domainStartPage
2502 );
2503 // Include the template information if we shouldn't create a lock hash
2504 if (!$createLockHashBase) {
2505 $hashParameters['all'] = $this->all;
2506 }
2507 // Call hook to influence the hash calculation
2508 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'])) {
2509 $_params = array(
2510 'hashParameters' => &$hashParameters,
2511 'createLockHashBase' => $createLockHashBase
2512 );
2513 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'] as $_funcRef) {
2514 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2515 }
2516 }
2517 return serialize($hashParameters);
2518 }
2519
2520 /**
2521 * Checks if config-array exists already but if not, gets it
2522 *
2523 * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
2524 * @return void
2525 */
2526 public function getConfigArray() {
2527 $setStatPageName = FALSE;
2528 // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
2529 if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
2530 $GLOBALS['TT']->push('Parse template', '');
2531 // Force parsing, if set?:
2532 $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
2533 // Start parsing the TS template. Might return cached version.
2534 $this->tmpl->start($this->rootLine);
2535 $GLOBALS['TT']->pull();
2536 if ($this->tmpl->loaded) {
2537 $GLOBALS['TT']->push('Setting the config-array', '');
2538 // toplevel - objArrayName
2539 $this->sPre = $this->tmpl->setup['types.'][$this->type];
2540 $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
2541 if (!is_array($this->pSetup)) {
2542 $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
2543 if ($this->checkPageUnavailableHandler()) {
2544 $this->pageUnavailableAndExit($message);
2545 } else {
2546 $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
2547 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
2548 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
2549 }
2550 } else {
2551 $this->config['config'] = array();
2552 // Filling the config-array, first with the main "config." part
2553 if (is_array($this->tmpl->setup['config.'])) {
2554 $this->config['config'] = $this->tmpl->setup['config.'];
2555 }
2556 // override it with the page/type-specific "config."
2557 if (is_array($this->pSetup['config.'])) {
2558 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
2559 }
2560 if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
2561 $this->config['config']['typolinkCheckRootline'] = TRUE;
2562 }
2563 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
2564 if (GeneralUtility::compat_version('4.0')) {
2565 if (!isset($this->config['config']['removeDefaultJS'])) {
2566 $this->config['config']['removeDefaultJS'] = 'external';
2567 }
2568 if (!isset($this->config['config']['inlineStyle2TempFile'])) {
2569 $this->config['config']['inlineStyle2TempFile'] = 1;
2570 }
2571 }
2572 if (!isset($this->config['config']['compressJs'])) {
2573 $this->config['config']['compressJs'] = 0;
2574 }
2575 // Processing for the config_array:
2576 $this->config['rootLine'] = $this->tmpl->rootLine;
2577 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ?: 'index.php';
2578 // Class for render Header and Footer parts
2579 $template = '';
2580 if ($this->pSetup['pageHeaderFooterTemplateFile']) {
2581 $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
2582 if ($file) {
2583 $this->getPageRenderer()->setTemplateFile($file);
2584 }
2585 }
2586 }
2587 $GLOBALS['TT']->pull();
2588 } else {
2589 if ($this->checkPageUnavailableHandler()) {
2590 $this->pageUnavailableAndExit('No TypoScript template found!');
2591 } else {
2592 $message = 'No TypoScript template found!';
2593 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
2594 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1294587218);
2595 }
2596 }
2597 }
2598
2599 // No cache
2600 // Set $this->no_cache TRUE if the config.no_cache value is set!
2601 if ($this->config['config']['no_cache']) {
2602 $this->set_no_cache('config.no_cache is set');
2603 }
2604 // Merge GET with defaultGetVars
2605 if (!empty($this->config['config']['defaultGetVars.'])) {
2606 $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
2607 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
2608 GeneralUtility::_GETset($modifiedGetVars);
2609 }
2610 // Hook for postProcessing the configuration array
2611 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
2612 $params = array('config' => &$this->config['config']);
2613 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
2614 GeneralUtility::callUserFunction($funcRef, $params, $this);
2615 }
2616 }
2617 }
2618
2619 /********************************************
2620 *
2621 * Further initialization and data processing
2622 * (jumpurl/submission of forms)
2623 *
2624 *******************************************/
2625
2626 /**
2627 * Get the compressed $GLOBALS['TCA'] array for use in the front-end
2628 * A compressed $GLOBALS['TCA'] array holds only the ctrl- and feInterface-part for each table.
2629 * But the column-definitions are omitted in order to save some memory and be more efficient.
2630 * Operates on the global variable, $TCA
2631 *
2632 * @return void
2633 * @deprecated since 6,1, will be removed in two versions.
2634 */
2635 public function getCompressedTCarray() {
2636 // Full TCA is always loaded during bootstrap in FE, this method is obsolete.
2637 GeneralUtility::logDeprecatedFunction();
2638 }
2639
2640 /**
2641 * Includes TCA definitions from loaded extensions (ext_tables.php files).
2642 * Normally in the frontend only a part of the global $TCA array is loaded,
2643 * namely the "ctrl" part. Thus it doesn't take up too much memory. To load
2644 * full TCA for the table, use GeneralUtility::loadTCA($tableName)
2645 * after calling this function.
2646 *
2647 * @param integer $TCAloaded Probably, keep hands of this value. Just don't set it.
2648 * @return void
2649 * @see getCompressedTCarray()
2650 * @deprecated since 6.1, will be removed in two versions. Obsolete in regular frontend, eid scripts should use \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA()
2651 */
2652 public function includeTCA($TCAloaded = 1) {
2653 // Full TCA is always loaded during bootstrap in FE, this method is obsolete.
2654 GeneralUtility::logDeprecatedFunction();
2655
2656 // Compatibility layer:
2657 // The if below is NOT true in usual frontend (non eid) context, TCA is loaded by bootstrap.
2658 // If an eid script calls this method to load TCA, use
2659 // \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA() instead.
2660 if (!isset($GLOBALS['TCA']['pages'])) {
2661 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadCachedTca();
2662 }
2663 }
2664
2665 /**
2666 * Setting the language key that will be used by the current page.
2667 * In this function it should be checked, 1) that this language exists, 2) that a page_overlay_record exists, .. and if not the default language, 0 (zero), should be set.
2668 *
2669 * @return void
2670 * @access private
2671 */
2672 public function settingLanguage() {
2673 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'])) {
2674 $_params = array();
2675 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_preProcess'] as $_funcRef) {
2676 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2677 }
2678 }
2679
2680 // Initialize charset settings etc.
2681 $this->initLLvars();
2682
2683 // Get values from TypoScript:
2684 $this->sys_language_uid = ($this->sys_language_content = (int)$this->config['config']['sys_language_uid']);
2685 list($this->sys_language_mode, $sys_language_content) = GeneralUtility::trimExplode(';', $this->config['config']['sys_language_mode']);
2686 $this->sys_language_contentOL = $this->config['config']['sys_language_overlay'];
2687 // If sys_language_uid is set to another language than default:
2688 if ($this->sys_language_uid > 0) {
2689 // check whether a shortcut is overwritten by a translated page
2690 // we can only do this now, as this is the place where we get
2691 // to know about translations
2692 $this->checkTranslatedShortcut();
2693 // Request the overlay record for the sys_language_uid:
2694 $olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid);
2695 if (!count($olRec)) {
2696 // If no OL record exists and a foreign language is asked for...
2697 if ($this->sys_language_uid) {
2698 // If requested translation is not available:
2699 if (GeneralUtility::hideIfNotTranslated($this->page['l18n_cfg'])) {
2700 $this->pageNotFoundAndExit('Page is not available in the requested language.');
2701 } else {
2702 switch ((string) $this->sys_language_mode) {
2703 case 'strict':
2704 $this->pageNotFoundAndExit('Page is not available in the requested language (strict).');
2705 break;
2706 case 'content_fallback':
2707 $fallBackOrder = GeneralUtility::intExplode(',', $sys_language_content);
2708 foreach ($fallBackOrder as $orderValue) {
2709 if ((string)$orderValue === '0' || count($this->sys_page->getPageOverlay($this->id, $orderValue))) {
2710 $this->sys_language_content = $orderValue;
2711 // Setting content uid (but leaving the sys_language_uid)
2712 break;
2713 }
2714 }
2715 break;
2716 case 'ignore':
2717 $this->sys_language_content = $this->sys_language_uid;
2718 break;
2719 default:
2720 // Default is that everything defaults to the default language...
2721 $this->sys_language_uid = ($this->sys_language_content = 0);
2722 }
2723 }
2724 }
2725 } else {
2726 // Setting sys_language if an overlay record was found (which it is only if a language is used)
2727 $this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid);
2728 }
2729 }
2730 // Setting sys_language_uid inside sys-page:
2731 $this->sys_page->sys_language_uid = $this->sys_language_uid;
2732 // If default translation is not available:
2733 if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg'] & 1) {
2734 $message = 'Page is not available in default language.';
2735 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
2736 $this->pageNotFoundAndExit($message);
2737 }
2738 $this->updateRootLinesWithTranslations();
2739 // Finding the ISO code:
2740 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables') && $this->sys_language_content) {
2741 // using sys_language_content because the ISO code only (currently) affect content selection from FlexForms - which should follow "sys_language_content"
2742 // Set the fourth parameter to TRUE in the next two getRawRecord() calls to
2743 // avoid versioning overlay to be applied as it generates an SQL error
2744 $sys_language_row = $this->sys_page->getRawRecord('sys_language', $this->sys_language_content, 'static_lang_isocode', TRUE);
2745 if (is_array($sys_language_row) && $sys_language_row['static_lang_isocode']) {
2746 $stLrow = $this->sys_page->getRawRecord('static_languages', $sys_language_row['static_lang_isocode'], 'lg_iso_2', TRUE);
2747 $this->sys_language_isocode = $stLrow['lg_iso_2'];
2748 }
2749 }
2750 // Setting softMergeIfNotBlank:
2751 $table_fields = GeneralUtility::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'], TRUE);
2752 foreach ($table_fields as $TF) {
2753 list($tN, $fN) = explode(':', $TF);
2754 $GLOBALS['TCA'][$tN]['columns'][$fN]['l10n_mode'] = 'mergeIfNotBlank';
2755 }
2756 // Setting softExclude:
2757 $table_fields = GeneralUtility::trimExplode(',', $this->config['config']['sys_language_softExclude'], TRUE);
2758 foreach ($table_fields as $TF) {
2759 list($tN, $fN) = explode(':', $TF);
2760 $GLOBALS['TCA'][$tN]['columns'][$fN]['l10n_mode'] = 'exclude';
2761 }
2762 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'])) {
2763 $_params = array();
2764 foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'] as $_funcRef) {
2765 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2766 }
2767 }
2768 }
2769
2770 /**
2771 * Updating content of the two rootLines IF the language key is set!
2772 */
2773 protected function updateRootLinesWithTranslations() {
2774 if ($this->sys_language_uid) {
2775 $this->rootLine = $this->sys_page->getRootLine($this->id, $this->MP);
2776 $this->tmpl->updateRootlineData($this->rootLine);
2777 }
2778 }
2779
2780 /**
2781 * Setting locale for frontend rendering
2782 *
2783 * @return void
2784 */
2785 public function settingLocale() {
2786 // Setting locale
2787 if ($this->config['config']['locale_all']) {
2788 // There's a problem that PHP parses float values in scripts wrong if the
2789 // locale LC_NUMERIC is set to something with a comma as decimal point
2790 // Do we set all except LC_NUMERIC
2791 $locale = setlocale(LC_COLLATE, $this->config['config']['locale_all']);
2792 if ($locale) {
2793 // PHP fatals with uppercase I characters in method names with turkish locale LC_CTYPE
2794 // @see http://bugs.php.net/bug.php?id=35050
2795 if (substr($this->config['config']['locale_all'], 0, 2) != 'tr') {
2796 setlocale(LC_CTYPE, $this->config['config']['locale_all']);
2797 }
2798 setlocale(LC_MONETARY, $this->config['config']['locale_all']);
2799 setlocale(LC_TIME, $this->config['config']['locale_all']);
2800 $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']);
2801 } else {
2802 $GLOBALS['TT']->setTSlogMessage('Locale "' . htmlspecialchars($this->config['config']['locale_all']) . '" not found.', 3);
2803 }
2804 }
2805 }
2806
2807 /**
2808 * Checks whether a translated shortcut page has a different shortcut
2809 * target than the original language page.
2810 * If that is the case, things get corrected to follow that alternative
2811 * shortcut
2812 *
2813 * @return void
2814 * @author Ingo Renner <ingo@typo3.org>
2815 */
2816 protected function checkTranslatedShortcut() {
2817 if (!is_null($this->originalShortcutPage)) {
2818 $originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $this->sys_language_uid);
2819 if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) {
2820 // the translation of the original shortcut page has a different shortcut target!
2821 // set the correct page and id
2822 $shortcut = $this->getPageShortcut($originalShortcutPageOverlay['shortcut'], $originalShortcutPageOverlay['shortcut_mode'], $originalShortcutPageOverlay['uid']);
2823 $this->id = ($this->contentPid = $shortcut['uid']);
2824 $this->page = $this->sys_page->getPage($this->id);
2825 // Fix various effects on things like menus f.e.
2826 $this->fetch_the_id();
2827 $this->tmpl->rootLine = array_reverse($this->rootLine);
2828 }
2829 }
2830 }
2831
2832 /**
2833 * Handle data submission
2834 *
2835 * @return void
2836 */
2837 public function handleDataSubmission() {
2838 // Check Submission of data.
2839 // This is done at this point, because we need the config values
2840 switch ($this->checkDataSubmission()) {
2841 case 'email':
2842 $this->sendFormmail();
2843 break;
2844 }
2845 }
2846
2847 /**
2848 * Checks if any email-submissions
2849 *
2850 * @return string "email" if a formmail has been sent, "" if none.
2851 */
2852 protected function checkDataSubmission() {
2853 $ret = '';
2854 $formtype_mail = isset($_POST['formtype_mail']) || isset($_POST['formtype_mail_x']);
2855 if ($formtype_mail) {
2856 $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
2857 if (GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') == $refInfo['host'] || $this->TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
2858 if ($this->locDataCheck($_POST['locationData'])) {
2859 if ($formtype_mail) {
2860 $ret = 'email';
2861 }
2862 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": Return value: ' . $ret, 0);
2863 return $ret;
2864 }
2865 } else {
2866 $GLOBALS['TT']->setTSlogMessage('"Check Data Submission": HTTP_HOST and REFERER HOST di