Project

General

Profile

Feature #19361 ยป 20080919_introduce_redirect_status_codes.patch

Administrator Admin, 2008-09-21 08:14

View differences:

t3lib/class.t3lib_page.php (working copy)
* @return mixed If found, returns integer with page UID where found. Otherwise blank. Might exit if location-header is sent, see description.
* @see tslib_fe::findDomainRecord()
*/
function getDomainStartPage($domain, $path='',$request_uri='') {
$domain = explode(':',$domain);
$domain = strtolower(ereg_replace('\.$','',$domain[0]));
// Removing extra trailing slashes
function getDomainStartPage($domain, $path='',$request_uri='') {
$domain = explode(':', $domain);
$domain = strtolower(ereg_replace('\.$', '', $domain[0]));
// Removing extra trailing slashes
$path = trim(ereg_replace('\/[^\/]*$','',$path));
// Appending to domain string
$domain.= $path;
$domain = ereg_replace('\/*$','',$domain);
// Appending to domain string
$domain .= $path;
$domain = ereg_replace('\/*$', '', $domain);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'pages.uid,sys_domain.redirectTo,sys_domain.prepend_params',
'pages,sys_domain',
'pages.uid=sys_domain.pid
AND sys_domain.hidden=0
AND (sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain, 'sys_domain').' OR sys_domain.domainName='.$GLOBALS['TYPO3_DB']->fullQuoteStr($domain.'/', 'sys_domain').') '.
$this->where_hid_del.$this->where_groupAccess,
'pages.uid, sys_domain.redirectTo, sys_domain.redirectHttpStatusCode, sys_domain.prepend_params',
'pages, sys_domain',
'pages.uid = sys_domain.pid
AND sys_domain.hidden = 0
AND (sys_domain.domainName = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($domain, 'sys_domain') . ' OR sys_domain.domainName = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($domain . '/', 'sys_domain') . ') ' .
$this->where_hid_del . $this->where_groupAccess,
'',
'',
1
);
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
$GLOBALS['TYPO3_DB']->sql_free_result($res);
if ($row) {
if ($row) {
if ($row['redirectTo']) {
$rURL = $row['redirectTo'];
if ($row['prepend_params']) {
$rURL = ereg_replace('\/$','',$rURL);
$prependStr = ereg_replace('^\/','',substr($request_uri,strlen($path)));
$rURL.= '/'.$prependStr;
if ($row['prepend_params']) {
$rURL = ereg_replace('\/$', '', $rURL);
$prependStr = ereg_replace('^\/', '', substr($request_uri, strlen($path)));
$rURL .= '/' . $prependStr;
}
Header('HTTP/1.1 301 Moved Permanently');
Header('Location: '.t3lib_div::locationHeaderUrl($rURL));
$statusCode = intval($row['redirectHttpStatusCode']);
if ($statusCode && defined('t3lib_div::HTTP_STATUS_' . $statusCode)) {
header(constant('t3lib_div::HTTP_STATUS_' . $statusCode)));
header('Location: '.t3lib_div::locationHeaderUrl($rURL), true, $statusCode);
} else {
header(constant('t3lib_div::HTTP_STATUS_301')));
header('Location: '.t3lib_div::locationHeaderUrl($rURL));
}
exit;
} else {
return $row['uid'];
typo3/sysext/cms/locallang_tca.xml (working copy)
<label index="sys_domain">Domain</label>
<label index="sys_domain.domainName">Domain:</label>
<label index="sys_domain.redirectTo">Redirect to:</label>
<label index="sys_domain.redirectHttpCode">HTTP Status Code for the Redirect:</label>
<label index="sys_domain.prepend_params">Transfer parameters to Redirect URL:</label>
<label index="sys_template">Template</label>
<label index="sys_template.title">Template title:</label>
typo3/sysext/cms/ext_tables.sql (working copy)
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
domainName varchar(80) DEFAULT '' NOT NULL,
redirectTo varchar(120) DEFAULT '' NOT NULL,
redirectHttpCode tinyint(4) unsigned DEFAULT '0' NOT NULL,
sorting int(10) unsigned DEFAULT '0' NOT NULL,
prepend_params int(10) DEFAULT '0' NOT NULL,
typo3/sysext/cms/tbl_cms.php (working copy)
'softref' => 'substitute'
),
),
'redirectHttpStatusCode' => array(
'exclude' => 1,
'label' => 'LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode',
'config' => array(
'type' => 'input',
'size' => 4,
'max' => 4,
'eval' => int,
'checkbox' => 0,
'default' => 301,
'range' => array(
'upper' => 1000,
'lower' => 10
),
'default' => 0
)
),
'hidden' => array(
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.disable',
'exclude' => 1,
......
'1' => array('showitem' => 'hidden;;;;1-1-1,domainName;;1;;3-3-3,prepend_params')
),
'palettes' => array(
'1' => array('showitem' => 'redirectTo')
'1' => array('showitem' => 'redirectTo, redirectHttpStatusCode')
)
);
    (1-1/1)