Your IP : 216.73.216.41


Current Path : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/preview/
Upload File :
Current File : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/preview/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 EasyFolderListingProViewPreview extends JViewLegacy
{
	protected $abspath = '';
	protected $filename = '';
	protected $extension = '';
	protected $previewer = 'google';
	
	/**
	 * 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_PREVIEW_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);
		
		//Note: the 'expires' element is ignored for previewing
		if ($file_data)
		{
			$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.= $file_data['relpath'].'/'.$file_data['filename'].'.'.$file_data['ext'];
			$path = ValorUtilities::changeSlashes($path);
			
			$doNotLog = JFactory::getApplication()->input->get('nolog', false, 'bool');
			
			//register the preview hit in the database
			if ($doNotLog == false)
			{
				$myModel->logPreviewHit($path, $file_data['userid'], $ip);
			}
			
			//assign the file name and extension
			$this->filename = $file_data['filename'];
			$this->extension = $file_data['ext'];
			
			//assign the previewer
			if (!empty($file_data['previewer']))
			{
				$this->previewer = $file_data['previewer'];
			}
		}
		
		return $path;
	}
}