Added Google Docs Viewer

This commit is contained in:
Prasath Mani 2018-11-02 17:48:54 +05:30
parent 9b5e70587e
commit 07151e1643
2 changed files with 25 additions and 2 deletions

View file

@ -4,6 +4,9 @@ It is a simple, fast and small file manager with single php file. It is also a w
## Demo
<a href="https://tinyfilemanager.herokuapp.com" target="_blank">tinyfilemanager.herokuapp.com</a>
Login Details : admin/admin | user/12345
## Documents
<a href="https://tinyfilemanager.github.io/" target="_blank">tinyfilemanager.github.io</a>
<hr>
@ -50,6 +53,7 @@ To enable/disable authentication set $use_auth to true or false.
<li>:sunglasses: Support user permissions - based on session and each user root folder mapping</li>
<li>:floppy_disk: Copy direct file URL</li>
<li>:pencil2: Edit text formats file using advanced editor</li>
<li>:page_facing_up: Google Drive viewer helps you preview PDF/DOC/XLS/PPT/etc. 25 MB can be previewed with the Google Drive viewer</li>
<li>:zap: Backup files</li>
<li>:mag_right: Search - Advanced Ajax based seach</li>
<li>:file_folder: Exclude folders from listing</li>

View file

@ -64,6 +64,9 @@ $upload_extensions = ''; // 'gif,png,jpg'
//Array of files and folders excluded from listing
$GLOBALS['exclude_items'] = array();
//Google Docs Viewer
$GLOBALS['online_viewer'] = true;
// include user config php file
if (defined('FM_CONFIG') && is_file(FM_CONFIG)) {
include(FM_CONFIG);
@ -845,12 +848,16 @@ if (isset($_GET['view'])) {
$is_audio = false;
$is_video = false;
$is_text = false;
$is_onlineViewer = false;
$view_title = 'File';
$filenames = false; // for zip
$content = ''; // for text
if ($ext == 'zip') {
if($GLOBALS['online_viewer'] && in_array($ext, fm_get_onlineViewer_exts())){
$is_onlineViewer = true;
}
elseif ($ext == 'zip') {
$is_zip = true;
$view_title = 'Archive';
$filenames = fm_get_zif_info($file_path);
@ -941,7 +948,10 @@ if (isset($_GET['view'])) {
<b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-chevron-circle-left"></i> Back</a></b>
</p>
<?php
if ($is_zip) {
if($is_onlineViewer) {
// Google docs viewer
echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
} elseif ($is_zip) {
// ZIP content
if ($filenames !== false) {
echo '<code class="maxheight">';
@ -1974,6 +1984,15 @@ function fm_get_text_names()
);
}
/**
* Get audio files extensions
* @return array
*/
function fm_get_onlineViewer_exts()
{
return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar');
}
/**
* Class to work with zip files (using ZipArchive)
*/