"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/utils/utils.php" between
Z-Push-2.6.3.tar.gz and Z-Push-2.6.4.tar.gz

About: Z-Push is an PHP application to synchronize ActiveSync compatible devices such as mobile phones, tablets and Outlook 2013 and above. Hint: This is an unofficial tarball offered by the read-only GitHub mirror. Recommended is an installation via the Z-Push git repository.

utils.php  (Z-Push-2.6.3):utils.php  (Z-Push-2.6.4)
skipping to change at line 1411 skipping to change at line 1411
$rawheaders = Utils::getRawMailHeaders($mail); $rawheaders = Utils::getRawMailHeaders($mail);
if (!$rawheaders) { if (!$rawheaders) {
return; return;
} }
$message->headers["subject"] = isset($message->headers["subject"]) ? Uti ls::convertRawHeader2Utf8($rawheaders["subject"], $message->headers["subject"]) : ""; $message->headers["subject"] = isset($message->headers["subject"]) ? Uti ls::convertRawHeader2Utf8($rawheaders["subject"], $message->headers["subject"]) : "";
$message->headers["from"] = Utils::convertRawHeader2Utf8($rawheaders["fr om"], $message->headers["from"]); $message->headers["from"] = Utils::convertRawHeader2Utf8($rawheaders["fr om"], $message->headers["from"]);
} }
/** /**
* Tries to load the content of a file from disk with retries in case of fil e system returns an empty file. * Tries to load the content of a file from disk with retries in case of fil e system returns an empty file.
* In case of non empty files it tries to unserialize them. * If $unserialize set true, in case of non empty files it tries to unserial ize them.
* *
* @param $filename * @param $filename
* $filename is the name of the file to be opened * $filename is the name of the file to be opened
* *
* @param $functName * @param $functName
* $functName is the name of the caller function. Usefull to be print ed into the log file * $functName is the name of the caller function. Usefull to be print ed into the log file
* *
* @param $suppressWarnings * @param $suppressWarnings
* $suppressWarnings boolean. True if file_get_contents function has to be called with suppress warnings enabled, False otherwise * $suppressWarnings boolean. True if file_get_contents function has to be called with suppress warnings enabled, False otherwise
* *
* @param $unserialize
* $unserialize boolean. True to return unserialized read data, false
otherwise.
*
* @access private * @access private
* @return string * @return string
*/ */
public static function SafeGetContentsUnserialize($filename, $functName, $su ppressWarnings) { public static function SafeGetContents($filename, $functName, $suppressWarni ngs, $unserialize = false) {
$attempts = (defined('FILE_STATE_ATTEMPTS') ? FILE_STATE_ATTEMPTS : 3); $attempts = (defined('FILE_STATE_ATTEMPTS') ? FILE_STATE_ATTEMPTS : 3);
$sleep_time = (defined('FILE_STATE_SLEEP') ? FILE_STATE_SLEEP : 100); $sleep_time = (defined('FILE_STATE_SLEEP') ? FILE_STATE_SLEEP : 100);
$unserialize_attempts_max = (defined('FILE_STATE_UNSERIALIZE_ATTEMPTS') ? FILE_STATE_UNSERIALIZE_ATTEMPTS : 1); $unserialize_attempts_max = (defined('FILE_STATE_UNSERIALIZE_ATTEMPTS') ? FILE_STATE_UNSERIALIZE_ATTEMPTS : 1);
$unserialize_attempt = 0; $unserialize_attempt = 0;
$contents = false; $contents = false;
do { do {
if ($unserialize_attempt > 0) {
ZLog::Write(LOGLEVEL_WARN, sprintf("FileStateMachine->%s(): Fail
ed on unserializing filename '%s' - attempt: %d", $functName, $filename, $unseri
alize_attempt));
}
if ($unserialize_attempt === $unserialize_attempts_max) {
break;
}
$i = 1; $i = 1;
while (($i <= $attempts) && (($filecontents = ($suppressWarnings ? @ file_get_contents($filename) : file_get_contents($filename))) === '')) { while (($i <= $attempts) && (($filecontents = ($suppressWarnings ? @ file_get_contents($filename) : file_get_contents($filename))) === '')) {
ZLog::Write(LOGLEVEL_WARN, sprintf("FileStateMachine->%s(): Fail ed on reading filename '%s' - attempt: %d", $functName, $filename, $i)); ZLog::Write(LOGLEVEL_WARN, sprintf("FileStateMachine->%s(): Fail ed on reading filename '%s' - attempt: %d", $functName, $filename, $i));
$i++; $i++;
usleep($sleep_time * 1000); usleep($sleep_time * 1000);
} }
if ($i > $attempts) { if ($i > $attempts) {
ZLog::Write(LOGLEVEL_FATAL, sprintf("FileStateMachine->%s(): Una ZLog::Write(LOGLEVEL_FATAL, sprintf("FileStateMachine->%s(): Una
ble to read filename '%s' after %d retries",$functName, $filename, --$i)); ble to read filename '%s' after %d attempts",$functName, $filename, --$i));
if ($unserialize !== true ) {
return $filecontents;
}
break; break;
} else { } else {
if ($unserialize_attempt > 0) { if ($unserialize !== true ) {
ZLog::Write(LOGLEVEL_WARN, sprintf("FileStateMachine->%s(): return $filecontents;
Failed on unserializing filename '%s' - attempt: %d", $functName, $filename, $un
serialize_attempt));
} }
$unserialize_attempt ++; $unserialize_attempt ++;
} }
//loop until unserialize succed or n° tries excedes } while ( ($filecontents !== false) && (($contents = unserialize($fileco
} while ( ($filecontents !== false) && (($contents = unserialize($fileco ntents)) === false));
ntents)) === false) && $unserialize_attempt <= $unserialize_attempts_max);
if ($contents === false && $filecontents !== '' && $filecontents !== fal se) { if ($contents === false && $filecontents !== '' && $filecontents !== fal se) {
ZLog::Write(LOGLEVEL_FATAL, sprintf("FileStateMachine->%s():Unable t o unserialize filename '%s' after %d retries", $functName, $filename, --$unseria lize_attempt)); ZLog::Write(LOGLEVEL_FATAL, sprintf("FileStateMachine->%s():Unable t o unserialize filename '%s' after %d attempts", $functName, $filename, $unserial ize_attempt));
} }
return $contents; return $contents;
} }
} }
// TODO Win1252/UTF8 functions are deprecated and will be removed sometime // TODO Win1252/UTF8 functions are deprecated and will be removed sometime
//if the ICS backend is loaded in CombinedBackend and Zarafa > 7 //if the ICS backend is loaded in CombinedBackend and Zarafa > 7
//STORE_SUPPORTS_UNICODE is true and the convertion will not be done //STORE_SUPPORTS_UNICODE is true and the convertion will not be done
//for other backends. //for other backends.
 End of changes. 9 change blocks. 
13 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)