-
Notifications
You must be signed in to change notification settings - Fork 0
/
downlot.php
45 lines (40 loc) · 1.59 KB
/
downlot.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
<?php
include "config/koneksi.php";
$direktori = "files/"; // folder tempat penyimpanan file yang boleh didownload
$filename = $_GET['file'];
$file_extension = strtolower(substr(strrchr($filename,"."),1));
switch($file_extension){
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "rar": $ctype="application/rar"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/proses";
}
if ($file_extension=='php'){
echo "<h1>Access forbidden!</h1>
<p>Maaf, file yang Anda download sudah tidak tersedia atau filenya (direktorinya) telah diproteksi. <br />
Silahkan hubungi <a href='mailto:[email protected]'>webmaster</a>.</p>";
exit;
}
else{
mysql_query("update download set hits=hits+1 where nama_file='$filename'");
header("Content-Type: octet/stream");
header("Pragma: private");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($direktori.$filename));
readfile("$direktori$filename");
exit();
}
?>