<?php
  /**************************************************************************\
  * phpGroupWare - phpgw_dj                                                  *
  * http://www.phpgroupware.org                                              *
  * Written by Miles Lott <milosch@phpgroupware.org>                         *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: download.php,v 1.2 2001/06/20 00:23:28 milosch Exp $ */

	$phpgw_info['flags'] = array(
		'currentapp'           => 'dj',
		'enable_browser_class' => True,
		'noheader'             => True,
		'nonavbar'             => True,
		'noappheader'          => True,
		'noappfooter'          => True
	);
	include('../header.inc.php');

	$sep = SEP;

	if (!$song_id)
	{
		Header("Location: " . $phpgw->link("/dj/index.php"));
		$phpgw->common->phpgw_exit();
	}
	else
	{
		$sql = "SELECT song_name FROM phpgw_dj_songlist WHERE song_id=" . $song_id;
		$phpgw->db->query($sql);
		$phpgw->db->next_record();
		$filename = $phpgw->db->f(0);

		if ($filename)
		{
			if ($fp = fopen($filename, "r"))
			{
				$content = fread($fp, filesize($filename));
				fclose($fp);
			}

			$phpgw->browser->content_header($filename,'application/octet-stream',filesize($filename));
			echo $content;
		}
	}
?>
