download-script
style.css:
Code (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
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
* {
font-family: Geneva, Verdana, Arial, Bitstream Vera Sans, Helvetica, sans-serif;
line-height: 1.4em;
}
body, p {
font-size: 12px;
}
address {
margin-top: 24px;
}
div.Link {
text-align: right;
}
div.Link a {
padding: 6px;
margin: 12px;
border: 1px solid silver;
text-decoration: none;
background-color: #efefef;
}
div.Link a:hover {
color: red;
background-color: #cdcdcd;
}
.Library {
border: 1px solid silver;
padding: 12px;
}
.Library img {
vertical-align: middle;
border: 0px;
}
.Library a {
color: black;
text-decoration: none;
padding: 2px;
padding-left: 6px;
padding-right: 12px;
}
.Library a:hover {
color: navy;
background-color: #cdcdcd;
}
font-family: Geneva, Verdana, Arial, Bitstream Vera Sans, Helvetica, sans-serif;
line-height: 1.4em;
}
body, p {
font-size: 12px;
}
address {
margin-top: 24px;
}
div.Link {
text-align: right;
}
div.Link a {
padding: 6px;
margin: 12px;
border: 1px solid silver;
text-decoration: none;
background-color: #efefef;
}
div.Link a:hover {
color: red;
background-color: #cdcdcd;
}
.Library {
border: 1px solid silver;
padding: 12px;
}
.Library img {
vertical-align: middle;
border: 0px;
}
.Library a {
color: black;
text-decoration: none;
padding: 2px;
padding-left: 6px;
padding-right: 12px;
}
.Library a:hover {
color: navy;
background-color: #cdcdcd;
}
Index.php:
Code (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
$rootmap = "/downloadmap";
$rootmap = str_replace("../", "", $rootmap);
$rootmap = str_replace("./", "", $rootmap);
$rootmap = str_replace("/..", "", $rootmap);
$rootmap = str_replace("/../", "", $rootmap);
$rootmap = str_replace(".", "", $rootmap);
$rootmap = str_replace(chr(92), "", $rootmap);
$rootmap = str_replace("?", "", $rootmap);
if(isset($_GET["download"]))
{
if (strstr($_SERVER["HTTP_REFERER"], "yoursite.eu"))
{
if(file_exists($rootmap.$_GET['p']."/".$_GET['download']))
{
$size = filesize($rootmap.$_GET['p']."/".$_GET['download']);
header("Content-Length: $size");
header('Content-type: Application/octet-stream');
header('Content-Disposition: attachment; filename='.$_GET['download']);
readfile($rootmap.$_GET['p']."/".$_GET['download']);
}
else
{
echo "File does not exist";
}
exit();
}
else
{
echo "<h1>Antileech activated</h1>";
echo "You are not comming from: <b>www.yoursite.eu</b>";
exit();
}
}
function size($size, $retstring = null)
{
$sizes = array('Bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
if ($retstring === null)
{
$retstring = '%01.2f %s';
}
$lastsizestring = end($sizes);
foreach ($sizes as $sizestring)
{
if ($size < 1024)
{
break;
}
if ($sizestring != $lastsizestring)
{
$size /= 1024;
}
}
if ($sizestring == $sizes[0])
{
$retstring = '%01d %s';
}
return sprintf($retstring, $size, $sizestring);
}
function array_files($rootmap)
{
if (file_exists($rootmap))
{
$dir = opendir($rootmap);
}
else
{
echo "Directory does not exist.";
exit();
}
if (isset($_GET['p']) ? $_GET["p"] : "")
{
$pathEnc = str_replace("%2F", "/", rawurlencode($_GET['p']));
$page_up = substr($pathEnc, 0, strrpos($pathEnc, "/"));
echo "<tr><td><a href='index.php?p=". $page_up ."'>[Up]</a></td></tr><tr><td></td></tr><tr><td></td>";
}
while (false !== ($file = readdir($dir)))
{
if($file != "." && $file != ".." && $file != "Thumbs.db" && $file != "index.php" && $file != ".htaccess" && $file != "temp")
{
if (is_dir($rootmap."/".$file))
{
$page = $_GET['p'];
echo "<tr><td><a href='index.php?p=".$page."/".$file."'><img src='./folder.gif' alt='(x)' /> " .$file. "</a></td></tr>";
}
else
{
$size = filesize($rootmap."/".$file);
$filesize = size($size, $retstring = null);
$ext = strrchr($file, ".");
$ext = str_replace(".", "", $ext);
echo "<tr><td><a href='index.php?p=".$page."&download=".$file."'><img src='./".$ext.".gif' alt='(x)' /> ".$file."</a></td><td>FileSize: " .$filesize. "</td></tr>";
}
}
}
closedir($dir);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<titleDownload Library</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h1>Download Library</h1>
<h2><?php echo str_replace("/", " » ", $_GET['p']) ?></h2>
<div class="Link"></div>
<div class="Library">
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<?php
if(isset($_GET["p"]))
{
array_files($rootmap.$_GET["p"]);
}
else
{
array_files($rootmap);
}
?>
</table>
</div>
<address>www.yoursite.eu</address>
</body>
</html>
$rootmap = "/downloadmap";
$rootmap = str_replace("../", "", $rootmap);
$rootmap = str_replace("./", "", $rootmap);
$rootmap = str_replace("/..", "", $rootmap);
$rootmap = str_replace("/../", "", $rootmap);
$rootmap = str_replace(".", "", $rootmap);
$rootmap = str_replace(chr(92), "", $rootmap);
$rootmap = str_replace("?", "", $rootmap);
if(isset($_GET["download"]))
{
if (strstr($_SERVER["HTTP_REFERER"], "yoursite.eu"))
{
if(file_exists($rootmap.$_GET['p']."/".$_GET['download']))
{
$size = filesize($rootmap.$_GET['p']."/".$_GET['download']);
header("Content-Length: $size");
header('Content-type: Application/octet-stream');
header('Content-Disposition: attachment; filename='.$_GET['download']);
readfile($rootmap.$_GET['p']."/".$_GET['download']);
}
else
{
echo "File does not exist";
}
exit();
}
else
{
echo "<h1>Antileech activated</h1>";
echo "You are not comming from: <b>www.yoursite.eu</b>";
exit();
}
}
function size($size, $retstring = null)
{
$sizes = array('Bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
if ($retstring === null)
{
$retstring = '%01.2f %s';
}
$lastsizestring = end($sizes);
foreach ($sizes as $sizestring)
{
if ($size < 1024)
{
break;
}
if ($sizestring != $lastsizestring)
{
$size /= 1024;
}
}
if ($sizestring == $sizes[0])
{
$retstring = '%01d %s';
}
return sprintf($retstring, $size, $sizestring);
}
function array_files($rootmap)
{
if (file_exists($rootmap))
{
$dir = opendir($rootmap);
}
else
{
echo "Directory does not exist.";
exit();
}
if (isset($_GET['p']) ? $_GET["p"] : "")
{
$pathEnc = str_replace("%2F", "/", rawurlencode($_GET['p']));
$page_up = substr($pathEnc, 0, strrpos($pathEnc, "/"));
echo "<tr><td><a href='index.php?p=". $page_up ."'>[Up]</a></td></tr><tr><td></td></tr><tr><td></td>";
}
while (false !== ($file = readdir($dir)))
{
if($file != "." && $file != ".." && $file != "Thumbs.db" && $file != "index.php" && $file != ".htaccess" && $file != "temp")
{
if (is_dir($rootmap."/".$file))
{
$page = $_GET['p'];
echo "<tr><td><a href='index.php?p=".$page."/".$file."'><img src='./folder.gif' alt='(x)' /> " .$file. "</a></td></tr>";
}
else
{
$size = filesize($rootmap."/".$file);
$filesize = size($size, $retstring = null);
$ext = strrchr($file, ".");
$ext = str_replace(".", "", $ext);
echo "<tr><td><a href='index.php?p=".$page."&download=".$file."'><img src='./".$ext.".gif' alt='(x)' /> ".$file."</a></td><td>FileSize: " .$filesize. "</td></tr>";
}
}
}
closedir($dir);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<titleDownload Library</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h1>Download Library</h1>
<h2><?php echo str_replace("/", " » ", $_GET['p']) ?></h2>
<div class="Link"></div>
<div class="Library">
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<?php
if(isset($_GET["p"]))
{
array_files($rootmap.$_GET["p"]);
}
else
{
array_files($rootmap);
}
?>
</table>
</div>
<address>www.yoursite.eu</address>
</body>
</html>