| Current Path : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/download/ |
| Current File : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/download/view.raw.php |
<?php
/**
* @version 3.2
* @author Michael A. Gilkes (michael@valorapps.com)
* @copyright Michael Albert Gilkes
* @license GNU/GPLv3
Easy Folder Listing Pro Component for Joomla!
Copyright (C) 2012-2016 Michael Albert Gilkes (Valor Apps)
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once(JPATH_SITE.'/components/com_easyfolderlistingpro/helpers/EFLPListing.Class.php');
jimport('joomla.filesystem.file');
class EasyFolderListingProViewDownload extends JViewLegacy
{
protected $abspath = '';
protected $filename = '';
protected $extension = '';
protected $attachment = '';
/**
* Overwriting JView display method
*/
function display($tpl = null)
{
//Load data from the request
$data = JFactory::getApplication()->input->get('data', '', 'raw');
//if no data exists. log the error
if (empty($data))
{
JLog::add(JText::sprintf('COM_EFLP_DOWNLOAD_NODATA_ERROR', ValorUtilities::getUserIP()), JLog::ALERT, 'com_easyfolderlistingpro');
}
else
{
$this->abspath = $this->processData($data);
}
parent::display($tpl);
}
/**
* Decode the data. Deconstruct the file data. Log the preview hit. Format the absolute
* path for preview.
*/
protected function processData($data)
{
//stores the absolute path
$path = '';
$file_data = ValorUtilities::elucidate($data);
if ($file_data)
{
//define the relative path to the file
$relfilepath = $file_data['relpath'].'/'.$file_data['filename'].'.'.$file_data['ext'];
//define the current time
$now = time();
//make sure the expires is the integer type
$file_data['expires'] = (int)$file_data['expires'];
//Check to see of the link hasn't expired
if ($file_data['expires'] !== 0 && $file_data['expires'] < $now)
{
JLog::add(JText::sprintf('COM_EFLP_DOWNLOAD_EXPIRED_ERROR', ValorUtilities::getUserIP(), $relfilepath), JLog::ALERT, 'com_easyfolderlistingpro');
return $path; //bye
}
$myModel = $this->getModel();
//get the IP
$ip = ValorUtilities::getUserIP();
//put together the file path
$path = ValorUtilities::compilePath($file_data['folder'], $file_data['userfolders'], $file_data['guestfolder'], $file_data['username']);
$path.= $relfilepath;
$path = ValorUtilities::changeSlashes($path);
//register the download hit in the database
$myModel->logDownloadHit($path, $file_data['userid'], $ip);
//assign the file name and extension
$this->filename = $file_data['filename'];
$this->extension = $file_data['ext'];
//assign the attachment
if ($file_data['attachment'])
{
$this->attachment = 'attachment';
}
else
{
$this->attachment = 'inline';
}
}
return $path;
}
}