hi guys, could anyone help me out with this error please, on joomla music component. this appears when i click a download icon to download a specific music track.
thank you.
this is the erroe:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/4/d318289315/htdocs/jtamil/components/com_muscol/views/file/view.raw.php on line 20
Line 20 on the code:
public function display($tpl = null)
Full code:
<?php
/**
* @version 1.0.1
* @package muscol
* @copyright 2009 JoomlaMusicSolutions.com
* @license GPLv2
*/
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.path');
class ArtistsViewFile extends JView
{
public function display($tpl = null)
{
global $mainframe, $option;
$user = JFactory::getUser();
$params = &JComponentHelper::getParams( 'com_muscol' );
$id = JRequest::getInt('id');
if(!$id)
{
JError::raiseError(404, 'Page Not Found');
return;
}
if( (!$user->id && $params->get('allowsongdownload') == 1 ) || $params->get('allowsongdownload') == 0)
{
JError::raiseError(401, 'You must be logged in to download this content');
return;
}
$model =& $this->getModel('file');
//$model->hit();
$data =& $model->getData();
$fileName =& $data->filename;
$this->fileName = $fileName ;
$dirname = $params->get('songspath');
if(substr($dirname, 0, 1) == "/") $dirname = substr($dirname, 0);
if($dirname == "") $filePath = JPath::clean( JPATH_SITE.DS.$fileName );
else $filePath = JPath::clean( JPATH_SITE.DS.$dirname.DS.$fileName );
if( !JFile::exists( $filePath ) )
{
JError::raiseError(404, 'Page Not Found');
return;
}
$new = true ;
if($new){
$this->download($filePath);
die();
}
else{//old system
//$fileName = $data->get('file');
//$extension = array_pop( explode('.', $fileName) );
$extension = $data->extension ;
//$fileName = $data->get('alias').'.'.$extension;
$fileContent = JFile::read( $filePath );
$fileSize = strlen($fileContent);
require(JPATH_COMPONENT.DS.'helpers'.DS.'mime.mapping.php');
$mime = $mime_extension_map[$extension]; //application/octet-stream
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
$doc =& JFactory::getDocument();
$doc->setMimeEncoding( $mime );
//$doc->setModifiedDate( $data->get('modified') );
$doc->render();
header('Content-Disposition: attachment; filename="'.$fileName.'" ');
header('Content-Length: '. $fileSize);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Transfer-Encoding: binary');
if( ! ini_get('safe_mode') ) { // set_time_limit doesn't work in safe mode
@set_time_limit(0);
}
echo $fileContent;
}
}
function download($filePath, $inline = false)
{
// Fix [3164]
while (@ob_end_clean());
$this->mime = $this->filenameToMIME($this->fileName, false);
$fsize = @filesize($filePath);
$mod_date = date('r', filemtime( $filePath ) );
$cont_dis = $inline ? 'inline' : 'attachment';
// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
header('Content-Disposition:' . $cont_dis .';'
. ' filename="' . $this->fileName . '";'
. ' modification-date="' . $mod_date . '";'
. ' size=' . $fsize .';'
); //RFC2183
header("Content-Type: " . $this->mime ); // MIME type
header("Content-Length: " . $fsize);
if( ! ini_get('safe_mode') ) { // set_time_limit doesn't work in safe mode
@set_time_limit(0);
}
// No encoding - we aren't using compression... (RFC1945)
//header("Content-Encoding: none");
//header("Vary: none");
$this->readfile_chunked($filePath);
// The caller MUST 'die();'
}
function readfile_chunked($filename,$retbytes=true)
{
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
@ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}
function filenameToMIME($filename, $unknown = true)
{
$pos = strlen($filename) + 1;
$type = '';
$map = &$this->_getMimeExtensionMap();
for ($i = 0;
$i <= $map['__MAXPERIOD__'] &&
strrpos(substr($filename, 0, $pos - 1), '.') !== false;
$i++) {
$pos = strrpos(substr($filename, 0, $pos - 1), '.') + 1;
}
$type = $this->extToMIME(substr($filename, $pos));
if (empty($type) ||
(!$unknown && (strpos($type, 'x-extension') !== false))) {
return 'application/octet-stream';
} else {
return $type;
}
}
function extToMIME($ext)
{
if (empty($ext)) {
return 'application/octet-stream';
} else {
$ext = strtolower($ext);
$map = &$this->_getMimeExtensionMap();
$pos = 0;
while (!isset($map[$ext]) && $pos !== false) {
$pos = strpos($ext, '.');
if ($pos !== false) {
$ext = substr($ext, $pos + 1);
}
}
if (isset($map[$ext])) {
return $map[$ext];
} else {
return 'x-extension/' . $ext;
}
}
}
function &_getMimeExtensionMap()
{
static $mime_extension_map;
if (!isset($mime_extension_map)) {
require JPATH_SITE . DS . 'components' . DS . 'com_muscol' . DS . 'helpers' . DS . 'mime.mapping.php';
}
return $mime_extension_map;
}
}