Project

General

Profile

Feature #19178 » 0009094_v5.patch

Administrator Admin, 2008-10-31 22:12

View differences:

t3lib/config_default.php (Arbeitskopie)
'addAllowedPaths' => '', // Additional relative paths (comma-list) to allow TypoScript resources be in. Should be prepended with '/'. If not, then any path where the first part is like this path will match. That is: 'myfolder/ , myarchive' will match eg. 'myfolder/', 'myarchive/', 'myarchive_one/', 'myarchive_2/' ... No check is done to see if this directory actually exists in the root of the site. Paths are matched by simply checking if these strings equals the first part of any TypoScript resource filepath. (See class template, function init() in t3lib/class.t3lib_tsparser.php)
'allowedTempPaths' => '', // Additional paths allowed for temporary images. Used with imgResource. Eg. 'alttypo3temp/,another_temp_dir/';
'debug' => 0, // Boolean. If set, some debug HTML-comments may be output somewhere. Can also be set by TypoScript.
'simulateStaticDocuments' => 0, // Boolean. This is the default value for simulateStaticDocuments (configurable with TypoScript which overrides this, if the TypoScript value is present)
'simulateStaticDocuments' => 0, // Boolean. This is the default value for simulateStaticDocuments (configurable with TypoScript which overrides this, if the TypoScript value is present), since TYPO3 4.3 you also need to install the system extension "simulatestatic" to get this to work.
'noPHPscriptInclude' => 0, // Boolean. If set, PHP-scripts are not included by TypoScript configurations, unless they reside in 'media/scripts/'-folder. This is a security option to ensure that users with template-access do not terrorize
'strictFormmail' => TRUE, // Boolean. If set, the internal "formmail" feature in TYPO3 will send mail ONLY to recipients which has been encoded by the system itself. This protects against spammers misusing the formmailer.
'secureFormmail' => TRUE, // Boolean. If set, the internal "formmail" feature in TYPO3 will send mail ONLY to the recipients that are defined in the form CE record. This protects against spammers misusing the formmailer.
t3lib/class.t3lib_tstemplate.php (Arbeitskopie)
/**
* The mother of all functions creating links/URLs etc in a TypoScript environment.
* See the references below.
* Basically this function takes care of issues such as type,id,alias and Mount Points, simulate static documents, M5/B6 encoded parameters etc.
* Basically this function takes care of issues such as type,id,alias and Mount Points, URL rewriting (through hooks), M5/B6 encoded parameters etc.
* It is important to pass all links created through this function since this is the guarantee that globally configured settings for link creating are observed and that your applications will conform to the various/many configuration options in TypoScript Templates regarding this.
*
* @param array The page record of the page to which we are creating a link. Needed due to fields like uid, alias, target, no_cache, title and sectionIndex_uid.
......
} else {
$LD['type'] = '';
}
$LD['orig_type'] = $LD['type']; // Preserving the type number. Will not be cleared if simulateStaticDocuments.
$LD['orig_type'] = $LD['type']; // Preserving the type number.
// noCache
$LD['no_cache'] = (trim($page['no_cache']) || $no_cache) ? '&no_cache=1' : '';
......
$LD['linkVars'] = $GLOBALS['TSFE']->linkVars.$addParams;
}
// If simulateStaticDocuments is enabled:
if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']) {
$LD['type'] = '';
$LD['url'] = '';
// MD5/base64 method limitation:
$remainLinkVars='';
$flag_simulateStaticDocuments_pEnc = t3lib_div::inList('md5,base64',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc']) && !$LD['no_cache'];
if ($flag_simulateStaticDocuments_pEnc) {
list($LD['linkVars'], $remainLinkVars) = $GLOBALS['TSFE']->simulateStaticDocuments_pEnc_onlyP_proc($LD['linkVars']);
}
$LD['url'].=$GLOBALS['TSFE']->makeSimulFileName(
$page['title'],
$page['alias'] ? $page['alias'] : $page['uid'],
intval($typeNum),
$LD['linkVars'],
$LD['no_cache'] ? true : false
);
if ($flag_simulateStaticDocuments_pEnc) {
$LD['linkVars']=$remainLinkVars;
}
if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']=='PATH_INFO') {
$LD['url'] = str_replace('.','/',$LD['url']);
$LD['url'] = 'index.php/'.$LD['url'].'/?';
} else {
$LD['url'].= '.html?';
}
}
// Add absRefPrefix if exists.
$LD['url'] = $GLOBALS['TSFE']->absRefPrefix.$LD['url'];
typo3/sysext/simulatestatic/class.tx_simulatestatic.php (Revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2008 Kasper Skaarhoj <kasperYYYY@typo3.com>
* (c) 2008 Benjamin Mack <benni . typo3 . o)rg>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Class that does the simulatestatic feature (Speaking URLs)
* Was extracted for TYPO3 4.3 from the core
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
* @author Benjamin Mack <benni . typo3 . o)rg>
*/
class tx_simulatestatic {
public $enabled = false;
public $replacementChar = '';
public $conf = array();
public $pEncodingAllowedParamNames = array();
/**
* Initializes the extension, sets some configuration options and does some basic checks
*
* @param array holds all the information about the link that is about to be created
* @param tslib_fe is a reference to the parent object that calls the hook
* @return void
*/
public function hookInitConfig(array &$parameters, tslib_fe &$parentObject) {
$TSconf = &$parameters['config'];
// if .simulateStaticDocuments was not present, the installation-wide default value will be used
if (!isset($TSconf['simulateStaticDocuments'])) {
$TSconf['simulateStaticDocuments'] = trim($parentObject->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']);
}
// simulateStatic was not activated
if (!$TSconf['simulateStaticDocuments']) {
return;
}
$this->enabled = true;
// setting configuration options
$this->conf = array(
'mode' => $TSconf['simulateStaticDocuments'],
'dontRedirectPathInfoError' => ($TSconf['simulateStaticDocuments_dontRedirectPathInfoError'] ? $TSconf['simulateStaticDocuments_dontRedirectPathInfoError'] : $TSconf['simulateStaticDocuments.']['dontRedirectPathInfoError']),
'pEncoding' => ($TSconf['simulateStaticDocuments_pEnc'] ? $TSconf['simulateStaticDocuments_pEnc'] : $TSconf['simulateStaticDocuments.']['pEncoding']),
'pEncodingOnlyP' => ($TSconf['simulateStaticDocuments_pEnc_onlyP'] ? $TSconf['simulateStaticDocuments_pEnc_onlyP'] : $TSconf['simulateStaticDocuments.']['pEncoding_onlyP']),
'addTitle' => ($TSconf['simulateStaticDocuments_addTitle'] ? $TSconf['simulateStaticDocuments_addTitle'] : $TSconf['simulateStaticDocuments.']['addTitle']),
'noTypeIfNoTitle' => ($TSconf['simulateStaticDocuments_noTypeIfNoTitle'] ? $TSconf['simulateStaticDocuments_noTypeIfNoTitle'] : $TSconf['simulateStaticDocuments.']['noTypeIfNoTitle']),
'replacementChar' => (t3lib_div::compat_version('4.0') ? '-' : '_')
);
if ($this->conf['pEncodingOnlyP']) {
$tempParts = t3lib_div::trimExplode(',', $this->conf['pEncodingOnlyP'], 1);
foreach ($tempParts as $tempPart) {
$this->pEncodingAllowedParamNames[$tempPart] = 1;
}
}
// Checks and sets replacement character for simulateStaticDocuments.
$replacement = trim($TSconf['simulateStaticDocuments_replacementChar'] ? $TSconf['simulateStaticDocuments_replacementChar'] : $TSconf['simulateStaticDocuments.']['replacementChar']);
if ($replacement && (urlencode($replacement) == $replacement)) {
$this->conf['replacementChar'] = $replacement;
}
// Force absRefPrefix to this value is PATH_INFO is used.
$absRefPrefix = $TSconf['absRefPrefix'];
$absRefPrefix = trim($absRefPrefix);
if ((!strcmp($mode['conf'], 'PATH_INFO') || $parentObject->absRefPrefix_force) && !$absRefPrefix) {
$absRefPrefix = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/';
}
$parentObject->absRefPrefix = $absRefPrefix;
$parentObject->config['config']['absRefPrefix'] = $absRefPrefix;
// Check PATH_INFO url
if ($parentObject->absRefPrefix_force && strcmp($this->conf['mode'], 'PATH_INFO')) {
$redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php?id=' . $parentObject->id . '&type='.$parentObject->type;
if ($this->conf['dontRedirectPathInfoError']) {
if ($parentObject->checkPageUnavailableHandler()) {
$parentObject->pageUnavailableAndExit('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!');
} else {
$message = 'PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!';
header(t3lib_div::HTTP_STATUS_503);
t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
$parentObject->printError($message.'<br /><br /><a href="' . htmlspecialchars($redirectUrl) . '">Click here to get to the right page.</a>','Error: PATH_INFO not configured');
}
} else {
t3lib_div::redirect(t3lib_div::locationHeaderUrl($redirectUrl));
}
exit;
// Set no_cache if PATH_INFO is NOT used as simulateStaticDoc.
// and if absRefPrefix_force shows that such an URL has been passed along.
// $this->set_no_cache();
}
}
/**
* Hook for creating a speaking URL when using the generic linkData function
*
* @param array holds all the information about the link that is about to be created
* @param t3lib_TStemplate is a reference to the parent object that calls the hook
* @return void
*/
public function hookLinkDataPostProc(array &$parameters, t3lib_TStemplate &$parentObject) {
if (!$this->enabled) {
return;
}
$LD = &$parameters['LD'];
$page = &$parameters['args']['page'];
$LD['type'] = '';
// MD5/base64 method limitation
$remainLinkVars = '';
$flag_pEncoding = (t3lib_div::inList('md5,base64', $this->conf['pEncoding']) && !$LD['no_cache']);
if ($flag_pEncoding) {
list($LD['linkVars'], $remainLinkVars) = $this->processEncodedQueryString($LD['linkVars']);
}
$url = $this->makeSimulatedFileName(
$page['title'],
($page['alias'] ? $page['alias'] : $page['uid']),
intval($parameters['typeNum']),
$LD['linkVars'],
($LD['no_cache'] ? true : false)
);
if ($this->conf['mode'] == 'PATH_INFO') {
$url = 'index.php/' . str_replace('.', '/', $url) . '/';
} else {
$url .= '.html';
}
$LD['url'] = $GLOBALS['TSFE']->absRefPrefix . $url . '?';
if ($flag_pEncoding) {
$LD['linkVars'] = $remainLinkVars;
}
// If the special key 'sectionIndex_uid' (added 'manually' in tslib/menu.php to the page-record) is set,
// then the link jumps directly to a section on the page.
$LD['sectionIndex'] = ($page['sectionIndex_uid'] ? '#c'.$page['sectionIndex_uid'] : '');
// Compile the normal total url
$LD['totalURL'] = $parentObject->removeQueryString($LD['url'] . $LD['type'] . $LD['no_cache'] . $LD['linkVars'] . $GLOBALS['TSFE']->getMethodUrlIdToken) . $LD['sectionIndex'];
}
/**
* Hook for checking to see if the URL is a speaking URL
*
* Here a .htaccess file maps all .html-files to index.php and
* then we extract the id and type from the name of that HTML-file. (AKA "simulateStaticDocuments")
* Support for RewriteRule to generate (simulateStaticDocuments)
* With the mod_rewrite compiled into apache, put these lines into a .htaccess in this directory:
* RewriteEngine On
* RewriteRule ^[^/]*\.html$ index.php
* The url must end with '.html' and the format must comply with either of these:
* 1: '[title].[id].[type].html' - title is just for easy recognition in the
* logfile!; no practical use of the title for TYPO3.
* 2: '[id].[type].html' - above, but title is omitted; no practical use of
* the title for TYPO3.
* 3: '[id].html' - only id, type is set to the default, zero!
* NOTE: In all case 'id' may be the uid-number OR the page alias (if any)
*
* @param array includes a reference to the parent Object (which is the global TSFE)
* @param tslib_fe is a reference to the global TSFE
* @return void
*/
public function hookCheckAlternativeIDMethods(array &$parameters, tslib_fe &$parentObject) {
// If there has been a redirect (basically; we arrived here otherwise
// than via "index.php" in the URL)
// this can happend either due to a CGI-script or because of reWrite rule.
// Earlier we used $_SERVER['REDIRECT_URL'] to check
if ($parentObject->siteScript && substr($parentObject->siteScript, 0, 9) != 'index.php') {
$uParts = parse_url($parentObject->siteScript);
$fI = t3lib_div::split_fileref($uParts['path']);
if (!$fI['path'] && $fI['file'] && substr($fI['file'], -5) == '.html') {
$parts = explode('.', $fI['file']);
$pCount = count($parts);
if ($pCount > 2) {
$parentObject->type = intval($parts[$pCount-2]);
$parentObject->id = $parts[$pCount-3];
} else {
$parentObject->type = 0;
$parentObject->id = $parts[0];
}
}
}
}
/**
* Analyzes the second part of a id-string (after the "+"), looking for B6 or M5 encoding
* and if found it will resolve it and restore the variables in global $_GET.
* If values for ->cHash, ->no_cache, ->jumpurl and ->MP is found,
* they are also loaded into the internal vars of this class.
* => Not yet used, could be ported from tslib_fe as well
*
* @param string String to analyze
* @return void
*/
protected function idPartsAnalyze($string) {
$getVars = '';
switch (substr($string, 0, 2)) {
case 'B6':
$addParams = base64_decode(str_replace('_', '=', str_replace('-', '/', substr($string, 2))));
parse_str($addParams, $getVars);
break;
case 'M5':
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('params', 'cache_md5params', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(substr($string, 2), 'cache_md5params'));
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
$GLOBALS['TSFE']->updateMD5paramsRecord(substr($string, 2));
parse_str($row['params'], $getVars);
break;
}
$GLOBALS['TSFE']->mergingWithGetVars($getVars);
}
/********************************************
*
* Various internal API functions
*
*******************************************/
/**
* This is just a wrapper function to use the params from the array split up. Can be deleted once the function in class.t3lib_fe.php is deleted
*
* @param array Parameter array delivered from tslib_fe::makeSimulFileName
* @param tslib_fe Reference to the calling TSFE instance
* @return string The body of the filename.
* @see makeSimulatedFileName()
* @deprecated: Will be deleted in TYPO3 4.5
*/
public function makeSimulatedFileNameCompat(array &$parameters, tslib_fe &$parentObject) {
return $this->makeSimulatedFileName(
$parameters['inTitle'],
$parameters['page'],
$parameters['type'],
$parameters['addParams'],
$parameters['no_cache']
);
}
/**
* Make simulation filename (without the ".html" ending, only body of filename)
*
* @param string The page title to use
* @param mixed The page id (integer) or alias (string)
* @param integer The type number
* @param string Query-parameters to encode (will be done only if caching is enabled and TypoScript configured for it. I don't know it this makes much sense in fact...)
* @param boolean The "no_cache" status of the link.
* @return string The body of the filename.
* @see getSimulFileName(), t3lib_tstemplate::linkData(), tslib_frameset::frameParams()
*/
public function makeSimulatedFileName($inTitle, $page, $type, $addParams = '', $no_cache = false) {
// Default value is 30 but values > 1 will be override this
$titleChars = intval($this->conf['addTitle']);
if ($titleChars == 1) {
$titleChars = 30;
}
$out = ($titleChars ? $this->fileNameASCIIPrefix($inTitle, $titleChars) : '');
$enc = '';
if (strcmp($addParams, '') && !$no_cache) {
switch ((string)$this->conf['pEncoding']) {
case 'md5':
$md5 = substr(md5($addParams), 0, 10);
$enc = '+M5'.$md5;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'md5hash',
'cache_md5params',
'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')
);
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$insertFields = array(
'md5hash' => $md5,
'tstamp' => time(),
'type' => 1,
'params' => $addParams
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
break;
case 'base64':
$enc = '+B6' . str_replace('=', '_', str_replace('/', '-', base64_encode($addParams)));
break;
}
}
// Setting page and type number:
return $out . $page . $enc . (($type || $out || !$this->conf['noTypeIfNoTitle']) ? '.' . $type : '');
}
/**
* Returns the simulated static file name (*.html) for the current page (using the page record in $this->page)
*
* @return string The filename (without path)
* @see makeSimulatedFileName(), publish.php
*/
public function getSimulatedFileName() {
return $this->makeSimulatedFileName(
$GLOBALS['TSFE']->page['title'],
($GLOBALS['TSFE']->page['alias'] ? $GLOBALS['TSFE']->page['alias'] : $GLOBALS['TSFE']->id),
$GLOBALS['TSFE']->type
) . '.html';
}
/**
* Processes a query-string with GET-parameters and returns two strings, one with the parameters that CAN be encoded and one array with those which can't be encoded (encoded by the M5 or B6 methods)
*
* @param string Query string to analyse
* @return array Two num keys returned, first is the parameters that MAY be encoded, second is the non-encodable parameters.
* @see makeSimulatedFileName(), t3lib_tstemplate::linkData()
*/
public function processEncodedQueryString($linkVars) {
$remainingLinkVars = '';
if (strcmp($linkVars, '')) {
$parts = t3lib_div::trimExplode('&', $linkVars);
// This sorts the parameters - and may not be needed and further
// it will generate new MD5 hashes in many cases. Maybe not so smart. Hmm?
sort($parts);
$remainingParts = array();
foreach ($parts as $index => $value) {
if (strlen($value)) {
list($parameterName) = explode('=', $value, 2);
$parameterName = rawurldecode($parameterName);
if (!$this->pEncodingAllowedParamNames[$parameterName]) {
unset($parts[$index]);
$remainingParts[] = $value;
}
} else {
unset($parts[$index]);
}
}
$linkVars = (count($parts) ? '&' . implode('&', $parts) : '');
$remainingLinkVars = (count($remainingParts) ? '&' . implode('&', $remainingParts) : '');
}
return array($linkVars, $remainingLinkVars);
}
/**
* Converts input string to an ASCII based file name prefix
*
* @param string String to base output on
* @param integer Number of characters in the string
* @param string Character to put in the end of string to merge it with the next value.
* @return string Converted string
*/
public function fileNameASCIIPrefix($inTitle, $maxTitleChars, $mergeChar = '.') {
$out = $GLOBALS['TSFE']->csConvObj->specCharsToASCII($GLOBALS['TSFE']->renderCharset, $inTitle);
// Get replacement character
$replacementChar = $this->conf['replacementChar'];
$replacementChars = '_\-' . ($replacementChar != '_' && $replacementChar != '-' ? $replacementChar : '');
$out = preg_replace('/[^A-Za-z0-9_-]/', $replacementChar, trim(substr($out, 0, $maxTitleChars)));
$out = preg_replace('/([' . $replacementChars . ']){2,}/', '\1', $out);
$out = preg_replace('/[' . $replacementChars . ']?$/', '', $out);
$out = preg_replace('/^[' . $replacementChars . ']?/', '', $out);
return (strlen($out) ? $out . $mergeChar : '');
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/simulatestatic/class.tx_simulatestatic.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/simulatestatic/class.tx_simulatestatic.php']);
}
?>
typo3/sysext/simulatestatic/ext_localconf.php (Revision 0)
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'][$_EXTKEY] = 'EXT:simulatestatic/class.tx_simulatestatic.php:&tx_simulatestatic->hookInitConfig';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'][$_EXTKEY] = 'EXT:simulatestatic/class.tx_simulatestatic.php:&tx_simulatestatic->hookLinkDataPostProc';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'][$_EXTKEY] = 'EXT:simulatestatic/class.tx_simulatestatic.php:&tx_simulatestatic->hookCheckAlternativeIDMethods';
?>
typo3/sysext/simulatestatic/ext_emconf.php (Revision 0)
<?php
########################################################################
# Extension Manager/Repository config file for ext: "simulatestatic"
#
# Auto generated 31-10-2008 22:05
#
# Manual updates:
# Only the data in the array - anything else is removed by next write.
# "version" and "dependencies" must not be touched!
########################################################################
$EM_CONF[$_EXTKEY] = array(
'title' => 'Simulate Static URLs',
'description' => 'Adds the possibility to have Speaking URLs in the TYPO3 Frontend pages.',
'category' => 'fe',
'shy' => 0,
'dependencies' => '',
'conflicts' => '',
'priority' => '',
'loadOrder' => '',
'module' => '',
'state' => 'stable',
'internal' => 0,
'uploadfolder' => 0,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 1,
'lockType' => '',
'author' => 'Benjamin Mack',
'author_email' => 'benni@typo3.org',
'author_company' => '',
'CGLcompliance' => '',
'CGLcompliance_note' => '',
'version' => '1.0.0',
'_md5_values_when_last_written' => 'a:2:{s:27:"class.tx_simulatestatic.php";s:4:"055c";s:17:"ext_localconf.php";s:4:"eace";}',
'constraints' => array(
'depends' => array(
'php' => '5.1.0-0.0.0',
'typo3' => '4.3.0-4.3.99',
),
'conflicts' => array(
),
'suggests' => array(
),
),
'suggests' => array(
),
);
?>
typo3/sysext/cms/tslib/class.tslib_fe.php (Arbeitskopie)
var $uniqueString='';
var $indexedDocTitle=''; // This value will be used as the title for the page in the indexer (if indexing happens)
var $altPageTitle=''; // Alternative page title (normally the title of the page record). Can be set from applications you make.
var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method.
var $pEncAllowedParamNames=array(); // An array that holds parameter names (keys) of GET parameters which MAY be MD5/base64 encoded with simulate_static_documents method. @deprecated since TYPO3 4.3, remove in TYPO3 4.5
var $baseUrl=''; // The base URL set for the page header.
var $anchorPrefix=''; // The proper anchor prefix needed when using speaking urls. (only set if baseUrl is set)
......
/**
* Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
*
* Three options:
* 1) Apache mod_rewrite: Here a .htaccess file maps all .html-files to index.php and then we extract the id and type from the name of that HTML-file. (AKA "simulateStaticDocuments")
* 2) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
* 3) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
* Two options:
* 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)
* 2) Using hook which enables features like those provided from "simulatestatic" or "realurl" extension (AKA "Speaking URLs")
*
* Support for RewriteRule to generate (simulateStaticDocuments)
* With the mod_rewrite compiled into apache, put these lines into a .htaccess in this directory:
* RewriteEngine On
* RewriteRule ^[^/]*\.html$ index.php
* The url must end with '.html' and the format must comply with either of these:
* 1: '[title].[id].[type].html' - title is just for easy recognition in the logfile!; no practical use of the title for TYPO3.
* 2: '[id].[type].html' - above, but title is omitted; no practical use of the title for TYPO3.
* 3: '[id].html' - only id, type is set to the default, zero!
* NOTE: In all case 'id' may be the uid-number OR the page alias (if any)
*
* @return void
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
*/
function checkAlternativeIdMethods() {
$this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');
// Resolving of "simulateStaticDocuments" URLs:
if ($this->siteScript && substr($this->siteScript,0,9)!='index.php') { // If there has been a redirect (basically; we arrived here otherwise than via "index.php" in the URL) this can happend either due to a CGI-script or because of reWrite rule. Earlier we used $_SERVER['REDIRECT_URL'] to check but
$uParts = parse_url($this->siteScript); // Parse the path:
$fI = t3lib_div::split_fileref($uParts['path']);
if (!$fI['path'] && $fI['file'] && substr($fI['file'],-5)=='.html') {
$parts = explode('.',$fI['file']);
$pCount = count($parts);
if ($pCount>2) {
$this->type = intval($parts[$pCount-2]);
$this->id = $parts[$pCount-3];
} else {
$this->type = 0;
$this->id = $parts[0];
}
}
}
// If PATH_INFO
if (t3lib_div::getIndpEnv('PATH_INFO')) { // If pathinfo contains stuff...
$parts=t3lib_div::trimExplode('/',t3lib_div::getIndpEnv('PATH_INFO'),1);
......
* @param string String to analyze
* @return void
* @access private
* @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function idPartsAnalyze($str) {
$GET_VARS = '';
......
$this->config['config'] = t3lib_div::array_merge_recursive_overrule($this->config['config'], $this->pSetup['config.']);
}
// if .simulateStaticDocuments was not present, the default value will rule.
if (!isset($this->config['config']['simulateStaticDocuments'])) {
$this->config['config']['simulateStaticDocuments'] = trim($this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments']);
}
if ($this->config['config']['simulateStaticDocuments']) {
// Set replacement char only if it is needed
$this->setSimulReplacementChar();
}
if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
$this->config['config']['typolinkCheckRootline'] = true;
}
......
// No cache
if ($this->config['config']['no_cache']) { $this->set_no_cache(); } // Set $this->no_cache true if the config.no_cache value is set!
// Check PATH_INFO url
if ($this->absRefPrefix_force && strcmp($this->config['config']['simulateStaticDocuments'],'PATH_INFO')) {
$redirectUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php?id='.$this->id.'&type='.$this->type;
if ($this->config['config']['simulateStaticDocuments_dontRedirectPathInfoError']) {
if ($this->checkPageUnavailableHandler()) {
$this->pageUnavailableAndExit('PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!');
} else {
$message = 'PATH_INFO was not configured for this website, and the URL tries to find the page by PATH_INFO!';
header('HTTP/1.0 503 Service Temporarily Unavailable');
t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
$this->printError($message.'<br /><br /><a href="'.htmlspecialchars($redirectUrl).'">Click here to get to the right page.</a>','Error: PATH_INFO not configured');
}
} else {
header('Location: '.t3lib_div::locationHeaderUrl($redirectUrl));
// Hook for postProcessing the configuration array
if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
$params = array('config' => &$this->config['config']);
foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
t3lib_div::callUserFunction($funcRef, $params, $this);
}
exit;
// $this->set_no_cache(); // Set no_cache if PATH_INFO is NOT used as simulateStaticDoc. and if absRefPrefix_force shows that such an URL has been passed along.
}
}
......
* @param string Query-parameters to encode (will be done only if caching is enabled and TypoScript configured for it. I don't know it this makes much sense in fact...)
* @param boolean The "no_cache" status of the link.
* @return string The body of the filename.
* @see getSimulFileName(), t3lib_tstemplate::linkData(), tslib_frameset::frameParams()
* @see getSimulFileName(), t3lib_tstemplate::linkData(), tslib_frameset::frameParams(), tx_
* @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache=false) {
$titleChars = intval($this->config['config']['simulateStaticDocuments_addTitle']);
// Default value is 30 but values > 1 will be override this
if($titleChars==1) { $titleChars = 30; }
$out = '';
if ($titleChars) {
$out = $this->fileNameASCIIPrefix($inTitle, $titleChars);
function makeSimulFileName($inTitle, $page, $type, $addParams = '', $no_cache = false) {
if (t3lib_extMgm::isLoaded('simulatestatic')) {
return t3lib_div::callUserFunc(
'EXT:simulatestatic/class.tx_simulatestatic.php:&tx_simulatestatic->makeSimulatedFileNameCompat',
array(
'inTitle' => $inTitle,
'page' => $page,
'type' => $type,
'addParams' => $addParams,
'no_cache' => $no_cache
), $this);
} else {
return false;
}
$enc = '';
if (strcmp($addParams,'') && !$no_cache) {
switch ((string)$this->config['config']['simulateStaticDocuments_pEnc']) {
case 'md5':
$md5 = substr(md5($addParams),0,10);
$enc = '+M5'.$md5;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_md5params', 'md5hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params'));
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$insertFields = array(
'md5hash' => $md5,
'tstamp' => time(),
'type' => 1,
'params' => $addParams
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
}
break;
case 'base64':
$enc = '+B6'.str_replace('=','_',str_replace('/','-',base64_encode($addParams)));
break;
}
}
// Setting page and type number:
$url = $out.$page.$enc;
$url.= ($type || $out || !$this->config['config']['simulateStaticDocuments_noTypeIfNoTitle']) ? '.'.$type : '';
return $url;
}
/**
......
* @param string Query string to analyse
* @return array Two num keys returned, first is the parameters that MAY be encoded, second is the non-encodable parameters.
* @see makeSimulFileName(), t3lib_tstemplate::linkData()
* @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function simulateStaticDocuments_pEnc_onlyP_proc($linkVars) {
$remainLinkVars = '';
if (strcmp($linkVars,'')) {
$p = explode('&',$linkVars);
sort($p); // This sorts the parameters - and may not be needed and further it will generate new MD5 hashes in many cases. Maybe not so smart. Hmm?
$rem = array();
foreach($p as $k => $v) {
if (strlen($v)) {
list($pName) = explode('=',$v,2);
$pName = rawurldecode($pName);
if (!$this->pEncAllowedParamNames[$pName]) {
unset($p[$k]);
$rem[] = $v;
}
} else unset($p[$k]);
}
$linkVars = count($p) ? '&'.implode('&',$p) : '';
$remainLinkVars = count($rem) ? '&'.implode('&',$rem) : '';
if (t3lib_extMgm::isLoaded('simulatestatic')) {
return t3lib_div::callUserFunc(
'EXT:simulatestatic/class.tx_simulatestatic.php:&tx_simulatestatic->processEncodedQueryString',
$linkVars,
$this
);
} else {
return false;
}
return array($linkVars, $remainLinkVars);
}
/**
......
*
* @return string The filename (without path)
* @see makeSimulFileName(), publish.php
* @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function getSimulFileName() {
$url = '';
$url.= $this->makeSimulFileName($this->page['title'], $this->page['alias']?$this->page['alias']:$this->id, $this->type).'.html';
return $url;
return $this->makeSimulFileName(
$this->page['title'],
($this->page['alias'] ? $this->page['alias'] : $this->id),
$this->type
) . '.html';
}
/**
* Checks and sets replacement character for simulateStaticDocuments. Default is underscore.
*
* @return void
* @deprecated since TYPO3 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function setSimulReplacementChar() {
$replacement = $defChar = t3lib_div::compat_version('4.0') ? '-' : '_';
......
* @param integer Number of characters in the string
* @param string Character to put in the end of string to merge it with the next value.
* @return string String
* @deprecated since TYPO3, 4.3, will be removed in TYPO3 4.5, please use the "simulatestatic" sysext directly
*/
function fileNameASCIIPrefix($inTitle,$titleChars,$mergeChar='.') {
$out = $this->csConvObj->specCharsToASCII($this->renderCharset, $inTitle);
typo3/sysext/cms/tslib/class.tslib_pagegen.php (Arbeitskopie)
}
}
}
if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP']) {
$temp_parts = t3lib_div::trimExplode(',',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP'],1);
foreach ($temp_parts as $temp_p) {
$GLOBALS['TSFE']->pEncAllowedParamNames[$temp_p]=1;
}
}
// Global vars...
$GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
$GLOBALS['TSFE']->debug = ''.$GLOBALS['TSFE']->config['config']['debug'];
......
$GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-10,10,0);
}
$GLOBALS['TSFE']->absRefPrefix = ($GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : '');
$GLOBALS['TSFE']->absRefPrefix = trim(''.$GLOBALS['TSFE']->config['config']['absRefPrefix']);
if ((!strcmp($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'],'PATH_INFO') || $GLOBALS['TSFE']->absRefPrefix_force)
&& !$GLOBALS['TSFE']->absRefPrefix) {
$GLOBALS['TSFE']->absRefPrefix=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
} // Force absRefPrefix to this value is PATH_INFO is used.
if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
$tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'_top',$GLOBALS['TSFE']->no_cache,'');
$GLOBALS['TSFE']->JSCode = 'if(!parent.'.trim($GLOBALS['TSFE']->sPre).' && !parent.view_frame) top.location.href="'.$GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']).'"';
typo3/sysext/install/mod/class.tx_install.php (Arbeitskopie)
require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_compatversion.php');
require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_notinmenu.php');
require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_mergeadvanced.php');
require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_installsysexts.php');
/**
typo3/sysext/install/updates/class.tx_coreupdates_installsysexts.php (Revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Benjamin Mack <benni@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contains the update class for adding the system extension "simulate static".
*
* @author Benjamin Mack <benni@typo3.org>
*/
class tx_coreupdates_installsysexts {
public $versionNumber; // version number coming from t3lib_div::int_from_ver()
/**
* parent object
*
* @var tx_install
*/
public $pObj;
public $userInput; // user input
/**
* Checks if an update is needed
*
* @param string &$description: The description for the update
* @return boolean whether an update is needed (true) or not (false)
*/
public function checkForUpdate(&$description) {
$result = false;
$description = 'Installs the System Extension "simulatestatic" if you do not want to use RealURL or CoolURI but still want the Speaking URL feature. This feature was moved from the core to an extension and can be installed if used. If you used "config.simulatestaticdocuments = 1" in this installation before, you should install this system extension. Be sure to read the manual of "simulatestatic".';
if (!t3lib_extMgm::isLoaded('simulatestatic')) {
$result = true;
}
return $result;
}
/**
* Adds the extension "simulate static" to the extList in TYPO3_CONF_VARS
*
* @param array &$dbQueries: queries done in this update
* @param mixed &$customMessages: custom messages
* @return boolean whether it worked (true) or not (false)
*/
public function performUpdate(&$dbQueries, &$customMessages) {
$result = false;
$extList = $this->addExtToList('simulatestatic');
if ($extList) {
$this->writeNewExtensionList($extList);
$result = true;
}
return $result;
}
/**
* Adds extension to extension list and returns new list. If -1 is returned, an error happend.
* Does NOT check dependencies yet.
*
* @param string Extension key
* @return string New list of installed extensions or -1 if error
*/
function addExtToList($extKey) {
// Get list of installed extensions and add this one.
$listArr = array_keys($GLOBALS['TYPO3_LOADED_EXT']);
$listArr[] = $extKey;
// Implode unique list of extensions to load and return:
return implode(',', array_unique($listArr));
}
/**
* Writes the extension list to "localconf.php" file
* Removes the temp_CACHED* files before return.
*
* @param string List of extensions
* @return void
*/
protected function writeNewExtensionList($newExtList) {
// Instance of install tool
$instObj = new t3lib_install;
$instObj->allowUpdateLocalConf = 1;
$instObj->updateIdentity = 'TYPO3 Core Update Manager';
// Get lines from localconf file
$lines = $instObj->writeToLocalconf_control();
$instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
$instObj->writeToLocalconf_control($lines);
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
t3lib_extMgm::removeCacheFiles();
}
}
?>
typo3/sysext/install/ext_localconf.php (Arbeitskopie)
// remove pagetype "advanced" since TYPO3 4.2
// this is merged with doctype "standard" with tab view to edit
$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['mergeAdvancedDoktypeConversion'] = 'tx_coreupdates_mergeadvanced';
// add outsourced system extensions since TYPO3 4.3
$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['installSystemExtensions'] = 'tx_coreupdates_installsysexts';
?>
(5-5/5)