Project

General

Profile

Bug #17251 » tslib_fe.patch.php

Administrator Admin, 2007-04-30 10:34

 
<?php
/**
*
*
*
*/



/**
* Calculates a hash string based on additional parameters in the url. This is used to cache pages with more parameters than just id and type
*
* @return void
* @see reqCHash()
*/
function makeCacheHash() {
/* Declare */
$GET = t3lib_div::_GET();
$cHashNeeded = false;
$this->cHash_array = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('',$GET));
$cHash_calc = t3lib_div::shortMD5(serialize($cHash_array)); // Calculating the correct cHash

/* Begin */
if ((count($this->cHash_array) == 1) && isset($this->cHash_array['encryptionKey'])) {
//We have only 1 key, and it's 'encryptionKey', also all GET parameters are TYPO3 reserved variables -> no cHash needed
$cHashNeeded = false;
//Reset cHash_array
$this->cHash_array = array();
} elseif ((count($this->cHash_array) == 2) && isset($this->cHash_array['']) && isset($this->cHash_array['encryptionKey'])) {
//If we have only 2 keys, and theses two keys are '' and 'encryptionKey', then whe are sure that we have NO _GET parameters
$cHashNeeded = false;
//Reset cHash_array
$this->cHash_array = array();
} else {
//Here we need a correct cHash
$cHashNeeded = true;
}

//*** Checks cHash needed against cHash found, and compare it (a missing cHash or a useless cHash is WRONG)
if (($cHashNeeded XOR $this->cHash) || strcmp($cHash_calc, $this->cHash)) {
if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) {
$this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)');
} else {
$this->set_no_cache();
$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);
}
}

}


?>
(1-1/2)