-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompress.php
executable file
·30 lines (30 loc) · 1.07 KB
/
compress.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<link rel="stylesheet" href="./styles/stylesheet.css" type="text/css" />
<div id="logo">
<center><a href='./index.php'><img src="./styles/images/logo.png"></a></center>
</div><br>
<?php
require_once ("./includes/functions.php");
$startingbyte = $_GET['sbytes'];
$length = "52428800"; //50 MB in bytes
$endbyte = $startingbyte + $length;
$filename = $_GET['name'];
$filesize = filesize($filename);
//Compression complete
if ($startingbyte > $filesize) {
unlink($filename);
echo "<font color='green'><b>Compression Complete!</b></font><br><br>";
echo "<script>window.location = '$filename.gz';</script>";
} else {
echo "Compression status:<br><progress max='$filesize' value='$endbyte'></progress>";
$openfile = fopen($filename, "r");
//Place file pointer
fseek($openfile, $startingbyte);
$readfile = fread($openfile, $length);
$gzfile = "$filename.gz";
$gzop = gzopen($gzfile, 'a9');
gzwrite($gzop, $readfile);
gzclose($gzop);
fclose($openfile);
echo "<script>window.location = 'compress.php?sbytes=$endbyte&name=$filename';</script>";
}
?>