Added feature #15621: Feature: TYPO3 misses page-option to force SSL oder Non-SSL...
authorSteffen Kamper <info@sk-typo3.de>
Tue, 12 Oct 2010 21:17:18 +0000 (21:17 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Tue, 12 Oct 2010 21:17:18 +0000 (21:17 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9048 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/utility/class.t3lib_utility_http.php
typo3/sysext/cms/ext_tables.php
typo3/sysext/cms/ext_tables.sql
typo3/sysext/cms/locallang_tca.xml
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php

index f24949c..1439149 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 2010-10-12  Steffen Kamper  <steffen@typo3.org>
 
 
 2010-10-12  Steffen Kamper  <steffen@typo3.org>
 
+       * Added feature #15621: Feature: TYPO3 misses page-option to force SSL oder Non-SSL to page (Thanks to Steffen Ritter)
        * Update #15970: Update ExtJS to version 3.3.0
        * Follow-up to #15900: [Feature] Add SVG support for all browsers
 
        * Update #15970: Update ExtJS to version 3.3.0
        * Follow-up to #15900: [Feature] Add SVG support for all browsers
 
index 366519b..dc1133b 100644 (file)
@@ -78,6 +78,10 @@ class t3lib_utility_Http {
        const HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Timeout';
        const HTTP_STATUS_505 = 'HTTP/1.1 505 Version Not Supported';
 
        const HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Timeout';
        const HTTP_STATUS_505 = 'HTTP/1.1 505 Version Not Supported';
 
+               // URL Schemes
+       const SCHEME_HTTP = 1;
+       const SCHEME_HTTPS = 2;
+
        /**
         * Sends a redirect header response and exits. Additionaly the URL is
         * checked and if needed corrected to match the format required for a
        /**
         * Sends a redirect header response and exits. Additionaly the URL is
         * checked and if needed corrected to match the format required for a
index 5a67946..97faeba 100755 (executable)
@@ -143,6 +143,19 @@ if (TYPO3_MODE == 'BE') {
                                'default' => '0'
                        )
                ),
                                'default' => '0'
                        )
                ),
+               'url_scheme' => array (
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.url_scheme',
+                       'config' => array (
+                               'type' => 'select',
+                               'items' => array (
+                                       array('', 0),
+                                       array('LLL:EXT:cms/locallang_tca.xml:pages.url_scheme.http', 1),
+                                       array('LLL:EXT:cms/locallang_tca.xml:pages.url_scheme.https', 2)
+                               ),
+                               'default' => 0
+                       )
+               ),
                'fe_group' => array (
                        'exclude' => 1,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.fe_group',
                'fe_group' => array (
                        'exclude' => 1,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.fe_group',
@@ -583,7 +596,7 @@ if (TYPO3_MODE == 'BE') {
        $TCA['pages']['palettes'] = t3lib_div::array_merge($TCA['pages']['palettes'],array(
                '1' => array('showitem' => 'starttime, endtime, extendToSubpages'),
                '2' => array('showitem' => 'layout, lastUpdated, newUntil, no_search'),
        $TCA['pages']['palettes'] = t3lib_div::array_merge($TCA['pages']['palettes'],array(
                '1' => array('showitem' => 'starttime, endtime, extendToSubpages'),
                '2' => array('showitem' => 'layout, lastUpdated, newUntil, no_search'),
-               '3' => array('showitem' => 'alias, target, no_cache, cache_timeout'),
+               '3' => array('showitem' => 'alias, target, no_cache, cache_timeout, url_scheme'),
                '5' => array('showitem' => 'author, author_email', 'canNotCollapse' => 1)
        ));
 
                '5' => array('showitem' => 'author, author_email', 'canNotCollapse' => 1)
        ));
 
index 79230a1..36e58ff 100755 (executable)
@@ -452,6 +452,7 @@ CREATE TABLE pages (
   fe_group varchar(100) DEFAULT '0' NOT NULL,
   subtitle varchar(255) DEFAULT '' NOT NULL,
   layout tinyint(3) unsigned DEFAULT '0' NOT NULL,
   fe_group varchar(100) DEFAULT '0' NOT NULL,
   subtitle varchar(255) DEFAULT '' NOT NULL,
   layout tinyint(3) unsigned DEFAULT '0' NOT NULL,
+  url_scheme tinyint(3) unsigned DEFAULT '0' NOT NULL,
   target varchar(80) DEFAULT '' NOT NULL,
   media text,
   lastUpdated int(10) unsigned DEFAULT '0' NOT NULL,
   target varchar(80) DEFAULT '' NOT NULL,
   media text,
   lastUpdated int(10) unsigned DEFAULT '0' NOT NULL,
index 6d8f484..25941f0 100755 (executable)
@@ -22,6 +22,9 @@
                        <label index="pages.layout.I.1">Layout 1</label>
                        <label index="pages.layout.I.2">Layout 2</label>
                        <label index="pages.layout.I.3">Layout 3</label>
                        <label index="pages.layout.I.1">Layout 1</label>
                        <label index="pages.layout.I.2">Layout 2</label>
                        <label index="pages.layout.I.3">Layout 3</label>
+                       <label index="pages.url_scheme">URL Scheme:</label>
+                       <label index="pages.url_scheme.http">Force HTTP</label>
+                       <label index="pages.url_scheme.https">Force HTTPS</label>
                        <label index="pages.extendToSubpages">Include subpages:</label>
                        <label index="pages.nav_title">Navigation title:</label>
                        <label index="pages.nav_hide">Hide in menu:</label>
                        <label index="pages.extendToSubpages">Include subpages:</label>
                        <label index="pages.nav_title">Navigation title:</label>
                        <label index="pages.nav_hide">Hide in menu:</label>
index a0ec8e6..3116174 100644 (file)
@@ -6736,14 +6736,18 @@ class tslib_cObj {
 
                                                $absoluteUrlScheme = 'http';
                                                        // URL shall be absolute:
 
                                                $absoluteUrlScheme = 'http';
                                                        // URL shall be absolute:
-                                               if (isset($conf['forceAbsoluteUrl']) && $conf['forceAbsoluteUrl']) {
-                                                               // If no domain records are defined, use current domain:
-                                                       if ($targetDomain === '') {
-                                                               $targetDomain = $currentDomain;
-                                                       }
+                                               if (isset($conf['forceAbsoluteUrl']) && $conf['forceAbsoluteUrl'] || $page['url_scheme'] > 0) {
                                                                // Override scheme:
                                                        if (isset($conf['forceAbsoluteUrl.']['scheme']) && $conf['forceAbsoluteUrl.']['scheme']) {
                                                                $absoluteUrlScheme = $conf['forceAbsoluteUrl.']['scheme'];
                                                                // Override scheme:
                                                        if (isset($conf['forceAbsoluteUrl.']['scheme']) && $conf['forceAbsoluteUrl.']['scheme']) {
                                                                $absoluteUrlScheme = $conf['forceAbsoluteUrl.']['scheme'];
+                                                       } elseif ($page['url_scheme'] > 0) {
+                                                               $absoluteUrlScheme = ((int) $page['url_scheme'] === t3lib_utility_http::SCHEME_HTTP) ? 'http' : 'https';
+                                                       }
+
+                                                               // If no domain records are defined, use current domain:
+                                                       if ($targetDomain === '' && $conf['forceAbsoluteUrl'] ||
+                                                                       $absoluteUrlScheme !== parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME)) {
+                                                               $targetDomain = $currentDomain;
                                                        }
                                                }
 
                                                        }
                                                }
 
index 7540d78..c1d5eda 100644 (file)
                        $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
                }
 
                        $this->pageNotFoundAndExit($pNotFoundMsg[$this->pageNotFound]);
                }
 
+               if ($this->page['url_scheme'] > 0) {
+                       $newUrl = '';
+                       $requestUrlScheme = parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
+                       if ((int) $this->page['url_scheme'] === t3lib_utility_http::SCHEME_HTTP && $requestUrlScheme == 'https') {
+                               $newUrl = 'http://' . substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), 8);
+                       } elseif ((int) $this->page['url_scheme'] === t3lib_utility_http::SCHEME_HTTPS && $requestUrlScheme == 'http') {
+                               $newUrl = 'https://' . substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), 7);
+                       }
+                       if ($newUrl !== '') {
+                               if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+                                       $headerCode = t3lib_utility_Http::HTTP_STATUS_303;
+                               } else {
+                                       $headerCode = t3lib_utility_Http::HTTP_STATUS_301;
+                               }
+                               t3lib_utility_http::redirect($newUrl, $headerCode);
+                       }
+               }
                        // set no_cache if set
                if ($this->page['no_cache'])    {
                        $this->set_no_cache();
                        // set no_cache if set
                if ($this->page['no_cache'])    {
                        $this->set_no_cache();