Mong mọi người giúp đỡ ! em gà PHP lắm
Em vừa làm 1 web nhạc xài code Nukeviet 2.0 ! trong đó có phần Nvmusic !
hôm này vừa check thấy phần download bài hát ko thấy bắt buộc đăng nhập mới download đc tuy em đặt cấu hình chỉ member mới download đc ! nhưng khách nghe có thể download vô tư mà chẳng cần Llgin ! ! Mọi giúp xem hộ code em với
Max trên em cũng thấy Funtion download nhưng chẳng biết sửa thế nào
// download file nhac
function download() {
global $prefix, $db, $sitename, $anonlisten, $musicfolder, $nukeurl;
$id = ( isset($_GET['id']) ) ? intval($_GET['id']) : intval($_POST['id']);
if(!$id || $id==0) { die(); }
if ((defined('IS_ADMMOD')) || ($anonlisten==1) || ($anonlisten==0 AND (defined('IS_USER')))) {
if (defined('IS_ADMMOD')) {
$result = $db->sql_query("select loaifile, fileurl, mdirname FROM ".$prefix."_nvmusic where id='$id'");
}
else {
$result = $db->sql_query("select loaifile, fileurl, mdirname FROM ".$prefix."_nvmusic where id='$id' AND active='1'");
}
if ($numrows = $db->sql_numrows($result) != 1) {
die("Khong ton tai ca khuc nay");
}
$row = $db->sql_fetchrow($result);
$fileurl = stripslashes($row['fileurl']);
$ext = stripslashes($row['loaifile']);
$mdirname = intval($row['mdirname']);
if ($mdirname == 0) {
$link = $fileurl;
}
else {
list($mdir_link) = $db->sql_fetchrow($db->sql_query("select mdir_link from ".$prefix."_nvmusic_dir where id='$mdirname'"));
if ($mdirname == 1) $link = "$nukeurl/$musicfolder/$mdir_link/$fileurl"; else $link = "$mdir_link/$fileurl";
}
$db->sql_query("UPDATE ".$prefix."_nvmusic set datai=datai+1 WHERE id=$id");
$url =str_replace(" ","%20",$link);
if(eregi("".$nukeurl."",$url)) {
$lastx = strrpos($url,"/");
if ($mdirname == 1) $file_name = strtolower(substr($url,$lastx+12)); else $file_name = strtolower(substr($url,$lastx+1));
switch($ext) {
case "mp3": $ctype="audio/mp3"; break;
case "wav": $ctype="audio/x-wav"; break;
case "mpeg":
case "mpg":
case "mpe": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
case "wmv" :
case "avi": $ctype="video/x-msvideo"; break;
default: $ctype="application/force-download";
}
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Type: $ctype; name=\"".$file_name."\"");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Disposition: attachment; filename="'.$file_name.'"');
ob_start();
readfile ($url);
$size=ob_get_length();
header("Content-Length: $size");
ob_end_flush();
exit();
} else {
Header("Location: $url");
exit();
}
}
else {
die("Ban khong duoc tai file nay");
}
}
Bookmarks