| Current Path : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/preview/tmpl/ |
| Current File : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/preview/tmpl/default.php |
<?php
/**
* @version 3.2.10
* @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/>.
*/
/*
Google Docs supports over 15 different file types, listed below:
Microsoft Word (.DOC and .DOCX)
Microsoft Excel (.XLS and .XLSX)
Microsoft PowerPoint (.PPT and .PPTX)
Adobe Portable Document Format (.PDF)
Apple Pages (.PAGES)
Adobe Illustrator (.AI)
Adobe Photoshop (.PSD)
Tagged Image File Format (.TIFF)
Autodesk AutoCad (.DXF)
Scalable Vector Graphics (.SVG)
PostScript (.EPS, .PS)
TrueType (.TTF)
XML Paper Specification (.XPS)
Archive file types (.ZIP and .RAR)
*/
/**
* NOTE: Preview ignores Access Level. So, it creates a security hole for accessing any
* file regardless of user access level.
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
ob_end_clean();
if (empty($this->abspath) || empty($this->filename))
{
exit(0); /* Can't preview a non-existent file. Bye */
}
if ($this->previewer == 'google' && stripos(EFLPListing::GOOGLE_PREVIEW_EXTS, $this->extension) === false)
{
exit(0); /* Can't preview files other than expected files. Bye */
}
elseif ($this->previewer == 'native' && stripos(EFLPListing::BROWSER_PREVIEW_EXTS, $this->extension) === false)
{
exit(0); /* Can't preview files other than expected files. Bye */
}
elseif ($this->previewer != 'none' && $this->previewer != 'native' && $this->previewer != 'google')
{
exit(0); /* Previewer must be set to none if you want to preview any file. Bye */
}
$mime = '';
//find the mime type of previewer is none
if ($this->previewer == 'none')
{
$mime = ValorUtilities::actualMIME($this->abspath);
}
if (empty($mime))
{
switch ($this->extension)
{
case 'doc': $mime = 'application/msword'; break;
case 'docx': $mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; break;
case 'xls': $mime = 'application/vnd.ms-excel'; break;
case 'xlsx': $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; break;
case 'ppt': $mime = 'application/vnd.ms-powerpoint'; break;
case 'pptx': $mime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; break;
case 'pdf': $mime = 'application/pdf'; break;
case 'pages': $mime = 'application/x-iwork-pages-sffpages'; break;
case 'ai': $mime = 'application/illustrator'; break;
case 'psd': $mime = 'application/photoshop'; break;
case 'tiff': $mime = 'image/tiff'; break;
case 'dxf': $mime = 'application/dxf'; break;
case 'svg': $mime = 'image/svg+xml'; break;
case 'eps':
case 'ps': $mime = 'application/postscript'; break;
case 'ttf': $mime = 'application/x-font-ttf'; break;
case 'xps': $mime = 'application/vnd.ms-xpsdocument'; break;
case 'zip': $mime = 'application/zip'; break;
case 'rar': $mime = 'application/x-rar-compressed'; break;
case 'gif': $mime = 'image/gif'; break;
case 'png': $mime = 'image/png'; break;
case 'jpeg':
case 'jpg': $mime = 'image/jpg'; break;
case 'bmp': $mime = 'image/bmp'; break;
case 'mp3': $mime = 'audio/mpeg'; break;
default: $mime = 'application/octet-stream';
}
}
/*
* Implemented PHP Pseudo Streaming
* Source: http://www.tuxxin.com/php-mp4-streaming/
*/
$fp = @fopen($this->abspath, 'rb');
$size = filesize($this->abspath); // File size
$length = $size; // Content length
$start = 0; // Start byte
$end = $size - 1; // End byte
header('Content-type: '.$mime);
header("Accept-Ranges: bytes");
if (isset($_SERVER['HTTP_RANGE']))
{
$c_start = $start;
$c_end = $end;
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
if (strpos($range, ',') !== false)
{
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit(0);
}
if ($range == '-')
{
$c_start = $size - substr($range, 1);
}
else
{
$range = explode('-', $range);
$c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
}
$c_end = ($c_end > $end) ? $end : $c_end;
if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size)
{
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit(0);
}
$start = $c_start;
$end = $c_end;
$length = $end - $start + 1;
fseek($fp, $start);
header('HTTP/1.1 206 Partial Content');
}
header("Content-Range: bytes $start-$end/$size");
header("Content-Length: ".$length);
$buffer = 1024 * 8;
while(!feof($fp) && ($p = ftell($fp)) <= $end)
{
if ($p + $buffer > $end)
{
$buffer = $end - $p + 1;
}
set_time_limit(0);
echo fread($fp, $buffer);
flush();
}
fclose($fp);
exit(0);