В общем вот нашел решение проблемы:
PHP код:
protected function encodeSpURL_cHashCache($newUrl, &$paramKeyValues) {
// If "cHash" is the ONLY parameter left...
// (if there are others our problem is that the cHash probably covers those
// as well and if we include the cHash anyways we might get duplicates for
// the same speaking URL in the cache table!)
if (isset($paramKeyValues['cHash'])) {
if ($this->rebuildCHash) {
$cacheHashClassExists = class_exists('t3lib_cacheHash');
$cacheHash = ($cacheHashClassExists ? t3lib_div::makeInstance('t3lib_cacheHash') : NULL);
/* @var t3lib_cacheHash $cacheHash */
$cHashParameters = array_merge($this->cHashParameters, $paramKeyValues);
unset($cHashParameters['cHash']);
$cHashParameters = t3lib_div::implodeArrayForUrl('', $cHashParameters);
if ($cacheHashClassExists) {
$cHashParameters = $cacheHash->getRelevantParameters($cHashParameters);
} else {
$cHashParameters = t3lib_div::cHashParams($cHashParameters);
}
unset($cHashParameters['']);
if (count($cHashParameters) == 1) {
// No cHash needed.
unset($paramKeyValues['cHash']);
}
elseif (count($cHashParameters) > 1) {
if ($cacheHashClassExists) {
$paramKeyValues['cHash'] = $cacheHash->calculateCacheHash($cHashParameters);
} elseif (method_exists('t3lib_div', 'calculateCHash')) {
$paramKeyValues['cHash'] = t3lib_div::calculateCHash($cHashParameters);
} else {
$paramKeyValues['cHash'] = t3lib_div::shortMD5(serialize($cHashParameters));
}
}
unset($cHashParameters);
}
if (count($paramKeyValues) == 1) {
$stringForHash = $newUrl;
if (count($this->additionalParametersForChash)) {
$stringForHash .= '|' . serialize($this->additionalParametersForChash);
}
$spUrlHash = md5($stringForHash);
$spUrlHashQuoted = $GLOBALS['TYPO3_DB']->fullQuoteStr($spUrlHash, 'tx_realurl_chashcache');
// first, look if a cHash is already there for this SpURL
list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('chash_string',
'tx_realurl_chashcache', 'spurl_hash=' . $spUrlHashQuoted);
$GLOBALS['TEMP2222']['additionalParametersForChash'] = $this->additionalParametersForChash;
$GLOBALS['TEMP2222']['paramKeyValues'] = $paramKeyValues;
if (!is_array($row)) {
// Nothing found, insert to the cache
$data = array(
'spurl_hash' => $spUrlHash,
'spurl_string' => $this->enableChashUrlDebug ? $stringForHash : null,
'chash_string' => $paramKeyValues['cHash']
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_realurl_chashcache', $data);
}
else {
// If one found, check if it is different, and if so update:
if ($row['chash_string'] != $paramKeyValues['cHash']) {
// If that chash_string is different from the one we want to
// insert, that might be a bug or mean that encryptionKey was
// changed so cHash values will be different now
// In any case we will just silently update the value:
$data = array(
'chash_string' => $paramKeyValues['cHash']
);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_realurl_chashcache',
'spurl_hash=' . $spUrlHashQuoted, $data);
}
}
// Unset "cHash" (and array should now be empty!)
unset($paramKeyValues['cHash']);
}
else
$GLOBALS['TEMP2222'] = 2;
}
}
Это кусок кода из realurl...
Который проверяет - как то понимаю правильность запрошенного cHash...
Если правлиьно - значит пишет в mysql-табличку, если нет... Ничего...
Как это работает - и как сделать подобную проверку в php-коде?
И вот еще одну функцию нашел:
https://svn.jambage.com:8766/typo3/f...r_setfixed.php
PHP код:
public function storeFixedPiVars ($vars) {
// Create a unique hash value
if (class_exists('t3lib_cacheHash')) {
$cacheHash = t3lib_div::makeInstance('t3lib_cacheHash');
$regHash_calc = $cacheHash->calculateCacheHash($vars);
$regHash_calc = substr($regHash_calc, 0, 20);
} else {
// t3lib_div::cHashParams is deprecated in TYPO3 4.7
$regHash_array = t3lib_div::cHashParams(t3lib_div::implodeArrayForUrl('', $vars));
$regHash_calc = t3lib_div::shortMD5(serialize($regHash_array), 20);
}
// and store it with a serialized version of the array in the DB
$res =
$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'md5hash',
'cache_md5params',
'md5hash=' .
$GLOBALS['TYPO3_DB']->fullQuoteStr(
$regHash_calc,
'cache_md5params'
)
);
if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
$insertFields = array (
'md5hash' => $regHash_calc,
'tstamp' => time(),
'type' => 99,
'params' => serialize($vars)
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery(
'cache_md5params',
$insertFields
);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return $regHash_calc;
}
И так как в выше описанных примерах пока не получилось разобраться нашел такое решение - не идеальное с точки зрения разработки...
PHP код:
$spUrlHashQuoted = $GLOBALS['_GET']['cHash'];
$result = mysql_query("SELECT * FROM tx_realurl_chashcache WHERE chash_string='{$spUrlHashQuoted}' LIMIT 1;");
if ( mysql_num_rows($result) == 0 )
{ // не правильно...
Подскажите пожалуйста как такая операция делается через API-TYPO3?
Вот тоже - про затопление - плагинов через ввод битых cHash
http://forge.typo3.org/issues/29365
---