First commit
101
cms/plugins/filebrowser/admin.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/filebrowser/admin.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/* utf-8 marker: äöü */
|
||||
|
||||
if (!$adm || $cf['filebrowser']['external']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
initvar('filebrowser');
|
||||
|
||||
function filebrowserSafeQS($querystring)
|
||||
{
|
||||
return(htmlspecialchars(strip_tags($querystring), ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if ($filebrowser) {
|
||||
$plugin = basename(dirname(__FILE__));
|
||||
$plugin = basename(dirname(__FILE__), "/");
|
||||
$o .= '<div class="plugintext">
|
||||
<div class="plugineditcaption">
|
||||
Filebrowser for CMSimple
|
||||
</div>
|
||||
<hr />
|
||||
<p>' . $tx['message']['plugin_standard1'] . '</p><p>' . $tx['message']['plugin_standard2'] . ' <a href="./?file=config&action=array"><b>' . $tx['filetype']['config'] . '</b></a></p>
|
||||
<hr />
|
||||
<p>Author: <a href="http://zeichenkombinat.de/" target="_blank">Martin Damken</a></p>
|
||||
<p>Adapted for CMSimple 4.0 and higher by <a href="http://www.ge-webdesign.de/" target="_blank">ge-webdesign.de</a></p>
|
||||
</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
if(!($images || $downloads || $userfiles || $media)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($_GET['subdir']) && strstr($_GET['subdir'],'userfiles/images/')) {
|
||||
$f = 'images';
|
||||
}
|
||||
|
||||
if(isset($_GET['subdir']) && strstr($_GET['subdir'],'userfiles/downloads/')) {
|
||||
$f = 'downloads';
|
||||
}
|
||||
|
||||
if(isset($_GET['subdir']) && strstr($_GET['subdir'],'userfiles/media/')) {
|
||||
$f = 'media';
|
||||
}
|
||||
|
||||
if($userfiles && $f != 'images' && $f != 'downloads' && $f != 'media'){$f = 'userfiles';}
|
||||
|
||||
$browser = $_SESSION['fb_browser'];
|
||||
define('CMSIMPLE_FB_PATH', $pth['folder']['plugins'] . 'filebrowser/');
|
||||
$hjs .= '<script type="text/javascript" src="' . CMSIMPLE_FB_PATH . 'js/filebrowser.js"></script>';
|
||||
|
||||
$subdir = isset($_GET['subdir']) ? str_replace(array('..', '.'), '', $_GET['subdir']) : '';
|
||||
|
||||
if (strpos($subdir, $browser->baseDirectories['userfiles']) !== 0) {
|
||||
$subdir = $browser->baseDirectories[$f];
|
||||
}
|
||||
|
||||
$browser->baseDirectory = $browser->baseDirectories['userfiles'];
|
||||
$browser->currentDirectory = filebrowserSafeQS(rtrim($subdir, '/')) . '/';
|
||||
$browser->linkType = $f;
|
||||
$browser->setLinkParams('userfiles');
|
||||
|
||||
if (isset($_POST['deleteFile']) && isset($_POST['file'])) {
|
||||
csrfProtection();
|
||||
$browser->deleteFile($_POST['file']);
|
||||
}
|
||||
if (isset($_POST['deleteFolder']) && isset($_POST['folder'])) {
|
||||
csrfProtection();
|
||||
$browser->deleteFolder($_POST['folder']);
|
||||
}
|
||||
if (isset($_POST['upload'])) {
|
||||
csrfProtection();
|
||||
$browser->uploadFile();
|
||||
}
|
||||
if (isset($_POST['createFolder'])) {
|
||||
csrfProtection();
|
||||
$browser->createFolder();
|
||||
}
|
||||
if (isset($_POST['renameFile'])) {
|
||||
csrfProtection();
|
||||
$browser->renameFile();
|
||||
}
|
||||
|
||||
$browser->readDirectory();
|
||||
|
||||
$o .= $browser->render('cmsbrowser');
|
||||
|
||||
$f = 'filebrowser';
|
||||
$images = $downloads = $userfiles = $media = false;
|
||||
/*
|
||||
* EOF filebrowser/admin.php
|
||||
*/
|
||||
|
||||
?>
|
392
cms/plugins/filebrowser/classes/filebrowser.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
535
cms/plugins/filebrowser/classes/filebrowser_view.php
Normal 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) . ' kb';
|
||||
|
||||
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
|
||||
{
|
||||
$html .= ' / ' . $image[0] . ' x ' . $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) . ' kb';
|
||||
|
||||
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
|
||||
{
|
||||
$html .= ' / ' . $image[0] . ' x ' . $image[1];
|
||||
}
|
||||
$html .= '</span>
|
||||
</li>
|
||||
';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$html .= '<br style="clear: both;"></ul>
|
||||
<div style="clear: both; padding: 36px;"> </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 != '?&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) . ' kb';
|
||||
|
||||
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
|
||||
{
|
||||
$html .= ' / ' . $image[0] . ' x ' . $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 != '?&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) . ' kb';
|
||||
|
||||
if(preg_match('/.jpg|.jpeg|.png|.webp|.gif/i',$file))
|
||||
{
|
||||
$html .= ' / ' . $image[0] . ' x ' . $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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
13
cms/plugins/filebrowser/classes/required_classes.php
Normal 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';
|
||||
?>
|
86
cms/plugins/filebrowser/editorbrowser.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php /* utf-8 marker: äöü */
|
||||
|
||||
require_once './classes/filebrowser_view.php';
|
||||
require_once './classes/filebrowser.php';
|
||||
global $cf;
|
||||
include ('../../cmsimple/config.php');
|
||||
|
||||
if (!isset($_SESSION)) { session_start(); }
|
||||
|
||||
//if(!isset($_SESSION['fb_sn']))die('fatal error');
|
||||
//echo 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
if(isset($_SESSION['fb_sn']))$fbsn = $_SESSION['fb_sn'];
|
||||
|
||||
$fb_access = FALSE;
|
||||
if (isset($_SESSION['fb_sn']) && $_SESSION['fb_session'] === session_id()) $fb_access = TRUE;
|
||||
if ($fb_access === FALSE) die('no access');
|
||||
|
||||
$base = './../../';
|
||||
$browser = $_SESSION['fb_browser'];
|
||||
$browser->setBrowseBase($base);
|
||||
|
||||
//$_GET['base'] = isset($_GET['base']) ? str_replace(array('../', './', '<', '>', '(', ')', ';', ':'), '', $_GET['base']) : '';
|
||||
//$_SESSION['fb_browse_base'] = $_GET['base'];
|
||||
|
||||
if (isset($_GET['type']) && $_GET['type'] === 'file') $_GET['prefix'] = '?&download=';
|
||||
|
||||
//$my_prefix = $_GET['type'] === 'file' ? '?&download=' : $_GET['prefix'];
|
||||
//var_dump($_SESSION);
|
||||
|
||||
$fb_type = null;
|
||||
|
||||
if (isset($_GET['type']))
|
||||
{
|
||||
$fb_type = $_GET['type'];
|
||||
if ($fb_type == 'image') {$fb_type = 'images';}
|
||||
if ($fb_type == 'file') {$fb_type = 'downloads';}
|
||||
}
|
||||
|
||||
if ($fb_type && array_key_exists($fb_type, $browser->baseDirectories)) {
|
||||
$browser->linkType = $fb_type;
|
||||
|
||||
if(isset($_GET['prefix'])){$browser->setLinkPrefix($_GET['prefix']);}
|
||||
$browser->linkType = $fb_type;
|
||||
|
||||
$src = $_GET;
|
||||
$src['type'] = $fb_type;
|
||||
unset($src['subdir']);
|
||||
// the following is a simplyfied http_build_query()
|
||||
$dst = array();
|
||||
foreach ($src as $key => $val) {$dst[] = urlencode($key) . '=' . urlencode($val);}
|
||||
$dst = implode('&', $dst);
|
||||
$browser->setlinkParams($dst);
|
||||
|
||||
$browser->baseDirectory = $browser->baseDirectories[$fb_type];
|
||||
$browser->currentDirectory = $browser->baseDirectories[$fb_type];
|
||||
|
||||
if (isset($_GET['subdir'])) {
|
||||
$subdir = str_replace(array('../', './', '?', '<', '>', ':'), '', $_GET['subdir']);
|
||||
|
||||
if (strpos($subdir, $browser->currentDirectory) === 0) {
|
||||
$browser->currentDirectory = rtrim($subdir, '/') . '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['upload']))$browser->uploadFile();
|
||||
if (isset($_POST['createFolder']))$browser->createFolder();
|
||||
if (isset($_POST['renameFile']))$browser->renameFile();
|
||||
|
||||
$browser->readDirectory();
|
||||
|
||||
if(isset($_GET['editor']))$jsFile = 'editorhooks/' . basename($_GET['editor']) . '/script.php';
|
||||
|
||||
$script = 'xxx';
|
||||
if (isset($jsFile) && file_exists($jsFile)) include $jsFile;
|
||||
$test = '';
|
||||
|
||||
//$test .= print_r($_SERVER, true);
|
||||
|
||||
$browser->view->partials['script'] = $script;
|
||||
$browser->view->partials['test'] = $test;
|
||||
$browser->browserPath = '';
|
||||
echo $browser->render('editorbrowser');
|
||||
}
|
||||
else die('fatal error');
|
||||
?>
|
15
cms/plugins/filebrowser/editorhooks/ckeditor/script.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/* utf-8 marker: äöü */
|
||||
/* script.php build: 2011012801 */
|
||||
$script = '
|
||||
<script language="javascript" type="text/javascript">
|
||||
function setLink(link){
|
||||
|
||||
//window.opener.CKEDITOR.tools.callFunction( 2, link );
|
||||
window.opener.CKEDITOR.tools.callFunction('.$_GET['CKEditorFuncNum'].', link );
|
||||
|
||||
window.close();
|
||||
}
|
||||
</script>
|
||||
';
|
||||
?>
|
13
cms/plugins/filebrowser/editorhooks/tinymce/index.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/* utf-8 marker: äöü */
|
||||
if($s < 0){ return '';}
|
||||
$script = file_get_contents(dirname(__FILE__) . '/tinymce.js');
|
||||
$base = CMSIMPLE_ROOT . 'plugins/';
|
||||
$prefix = CMSIMPLE_BASE;
|
||||
$script = str_replace('%URL%', $base . 'filebrowser/editorbrowser.php?editor=tinymce&prefix='. $prefix .'&base=./&level=' . $l[$s], $script);
|
||||
|
||||
return $script;
|
||||
/*
|
||||
* end of plugins/wr_filebrowser/tinymce.php
|
||||
*/
|
||||
?>
|
34
cms/plugins/filebrowser/editorhooks/tinymce/script.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
$script = '
|
||||
<script>
|
||||
|
||||
|
||||
var FileBrowserDialogue = {
|
||||
|
||||
init : function () {
|
||||
// Nothing to do
|
||||
},
|
||||
|
||||
|
||||
submit : function (url) {
|
||||
var URL = url;
|
||||
var args = top.tinymce.activeEditor.windowManager.getParams();
|
||||
var win = args.window;
|
||||
var input = win.document.getElementById(args.input);
|
||||
|
||||
input.value = URL;
|
||||
if (input.onchange) input.onchange(); //??? falls noch ein anderer trigger ???
|
||||
top.tinymce.activeEditor.windowManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setLink(link){
|
||||
|
||||
FileBrowserDialogue.submit(link);
|
||||
return true;
|
||||
}
|
||||
|
||||
</script>';
|
||||
?>
|
33
cms/plugins/filebrowser/editorhooks/tinymce/tinymce.js
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
function wrFilebrowser (field_name, url, type, win) {
|
||||
poppedUpWin = win;
|
||||
inputField = field_name;
|
||||
|
||||
// alert("Field_Name: " + field_name + "nURL: " + url + "nType: " + type + "nWin: " + win); // debug/testing
|
||||
|
||||
var cmsURL = "%URL%";
|
||||
|
||||
if (cmsURL.indexOf("?") < 0) {
|
||||
cmsURL = cmsURL + "?type="+ type ;
|
||||
}
|
||||
else {
|
||||
cmsURL = cmsURL + "&type="+type ;
|
||||
}
|
||||
|
||||
tinyMCE.activeEditor.windowManager.open(
|
||||
{
|
||||
file : cmsURL,
|
||||
width : 800,
|
||||
height : 600,
|
||||
resizable : "yes",
|
||||
inline : "yes",
|
||||
close_previous : "no",
|
||||
popup_css : false
|
||||
},
|
||||
{
|
||||
window : win,
|
||||
input : field_name
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
BIN
cms/plugins/filebrowser/icons/add.png
Normal file
After Width: | Height: | Size: 656 B |
BIN
cms/plugins/filebrowser/icons/delete-file.png
Normal file
After Width: | Height: | Size: 781 B |
BIN
cms/plugins/filebrowser/icons/delete-file_old.png
Normal file
After Width: | Height: | Size: 961 B |
BIN
cms/plugins/filebrowser/icons/delete-file_old_1.png
Normal file
After Width: | Height: | Size: 961 B |
BIN
cms/plugins/filebrowser/icons/delete.gif
Normal file
After Width: | Height: | Size: 989 B |
BIN
cms/plugins/filebrowser/icons/folder-open.png
Normal file
After Width: | Height: | Size: 625 B |
BIN
cms/plugins/filebrowser/icons/folder-open1.png
Normal file
After Width: | Height: | Size: 905 B |
BIN
cms/plugins/filebrowser/icons/folder-open2.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
cms/plugins/filebrowser/icons/folder.png
Normal file
After Width: | Height: | Size: 581 B |
BIN
cms/plugins/filebrowser/icons/folder1.png
Normal file
After Width: | Height: | Size: 848 B |
BIN
cms/plugins/filebrowser/icons/folder2.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
cms/plugins/filebrowser/icons/folder_lat.png
Normal file
After Width: | Height: | Size: 581 B |
85
cms/plugins/filebrowser/index.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
if (!defined('CMSIMPLE_VERSION') || preg_match('#/filebrowser/index.php#i',$_SERVER['SCRIPT_NAME']))
|
||||
{
|
||||
die('no direct access');
|
||||
}
|
||||
|
||||
/* utf-8 marker: äöü */
|
||||
if(!$adm) {return true;}
|
||||
|
||||
if(!isset($_SESSION)){session_start();}
|
||||
|
||||
$temp = './';
|
||||
$editor_fb = new CMSimpleFileBrowser();
|
||||
$editor_fb->setBrowseBase(CMSIMPLE_BASE);
|
||||
$editor_fb->setBrowserPath($pth['folder']['plugins'] . 'filebrowser/');
|
||||
$editor_fb->setMaxFileSize('images', $cf['images']['maxsize']);
|
||||
$editor_fb->setMaxFileSize('downloads', $cf['downloads']['maxsize']);
|
||||
|
||||
|
||||
$_SESSION['fb_browser'] = $editor_fb;
|
||||
$_SESSION['fb_session'] = session_id();
|
||||
$_SESSION['fb_sn'] = $sn;
|
||||
$_SESSION['fb_sl'] = $sl;
|
||||
$_SESSION['fb_snForCsrf'] = $snForCsrf;
|
||||
|
||||
|
||||
if($subsite_folder == '/')
|
||||
{
|
||||
$_SESSION['subsite_folder'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['subsite_folder'] = $subsite_folder;
|
||||
}
|
||||
|
||||
if($pth['folder']['base'] != './' && !is_writable('./userfiles'))
|
||||
{
|
||||
$_SESSION['subsite_folder_link'] = $subsite_folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['subsite_folder_link'] = '';
|
||||
}
|
||||
|
||||
if(is_writable('./userfiles'))
|
||||
{
|
||||
$_SESSION['subsite_folder_userfiles'] = $_SESSION['fb_sn'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CMSIMPLE_ROOT != '/')
|
||||
{
|
||||
$_SESSION['subsite_folder_userfiles'] = CMSIMPLE_ROOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['subsite_folder_userfiles'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// outcomment following lines for development only
|
||||
|
||||
//echo '$_SESSION[\'subsite_folder\']: ' . $_SESSION['subsite_folder'] . '<br>';
|
||||
//echo '$_SESSION[\'subsite_folder_userfiles\']: ' . $_SESSION['subsite_folder_userfiles'] . '<br>';
|
||||
|
||||
/*
|
||||
if(is_writable('./userfiles'))
|
||||
{
|
||||
echo 'userfiles folder writable<br><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'userfiles folder <b>NOT</b> writable<br><br>';
|
||||
}
|
||||
|
||||
echo '$subsite_folder : ' . $subsite_folder . '<br>';
|
||||
echo '$_SESSION[\'fb_sn\'] : ' . $_SESSION['fb_sn'] . '<br>';
|
||||
echo '$_SESSION[\'subsite_folder\'] : ' . $_SESSION['subsite_folder'] . '<br>';
|
||||
echo '$_SESSION[\'subsite_folder_link\'] : ' . $_SESSION['subsite_folder_link'] . '<br>';
|
||||
echo '$_SESSION[\'subsite_folder_userfiles\'] : ' . $_SESSION['subsite_folder_userfiles'] . '<br>';
|
||||
echo 'CMSIMPLE_ROOT : ' . CMSIMPLE_ROOT . '<br>';
|
||||
*/
|
||||
|
||||
?>
|
55
cms/plugins/filebrowser/js/filebrowser.js
Normal file
@ -0,0 +1,55 @@
|
||||
function confirmFileDelete(string)
|
||||
{
|
||||
return confirm(string);
|
||||
}
|
||||
|
||||
function confirmFolderDelete(string)
|
||||
{
|
||||
return confirm(string);
|
||||
}
|
||||
|
||||
function showcmsimplefbForm(id)
|
||||
{
|
||||
forms = document.getElementsByTagName('fieldset');
|
||||
for(i=0; i<forms.length; i++){
|
||||
form = forms[i];
|
||||
if(form.className == "cmsimplefbform"){
|
||||
form.style.display='none';
|
||||
}
|
||||
}
|
||||
document.getElementById(id).style.display='block';
|
||||
document.getElementById(id).getElementsByTagName('input')[0].focus();
|
||||
}
|
||||
|
||||
function closecmsimplefbForm(id)
|
||||
{
|
||||
document.getElementById(id).style.display='none';
|
||||
}
|
||||
|
||||
function oldshowRenameForm(id)
|
||||
{
|
||||
|
||||
document.getElementById("rename_" + id).style.display='inline';
|
||||
document.getElementById("rename_" + id).renameFile.select();
|
||||
document.getElementById("file_" + id).style.display='none';
|
||||
}
|
||||
|
||||
|
||||
function showRenameForm(id, message)
|
||||
{ var oldName = document.getElementById("rename_" + id).renameFile.value;
|
||||
var newName = prompt(message, oldName);
|
||||
|
||||
if(newName){
|
||||
// document.getElementById("rename_" + id).style.display='inline';
|
||||
document.getElementById("rename_" + id).renameFile.value=newName;
|
||||
document.getElementById("rename_" + id).submit();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function hideRenameForm(id)
|
||||
{
|
||||
document.getElementById("rename_" + id).style.display='none';
|
||||
document.getElementById("file_" + id).style.display='inline';
|
||||
}
|
92
cms/plugins/filebrowser/tpl/cmsbrowser.html
Normal file
@ -0,0 +1,92 @@
|
||||
<?php global $tx, $csrfSession; ?>
|
||||
<!--utf-8 marker: äöü -->
|
||||
|
||||
<?php
|
||||
if(@$_POST['fb_viewSelect'])
|
||||
{
|
||||
csrfProtection();
|
||||
$_SESSION['fb_view'] = $_POST['fb_viewSelect'];
|
||||
}
|
||||
echo '<form method="post" action="#">
|
||||
<input type="hidden" name="csrf_token" value="' . $_SESSION[$csrfSession] . '">
|
||||
<select name="fb_viewSelect" style="float: right; width: 160px; background: #fff; border: 2px solid #c60; padding: 2px; margin: 6px 3px 0 0;" onchange="this.form.submit()">
|
||||
<option value="list" style="padding: 0 6px;"';
|
||||
if(@$_SESSION['fb_view'] == 'list')
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $tx['filebrowser']['view_list'] . '</option>
|
||||
<option value="miniatur" style="padding: 0 6px;"';
|
||||
if((@$_SESSION['fb_view'] == 'miniatur' || !isset($_SESSION['fb_view'])))
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $tx['filebrowser']['view_thumbs'] . '</option>
|
||||
</select>
|
||||
<noscript><input type="submit" value="Submit" /></noscript>
|
||||
</form>
|
||||
<div style="clear: both;"></div>';
|
||||
?>
|
||||
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 20%; min-width: 280px; vertical-align: top;">
|
||||
<div id="CMSimpleFileBrowserMenu">
|
||||
<div id="folders">
|
||||
%FOLDERS%
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td style="vertical-align: top;">
|
||||
|
||||
<div id="CMSimpleFileBrowser" style="padding: 0 10px!important;">
|
||||
<div id="subfolders">
|
||||
|
||||
<div style="clear: both; margin: 0 0 10px 0;">
|
||||
<p>
|
||||
<?php echo '<b>' . $tx['filetype']['folder'] . ': <span style="white-space: nowrap; color: #c00; font-family: courier new, monospace; font-size: 16px;">' . $_SERVER['SERVER_NAME'] . str_replace($_SESSION['subsite_folder_link'],'',$_SESSION['fb_sn']) . '</span></b> <span style="white-space: nowrap; font-family: courier new, monospace; font-size: 16px;">' . str_replace($_SESSION['subsite_folder'],'',$this->currentDirectory) . '</span>'; ?>
|
||||
</p>
|
||||
<b><a href="javascript:void();" onClick="window.showcmsimplefbForm('cmsimplefbCreateDir');"><?php echo '=> ' . $this->translate('create_folder'); ?></a></b>
|
||||
</div>
|
||||
|
||||
<fieldset id="cmsimplefbCreateDir" class="cmsimplefbform">
|
||||
<legend><?php echo $this->translate('create_subfolder_in', $this->currentDirectory); ?> <a href="javascript:window.closecmsimplefbForm('cmsimplefbCreateDir');"><b>[ x ]</b></a></legend>
|
||||
<div style="padding: 14px 10px;">
|
||||
<form method="POST" action="">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[$csrfSession];?>">
|
||||
<input type="text" style="max-width: 240px;" name="createFolder" size="30" />
|
||||
<input type="submit" class="submit" value="<?php echo $this->translate('create_folder'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>
|
||||
%SUBFOLDERS%
|
||||
</div>
|
||||
<hr />
|
||||
<div id="files">
|
||||
<div style="font-weight: 700; margin-bottom: 12px;">
|
||||
<?php echo $this->translate('files');?> <a href="javascript:window.showcmsimplefbForm('cmsimplefbUploadFile');"> => <?php echo $this->translate('upload_file'); ?></a>
|
||||
</div>
|
||||
<fieldset id="cmsimplefbUploadFile" class="cmsimplefbform">
|
||||
<legend><?php echo $this->translate('upload_file_to', $this->currentDirectory); ?> <a href="javascript:window.closecmsimplefbForm('cmsimplefbUploadFile');"><b>[ x ]</b></a></legend>
|
||||
|
||||
<div style="padding: 4px 10px;">
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[$csrfSession];?>">
|
||||
<p><input type="file" name="fbupload" style="float: left;" /></p><br />
|
||||
<input type="hidden" name="upload" value="upload" />
|
||||
<p><input type="submit" class="submit" value="<?php echo $this->translate('upload_file'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>
|
||||
<p style="font-size: 14px;"><?php echo $this->translate('files_rename');?></p>
|
||||
%MESSAGE%
|
||||
%FILES%
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="clear:both;"></div>
|
101
cms/plugins/filebrowser/tpl/editorbrowser.html
Normal file
@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Filebrowser</title>
|
||||
<link rel="stylesheet" href="../../css/core.css" type="text/css">
|
||||
<style>body {padding: 0; margin: 0; overflow: auto;}</style>
|
||||
|
||||
%SCRIPT%
|
||||
|
||||
<script type="text/javascript" src="./js/filebrowser.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--utf-8 marker: äöü -->
|
||||
|
||||
<?php
|
||||
@session_start();
|
||||
|
||||
include('../../cmsimple/languages/' . $_SESSION['fb_sl'] . '.php');
|
||||
|
||||
if(@$_POST['fb_viewSelect'])
|
||||
{
|
||||
$_SESSION['fb_view'] = $_POST['fb_viewSelect'];
|
||||
}
|
||||
|
||||
echo '<form method="post" action="#">
|
||||
<input type="hidden" name="csrf_token" value="' . $_SESSION['csrf_token' . $_SESSION['fb_snForCsrf']] . '">
|
||||
<select name="fb_viewSelect" style="float: right; width: 160px; border: 2px solid #c60; padding: 2px; margin: 6px 3px 0 0;" onchange="this.form.submit()">
|
||||
<option value="list" style="padding: 0 6px;"';
|
||||
if(@$_SESSION['fb_view'] == 'list')
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $tx['filebrowser']['view_list'] . '</option>
|
||||
<option value="miniatur" style="padding: 0 6px;"';
|
||||
if((@$_SESSION['fb_view'] == 'miniatur' || !isset($_SESSION['fb_view'])))
|
||||
{
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . $tx['filebrowser']['view_thumbs'] . '</option>
|
||||
</select>
|
||||
<noscript><input type="submit" value="Submit"></noscript>
|
||||
</form>
|
||||
<div style="clear: both;"></div>';
|
||||
?>
|
||||
|
||||
<div style="position: absolute; width: 100%; height: 90%; overflow: scroll; border: 0px solid #080;">
|
||||
<div id="CMSimpleFileBrowserMenu">
|
||||
|
||||
<?php echo $tx['filetype']['folder'] . ': <span style="white-space: nowrap; color: #c00; font-family: courier new, monospace; font-size: 12px;">' . $_SERVER['SERVER_NAME'] . str_replace($_SESSION['subsite_folder_link'],'',$_SESSION['fb_sn']) . '</span> <span style="white-space: nowrap; font-family: courier new, monospace; font-size: 12px;">' . str_replace($_SESSION['subsite_folder'],'',$this->currentDirectory) . '</span>'; ?><br>
|
||||
|
||||
<a href="#" onClick="window.showcmsimplefbForm('cmsimplefbCreateDir');"><?php echo $this->translate('create_folder'); ?></a> |
|
||||
<a href="#" onClick="window.showcmsimplefbForm('cmsimplefbUploadFile');"><?php echo $this->translate('upload_file'); ?></a>
|
||||
<fieldset id="cmsimplefbUploadFile" class="cmsimplefbform">
|
||||
<legend><?php echo $this->translate('upload_file_to', $this->currentDirectory); ?> <a href="#" onClick="window.closecmsimplefbForm('cmsimplefbUploadFile');">[x]</a></legend>
|
||||
<div style="padding: 20px 30px;">
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token' . $_SESSION['fb_snForCsrf']];?>">
|
||||
<input type="file" name="fbupload">
|
||||
<input type="hidden" name="upload" value="upload">
|
||||
<input type="submit" class="submit" value="<?php echo $this->translate('upload_file'); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="cmsimplefbCreateDir" class="cmsimplefbform">
|
||||
<legend><?php echo $this->translate('create_subfolder_in', $this->currentDirectory); ?> <a href="#" onClick="window.closecmsimplefbForm('cmsimplefbCreateDir');">[x]</a></legend>
|
||||
<div style="padding: 20px 30px;">
|
||||
<form method="POST" action="">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token' . $_SESSION['fb_snForCsrf']];?>">
|
||||
<input type="text" name="createFolder" size="30">
|
||||
<input type="submit" class="submit" value="<?php echo $this->translate('create_folder'); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div id="CMSimpleFileBrowser">
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 20%; min-width: 200px; vertical-align: top;">
|
||||
<div id="folders" style="width: 100%; overflow: hidden;">
|
||||
%FOLDERS%
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td style="vertical-align: top;">
|
||||
<div id="files" style="overflow: auto; z-index: 3; font-weight: 300; padding: 0 6px 100px 16px;">
|
||||
<span class="cmsimplefb_files"><?php echo $this->translate('files');?></span><br>
|
||||
%MESSAGE%
|
||||
%FILES%
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|