function restore_noise($text)
{
global $debugObject;
if (is_object($debugObject)) {
$debugObject->debugLogEntry(1);
}
while (($pos = strpos($text, '___noise___')) !== false) {
// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
if (strlen($text) > $pos + 15) {
$key = '___noise___' . $text[$pos + 11] . $text[$pos + 12] . $text[$pos + 13] . $text[$pos + 14] . $text[$pos + 15];
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'located key of: ' . $key);
}
if (isset($this->noise[$key])) {
$text = substr($text, 0, $pos) . $this->noise[$key] . substr($text, $pos + 16);
} else {
// do this to prevent an infinite loop.
$text = substr($text, 0, $pos) . 'UNDEFINED NOISE FOR KEY: ' . $key . substr($text, $pos + 16);
}
} else {
// There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
$text = substr($text, 0, $pos) . 'NO NUMERIC NOISE KEY' . substr($text, $pos + 11);
}
}
return $text;
}