Location: PHPKode > projects > injooosm > components/com_injooosm/controllers/download.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: download.php 2009-11-22 14:03:00$
 * @author Christian Knorr
 * @package injooosm
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 */


// no direct access
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.controller' );

class injooosmControllerDownload extends injooosmController  {

    function download()  {

        JRequest::checkToken() or jexit( 'Invalid Token' );

        $format =& JRequest::getVar('format');
        $model = $this->getModel('download');
        $id =& JRequest::getInt('id');
        $track = $model->getFile($id);
        $trackname = str_replace(' ', '_', $track->title);
        if($format == "kml")  {
            $mime = "application/vnd.google-earth.kml+xml";
        } else {
            $mime = "application/x-octet-stream";
        }

        header("Content-Type: ".$mime."");
        header("Content-Disposition: attachment; filename=".$trackname.".".strtolower($format));
        header("Content Transfer-Encoding:binary");
        header("Cache-Control: post-check=0, pre-check=0");

        
        echo $model->download($id, $format, $track);

    }
    
}
Return current item: injooosm