放入文件夹 成员中, 创建新的文件夹 文件 ,将所有歌曲移到此处,创建新的 .htaccess 文件,并添加以下行:
Order Deny,AllowDeny from all
进入文件夹 成员, 创建文件 get_song.php 并添加以下代码:
if( !empty( $_GET['name'] ) ){ // check if user is logged if( is_logged() ) { $song_name = preg_replace( '#[^-w]#', '', $_GET['name'] ); $song_file = "{$_SERVER['document_ROOT']}/members/files/{$song_name}.mp3"; if( file_exists( $song_file ) ) { header( 'Cache-Control: public' ); header( 'Content-Description: File Transfer' ); header( "Content-Disposition: attachment; filename={$song_file}" ); header( 'Content-Type: application/mp3' ); header( 'Content-Transfer-Encoding: binary' ); readfile( $song_file ); exit; } }}die( "ERROR: invalid song or you don't have permissions to download it." );现在,您可以使用此URL来获取歌曲文件: http : _//mysite.com/members/get_song.php?name=my-
song-
_name



