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