Skip to content

Commit

Permalink
Changed if,elseif to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril Schreiber committed Mar 2, 2022
1 parent 65fb543 commit 5160cbc
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions destroyer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,32 @@
$filepath = $path . "/fd/" . $filename;

//True size
if ($unit == "kb") {
$trueSize = $rawSize * 1024;
} elseif ($unit == "mb") {
$trueSize = $rawSize * pow(1024, 2);
} elseif ($unit == "gb") {
$trueSize = $rawSize * pow(1024, 3);
switch ($unit) {
case "kb":
$trueSize = $rawSize * 1024;
break;
case "kb":
$trueSize = $rawSize * pow(1024, 2);
break;
case "kb":
$trueSize = $rawSize * pow(1024, 3);
break;
}


//echo "$filepath Raw: $rawSize True: $trueSize";

createfile($filename,$trueSize);
downloadfile($filename,$filepath);
createfile($filename, $trueSize);
downloadfile($filename, $filepath);


////////////
//Funtions//
////////////

//Create file function
function createfile($filename, $trueSize) {
function createfile($filename, $trueSize)
{
$fh = fopen($filename, 'w');
//$size = 1024 * 1024 * 10; // 10mb
$chunk = 1024;
Expand All @@ -44,10 +49,11 @@ function createfile($filename, $trueSize) {


//Download file function
function downloadfile($filename, $filepath) {
function downloadfile($filename, $filepath)
{
header('Content-Description: File Transfer');
header("Content-type: application/octet-stream");
header("Content-Length: ".filesize($filepath));
header("Content-Length: " . filesize($filepath));
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
Expand Down

0 comments on commit 5160cbc

Please sign in to comment.