- chr: documentation ( source)
- microtime: documentation ( source)
- ceil: documentation ( source)
- rand: documentation ( source)
<?php
$post_max_size = 8 * 1024 * 1024;
function generateFile($filename, $width, $lines, $type = 'binary-text') {
$text = '';
$t0 = microtime(TRUE);
for ($i = 0; $i < $lines; $i++) {
// Generate $width - 1 characters to leave space for the "\n" character.
for ($j = 0; $j < $width - 1; $j++) {
switch ($type) {
case 'text':
$text .= chr(rand(32, 126));
break;
case 'binary':
$text .= chr(rand(0, 31));
break;
case 'binary-text':
default:
$text .= rand(0, 1);
break;
}
}
$text .= "\n";
$t1 = microtime(TRUE);
print "Iteration $i - " . (($t1 - $t0) * 1000) . ' ms' . "\n";
$t0 = $t1;
}
// Create filename.
$filename = '/tmp/' . $filename . '.txt';
//file_put_contents($filename, $text);
return $filename;
}
echo generateFile('exceeding_post_max_size', ceil(($post_max_size + 1024) / 1024), 1024);
This script was stopped while abusing our resources