First commit

This commit is contained in:
2025-02-28 08:45:43 +01:00
commit 1f4e772600
1122 changed files with 74621 additions and 0 deletions

View File

@ -0,0 +1,392 @@
<?php
if (preg_match('#/filebrowser/classes/filebrowser.php#i',$_SERVER['SCRIPT_NAME']))
{
die('no direct access');
}
/* utf-8 marker: äöü */
class CMSimpleFileBrowser {
var $linkPrefix = '';
var $browseBase = '';
var $baseDirectory;
var $currentDirectory;
var $linkType;
var $folders = array();
var $files = array();
var $baseDirectories = array();
var $allowedExtensions = array();
var $maxFilesizes = array();
var $view;
var $message = '';
var $browserPath = '';
function __construct() {
global $pth, $plugin_cf, $cf, $userfiles_path, $userfiles_path_images, $userfiles_path_downloads, $userfiles_path_media;
/*
$image_extensions = array();
$temp = explode(',', $cf['filebrowser']['extensions_images']);
foreach ($temp as $ext) {
$extension = trim($ext, ' ./');
if ((bool) $extension) {
$image_extensions[] = strtolower($extension);
}
}
$download_extensions = array();
$temp = explode(',', $cf['filebrowser']['extensions_downloads']);
foreach ($temp as $ext) {
$extension = trim($ext, ' ./');
if ((bool) $extension) {
$download_extensions[] = strtolower($extension);
}
}
$media_extensions = array();
$temp = explode(',', $cf['filebrowser']['extensions_media']);
foreach ($temp as $ext) {
$extension = trim($ext, ' ./');
if ((bool) $extension) {
$media_extensions[] = strtolower($extension);
}
}
*/
$userfiles_extensions = array();
$temp = explode(',', $cf['filebrowser']['extensions_userfiles']);
foreach ($temp as $ext) {
$extension = trim($ext, ' ./');
if ((bool) $extension) {
$userfiles_extensions[] = strtolower($extension);
}
}
$this->browserPath = $pth['folder']['plugins'] . basename(dirname(dirname(__FILE__))) . '/';
$this->view = new CMSimpleFileBrowserView();
$this->baseDirectories['images'] = $userfiles_path_images;
$this->baseDirectories['downloads'] = $userfiles_path_downloads;;
$this->baseDirectories['userfiles'] = $userfiles_path;
$this->baseDirectories['media'] = $userfiles_path_media;
$this->allowedExtensions['images'] = $userfiles_extensions;
$this->allowedExtensions['downloads'] = $userfiles_extensions;
$this->allowedExtensions['userfiles'] = $userfiles_extensions;
$this->allowedExtensions['media'] = $userfiles_extensions;
}
function fileIsLinked($file) {
global $h, $c, $u;
$i = 0;
$usages = array();
foreach ($c as $page) {
if (preg_match('#<.*(src|href|download)=["|\'].*' . $file . '["|\'].*>#i', $page) > 0) {
$usages[] = '<a href="?' . $u[$i] . '">' . $h[$i] . '</a>';
}
$i++;
}
$usages = array_unique($usages);
if (count($usages) > 0) {
return $usages;
}
return false;
}
function readDirectory() {
$dir = $this->browseBase . $this->currentDirectory;
$this->files = array();
$handle = opendir($dir);
if ($handle) {
while (false !== ($file = readdir($handle))) {
if (strpos($file, '.') === 0) {
continue;
}
if (is_dir($dir . $file)) {
$this->folders[] = $this->currentDirectory . $file;
continue;
}
if ($this->isAllowedFile($file)) {
$this->files[] = $file;
}
}
closedir($handle);
natcasesort($this->folders);
natcasesort($this->files);
}
}
function getFolders($directory) {
$folders = array();
$handle = opendir($directory);
if ($handle) {
while (false !== ($file = readdir($handle))) {
if (strpos($file, '.') === 0) {
continue;
}
if (is_dir($directory . $file)) {
$folders[] = str_replace($this->browseBase, '', $directory . $file);
foreach ($this->getFolders($directory . $file . '/') as $subfolder) {
$folders[] = $subfolder;
}
}
}
closedir($handle);
natcasesort($folders);
}
return $folders;
}
function isAllowedFile($file) {
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if ($extension == $file) {
return false;
}
if (!in_array($extension, $this->allowedExtensions[$this->linkType])
&& !in_array('*', $this->allowedExtensions[$this->linkType])) {
return false;
}
return true;
}
function foldersArray($all = true) {
$folders = array();
$temp = $this->getFolders($this->browseBase . $this->baseDirectory);
$baseDepth = count(explode('/', $this->baseDirectory)) - 2;
foreach ($temp as $i => $folder) {
$ar = explode('/', $folder);
$level = count($ar);
$parent = '';
for ($i = 0; $i < $level - 1; $i++) {
$parent .= '/' . $ar[$i];
}
$parent = substr($parent, 1);
$folders[$folder]['level'] = count($ar) - $baseDepth;
$folders[$folder]['parent'] = $parent;
$folders[$folder]['children'] = array();
$linkList = '';
}
foreach ($folders as $folder => $data) {
$folders[$folder]['children'] = $this->gatherChildren($folder, $folders);
}
$this->view->currentDirectory = $this->currentDirectory;
foreach ($folders as $folder => $data) {
$folders[$folder]['linkList'] = $this->view->folderLink($folder, $folders);
}
return $folders;
}
function gatherChildren($parent, $folders) {
$children = array();
foreach ($folders as $key => $folder) {
if ($folder['parent'] == $parent) {
$children[] = $key;
}
}
return $children;
}
function deleteFile($file) {
$file = $this->browseBase . $this->currentDirectory . basename($file);
if (is_array($this->fileIsLinked($file)))
{
$this->view->message .= '<div class="cmsimplecore_warning"><p>';
$this->view->error('error_not_deleted', $file);
$this->view->message .= '</p><p>';
$this->view->error('error_file_is_used', $file);
$this->view->message .= '</p>';
foreach ($this->fileIsLinked($file) as $page)
{
$this->view->message .= '<ul style="font-weight: 300;"><li>' . $page . '</li>';
}
$this->view->message .= '</ul></div>';
return;
}
if (unlink($file)) {
$this->view->success('success_deleted', $file);
} else {
$this->view->error('error_not_deleted', $file);
}
}
function uploadFile()
{
$file = $_FILES['fbupload'];
$dir = explode('/',$this->currentDirectory);
if (isset($this->maxFilesizes[$dir[1]]))
{
if ($file['size'] > $this->maxFilesizes[$dir[1]]) {
$this->view->message.= '<p class="cmsimplecore_warning" style="text-align: center;">';
$this->view->error('error_not_uploaded', $file['name']);
$this->view->error('error_file_too_big', array(number_format($file['size']/1000, 2), number_format($this->maxFilesizes[$dir[1]]/1000, 2)));
$this->view->message.= '</p>';
return;
}
}
if ($file['error'] != 0)
{
$this->view->error('error_not_uploaded', $file['name']);
return;
}
$filename = $this->browseBase . $this->currentDirectory . basename($file['name']);
if (file_exists($filename))
{
$this->view->message.= '<p class="cmsimplecore_warning" style="text-align: center;">';
$this->view->error('error_not_uploaded', $file['name']);
$this->view->error('error_file_already_exists', $filename);
$this->view->message.= '</p>';
return;
}
if ($this->isAllowedFile($file['name']) == false)
{
$this->view->message.= '<p class="cmsimplecore_warning" style="text-align: center;">';
$this->view->error('error_not_uploaded', $file['name']);
$this->view->error('error_no_proper_extension', pathinfo($file['name'], PATHINFO_EXTENSION));
$this->view->message.= '</p>';
return;
}
if (move_uploaded_file($_FILES['fbupload']['tmp_name'], $filename))
{
chmod($filename, 0666);
$this->view->success('success_uploaded', $file['name']);
return;
}
$this->view->error('error_not_uploaded', $file['name']);
}
function createFolder()
{
$folder = basename($_POST['createFolder']);
$folder = str_replace(array(':', '*', '?', '"', '<', '>', '|', '.'), '', $folder);
$folder = str_replace(array(' ', ' ', ' ', ' ', ' '), '_', $folder);
$folder = $this->browseBase . $this->currentDirectory . $folder;
if (is_dir($folder))
{
$this->view->error('error_folder_already_exists', basename($folder));
return;
}
if (!mkdir($folder))
{
$this->view->error('error_unknown');
}
$this->view->success('success_folder_created', basename($folder));
chmod($folder, 0777);
return;
}
function deleteFolder() {
$folder = $this->browseBase . $this->currentDirectory . basename($_POST['folder']);
if (!rmdir($folder)) {
$this->view->error('error_not_deleted', basename($folder));
return;
}
$this->view->success('success_deleted', basename($folder));
return;
}
function renameFile() {
$newName = str_replace(array('..', '<', '>', ':', '?'), '', basename($_POST['renameFile']));
$newName = str_replace(array(' ', ' ', ' ', ' ', ' '), '_', $newName);
$oldName = $_POST['oldName'];
if ($oldName == $newName) {
return;
}
if (pathinfo($newName, PATHINFO_EXTENSION) !== pathinfo($oldName, PATHINFO_EXTENSION)) {
$this->view->message = 'You can not change the file extension!';
return;
}
if (file_exists($this->browseBase . $this->currentDirectory . '/' . $newName)) {
$this->view->error('error_file_already_exists', $newName);
return;
}
if (is_array($this->fileIsLinked($oldName))) {
$this->view->error('error_cant_rename', $oldName);
$this->view->error('error_file_is_used', $oldName);
foreach ($this->fileIsLinked($oldName) as $page) {
$this->view->message .= '<li>' . $page . '</li>';
}
$this->view->message .= '</ul>';
return;
}
if (rename($this->browseBase . $this->currentDirectory . '/' . $oldName, $this->browseBase . $this->currentDirectory . '/' . $newName)) {
$this->view->message = 'Renamed ' . $oldName . ' to ' . $newName . '!';
return;
}
$this->view->message = 'Something went wrong (CMSimpleFileBrowser::renameFile())';
return;
}
function render($template) {
$template = str_replace(array('.', '/', '\\', '<', ' '), '', $template);
if (!file_exists($this->browserPath . 'tpl/' . $template . '.html')) {
return "<p>CMSimpleFileBrowser::render() - Template not found: {$this->browserPath}tpl/$template.html'</p>";
}
$this->view->baseDirectory = $this->baseDirectory;
// $this->view->basePath = '';
$this->view->baseLink = $this->linkType;
$this->view->folders = $this->foldersArray();
$this->view->subfolders = $this->folders;
$this->view->files = $this->files;
return $this->view->loadTemplate($this->browserPath . 'tpl/' . $template . '.html');
}
function setLinkParams($paramsString) {
$this->view->linkParams = $paramsString;
}
function setLinkPrefix($prefix) {
$this->view->linkPrefix = $prefix;
}
function setBrowseBase($path) {
$this->browseBase = $path;
$this->view->basePath = $path;
}
function setBrowserPath($path) {
$this->view->browserPath = $path;
}
function setMaxFileSize($folder = '', $bytes = 0) {
if (key_exists($folder, $this->baseDirectories)){
$this->maxFilesizes[$folder] = (int) $bytes;
}
}
}
?>

View File

@ -0,0 +1,535 @@
<?php
if (preg_match('#/filebrowser/classes/filebrowser_view.php#i',$_SERVER['SCRIPT_NAME']))
{
die('no direct access');
}
/* utf-8 marker: äöü */
class CMSimpleFileBrowserView
{
var $partials = array();
var $browserPath = '';
var $basePath;
var $baseDirectory;
var $baseLink;
var $currentDirectory;
var $linkParams;
var $linkPrefix;
var $folders;
var $subfolders;
var $files;
var $message = '';
var $lang = array();
function __construct()
{
global $sl, $pth, $plugin_tx, $tx;
$lang = array();
// Own language files for subsites
if(file_exists('./languages/' . basename($sl) . '.php'))
{
$langFile = './languages/';
}
else
{
$langFile = $pth['folder']['cmsimple'] . 'languages/';
}
$langFile .= file_exists($langFile . $sl . '.php') ? $sl . '.php' : 'en.php';
include_once $langFile;
$this->lang = $tx['filebrowser'];
}
function folderList($folders)
{
global $tx, $plugin_tx, $adm, $subsite_folder;
// $title = $this->baseLink === 'images' ? 'Bilder' : 'Downloads';
if($adm == '')
{
$title = ucfirst($tx['title'][$this->baseLink]) ? $tx['title'][$this->baseLink] : ucfirst($tx['title']['userfiles'] . ' ' . $this->translate('folder')); // für Editorbrowser
}
else
{
$title = ucfirst($tx['title'][$this->baseLink]) ? $tx['title']['userfiles'] : ucfirst($tx['title']['userfiles'] . ' ' . $this->translate('folder')); // für CMS Browser
}
$html = '
<ul>
<li class="openFolder">
<a href="?' . $this->linkParams . '">' . $title . ' ' . $tx['filebrowser']['folder'] . '</a>
<ul>';
foreach ($folders as $folder => $data)
{
if ($data['level'] == 2)
{
$html .= $data['linkList'];
}
}
$html .='
</ul>
</li>
</ul>';
return $html;
}
function folderLink($folder, $folders)
{
global $subsite_folder;
$link = $_SESSION['fb_sn'];
if(!defined('CMSIMPLE_VERSION'))
{
$link = str_replace($_SESSION['subsite_folder'],'',$_SESSION['fb_sn']);
$link.='plugins/filebrowser/editorbrowser.php';
}
$class = 'folder';
if (substr($this->currentDirectory, 0, strlen($folder)) == $folder)
{
$class = 'openFolder';
}
$temp = explode('/', $folder);
$html = "\n" . '
<li class="' . $class . '">
<a href="?' . $this->linkParams . '&subdir=' . $folder . '/">' . end($temp) . '</a>';
if (count($folders[$folder]['children']) > 0)
{
if (substr($this->currentDirectory, 0, strlen($folder)) !== $folder)
{
$class = 'unseen';
}
$html .= '
<ul class="' . $class . '">';
foreach ($folders[$folder]['children'] as $child)
{
$html .= $this->folderLink($child, $folders);
}
$html .= '
</ul>';
}
$html .= '
</li>';
return $html;
}
function subfolderList($folders)
{
global $csrfSession;
$html = '';
if (is_array($folders) && count($folders) > 0)
{
$html = '<ul>';
foreach ($folders as $folder)
{
$name = str_replace($this->currentDirectory, '', $folder);
$html .= '
<li class="folder">
<form style="display: inline;" method="POST" action="" onsubmit="return confirmFolderDelete(\'' . $this->translate('confirm_delete', $this->basePath . $folder) . '\');">
<input type="hidden" name="csrf_token" value="' . $_SESSION['csrf_token' . $_SESSION['fb_snForCsrf']] . '">
<input type="image" src="' . $this->browserPath . 'icons/delete.gif" alt="delete" title="delete folder" style="float: left; margin-right: 8px;" />
<input type="hidden" name="deleteFolder" />
<input type="hidden" name="folder" value="' . $folder . '" />
</form>
<a href="?' . $this->linkParams . '&subdir=' . $folder . '/">' . $name . '</a></li>';
}
$html .= '</ul>
';
}
return $html;
}
function fileList($files)
{
global $cf, $images, $csrfSession;
if(isset($_SESSION['fb_view']) && $_SESSION['fb_view'] == 'list')
{
$html = '
<ul class="fb_files_list">';
}
else
{
$html = '
<ul>';
}
$i = 0;
foreach ($files as $file)
{
if(isset($_SESSION['fb_view']) && $_SESSION['fb_view'] == 'miniatur' || !isset($_SESSION['fb_view'])) // thumbs view
{
$html.= '
<li style="width: ' . ($cf['filebrowser']['maxheight_of_thumbs']+$cf['filebrowser']['width_px_plus']) . 'px; height: ' . ($cf['filebrowser']['maxheight_of_thumbs']+66) . 'px; padding: 8px 0 12px 8px; margin: 6px 3px 9px 3px;">
<form style="display: inline;" method="POST" action="" onsubmit="return confirmFileDelete(\'' . $this->translate('confirm_delete', $this->currentDirectory . $file) . '\');">
<input type="hidden" name="csrf_token" value="' . $_SESSION[$csrfSession] . '">
<input type="image" src="' . $this->browserPath . 'icons/delete.gif" alt="delete" title="delete file" style="float: left; margin-right: 8px;" />
<input type="hidden" name="deleteFile" />
<input type="hidden" name="file" value="' . $file . '" />
</form>
<form method="POST" style="display:none;" action="" id="rename_' . $i . '">
<input type="hidden" name="csrf_token" value="' . $_SESSION[$csrfSession] . '">
<input type="text" size="25" name="renameFile" value="' . $file . '" onmouseout="hideRenameForm(\'' . $i . '\');"/>
<input type="hidden" name="oldName" value="' . $file . '" />
</form>
<a style="position:relative" class="cmsimplefbfile" href="javascript:void(0)" id="file_' . $i . '" ondblclick="showRenameForm(\'' . $i . '\', \'' . $this->translate('prompt_rename', $file) . '\');" title="' . $file . '">
<div style="clear: both; width: 240px; float: left; padding-top: 6px;">' . substr($file,0,14);
if(strlen($file) > 14 )
{
$html.= '...';
}
$html.= '</div>';
if
(
mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/gif'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/jpeg'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/png'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/tiff'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/bmp'
)
{
$image = getimagesize($this->basePath . $this->currentDirectory . $file);
$width = $image[0];
$height = $image[1];
if ($width > 100)
{
$ratio = $width / $height;
$width = 100;
$height = $width / $ratio;
}
}
$fbFileTypeArray = explode('.',$file);
$fbFileType = array_pop($fbFileTypeArray);
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '<span class="filebrowser_image"><img src="' . $this->basePath . $this->currentDirectory . $file . '" style="float: left; max-width: 92%; max-height: ' . $cf['filebrowser']['maxheight_of_thumbs'] . 'px; padding: 0; margin: 0;" alt="' . $file . '" /></span>';
}
else
{
$html.= '<div class="fb_dummy" style="line-height: 2.4em;">' . $fbFileType . '</div>';
}
$html .= '
</a>
<p style="clear: both; padding: 6px 0 0 0; margin: 0; font-size: 12px;">
' . round(filesize($this->basePath . $this->currentDirectory . $file) / 1024, 0) . '&nbsp;kb';
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '&nbsp;/&nbsp;' . $image[0] . '&nbsp;x&nbsp;' . $image[1];
}
$html .= '</p>
</li>
';
}
if(isset($_SESSION['fb_view']) && $_SESSION['fb_view'] == 'list') // list view
{
$html .= '
<li class="fb_file">
<form style="display: inline;" method="POST" action="" onsubmit="return confirmFileDelete(\'' . $this->translate('confirm_delete', $this->currentDirectory . $file) . '\');">
<input type="hidden" name="csrf_token" value="' . $_SESSION[$csrfSession] . '">
<input type="image" src="' . $this->browserPath . 'icons/delete.gif" alt="delete" title="delete file" style="margin-right: 8px;" />
<input type="hidden" name="deleteFile" />
<input type="hidden" name="file" value="' . $file . '" />
</form>
<form method="POST" style="display:none;" action="" id="rename_' . $i . '">
<input type="hidden" name="csrf_token" value="' . $_SESSION[$csrfSession] . '">
<input type="text" size="25" name="renameFile" value="' . $file . '" onmouseout="hideRenameForm(\'' . $i . '\');"/>
<input type="hidden" name="oldName" value="' . $file . '" />
</form>
<a style="position:relative" class="cmsimplefbfile" href="javascript:void(0)" id="file_' . $i . '" ondblclick="showRenameForm(\'' . $i . '\', \'' . $this->translate('prompt_rename', $file) . '\');" title="' . $file . '">' . substr($file,0,18);
if(strlen($file) > 18 )
{
$html.= '...';
}
if
(
mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/gif'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/jpeg'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/png'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/tiff'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/bmp'
)
{
$image = getimagesize($this->basePath . $this->currentDirectory . $file);
$width = $image[0];
$height = $image[1];
if ($width > 100)
{
$ratio = $width / $height;
$width = 100;
$height = $width / $ratio;
}
}
$fbFileTypeArray = explode('.',$file);
$fbFileType = array_pop($fbFileTypeArray);
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '<span class="filebrowser_image"><img src="' . $this->basePath . $this->currentDirectory . $file . '" style="max-height: ' . $cf['filebrowser']['maxheight_of_thumbs'] . 'px; padding: 0; margin: 0;" alt="' . $file . '" title="' . $file . '" /></span>';
}
$html .= '
</a>
<span class="fb_filedata"> - <span style="font-family: tahoma, verdana, arial, sans-serif; font-weight: 700; padding: 0;">' . $fbFileType . '</span> - ' . round(filesize($this->basePath . $this->currentDirectory . $file) / 1024, 0) . '&nbsp;kb';
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '&nbsp;/&nbsp;' . $image[0] . '&nbsp;x&nbsp;' . $image[1];
}
$html .= '</span>
</li>
';
}
$i++;
}
$html .= '<br style="clear: both;"></ul>
<div style="clear: both; padding: 36px;">&nbsp;</div>';
return $html;
}
function fileListForEditor($files)
{
global $cf;
if(isset($_SESSION['fb_view']) && $_SESSION['fb_view'] == 'list')
{
$html = '
<ul class="fb_files_list">';
}
else
{
$html = '
<ul>';
}
$dir = $this->basePath . $this->currentDirectory;
$is_image = (int) (strpos($this->linkParams, 'type=images') === 0);
foreach ($files as $file)
{
if // thumbs view
(
(isset($_SESSION['fb_view']) && $_SESSION['fb_view'] == 'miniatur' || !isset($_SESSION['fb_view']))
)
{
$html .= '
<li style="';
$html .= 'width: ' . ($cf['filebrowser']['maxheight_of_thumbs']+$cf['filebrowser']['width_px_plus']) . 'px; height: ' . ($cf['filebrowser']['maxheight_of_thumbs']+60) . 'px; padding: 8px 0 12px 8px; margin: 6px 3px 9px 3px;">';
$prefix = $this->linkPrefix;
if ($prefix != '?&amp;download=')
{
$prefix .= $this->currentDirectory;
}
$html .= '<a href="#" class="cmsimplefbfile" onclick="window.setLink(\'' . $prefix . $file . '\',' . $is_image . '); return false;" title="' . $file . '">' . substr($file,0,14);
if(strlen($file) > 14 )
{
$html.= '...';
}
if
(
mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/gif'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/jpeg'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/png'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/tiff'
|| mime_content_type($this->basePath . $this->currentDirectory . $file) == 'image/bmp'
)
{
$image = getimagesize($this->basePath . $this->currentDirectory . $file);
$width = $image[0];
$height = $image[1];
if ($width > 100)
{
$ratio = $width / $height;
$width = 100;
$height = $width / $ratio;
}
}
$fbFileTypeArray = explode('.',$file);
$fbFileType = array_pop($fbFileTypeArray);
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '<span class="filebrowser_image"><img src="' . $this->basePath . $this->currentDirectory . $file . '" style="float: left; max-width: 92%; max-height: ' . $cf['filebrowser']['maxheight_of_thumbs'] . 'px; padding: 0; margin: 0;" alt="' . $file . '" title="' . $file . '" /></span>';
}
else
{
$html.= '<div class="fb_dummy" style="line-height: 2.4em;">' . $fbFileType . '</div>';
}
$html .= '
</a>
<p style="clear: both; padding: 6px 0 0 0; margin: 0; font-size: 12px;">
' . round(filesize($this->basePath . $this->currentDirectory . $file) / 1024, 0) . '&nbsp;kb';
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '&nbsp;/&nbsp;' . $image[0] . '&nbsp;x&nbsp;' . $image[1];
}
$html .= '</p>';
$html .= '</li>';
}
else // list view
{
$html .= '
<li class="fb_file" style="';
$html .= 'width: 90%; background: transparent; border: 0;">';
$prefix = $this->linkPrefix;
if ($prefix != '?&amp;download=')
{
$prefix .= $this->currentDirectory;
}
$html .= '<a href="#" class="cmsimplefbfile" onclick="window.setLink(\'' . $prefix . $file . '\',' . $is_image . '); return false;" title="' . $file . '">' . substr($file,0,18);
if(strlen($file) > 18 )
{
$html.= '...';
}
if ((strpos($this->linkParams, 'type=images') !== FALSE && getimagesize($dir . $file)) || preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$image = getimagesize($dir . $file);
$width = $image[0];
$height = $image[1];
if ($width > 150)
{
$ratio = $width / $height;
$width = 150;
$height = $width / $ratio;
}
}
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '<span style="position: relative; z-index: 4; width: 100%; text-align: center;">
<img src="' . $this->basePath . $this->currentDirectory . $file . '" style="max-height: ' . $cf['filebrowser']['maxheight_of_thumbs'] . 'px;" alt="' . $file . '" title="' . $file . '" /></span>';
}
$fbFileTypeArray = explode('.',$file);
$fbFileType = array_pop($fbFileTypeArray);
$html .= '
</a>
<span class="fb_filedata"> - <span style="font-family: tahoma, verdana, arial, sans-serif; font-weight: 700; padding: 0;">' . $fbFileType . '</span> - ' . round(filesize($this->basePath . $this->currentDirectory . $file) / 1024, 0) . '&nbsp;kb';
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
{
$html .= '&nbsp;/&nbsp;' . $image[0] . '&nbsp;x&nbsp;' . $image[1];
}
$html .= '</span>
</li>
';
} // END else
} // END foreach
$html .= '</ul>';
return $html;
}
function loadTemplate($template)
{
global $csrfSession;
if (file_exists($template))
{
ob_start();
global $tx;
include $template;
}
$html = ob_get_clean();
$this->partials['folders'] = $this->folderList($this->folders);
$this->partials['subfolders'] = $this->subFolderList($this->subfolders);
if (basename($template) == 'cmsbrowser.html')
{
$this->partials['files'] = $this->fileList($this->files);
}
if (basename($template) == 'editorbrowser.html')
{
$this->partials['files'] = $this->fileListForEditor($this->files);
}
$this->partials['message'] = $this->message;
foreach ($this->partials as $placeholder => $value)
{
$html = str_replace('%' . strtoupper($placeholder) . '%', $value, $html);
}
$this->message = '';
return $html;
}
function error($message ='', $args = null)
{
global $tx;
$this->message .= $this->translate($message, $args);
}
function success($message, $args = null)
{
global $tx;
$this->message .= '<p style="width: auto;">' . $this->translate($message, $args) . '</p>';
}
function message($message)
{
$this->message .= '<p style="width: auto;">' . $message . '</p>';
}
function translate($string = '', $args = null)
{
if (strlen($string) === 0)
{
return '';
}
$html = '';
if (!isset($this->lang[$string]))
{
$html = '{' . $string . '}';
}
else
{
$html = $this->lang[$string];
}
//
if (is_array($args))
{
array_unshift($args, $html);
return call_user_func_array('sprintf', $args);
}
if (is_string($args))
{
$html = sprintf($html, $args);
return $html;
}
return $html;
}
}
?>

View File

@ -0,0 +1,13 @@
<?php
/* utf-8 marker: äöü */
if (!defined('CMSIMPLE_VERSION') || preg_match('#/filebrowser/classes/required_classes.php#i',$_SERVER['SCRIPT_NAME']))
{
die('no direct access');
}
global $pth;
require_once $pth['folder']['plugin'] . 'classes/filebrowser_view.php';
require_once $pth['folder']['plugin'] . 'classes/filebrowser.php';
?>