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