<?php
##
## PHP/MP3 streaming server,download action file
##

## mp3 stream core module
##
function _download($mp3file)
{
  
$file['name'] = str_replace(array(' ','__','_-_'),'_',basename($mp3file));
  
$file['size'] = filesize($mp3file);
  
clearstatcache(); // flush buffer

  
if($fp = @fopen($mp3file,'rb'))
  {
    
header('Content-Type: application/octet-stream');
    
//header('Content-Type: file/unknown');
    
header('Content-Disposition: attachment; filename='.$file['name']);
    
header('Content-Transfer-Encoding: binary');
    
header('Content-Length: '.$file['size']); // for remain time
    
header('Connection: Close');

    
fpassthru($fp);
  }
}

## configuration ################################

ini_set('include_path','.:'.dirname(__FILE__).'/..');
require_once 
'_lib/func.globals.php';
require_once 
'_lib/func.url.php';    // for header_nocache()
require_once '_lib/func.stream.php';    // for agent_decode()
require_once '_lib/func.error.php';    // for error()
require_once '_conf/config.php';

##################################################

header_nocache();
unset(
$fname);

$pinfo explode('/',$_SERVER['PATH_INFO']);
$fname $pinfo[1];

if(!
$fname$fname $_GET['fname'];

$mp3file $_pstream['mp3dir'].'/'.agent_decode($fname);

if(!
$_pstream['download']) error('sorroy !!!');
if(!
file_exists($mp3file)) error('file not exists');

## file download
##
_download($mp3file);

$not $_not 1// don't print check microtime result
exit; // don't print any messages 
?>