fix test.php, fix default configuration

This commit is contained in:
wing328
2015-06-27 22:54:37 +08:00
parent 259b31ccd4
commit 2258a4632d
5 changed files with 60 additions and 41 deletions

View File

@@ -134,22 +134,15 @@ class ObjectSerializer {
settype($data, $class);
$deserialized = $data;
} elseif ($class === '\SplFileObject') {
# determine temp folder path
if (!isset(Configuration::getDefaultConfig->$tempFolderPath) || '' === Configuration::$tempFolderPath) {
$tmpFolderPath = sys_get_temp_dir();
} else {
$tmpFolderPath = Configuration::tempFolderPath;
}
# determine file name
if (preg_match('/Content-Disposition: inline; filename=(.*)/i', $httpHeader, $match)) {
$filename = $tmpFolderPath.$match[1];
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else {
$filename = tempnam($tmpFolderPath, '');
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file afterwards", 3, Configuration::getDefaultConfiguration()->getDebugFile());
error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n" , 3, Configuration::getDefaultConfiguration()->getDebugFile());
} else {
$instance = new $class();