forked from swagkarna/Rafel-Rat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unzip.php
64 lines (52 loc) · 1.86 KB
/
unzip.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Income Pitbull - Quick UnZipper
* Place this in the same directory of the zip file. Then go to the file in your browser, enter the file name in the textbox, and hit "Unzip".
* For security reasons, this only is allowed to run inside it's own current directory....
* It is recommended to delete this file After use. .
*/
$curdir = dirname(__FILE__) . "/";
$status = "";
if ( isset($_POST['file']) )
{
$path = $curdir;
$file = basename($_POST['file']);
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ( (strpos($file, "/") !== false) || (strpos($file, "..") !== false) ) {
$status = "<strong>Error:</strong> You must stay within this directory. Slashes and other chars are blocked for security reasons!";
} elseif ( $ext !== "zip" ) {
$status = "<strong>Error:</strong> The file extension must be a 'zip' file!";
} else {
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$zip->extractTo($path);
$zip->close();
$status = "<strong>Success:</strong> '$file' extracted to '$path'.";
} else {
$status = "<strong>Error:</strong> Could not extract '$file'.";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div style="border:1px solid black;width:600px; margin: 30px auto; padding:10px 5px 20px 5px; text-align:center;font-family:Arial, Verdana;">
<h1 style="font-size:16px;font-weight:900;font-family: Arial, Verdana;text-decoration:underline;">Income Pitbull Quick Unzipper</h1>
<?php
if ( isset($status) && ! empty($status) ) {
echo '<p align="center">' . $status . '</p>';
}
?>
<form name="unzipform" action="" method="post">
<label for="file">Filename:</label>
<input type="text" name="file" placeholder="filename.zip" style="padding-left:4px;" />
<button>Unzip</button>
</form>
</div>
</body>
</html>