-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathecho-zip.php
43 lines (43 loc) · 917 Bytes
/
echo-zip.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
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$inputdata = fopen("php://input", "r");
$s = "";
$k = 0;
while ($data = fread($inputdata, 1024)) {
$s .= $data;
$k++;
if ($k == 200) {
header("HTTP/1.0 403 Forbidden");
exit();
}
}
fclose($inputdata);
$dir = opendir("c:/www/zip");
$files = array();
while ($file = readdir($dir)) {
if ($file != "." && $file !="..") {
$files[filemtime($file)] = $file;
}
}
closedir($dir);
krsort($files);
$fnum = 0;
foreach($files as $file) {
if ($fnum > 10) {
unlink($file);
}
$fnum++;
}
$param = array();
parse_str($_SERVER['QUERY_STRING'], $param);
$sname = uniqid()."-".$param['filename'];
$name = "/zip/".$sname;
$outputdata = fopen("c:/www".$name, "w");
fwrite($outputdata, $s);
fclose($outputdata);
?>
<html>
<body>
<p>Thank you for posting a file which has been named "<?php echo $sname; ?>"</p>
<a href="<?php echo $name; ?>">Your file</a>
</body>
</html>