Project

General

Profile

Feature #20202 » 0010717_v2.patch

Administrator Admin, 2009-03-31 12:26

View differences:

tests/t3lib/t3lib_div_testcase.php (Arbeitskopie)
$this->assertEquals($expectedArray, $actualArray);
}
/**
* Checks whether measurement strings like "100k" return the accordant
* byte representation like 102400 in this case.
*
* @test
*/
public function checkGetBytesFromSizeMeasurement() {
$this->assertEquals(
'102400',
t3lib_div::getBytesFromSizeMeasurement('100k')
);
$this->assertEquals(
'104857600',
t3lib_div::getBytesFromSizeMeasurement('100m')
);
$this->assertEquals(
'107374182400',
t3lib_div::getBytesFromSizeMeasurement('100g')
);
}
}
?>
t3lib/class.t3lib_extfilefunc.php (Arbeitskopie)
$this->unzipPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'];
$maxFileSize = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
if ($maxFileSize>0) {
if ($maxFileSize > 0) {
$this->maxCopyFileSize = $maxFileSize;
$this->maxMoveFileSize = $maxFileSize;
$this->maxUploadFileSize = $maxFileSize;
}
$this->maxUploadFileSize = t3lib_div::getMaxUploadFileSize();
// Initializing file processing commands:
$this->fileCmdMap = $fileCmds;
t3lib/class.t3lib_div.php (Arbeitskopie)
return $path;
}
/**
* Returns the maximum upload size for a file that is allowed. Measured in KB.
* This might be handy to find out the real upload limit that is possible for this
* TYPO3 installation. The first parameter can be used to set something that overrides
* the maxFileSize, usually for the TCA values.
*
* @param integer $localLimit: the number of Kilobytes (!) that should be used as
* the initial Limit, otherwise $TYPO3_CONF_VARS['BE']['maxFileSize'] will be used
* @return integer the maximum size of uploads that are allowed (measuered in kilobytes)
*/
public static function getMaxUploadFileSize($localLimit = 0) {
// don't allow more than the global max file size at all
$t3Limit = (intval($localLimit > 0 ? $localLimit : $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']));
// as TYPO3 is handling the file size in KB, multiply by 1024 to get bytes
$t3Limit = $t3Limit * 1024;
// check for PHP restrictions of the maximum size of one of the $_FILES
$phpUploadLimit = self::getBytesFromSizeMeasurement(ini_get('upload_max_filesize'));
// check for PHP restrictions of the maximum $_POST size
$phpPostLimit = self::getBytesFromSizeMeasurement(ini_get('post_max_size'));
// if the total amount of post data is smaller (!) than the upload_max_filesize directive,
// then this is the real limit in PHP
$phpUploadLimit = ($phpPostLimit < $phpUploadLimit ? $phpPostLimit : $phpUploadLimit);
// is the allowed PHP limit (upload_max_filesize) lower than the TYPO3 limit?, also: revert back to KB
return floor($phpUploadLimit < $t3Limit ? $phpUploadLimit : $t3Limit) / 1024;
}
/**
* Gets the bytes value from a measurement string like "100k".
*
* @param string $measurement: The measurement (e.g. "100k")
* @return integer The bytes value (e.g. 102400)
*/
public function getBytesFromSizeMeasurement($measurement) {
if (stripos($measurement, 'G')) {
$bytes = intval($measurement) * 1024 * 1024 * 1024;
} else if (stripos($measurement, 'M')) {
$bytes = intval($measurement) * 1024 * 1024;
} else if (stripos($measurement, 'K')) {
$bytes = intval($measurement) * 1024;
} else {
$bytes = intval($measurement);
}
return $bytes;
}
......
/*************************
*
* DEBUG helper FUNCTIONS
(2-2/2)