Anda di halaman 1dari 3

<?

php
$user_nama = preg_replace("/([^a-zA-Z0-9\-])/",'+',$_GET['unama']);
$usite = str_replace('+','.',$user_nama);

function mime_type($file) {
$file = strtolower($file);
$mime_types = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',

// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',

// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',

// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',

// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',

// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',

// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
$typ=typefile($file);
if (array_key_exists($typ,$mime_types)) $hasil=$mime_types[$typ];
if (!array_key_exists($typ,$mime_types)) $hasil="application/octet-stream";
return $hasil;
}
$rid= naetag($_GET['file']);
$q = mysqli_query($sql, "SELECT id,path,user_nama,hits,nama FROM file_naecms WHERE
id='$rid'");
$qarr = mysqli_fetch_array($q);
$path=(empty($qarr['path'])) ? "" : $qarr['path']."/" ;
$user_nama = $qarr['user_nama'];
$fid = $qarr['id'];
$folder="data/$user_nama/filemanager/$path";
$hits=$qarr['hits'] + 1;
$name= $qarr['nama'];
$size = filesize($folder.$name);
$nama = $name;
if (empty($nama)) header('location: http://'.$du.'/error.html');
$t2 = array_reverse(explode('.',$nama));
$outnama= str_replace('.mp3','',$nama);
$tgl=time();
$file=$folder.$nama;
$type=typefile($file);
$dom = $_SERVER['HTTP_HOST'];
if ($fid) {
mysqli_query($sql, "UPDATE file_naecms SET hits='$hits' WHERE id='$rid' AND
user_nama='$user_nama' ");
}

$bs = str_replace('+','.',$user_nama);
if (preg_match("/$dom|$bs|$/",$un[0])) {
if (strip_tags($_GET['mode']) == md5($rid) && !preg_match("/(jpg|jpeg|png|gif|css|
js)/i",$nama)) {
$_SESSION['did'] = $fid;
//halaman iklan//
include 'iklan_download.php';

}
else {
if ($_SESSION['did'] != $fid && !preg_match("/(jpg|jpeg|png|gif|css|
js)/i",$type)) {
header("location:
http://dl.$du/download/".md5($rid)."/$rid/$user_nama/$outnama");
}
else {

//link download asli//


if (preg_match("/(jpg|jpeg|png|gif)/i",$type)) {
header("Content-type: $type");
header("Content-disposition:
attachment;filename=$outnama");
header('Content-Length: '.filesize($file));
readfile($file);
}
else if (preg_match("/mp3/i",$type)) {
$outnama = str_replace(' ','_',$outnama).'.mp3';
header("Content-type: $type");
header("Content-disposition:
attachment;filename=$outnama");
header('Content-Length: '.filesize($file));
readfile($file);
}
else {
header('location: http://'.$du.'/'.$folder.$outnama.'');
}
}
}
}
else {
echo 'invalid download';
}
ob_end_flush();
?>

Anda mungkin juga menyukai