Compare commits

...

10 Commits

Author SHA1 Message Date
4d7a777730 fix scope 2017-02-21 18:10:54 +03:00
71fd3e8ce8 update packages 2017-02-21 18:06:27 +03:00
fabb6f5f6d add check error on upload
upload to tmp folder (delete if error)
2017-02-21 18:06:06 +03:00
9c4fc0347f add delete all files
if filename exist delete file, other - delete all files
var -> let and const
2017-02-21 16:23:32 +03:00
8ab3069acf update package formidable 2017-02-21 16:19:39 +03:00
96666e9723 Copyright 2017 2017-02-21 11:01:51 +03:00
bec8de63eb remove base ulr 2017-02-20 17:47:19 +03:00
6c01f7a11b add plugins 2017-02-17 19:27:29 +03:00
d83c103a31 update favicon.ico 2017-02-17 15:22:16 +03:00
dac9003e58 Fix Bug 33954 - open mobile editor by user agent 2017-02-15 16:47:30 +03:00
24 changed files with 206 additions and 176 deletions

View File

@ -1,13 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="App_Data\MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Zip" />
<PropertyGroup>
<To Condition=" '$(To)' == '' ">..\deploy\</To>
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
</PropertyGroup>
<ItemGroup>

View File

@ -1,20 +1,20 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Zip" />
<PropertyGroup>
<To Condition=" '$(To)' == '' ">..\deploy\</To>
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
<DirJava>$(RootDir)web\documentserver-example\java\</DirJava>
<DirNodeJS>$(RootDir)web\documentserver-example\nodejs\</DirNodeJS>
<DirPHP>$(RootDir)web\documentserver-example\php\</DirPHP>
<DirRuby>$(RootDir)web\documentserver-example\ruby\</DirRuby>
<DirCSharp>$(RootDir)web\documentserver-example\csharp\</DirCSharp>
<DirMvc>$(RootDir)web\documentserver-example\csharp-mvc\</DirMvc>
<DirJava>$(RootDir)web\documentserver-example\java\</DirJava>
<DirNodeJS>$(RootDir)web\documentserver-example\nodejs\</DirNodeJS>
<DirPHP>$(RootDir)web\documentserver-example\php\</DirPHP>
<DirRuby>$(RootDir)web\documentserver-example\ruby\</DirRuby>
</PropertyGroup>
<Target Name="Build">
<ItemGroup>
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)App_Data\*.dll;$(DirCSharp)obj\**;" />
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)obj\**;" />
</ItemGroup>
<Zip Files="@(ZipFilesCSharp)" WorkingDirectory="$(DirCSharp)" ZipFileName="$(To).Net (C#) Example.zip" />
@ -29,7 +29,7 @@
<Zip Files="@(ZipFilesJava)" WorkingDirectory="$(DirJava)" ZipFileName="$(To)Java Example.zip" />
<ItemGroup>
<ZipFilesNodeJS Include="$(DirNodeJS)**" Exclude="$(DirNodeJS)node_modules\**;$(DirNodeJS)run.bat" />
<ZipFilesNodeJS Include="$(DirNodeJS)**" Exclude="$(DirNodeJS)node_modules\**" />
</ItemGroup>
<Zip Files="@(ZipFilesNodeJS)" WorkingDirectory="$(DirNodeJS)" ZipFileName="$(To)Node.js Example.zip" />

View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("OnlineEditorsExampleMVC")]
[assembly: AssemblyCopyright("Ascensio System SIA 2016")]
[assembly: AssemblyCopyright("Ascensio System SIA 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("OnlineEditorsExample")]
[assembly: AssemblyCopyright("Ascensio System SIA 2016")]
[assembly: AssemblyCopyright("Ascensio System SIA 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

View File

@ -23,37 +23,39 @@
*
*/
var express = require("express");
var path = require("path");
var favicon = require("serve-favicon");
var bodyParser = require("body-parser");
var fileSystem = require("fs");
var formidable = require("formidable");
var syncRequest = require("sync-request");
var config = require('config');
var configServer = config.get('server');
var docManager = require("./helpers/docManager");
var documentService = require("./helpers/documentService");
var fileUtility = require("./helpers/fileUtility");
var siteUrl = configServer.get('siteUrl');
var fileChoiceUrl = configServer.has('fileChoiceUrl') ? configServer.get('fileChoiceUrl') : "";
var plugins = config.get('plugins');
const express = require("express");
const path = require("path");
const favicon = require("serve-favicon");
const bodyParser = require("body-parser");
const fileSystem = require("fs");
const formidable = require("formidable");
const syncRequest = require("sync-request");
const config = require('config');
const configServer = config.get('server');
const docManager = require("./helpers/docManager");
const documentService = require("./helpers/documentService");
const fileUtility = require("./helpers/fileUtility");
const siteUrl = configServer.get('siteUrl');
const fileChoiceUrl = configServer.has('fileChoiceUrl') ? configServer.get('fileChoiceUrl') : "";
const plugins = config.get('plugins');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
String.prototype.hashCode = function () {
for (var ret = 0, i = 0, len = this.length; i < len; i++) {
const len = this.length;
let ret = 0;
for (let i = 0; i < len; i++) {
ret = (31 * ret + this.charCodeAt(i)) << 0;
}
return ret;
};
String.prototype.format = function () {
var text = this.toString();
let text = this.toString();
if (!arguments.length) return text;
for (var i = 0; i < arguments.length; i++) {
for (let i = 0; i < arguments.length; i++) {
text = text.replace(new RegExp("\\{" + i + "\\}", "gi"), arguments[i]);
}
@ -61,11 +63,9 @@ String.prototype.format = function () {
};
var app = express();
const app = express();
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs")
app.set("view engine", "ejs");
app.use(function (req, res, next) {
@ -75,9 +75,9 @@ app.use(function (req, res, next) {
app.use(express.static(path.join(__dirname, "public")));
if (config.has('server.static')) {
var staticContent = config.get('server.static');
for (var i = 0; i < staticContent.length; ++i) {
var staticContentElem = staticContent[i];
const staticContent = config.get('server.static');
for (let i = 0; i < staticContent.length; ++i) {
const staticContentElem = staticContent[i];
app.use(staticContentElem['name'], express.static(staticContentElem['path'], staticContentElem['options']));
}
}
@ -115,32 +115,41 @@ app.post("/upload", function (req, res) {
docManager.init(__dirname, req, res);
docManager.storagePath(""); //mkdir if not exist
var userIp = docManager.curUserHostAddress();
var uploadDir = "./public/" + configServer.get('storageFolder') + "/" + userIp;
const userIp = docManager.curUserHostAddress();
const uploadDir = path.join("./public", configServer.get('storageFolder'), userIp);
const uploadDirTmp = path.join(uploadDir, 'tmp');
docManager.createDirectory(uploadDirTmp);
var form = new formidable.IncomingForm();
form.uploadDir = uploadDir;
const form = new formidable.IncomingForm();
form.uploadDir = uploadDirTmp;
form.keepExtensions = true;
form.parse(req, function (err, fields, files) {
if (err) {
docManager.cleanFolderRecursive(uploadDirTmp, true);
res.writeHead(200, { "Content-Type": "text/plain" });
res.write("{ \"error\": \"" + err.message + "\"}");
res.end();
return;
}
var file = files.uploadedFile;
const file = files.uploadedFile;
file.name = docManager.getCorrectName(file.name);
if (configServer.get('maxFileSize') < file.size || file.size <= 0) {
fileSystem.unlinkSync(file.path);
docManager.cleanFolderRecursive(uploadDirTmp, true);
res.writeHead(200, { "Content-Type": "text/plain" });
res.write("{ \"error\": \"File size is incorrect\"}");
res.end();
return;
}
var exts = [].concat(configServer.get('viewedDocs'), configServer.get('editedDocs'), configServer.get('convertedDocs'));
var curExt = fileUtility.getFileExtension(file.name);
const exts = [].concat(configServer.get('viewedDocs'), configServer.get('editedDocs'), configServer.get('convertedDocs'));
const curExt = fileUtility.getFileExtension(file.name);
if (exts.indexOf(curExt) == -1) {
fileSystem.unlinkSync(file.path);
docManager.cleanFolderRecursive(uploadDirTmp, true);
res.writeHead(200, { "Content-Type": "text/plain" });
res.write("{ \"error\": \"File type is not supported\"}");
res.end();
@ -148,14 +157,15 @@ app.post("/upload", function (req, res) {
}
fileSystem.rename(file.path, uploadDir + "/" + file.name, function (err) {
docManager.cleanFolderRecursive(uploadDirTmp, true);
res.writeHead(200, { "Content-Type": "text/plain" });
if (err) {
res.write("{ \"error\": \"" + err + "\"}");
} else {
res.write("{ \"filename\": \"" + file.name + "\"}");
var userid = req.query.userid ? req.query.userid : "uid-1";
var name = req.query.name ? req.query.name : "Jonn Smith";
const userid = req.query.userid ? req.query.userid : "uid-1";
const name = req.query.name ? req.query.name : "Jonn Smith";
docManager.saveFileData(file.name, userid, name);
}
@ -233,7 +243,7 @@ app.get("/convert", function (req, res) {
try {
if (configServer.get('convertedDocs').indexOf(fileExt) != -1) {
var key = documentService.generateRevisionId(fileUri);
const key = documentService.generateRevisionId(fileUri);
documentService.getConvertedUri(fileUri, fileExt, internalFileExt, key, true, callback);
} else {
writeResult(fileName, null, null);
@ -246,31 +256,20 @@ app.get("/convert", function (req, res) {
app.delete("/file", function (req, res) {
try {
docManager.init(__dirname, req, res);
docManager.init(__dirname, req, res);
let fileName = req.query.filename;
if (fileName) {
fileName = fileUtility.getFileName(fileName);
var fileName = fileUtility.getFileName(req.query.filename);
const filePath = docManager.storagePath(fileName);
fileSystem.unlinkSync(filePath);
var filePath = docManager.storagePath(fileName)
fileSystem.unlinkSync(filePath);
var userAddress = docManager.curUserHostAddress();
var historyPath = docManager.historyPath(fileName, userAddress, true);
var deleteFolderRecursive = function (path) {
if (fileSystem.existsSync(path)) {
var files = fileSystem.readdirSync(path);
files.forEach(function (file, index) {
var curPath = path + "/" + file;
if (fileSystem.lstatSync(curPath).isDirectory()) {
deleteFolderRecursive(curPath);
} else {
fileSystem.unlinkSync(curPath);
}
});
fileSystem.rmdirSync(path);
}
};
deleteFolderRecursive(historyPath);
const userAddress = docManager.curUserHostAddress();
const historyPath = docManager.historyPath(fileName, userAddress, true);
docManager.cleanFolderRecursive(historyPath, true);
} else {
docManager.cleanFolderRecursive(docManager.storagePath(''), false);
}
res.write("{\"success\":true}");
} catch (ex) {
@ -422,7 +421,11 @@ app.get("/editor", function (req, res) {
var key = docManager.getKey(fileName);
var url = docManager.getFileUri(fileName);
var mode = req.query.mode || "edit"; //mode: view/edit
var type = req.query.type || "desktop"; //type: embedded/mobile/desktop
var type = req.query.type || ""; //type: embedded/mobile/desktop
if (type == "") {
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
}
var canEdit = configServer.get('editedDocs').indexOf(fileUtility.getFileExtension(fileName)) != -1;
var countVersion = 1;
@ -497,7 +500,7 @@ app.get("/editor", function (req, res) {
});
app.use(function (req, res, next) {
var err = new Error("Not Found");
const err = new Error("Not Found");
err.status = 404;
next(err);
});

View File

@ -24,6 +24,7 @@
"convertedDocs": [".doc", ".odt", ".xls", ".ods", ".ppt", ".pps", ".odp", ".rtf", ".mht", ".html", ".htm", ".epub"],
"storageFolder": "files",
"maxFileSize": 1073741824,
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
"static":[
{
"name": "/public",
@ -32,15 +33,15 @@
]
},
"plugins": {
"url": "../../../../sdkjs-plugins/",
"url": "",
"pluginsData": [
"helloworld/config.json",
"chess/config.json",
"speech/config.json",
"youtube/config.json",
"cbr/config.json",
"ocr/config.json",
"clipart/config.json"
"../../../../sdkjs-plugins/helloworld/config.json",
"../../../../sdkjs-plugins/chess/config.json",
"../../../../sdkjs-plugins/speech/config.json",
"../../../../sdkjs-plugins/youtube/config.json",
"../../../../sdkjs-plugins/cbr/config.json",
"../../../../sdkjs-plugins/ocr/config.json",
"../../../../sdkjs-plugins/clipart/config.json"
]
}
}

View File

@ -5,18 +5,20 @@
},
"plugins": {
"pluginsData": [
"helloworld/config.json",
"chess/config.json",
"glavred/config.json",
"speech/config.json",
"youtube/config.json",
"cbr/config.json",
"num2word/config.json",
"ocr/config.json",
"yandextranslaterus/config.json",
"clipart/config.json",
"translate/config.json",
"templates/config.json"
"../../../../sdkjs-plugins/helloworld/config.json",
"../../../../sdkjs-plugins/chess/config.json",
"../../../../sdkjs-plugins/glavred/config.json",
"../../../../sdkjs-plugins/speech/config.json",
"../../../../sdkjs-plugins/youtube/config.json",
"../../../../sdkjs-plugins/cbr/config.json",
"../../../../sdkjs-plugins/num2word/config.json",
"../../../../sdkjs-plugins/ocr/config.json",
"../../../../sdkjs-plugins/yandextranslaterus/config.json",
"../../../../sdkjs-plugins/clipart/config.json",
"../../../../sdkjs-plugins/translate/config.json",
"../../../../sdkjs-plugins/templates/config.json",
"../../../../sdkjs-plugins/telegram/config.json",
"../../../../sdkjs-plugins/invoices/config.json"
],
"UIpluginsData": []
}

View File

@ -23,15 +23,15 @@
*
*/
var path = require("path");
var fileSystem = require("fs");
var fileUtility = require("./fileUtility");
var documentService = require("./documentService");
var cacheManager = require("./cacheManager");
var guidManager = require("./guidManager");
var configServer = require('config').get('server');
var storageFolder = configServer.get('storageFolder');
var os = require("os");
const path = require("path");
const fileSystem = require("fs");
const fileUtility = require("./fileUtility");
const documentService = require("./documentService");
const cacheManager = require("./cacheManager");
const guidManager = require("./guidManager");
const configServer = require('config').get('server');
const storageFolder = configServer.get('storageFolder');
const os = require("os");
const readline = require('readline');
const rl = readline.createInterface({
@ -39,14 +39,14 @@ const rl = readline.createInterface({
output: process.stdout
});
var docManager = {};
let docManager = {};
docManager.dir = null;
docManager.req = null;
docManager.res = null;
docManager.existsSync = function(path) {
var res = true;
let res = true;
try {
fileSystem.accessSync(path, fileSystem.F_OK);
} catch (e) {
@ -77,34 +77,34 @@ docManager.getLang = function () {
};
docManager.getCustomParams = function () {
var params = "";
let params = "";
var userid = docManager.req.query.userid;
const userid = docManager.req.query.userid;
params += (userid ? "&userid=" + userid : "");
var name = docManager.req.query.name;
const name = docManager.req.query.name;
params += (name ? "&name=" + name : "");
var lang = docManager.req.query.lang;
const lang = docManager.req.query.lang;
params += (lang ? "&lang=" + docManager.getLang() : "");
var fileName = docManager.req.query.fileName;
const fileName = docManager.req.query.fileName;
params += (fileName ? "&fileName=" + fileName : "");
var mode = docManager.req.query.mode;
const mode = docManager.req.query.mode;
params += (mode ? "&mode=" + mode : "");
var type = docManager.req.query.type;
const type = docManager.req.query.type;
params += (type ? "&type=" + type : "");
return params;
};
docManager.getCorrectName = function (fileName, userAddress) {
var baseName = fileUtility.getFileName(fileName, true);
var ext = fileUtility.getFileExtension(fileName);
var name = baseName + ext;
var index = 1;
const baseName = fileUtility.getFileName(fileName, true);
const ext = fileUtility.getFileExtension(fileName);
let name = baseName + ext;
let index = 1;
while (this.existsSync(docManager.storagePath(name, userAddress))) {
name = baseName + " (" + index + ")" + ext;
@ -115,7 +115,7 @@ docManager.getCorrectName = function (fileName, userAddress) {
};
docManager.createDemo = function (demoName, userid, username) {
var fileName = docManager.getCorrectName(demoName);
const fileName = docManager.getCorrectName(demoName);
docManager.copyFile(path.join(docManager.dir, "public", "samples", demoName), docManager.storagePath(fileName));
@ -125,14 +125,14 @@ docManager.createDemo = function (demoName, userid, username) {
};
docManager.saveFileData = function (fileName, userid, username) {
var userAddress = docManager.curUserHostAddress();
var date_create = fileSystem.statSync(docManager.storagePath(fileName)).mtime;
var minutes = (date_create.getMinutes() < 10 ? '0' : '') + date_create.getMinutes().toString();
var month = (date_create.getMonth() < 10 ? '0' : '') + (parseInt(date_create.getMonth().toString()) + 1);
var sec = (date_create.getSeconds() < 10 ? '0' : '') + date_create.getSeconds().toString();
var date_format = date_create.getFullYear() + "-" + month + "-" + date_create.getDate() + " " + date_create.getHours() + ":" + minutes + ":" + sec;
const userAddress = docManager.curUserHostAddress();
const date_create = fileSystem.statSync(docManager.storagePath(fileName)).mtime;
const minutes = (date_create.getMinutes() < 10 ? '0' : '') + date_create.getMinutes().toString();
const month = (date_create.getMonth() < 10 ? '0' : '') + (parseInt(date_create.getMonth().toString()) + 1);
const sec = (date_create.getSeconds() < 10 ? '0' : '') + date_create.getSeconds().toString();
const date_format = date_create.getFullYear() + "-" + month + "-" + date_create.getDate() + " " + date_create.getHours() + ":" + minutes + ":" + sec;
var file_info = docManager.historyPath(fileName, userAddress, true);
const file_info = docManager.historyPath(fileName, userAddress, true);
this.createDirectory(file_info);
fileSystem.writeFileSync(path.join(file_info, fileName + ".txt"), date_format + "," + userid + "," + username);
@ -141,7 +141,7 @@ docManager.saveFileData = function (fileName, userid, username) {
docManager.getFileData = function (fileName, userAddress) {
const history = path.join(docManager.historyPath(fileName, userAddress, true), fileName + ".txt");
if (!this.existsSync(history)) {
return ["2016-01-01", "uid-1", "John Smith"];
return ["2017-01-01", "uid-1", "John Smith"];
}
return ((fileSystem.readFileSync(history)).toString()).split(",");
@ -152,10 +152,10 @@ docManager.getFileUri = function (fileName) {
};
docManager.getlocalFileUri = function (fileName, version) {
var serverPath = docManager.getServerUrl();
var storagePath = storageFolder.length ? storageFolder + "/" : "";
var hostAddress = docManager.curUserHostAddress();
var url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
const serverPath = docManager.getServerUrl();
const storagePath = storageFolder.length ? storageFolder + "/" : "";
const hostAddress = docManager.curUserHostAddress();
const url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
if (!version) {
return url;
}
@ -167,22 +167,22 @@ docManager.getServerUrl = function () {
};
docManager.getCallback = function (fileName) {
var server = docManager.getServerUrl();
var hostAddress = docManager.curUserHostAddress();
var handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
const server = docManager.getServerUrl();
const hostAddress = docManager.curUserHostAddress();
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
return server + handler;
};
docManager.storagePath = function (fileName, userAddress) {
fileName = fileUtility.getFileName(fileName);
var directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
const directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
this.createDirectory(directory);
return path.join(directory, fileName);
};
docManager.historyPath = function (fileName, userAddress, create) {
var directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
if (!this.existsSync(directory)) {
return "";
}
@ -194,7 +194,7 @@ docManager.historyPath = function (fileName, userAddress, create) {
};
docManager.versionPath = function (fileName, userAddress, version) {
var historyPath = docManager.historyPath(fileName, userAddress, true);
const historyPath = docManager.historyPath(fileName, userAddress, true);
return path.join(historyPath, "" + version);
};
@ -219,17 +219,17 @@ docManager.changesUser = function (fileName, userAddress, version) {
};
docManager.getStoredFiles = function () {
var directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress());
const directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress());
this.createDirectory(directory);
var result = [];
var storedFiles = fileSystem.readdirSync(directory);
for (var i = 0; i < storedFiles.length; i++) {
var stats = fileSystem.lstatSync(path.join(directory, storedFiles[i]));
const result = [];
const storedFiles = fileSystem.readdirSync(directory);
for (let i = 0; i < storedFiles.length; i++) {
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i]));
if (!stats.isDirectory()) {
var time = stats.mtime.getTime();
var item = {
const time = stats.mtime.getTime();
const item = {
time: time,
name: storedFiles[i],
url: docManager.getlocalFileUri(storedFiles[i]),
@ -239,7 +239,8 @@ docManager.getStoredFiles = function () {
if (!result.length) {
result.push(item);
} else {
for (var j = 0; j < result.length; j++) {
let j = 0;
for (; j < result.length; j++) {
if (time > result[j].time) {
break;
}
@ -280,23 +281,23 @@ docManager.getInternalExtension = function (fileType) {
};
docManager.getKey = function (fileName) {
var userAddress = docManager.curUserHostAddress();
var key = userAddress + docManager.getlocalFileUri(fileName);
const userAddress = docManager.curUserHostAddress();
let key = userAddress + docManager.getlocalFileUri(fileName);
var historyPath = docManager.historyPath(fileName, userAddress);
let historyPath = docManager.historyPath(fileName, userAddress);
if (historyPath != ""){
key += docManager.countVersion(historyPath);
}
historyPath = docManager.historyPath(fileName, userAddress, true);
var stat = fileSystem.statSync(historyPath);
const stat = fileSystem.statSync(historyPath);
key += stat.mtime.toString();
return documentService.generateRevisionId(key);
};
docManager.getDate = function (date) {
var minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
const minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
return date.getMonth() + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + minutes;
};
@ -305,7 +306,7 @@ docManager.getChanges = function (fileName) {
};
docManager.countVersion = function(directory) {
var i = 0;
let i = 0;
while (this.existsSync(path.join(directory, '' + (i + 1)))) {
i++;
}
@ -313,8 +314,8 @@ docManager.countVersion = function(directory) {
};
docManager.getHistory = function (fileName, content, keyVersion, version) {
var oldVersion = false;
var contentJson = null;
let oldVersion = false;
let contentJson = null;
if (content) {
if (content.changes) {
contentJson = content.changes[0];
@ -324,11 +325,11 @@ docManager.getHistory = function (fileName, content, keyVersion, version) {
}
}
var userAddress = docManager.curUserHostAddress();
var username = content ? (oldVersion ? contentJson.username : contentJson.user.name) : (docManager.getFileData(fileName, userAddress))[2];
var userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (docManager.getFileData(fileName, userAddress))[1];
var created = content ? (oldVersion ? contentJson.date : contentJson.created) : (docManager.getFileData(fileName, userAddress))[0];
var res = (content && !oldVersion) ? content : {changes: content};
const userAddress = docManager.curUserHostAddress();
const username = content ? (oldVersion ? contentJson.username : contentJson.user.name) : (docManager.getFileData(fileName, userAddress))[2];
const userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (docManager.getFileData(fileName, userAddress))[1];
const created = content ? (oldVersion ? contentJson.date : contentJson.created) : (docManager.getFileData(fileName, userAddress))[0];
const res = (content && !oldVersion) ? content : {changes: content};
res.key = keyVersion;
res.version = version;
res.created = created;
@ -340,4 +341,21 @@ docManager.getHistory = function (fileName, content, keyVersion, version) {
return res;
};
docManager.cleanFolderRecursive = function (folder, me) {
if (fileSystem.existsSync(folder)) {
const files = fileSystem.readdirSync(folder);
files.forEach((file) => {
const curPath = path.join(folder, file);
if (fileSystem.lstatSync(curPath).isDirectory()) {
this.cleanFolderRecursive(curPath, true);
} else {
fileSystem.unlinkSync(curPath);
}
});
if (me) {
fileSystem.rmdirSync(folder);
}
}
};
module.exports = docManager;

View File

@ -14,16 +14,16 @@
"url": "https://github.com/ONLYOFFICE/document-server-integration/issues"
},
"dependencies": {
"body-parser": "~1.15.2",
"body-parser": "^1.16.1",
"config": "^1.21.0",
"debug": "~2.2.0",
"ejs": "~2.5.1",
"express": "^4.14.0",
"formidable": "~1.0.17",
"express": "^4.14.1",
"formidable": "^1.1.1",
"log4js": "^0.6.38",
"serve-favicon": "~2.3.0",
"sync-request": "~3.0.1",
"urllib": "~2.11.0",
"sync-request": "^4.0.1",
"urllib": "^2.20.0",
"xml2js": "~0.4.17"
},
"license": "MIT",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

View File

@ -145,7 +145,7 @@
<img class="icon-delete" src="images/delete-24.png" alt="Delete" title="Delete" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
@ -154,12 +154,12 @@
</td>
<td class="contentCells contentCells-shift contentCells-icon">
<% if (storedFiles[i].documentType == "text") { %>
<a href="editor?mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/review-24.png" alt="Open in editor for review" title="Open in editor for review" /></a>
<% } %>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
@ -227,7 +227,7 @@
<span id="loadScripts" data-docs="<%= preloaderUrl %>"></span>
<footer>&copy; Ascensio Systems Inc 2016. All rights reserved.</footer>
<footer>&copy; Ascensio Systems Inc 2017. All rights reserved.</footer>
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>

View File

@ -1,7 +1,7 @@
<?php
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
* (c) Copyright Ascensio System Limited 2010-2017
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).

View File

@ -20,6 +20,8 @@ $GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://doc.onlyoffice.com/web-apps/apps/a
$GLOBALS['EXAMPLE_URL'] = "";
$GLOBALS['MOBILE_REGEX'] = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx",
".ods", ".csv");

View File

@ -157,14 +157,18 @@
}
?>
var user = [{id:"0","name":"Jonn Smith"}, {id:"1","name":"Mark Pottato"}, {id:"2","name":"Hamish Mitchell"}]["<?php echo $_GET["user"] ?>" || 0];
var user = [{id:"0","name":"Jonn Smith"}, {id:"1","name":"Mark Pottato"}, {id:"2","name":"Hamish Mitchell"}]["<?php echo $_GET["user"] ?>" || 0];
var type = "<?php echo ($_GET["type"] == "mobile" ? "mobile" : ($_GET["type"] == "embedded" ? "embedded" : ($_GET["type"] == "desktop" ? "desktop" : ""))) ?>";
if (type == "") {
type = new RegExp("<?php echo $GLOBALS['MOBILE_REGEX'] ?>", "i").test(window.navigator.userAgent) ? "mobile" : "desktop";
}
docEditor = new DocsAPI.DocEditor("iframeEditor",
{
width: "100%",
height: "100%",
type: "<?php echo ($_GET["type"] == "mobile" ? "mobile" : ($_GET["type"] == "embedded" ? "embedded" : "desktop")) ?>",
type: type,
documentType: "<?php echo getDocumentType($filename) ?>",
document: {
title: fileName,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

View File

@ -1,7 +1,7 @@
<?php
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
* (c) Copyright Ascensio System Limited 2010-2017
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).

View File

@ -184,7 +184,7 @@
echo ' </a>';
echo ' </td>';
echo ' <td class="contentCells contentCells-icon">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'" target="_blank">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&type=desktop" target="_blank">';
echo ' <img src="css/images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>';
echo ' </a>';
echo ' </td>';
@ -194,13 +194,13 @@
echo ' </a>';
echo ' <td class="contentCells contentCells-shift contentCells-icon">';
if ($storeFile->documentType == "text") {
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=review" target="_blank">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=review&type=desktop" target="_blank">';
echo ' <img src="css/images/review-24.png" alt="Open in editor for review" title="Open in editor for review" /></a>';
echo ' </a>';
}
echo ' </td>';
echo ' <td class="contentCells contentCells-icon">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=view" target="_blank">';
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=view&type=desktop" target="_blank">';
echo ' <img src="css/images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>';
echo ' </a>';
echo ' </td>';

View File

@ -1,7 +1,7 @@
<?php
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
* (c) Copyright Ascensio System Limited 2010-2017
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 466 B

View File

@ -89,6 +89,6 @@ onlyoffice4enterprise/documentserver-ee</pre>
</div>
</div>
<footer>© Ascensio Systems Inc 2016. All rights reserved.</footer>
<footer>© Ascensio Systems Inc 2017. All rights reserved.</footer>
</body>
</html>