Location: PHPKode > scripts > AmaroK Web Frontend > obsidianmusic-2.3.0/pages/stream.php
<?php

//
//  ObsidianMusic
//   a.k.a. amaroK Web Frontend 2.0
//
//  Created 1/3/06
//   Copyright (C) Ryan Loebs (ObsidianX) 2005/2006
//   See LICENSE for GPL
//
//  stream.php - Actually streams the music to the user
//
///////////////////////////////////////

if(eregi("stream.php", $_SERVER['PHP_SELF'])){
	die("Cannot access directly.");
}


if(isset($_GET['sid'])) {
	$q = query(getquery("getfile", "", (int)$_GET['sid']));
	$res = fetch_assoc($q);
}
elseif(isset($_GET['song_id'])) {
	$q = query(getquery("getfile_id", "", (int)$_GET['song_id']));
	$res = fetch_assoc($q);
}
else {
	die();
}


$url = $res['rpath'];

$artistnr = $res['artist'];
$qa = query(getquery("arname", 'song', $artistnr));
$artist = fetch_assoc($qa);

if($res['deviceid'] > 0) {
	$devid = $res['deviceid'];
	$qd = query(getquery("getdevice", "", $devid));
	$resd = fetch_assoc($qd);
	
	$url = $resd['lastmountpoint'].ltrim($url, '.');
}
else {
	$url = ltrim($url, '.');
}

$ext = explode(".", $url);


if(is_file($url)) {
	header("Content-disposition: inline; filename=$artist[name] - $res[title]");
	header("Content-transfer-encoding: binary");
	
	if(ereg("((M|m)(P|p)(((G|g)|(3))|((E|e)(G|g))))", end($ext))){
		header("Content-type: audio/mpeg");
	}else if(ereg("(O|o)(G|g){2}", end($ext))){
		header("Content-type: application/ogg");
	}
	
	echo file_get_contents($url);
}
else {
	echo "File not found: $url";
}


Return current item: AmaroK Web Frontend