#1022 - Отображение картинок в редакторе страниц

parent 1e3bf8d0
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
<?php
include 'config/config.php';
if($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager") die('forbiden');
$config = include 'config/config.php';
//TODO switch to array
extract($config, EXTR_OVERWRITE);
include 'include/utils.php';
if ($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager")
{
response('forbiden', 403)->send();
exit;
}
include 'include/mime_type_lib.php';
if(strpos($_POST['path'],'/')===0
|| strpos($_POST['path'],'../')!==FALSE
|| strpos($_POST['path'],'./')===0)
die('wrong path');
if (
strpos($_POST['path'], '/') === 0
|| strpos($_POST['path'], '../') !== false
|| strpos($_POST['path'], './') === 0
)
{
response('wrong path', 400)->send();
exit;
}
if (strpos($_POST['name'], '/') !== false)
{
response('wrong path', 400)->send();
exit;
}
$path = $current_path . $_POST['path'];
$name = $_POST['name'];
if(strpos($_POST['name'],'/')!==FALSE)
die('wrong path');
$info = pathinfo($name);
$path=$current_path.$_POST['path'];
$name=$_POST['name'];
if ( ! in_array(fix_strtolower($info['extension']), $ext))
{
response('wrong extension', 400)->send();
exit;
}
$info=pathinfo($name);
if(!in_array(fix_strtolower($info['extension']), $ext)){
die('wrong extension');
if ( ! file_exists($path . $name))
{
response('File not found', 404)->send();
exit;
}
$img_size = (string)(filesize($path.$name)); // Get the image size as string
$img_size = (string) (filesize($path . $name)); // Get the image size as string
$mime_type = get_file_mime_type( $path.$name ); // Get the correct MIME type depending on the file.
$mime_type = get_file_mime_type($path . $name); // Get the correct MIME type depending on the file.
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-Type: " . $mime_type); // Set the correct MIME type
header("Content-Length: " . $img_size );
header('Content-Disposition: attachment; filename="'.($name).'"');
readfile($path.$name);
response(file_get_contents($path . $name), 200, array(
'Pragma' => 'private',
'Cache-control' => 'private, must-revalidate',
'Content-Type' => $mime_type,
'Content-Length' => $img_size,
'Content-Disposition' => 'attachment; filename="' . ($name) . '"'
))->send();
exit;
\ No newline at end of file
?>
\ No newline at end of file
This diff is collapsed.
<?php
/********************************
The following commented code can be uncommented if you wish
to quickly find information about your system's MIME setup.
Simply remove the "REMOVE ME TO TEST" lines below to have
the code run when this file runs.
In addition to these tests, you'll find some commented code
at the bottom of the file that can be used to test the
function.
Run the code with this command:
php mime_type_lib.php
********************************/
* The following commented code can be uncommented if you wish
* to quickly find information about your system's MIME setup.
*
* Simply remove the "REMOVE ME TO TEST" lines below to have
* the code run when this file runs.
*
* In addition to these tests, you'll find some commented code
* at the bottom of the file that can be used to test the
* function.
*
* Run the code with this command:
* php mime_type_lib.php
********************************/
/* REMOVE ME TO TEST
......@@ -31,26 +31,37 @@ else
REMOVE ME TO TEST */
if ( ! function_exists('get_file_mime_type'))
{
function get_file_mime_type($filename, $debug = false)
{
if (function_exists('finfo_open') && function_exists('finfo_file') && function_exists('finfo_close'))
{
$fileinfo = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($fileinfo, $filename);
finfo_close($fileinfo);
if( ! function_exists( 'get_file_mime_type' ) ) {
function get_file_mime_type( $filename, $debug = false ) {
if ( function_exists( 'finfo_open' ) && function_exists( 'finfo_file' ) && function_exists( 'finfo_close' ) ) {
$fileinfo = finfo_open( FILEINFO_MIME );
$mime_type = finfo_file( $fileinfo, $filename );
finfo_close( $fileinfo );
if ( ! empty( $mime_type ) ) {
if ( true === $debug )
if ( ! empty($mime_type))
{
if (true === $debug)
{
return array( 'mime_type' => $mime_type, 'method' => 'fileinfo' );
}
return $mime_type;
}
}
if ( function_exists( 'mime_content_type' ) ) {
$mime_type = mime_content_type( $filename );
if (function_exists('mime_content_type'))
{
$mime_type = mime_content_type($filename);
if ( ! empty( $mime_type ) ) {
if ( true === $debug )
if ( ! empty($mime_type))
{
if (true === $debug)
{
return array( 'mime_type' => $mime_type, 'method' => 'mime_content_type' );
}
return $mime_type;
}
}
......@@ -246,40 +257,44 @@ if( ! function_exists( 'get_file_mime_type' ) ) {
'zip' => 'application/zip'
);
$tmp_array=explode( '.', $filename );
$ext = strtolower( array_pop( $tmp_array ) );
$tmp_array = explode('.', $filename);
$ext = strtolower(array_pop($tmp_array));
if ( ! empty( $mime_types[$ext] ) ) {
if ( true === $debug )
return array( 'mime_type' => $mime_types[$ext], 'method' => 'from_array' );
return $mime_types[$ext];
if ( ! empty($mime_types[ $ext ]))
{
if (true === $debug)
{
return array( 'mime_type' => $mime_types[ $ext ], 'method' => 'from_array' );
}
if ( true === $debug )
return $mime_types[ $ext ];
}
if (true === $debug)
{
return array( 'mime_type' => 'application/octet-stream', 'method' => 'last_resort' );
}
return 'application/octet-stream';
}
}
/********************
The following code can be used to test the function.
First put a plain text file named "test.txt" and a
JPEG image file named "image.jpg" in the same folder
as this file.
Simply remove the "REMOVE ME TO TEST" lines below to have
the code run when this file runs.
Run the code with this command:
php mime_type_lib.php
********************/
* The following code can be used to test the function.
* First put a plain text file named "test.txt" and a
* JPEG image file named "image.jpg" in the same folder
* as this file.
*
* Simply remove the "REMOVE ME TO TEST" lines below to have
* the code run when this file runs.
*
* Run the code with this command:
* php mime_type_lib.php
********************/
/* REMOVE ME TO TEST
echo get_file_mime_type( 'test.txt' ) . "\n";
echo print_r( get_file_mime_type( 'image.jpg', true ), true ) . "\n";
REMOVE ME TO TEST */
?>
This diff is collapsed.
This diff is collapsed.
/**
* Copyright (C) 2013-2014 KO GmbH <copyright@kogmbh.com>
*
* @licstart
* This file is part of WebODF.
*
* WebODF is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License (GNU AGPL)
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* WebODF 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
*
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
@namespace cursor url(urn:webodf:names:cursor);
.caret {
opacity: 0 !important;
}
/**
* Copyright (C) 2012 KO GmbH <copyright@kogmbh.com>
*
* @licstart
* This file is part of WebODF.
*
* WebODF is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License (GNU AGPL)
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* WebODF 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with WebODF. If not, see <http://www.gnu.org/licenses/>.
* @licend
*
* @source: http://www.webodf.org/
* @source: https://github.com/kogmbh/WebODF/
*/
/*global runtime, document, odf, gui, console, webodf*/
function ODFViewerPlugin() {
"use strict";
function init(callback) {
var lib = document.createElement('script'),
pluginCSS;
lib.async = false;
lib.src = './webodf.js';
lib.type = 'text/javascript';
lib.onload = function () {
runtime.loadClass('gui.HyperlinkClickHandler');
runtime.loadClass('odf.OdfCanvas');
runtime.loadClass('ops.Session');
runtime.loadClass('gui.CaretManager');
runtime.loadClass("gui.HyperlinkTooltipView");
runtime.loadClass('gui.SessionController');
runtime.loadClass('gui.SvgSelectionView');
runtime.loadClass('gui.SelectionViewManager');
runtime.loadClass('gui.ShadowCursor');
runtime.loadClass('gui.SessionView');
callback();
};
document.getElementsByTagName('head')[0].appendChild(lib);
pluginCSS = document.createElement('link');
pluginCSS.setAttribute("rel", "stylesheet");
pluginCSS.setAttribute("type", "text/css");
pluginCSS.setAttribute("href", "./ODFViewerPlugin.css");
document.head.appendChild(pluginCSS);
}
// that should probably be provided by webodf
function nsResolver(prefix) {
var ns = {
'draw' : "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",
'presentation' : "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",
'text' : "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
'office' : "urn:oasis:names:tc:opendocument:xmlns:office:1.0"
};
return ns[prefix] || console.log('prefix [' + prefix + '] unknown.');
}
var self = this,
pluginName = "WebODF",
pluginURL = "http://webodf.org",
odfCanvas = null,
odfElement = null,
initialized = false,
root = null,
documentType = null,
pages = [],
currentPage = null;
this.initialize = function (viewerElement, documentUrl) {
// If the URL has a fragment (#...), try to load the file it represents
init(function () {
var session,
sessionController,
sessionView,
odtDocument,
shadowCursor,
selectionViewManager,
caretManager,
localMemberId = 'localuser',
hyperlinkTooltipView,
eventManager;
odfElement = document.getElementById('canvas');
odfCanvas = new odf.OdfCanvas(odfElement);
odfCanvas.load(documentUrl);
odfCanvas.addListener('statereadychange', function () {
root = odfCanvas.odfContainer().rootElement;
initialized = true;
documentType = odfCanvas.odfContainer().getDocumentType(root);
if (documentType === 'text') {
odfCanvas.enableAnnotations(true, false);
session = new ops.Session(odfCanvas);
odtDocument = session.getOdtDocument();
shadowCursor = new gui.ShadowCursor(odtDocument);
sessionController = new gui.SessionController(session, localMemberId, shadowCursor, {});
eventManager = sessionController.getEventManager();
caretManager = new gui.CaretManager(sessionController, odfCanvas.getViewport());
selectionViewManager = new gui.SelectionViewManager(gui.SvgSelectionView);
sessionView = new gui.SessionView({
caretAvatarsInitiallyVisible: false
}, localMemberId, session, sessionController.getSessionConstraints(), caretManager, selectionViewManager);
selectionViewManager.registerCursor(shadowCursor);
hyperlinkTooltipView = new gui.HyperlinkTooltipView(odfCanvas,
sessionController.getHyperlinkClickHandler().getModifier);
eventManager.subscribe("mousemove", hyperlinkTooltipView.showTooltip);
eventManager.subscribe("mouseout", hyperlinkTooltipView.hideTooltip);
var op = new ops.OpAddMember();
op.init({
memberid: localMemberId,
setProperties: {
fillName: runtime.tr("Unknown Author"),
color: "blue"
}
});
session.enqueue([op]);
sessionController.insertLocalCursor();
}
self.onLoad();
});
});
};
this.isSlideshow = function () {
return documentType === 'presentation';
};
this.onLoad = function () {};
this.getWidth = function () {
return odfElement.clientWidth;
};
this.getHeight = function () {
return odfElement.clientHeight;
};
this.fitToWidth = function (width) {
odfCanvas.fitToWidth(width);
};
this.fitToHeight = function (height) {
odfCanvas.fitToHeight(height);
};
this.fitToPage = function (width, height) {
odfCanvas.fitToContainingElement(width, height);
};
this.fitSmart = function (width) {
odfCanvas.fitSmart(width);
};
this.getZoomLevel = function () {
return odfCanvas.getZoomLevel();
};
this.setZoomLevel = function (value) {
odfCanvas.setZoomLevel(value);
};
// return a list of tuples (pagename, pagenode)
this.getPages = function () {
var pageNodes = Array.prototype.slice.call(root.getElementsByTagNameNS(nsResolver('draw'), 'page')),
pages = [],
i,
tuple;
for (i = 0; i < pageNodes.length; i += 1) {
tuple = [
pageNodes[i].getAttribute('draw:name'),
pageNodes[i]
];
pages.push(tuple);
}
return pages;
};
this.showPage = function (n) {
odfCanvas.showPage(n);
};
this.getPluginName = function () {
return pluginName;
};
this.getPluginVersion = function () {
var version;
if (String(typeof webodf) !== "undefined") {
version = webodf.Version;
} else {
version = "Unknown";
}
return version;
};
this.getPluginURL = function () {
return pluginURL;
};
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* This is just a sample file with CSS rules. You should write your own @font-face declarations
* to add support for your desired fonts.
*/
@font-face {
font-family: 'Novecentowide Book';
src: url("/ViewerJS/fonts/Novecentowide-Bold-webfont.eot");
src: url("/ViewerJS/fonts/Novecentowide-Bold-webfont.eot?#iefix") format("embedded-opentype"),
url("/ViewerJS/fonts/Novecentowide-Bold-webfont.woff") format("woff"),
url("/fonts/Novecentowide-Bold-webfont.ttf") format("truetype"),
url("/fonts/Novecentowide-Bold-webfont.svg#NovecentowideBookBold") format("svg");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'exotica';
src: url('/ViewerJS/fonts/Exotica-webfont.eot');
src: url('/ViewerJS/fonts/Exotica-webfont.eot?#iefix') format('embedded-opentype'),
url('/ViewerJS/fonts/Exotica-webfont.woff') format('woff'),
url('/ViewerJS/fonts/Exotica-webfont.ttf') format('truetype'),
url('/ViewerJS/fonts/Exotica-webfont.svg#exoticamedium') format('svg');
font-weight: normal;
font-style: normal;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment