Compare commits
47 Commits
v4.3.0.178
...
v4.4.0.232
| Author | SHA1 | Date | |
|---|---|---|---|
| 022acfb9cd | |||
| 66c19c1b89 | |||
| bbd8305ad9 | |||
| c5b6b7ab1b | |||
| c854249add | |||
| 837b56b20f | |||
| 80b081883e | |||
| 7c71d42975 | |||
| a52d5cb3be | |||
| a9d261a0ad | |||
| 5dea4c77a9 | |||
| 8eb017b092 | |||
| dd346a380e | |||
| 61497a8da7 | |||
| 34d568bdbc | |||
| 905084dc52 | |||
| e00b662660 | |||
| 5ded3f6135 | |||
| a096e96b29 | |||
| b452a171d1 | |||
| 282ea78799 | |||
| 4824373678 | |||
| df8a575d75 | |||
| e023ec3bb7 | |||
| 535ba03cdf | |||
| f5d416e371 | |||
| 931e05a175 | |||
| 293919bb6e | |||
| 35c4dd6a95 | |||
| 32aff45d7d | |||
| 1b73970ebc | |||
| c014250479 | |||
| b1e216da88 | |||
| 257bf005eb | |||
| 4d7a777730 | |||
| 71fd3e8ce8 | |||
| fabb6f5f6d | |||
| 9c4fc0347f | |||
| 8ab3069acf | |||
| 96666e9723 | |||
| bec8de63eb | |||
| 6c01f7a11b | |||
| d83c103a31 | |||
| dac9003e58 | |||
| 680670294b | |||
| 62906cd744 | |||
| f4e7a5cd6f |
1
.gitignore
vendored
@ -8,4 +8,5 @@
|
||||
/web/documentserver-example/nodejs/node_modules
|
||||
/web/documentserver-example/nodejs/public/files
|
||||
/web/documentserver-example/nodejs/config/local.json
|
||||
**/.vscode/
|
||||
**/.idea
|
||||
@ -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>
|
||||
|
||||
@ -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" />
|
||||
|
||||
|
||||
@ -129,8 +129,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=track"
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
};
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -61,8 +61,8 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
callbackUrl.Query = "type=track"
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(FileName);
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -191,7 +191,7 @@ public class DocumentManager
|
||||
{
|
||||
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
String query = "?type=track&userAddress=" + URLEncoder.encode(hostAddress) + "&fileName=" + URLEncoder.encode(fileName);
|
||||
String query = "?type=track&fileName=" + URLEncoder.encode(fileName) + "&userAddress=" + URLEncoder.encode(hostAddress);
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -23,37 +23,45 @@
|
||||
*
|
||||
*/
|
||||
|
||||
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 jwt = require('jsonwebtoken');
|
||||
const config = require('config');
|
||||
const configServer = config.get('server');
|
||||
const mime = require("mime");
|
||||
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');
|
||||
const cfgSignatureEnable = configServer.get('token.enable');
|
||||
const cfgSignatureUseForRequest = configServer.get('token.useforrequest');
|
||||
const cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
|
||||
const cfgSignatureSecret = configServer.get('token.secret');
|
||||
|
||||
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 +69,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 +81,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']));
|
||||
}
|
||||
}
|
||||
@ -110,37 +116,73 @@ app.get("/", function (req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/download", function(req, res) {
|
||||
docManager.init(__dirname, req, res);
|
||||
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var userAddress = docManager.curUserHostAddress();
|
||||
|
||||
var path = docManager.forcesavePath(fileName, userAddress, false);
|
||||
if (path == "") {
|
||||
path = docManager.storagePath(fileName, userAddress);
|
||||
}
|
||||
|
||||
res.setHeader("Content-Length", fileSystem.statSync(path).size);
|
||||
res.setHeader("Content-Type", mime.lookup(path));
|
||||
|
||||
res.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
|
||||
var filestream = fileSystem.createReadStream(path);
|
||||
filestream.pipe(res);
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
if (file == undefined) {
|
||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||
res.write("{ \"error\": \"Uploaded file not found\"}");
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
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 +190,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 +276,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 +289,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) {
|
||||
@ -290,7 +322,7 @@ app.post("/track", function (req, res) {
|
||||
|
||||
var processTrack = function (response, body, fileName, userAddress) {
|
||||
|
||||
var processSave = function (downloadUri, body, fileName, userAddress, resp, newVersion) {
|
||||
var processSave = function (downloadUri, body, fileName, userAddress, resp) {
|
||||
var curExt = fileUtility.getFileExtension(fileName);
|
||||
var downloadExt = fileUtility.getFileExtension(downloadUri);
|
||||
|
||||
@ -298,8 +330,8 @@ app.post("/track", function (req, res) {
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function(dUri){
|
||||
processSave(dUri, body, fileName, userAddress, resp, newVersion)
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
|
||||
processSave(dUri, body, fileName, userAddress, resp)
|
||||
});
|
||||
return;
|
||||
} catch (ex) {
|
||||
@ -312,7 +344,7 @@ app.post("/track", function (req, res) {
|
||||
|
||||
var path = docManager.storagePath(fileName, userAddress);
|
||||
|
||||
if (newVersion) {
|
||||
if (docManager.existsSync(path)) {
|
||||
var historyPath = docManager.historyPath(fileName, userAddress);
|
||||
if (historyPath == "") {
|
||||
historyPath = docManager.historyPath(fileName, userAddress, true);
|
||||
@ -342,10 +374,52 @@ app.post("/track", function (req, res) {
|
||||
|
||||
var path_prev = docManager.prevFilePath(fileName, userAddress, version);
|
||||
fileSystem.writeFileSync(path_prev, fileSystem.readFileSync(path));
|
||||
|
||||
var file = syncRequest("GET", downloadUri);
|
||||
fileSystem.writeFileSync(path, file.getBody());
|
||||
|
||||
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
|
||||
if (forcesavePath != "") {
|
||||
fileSystem.unlinkSync(forcesavePath);
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
}
|
||||
|
||||
response.write("{\"error\":0}");
|
||||
response.end();
|
||||
};
|
||||
|
||||
var processForceSave = function (downloadUri, body, fileName, userAddress, resp) {
|
||||
var curExt = fileUtility.getFileExtension(fileName);
|
||||
var downloadExt = fileUtility.getFileExtension(downloadUri);
|
||||
|
||||
if (downloadExt != curExt) {
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
|
||||
processForceSave(dUri, body, fileName, userAddress, resp)
|
||||
});
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
fileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
var path = docManager.storagePath(fileName, userAddress);
|
||||
|
||||
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
|
||||
if (forcesavePath == "") {
|
||||
forcesavePath = docManager.forcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
|
||||
var file = syncRequest("GET", downloadUri);
|
||||
fileSystem.writeFileSync(path, file.getBody());
|
||||
fileSystem.writeFileSync(forcesavePath, file.getBody());
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
}
|
||||
@ -367,10 +441,11 @@ app.post("/track", function (req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (body.status == 2 || body.status == 3 //MustSave, Corrupted
|
||||
|| body.status == 6 || body.status == 7) { //MustForceSave, CorruptedForceSave
|
||||
var newVersion = (body.status == 2 || body.status == 3);
|
||||
processSave(body.url, body, fileName, userAddress, response, newVersion);
|
||||
} else if (body.status == 2 || body.status == 3) { //MustSave, Corrupted
|
||||
processSave(body.url, body, fileName, userAddress, response);
|
||||
return;
|
||||
} else if (body.status == 6 || body.status == 7) { //MustForceSave, CorruptedForceSave
|
||||
processForceSave(body.url, body, fileName, userAddress, response);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -389,6 +464,29 @@ app.post("/track", function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
//checkjwt
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
var checkJwtHeaderRes = documentService.checkJwtHeader(req);
|
||||
if (checkJwtHeaderRes) {
|
||||
if (checkJwtHeaderRes.payload) {
|
||||
body = checkJwtHeaderRes.payload;
|
||||
}
|
||||
if (checkJwtHeaderRes.query) {
|
||||
if (checkJwtHeaderRes.query.useraddress) {
|
||||
userAddress = checkJwtHeaderRes.query.useraddress;
|
||||
}
|
||||
if (checkJwtHeaderRes.query.filename) {
|
||||
fileName = fileUtility.getFileName(checkJwtHeaderRes.query.filename);
|
||||
}
|
||||
}
|
||||
processTrack(res, body, fileName, userAddress);
|
||||
} else {
|
||||
res.write("{\"error\":1}");
|
||||
res.end();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.hasOwnProperty("status")) {
|
||||
processTrack(res, req.body, fileName, userAddress);
|
||||
} else {
|
||||
@ -403,8 +501,7 @@ app.get("/editor", function (req, res) {
|
||||
|
||||
var fileExt = req.query.fileExt;
|
||||
var history = [];
|
||||
var prevUrl = [];
|
||||
var diff = [];
|
||||
var historyData = [];
|
||||
var lang = docManager.getLang();
|
||||
var userid = req.query.userid ? req.query.userid : "uid-1";
|
||||
var name = req.query.name ? req.query.name : "Jonn Smith";
|
||||
@ -418,43 +515,69 @@ app.get("/editor", function (req, res) {
|
||||
}
|
||||
|
||||
var userAddress = docManager.curUserHostAddress();
|
||||
fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
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;
|
||||
|
||||
var historyPath = docManager.historyPath(fileName, userAddress);
|
||||
changes = null;
|
||||
var changes = null;
|
||||
var keyVersion = key;
|
||||
|
||||
if (historyPath != '') {
|
||||
|
||||
countVersion = docManager.countVersion(historyPath) + 1;
|
||||
var prevPath = docManager.getlocalFileUri(fileName, 1) + "/prev" + fileUtility.getFileExtension(fileName);
|
||||
var diffPath = null;
|
||||
for (var i = 1; i < countVersion; i++) {
|
||||
var keyPath = docManager.keyPath(fileName, userAddress, i);
|
||||
var keyVersion = "" + fileSystem.readFileSync(keyPath);
|
||||
for (var i = 1; i <= countVersion; i++) {
|
||||
if (i < countVersion) {
|
||||
var keyPath = docManager.keyPath(fileName, userAddress, i);
|
||||
keyVersion = "" + fileSystem.readFileSync(keyPath);
|
||||
} else {
|
||||
keyVersion = key;
|
||||
}
|
||||
history.push(docManager.getHistory(fileName, changes, keyVersion, i));
|
||||
|
||||
prevUrl.push(prevPath);
|
||||
prevPath = docManager.getlocalFileUri(fileName, i) + "/prev" + fileUtility.getFileExtension(fileName);
|
||||
|
||||
diff.push(diffPath);
|
||||
diffPath = docManager.getlocalFileUri(fileName, i) + "/diff.zip";
|
||||
|
||||
var changesFile = docManager.changesPath(fileName, userAddress, i);
|
||||
var changes = docManager.getChanges(changesFile);
|
||||
var historyD = {
|
||||
version: i,
|
||||
key: keyVersion,
|
||||
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileUtility.getFileExtension(fileName)),
|
||||
};
|
||||
if (i > 1) {
|
||||
historyD.previous = {
|
||||
key: historyData[i-2].key,
|
||||
url: historyData[i-2].url,
|
||||
|
||||
};
|
||||
historyD.changesUrl = docManager.getlocalFileUri(fileName, i-1) + "/diff.zip";
|
||||
}
|
||||
historyData.push(historyD);
|
||||
|
||||
if (i < countVersion) {
|
||||
var changesFile = docManager.changesPath(fileName, userAddress, i);
|
||||
changes = docManager.getChanges(changesFile);
|
||||
}
|
||||
}
|
||||
prevUrl.push(prevPath);
|
||||
diff.push(diffPath);
|
||||
} else {
|
||||
prevUrl.push(url);
|
||||
history.push(docManager.getHistory(fileName, changes, keyVersion, countVersion));
|
||||
historyData.push({
|
||||
version: countVersion,
|
||||
key: key,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
|
||||
if (cfgSignatureEnable) {
|
||||
for (var i = 0; i < historyData.length; i++) {
|
||||
historyData[i].token = jwt.sign(historyData[i], cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
}
|
||||
}
|
||||
history.push(docManager.getHistory(fileName, changes, key, countVersion));
|
||||
|
||||
var argss = {
|
||||
apiUrl: siteUrl + configServer.get('apiUrl'),
|
||||
@ -462,32 +585,42 @@ app.get("/editor", function (req, res) {
|
||||
name: fileName,
|
||||
ext: fileUtility.getFileExtension(fileName, true),
|
||||
uri: url,
|
||||
version: countVersion
|
||||
version: countVersion,
|
||||
created: new Date().toDateString()
|
||||
},
|
||||
editor: {
|
||||
type: type,
|
||||
documentType: fileUtility.getFileType(fileName),
|
||||
key: key,
|
||||
token: "",
|
||||
callbackUrl: docManager.getCallback(fileName),
|
||||
isEdit: canEdit && mode != "review",
|
||||
mode: canEdit && mode != "view" ? "edit" : "view",
|
||||
canBackToFolder: type != "embedded",
|
||||
getServerUrl: docManager.getServerUrl(),
|
||||
backUrl: docManager.getServerUrl(),
|
||||
curUserHostAddress: docManager.curUserHostAddress(),
|
||||
lang: lang,
|
||||
userid: userid,
|
||||
name: name,
|
||||
fileChoiceUrl: fileChoiceUrl,
|
||||
plugins: plugins
|
||||
plugins: JSON.stringify(plugins)
|
||||
},
|
||||
history: history,
|
||||
setHistoryData: {
|
||||
url: prevUrl,
|
||||
changesUrl: diff
|
||||
}
|
||||
historyData: historyData
|
||||
};
|
||||
|
||||
res.render("editor", argss);
|
||||
if (cfgSignatureEnable) {
|
||||
app.render('config', argss, function(err, html){
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
argss.editor.token = jwt.sign(JSON.parse("{"+html+"}"), cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
}
|
||||
res.render("editor", argss);
|
||||
});
|
||||
} else {
|
||||
res.render("editor", argss);
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
console.log(ex);
|
||||
@ -497,7 +630,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);
|
||||
});
|
||||
|
||||
@ -19,28 +19,30 @@
|
||||
"tempStorageUrl": "ResourceService.ashx",
|
||||
"apiUrl": "web-apps/apps/api/documents/api.js",
|
||||
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
|
||||
"exampleUrl": null,
|
||||
"viewedDocs": [".ppt", ".pps", ".odp", ".pdf", ".djvu", ".epub", ".xps"],
|
||||
"editedDocs": [".docx", ".doc", ".odt", ".xlsx", ".xls", ".ods", ".csv", ".pptx", ".ppsx", ".rtf", ".txt", ".mht", ".html", ".htm"],
|
||||
"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",
|
||||
"path": "public"
|
||||
}
|
||||
]
|
||||
],
|
||||
"token": {
|
||||
"enable": false,
|
||||
"useforrequest": true,
|
||||
"algorithmRequest": "HS256",
|
||||
"authorizationHeader": "Authorization",
|
||||
"authorizationHeaderPrefix": "Bearer ",
|
||||
"secret": "secret",
|
||||
"expiresIn": "5m"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"url": "../../../../sdkjs-plugins/",
|
||||
"pluginsData": [
|
||||
"helloworld/config.json",
|
||||
"chess/config.json",
|
||||
"speech/config.json",
|
||||
"youtube/config.json",
|
||||
"cbr/config.json",
|
||||
"ocr/config.json",
|
||||
"clipart/config.json"
|
||||
]
|
||||
"pluginsData": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,22 +2,5 @@
|
||||
"server": {
|
||||
"port": 80,
|
||||
"siteUrl": "http://127.0.0.1:8001/"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"UIpluginsData": []
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,5 @@
|
||||
"server": {
|
||||
"siteUrl": "/",
|
||||
"maxFileSize": 104857600
|
||||
},
|
||||
"plugins": {
|
||||
"url": "/sdkjs-plugins/"
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,15 +7,7 @@
|
||||
"name": "/public",
|
||||
"path": "public",
|
||||
"options": {"maxAge": "7d"}
|
||||
},
|
||||
{
|
||||
"name": "/sdkjs-plugins",
|
||||
"path": "sdkjs-plugins",
|
||||
"options": {"maxAge": "7d"}
|
||||
}
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"url": "/sdkjs-plugins/"
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,30 +23,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
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 readline = require('readline');
|
||||
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 rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
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 +71,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 +109,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,64 +119,81 @@ 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);
|
||||
};
|
||||
|
||||
docManager.getFileData = function (fileName, userAddress) {
|
||||
var file_info = docManager.historyPath(fileName, userAddress, true);
|
||||
if (!this.existsSync(file_info)) {
|
||||
return ["2016-01-01", "uid-1", "John Smith"];
|
||||
const history = path.join(docManager.historyPath(fileName, userAddress, true), fileName + ".txt");
|
||||
if (!this.existsSync(history)) {
|
||||
return ["2017-01-01", "uid-1", "John Smith"];
|
||||
}
|
||||
|
||||
return ((fileSystem.readFileSync(path.join(file_info, fileName + ".txt"))).toString()).split(",");
|
||||
return ((fileSystem.readFileSync(history)).toString()).split(",");
|
||||
};
|
||||
|
||||
docManager.getFileUri = function (fileName) {
|
||||
return docManager.getlocalFileUri(fileName);
|
||||
return docManager.getlocalFileUri(fileName, 0, true);
|
||||
};
|
||||
|
||||
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);
|
||||
docManager.getlocalFileUri = function (fileName, version, forDocumentServer) {
|
||||
const serverPath = docManager.getServerUrl(forDocumentServer);
|
||||
const storagePath = storageFolder.length ? storageFolder + "/" : "";
|
||||
const hostAddress = docManager.curUserHostAddress();
|
||||
const url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
|
||||
if (!version) {
|
||||
return url;
|
||||
}
|
||||
return url + "-history/" + version;
|
||||
};
|
||||
|
||||
docManager.getServerUrl = function () {
|
||||
return docManager.getProtocol() + "://" + docManager.req.get("host");
|
||||
docManager.getServerUrl = function (forDocumentServer) {
|
||||
return (forDocumentServer && !!configServer.get("exampleUrl")) ? configServer.get("exampleUrl") : (docManager.getProtocol() + "://" + docManager.req.get("host"));
|
||||
};
|
||||
|
||||
docManager.getCallback = function (fileName) {
|
||||
var server = docManager.getServerUrl();
|
||||
var hostAddress = docManager.curUserHostAddress();
|
||||
var handler = "/track?useraddress=" + encodeURIComponent(hostAddress) + "&filename=" + encodeURIComponent(fileName);
|
||||
const server = docManager.getServerUrl(true);
|
||||
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.forcesavePath = function (fileName, userAddress, create) {
|
||||
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
|
||||
if (!this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
directory = path.join(directory, fileName + "-history");
|
||||
if (!create && !this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
this.createDirectory(directory);
|
||||
directory = path.join(directory, fileName);
|
||||
if (!create && !this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
return directory;
|
||||
};
|
||||
|
||||
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 +205,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,27 +230,27 @@ 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]),
|
||||
documentType: fileUtility.getFileType(storedFiles[i])
|
||||
};
|
||||
|
||||
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 +291,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);
|
||||
let storagePath = docManager.storagePath(fileName, userAddress);
|
||||
const stat = fileSystem.statSync(storagePath);
|
||||
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 +316,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 +324,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 +335,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 +351,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;
|
||||
|
||||
@ -24,12 +24,22 @@
|
||||
*/
|
||||
|
||||
var path = require("path");
|
||||
var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
var xml2js = require("xml2js");
|
||||
var jwt = require("jsonwebtoken");
|
||||
var jwa = require("jwa");
|
||||
var fileUtility = require("./fileUtility");
|
||||
var guidManager = require("./guidManager");
|
||||
var configServer = require('config').get('server');
|
||||
var siteUrl = configServer.get('siteUrl');
|
||||
var cfgSignatureEnable = configServer.get('token.enable');
|
||||
var cfgSignatureUseForRequest = configServer.get('token.useforrequest');
|
||||
var cfgSignatureAuthorizationHeader = configServer.get('token.authorizationHeader');
|
||||
var cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizationHeaderPrefix');
|
||||
var cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
|
||||
var cfgSignatureSecret = configServer.get('token.secret');
|
||||
var cfgSignatureSecretAlgorithmRequest = configServer.get('token.algorithmRequest');
|
||||
|
||||
var documentService = {};
|
||||
|
||||
@ -64,12 +74,19 @@ documentService.getConvertedUri = function (documentUri, fromExtension, toExtens
|
||||
key: documentRevisionId
|
||||
};
|
||||
|
||||
urllib.request(siteUrl + configServer.get('converterUrl'),
|
||||
var uri = siteUrl + configServer.get('converterUrl');
|
||||
var headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
}
|
||||
|
||||
urllib.request(uri,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
headers: headers,
|
||||
data: params
|
||||
},
|
||||
callback);
|
||||
@ -79,15 +96,22 @@ documentService.getExternalUri = function (fileStream, contentLength, contentTyp
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId);
|
||||
|
||||
var urlTostorage = siteUrl + configServer.get('storageUrl') + "?key=" + documentRevisionId;
|
||||
var headers = {
|
||||
"Content-Type": contentType == null ? "application/octet-stream" : contentType,
|
||||
"Content-Length": contentLength.toString(),
|
||||
"charset": "utf-8"
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
const hmac = jwa(cfgSignatureSecretAlgorithmRequest);
|
||||
var payloadhash = hmac.sign(fileStream, cfgSignatureSecret);
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(urlTostorage, undefined, undefined, payloadhash);
|
||||
}
|
||||
|
||||
urllib.request(urlTostorage,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": contentType == null ? "application/octet-stream" : contentType,
|
||||
"Content-Length": contentLength.toString(),
|
||||
"charset": "utf-8"
|
||||
},
|
||||
headers: headers,
|
||||
data: fileStream
|
||||
},
|
||||
function (err, data) {
|
||||
@ -116,10 +140,10 @@ documentService.processConvertServiceResponceError = function (errorCode) {
|
||||
|
||||
switch (errorCode) {
|
||||
case -20:
|
||||
errorMessage = errorMessageTemplate + "vkey deciphering error";
|
||||
errorMessage = errorMessageTemplate + "Error encrypt signature";
|
||||
break;
|
||||
case -8:
|
||||
errorMessage = errorMessageTemplate + "Error document VKey";
|
||||
errorMessage = errorMessageTemplate + "Error document signature";
|
||||
break;
|
||||
case -7:
|
||||
errorMessage = errorMessageTemplate + "Error document request";
|
||||
@ -207,15 +231,43 @@ documentService.commandRequest = function (method, documentRevisionId, callback)
|
||||
key: documentRevisionId
|
||||
};
|
||||
|
||||
urllib.request(siteUrl + configServer.get('commandUrl'),
|
||||
var uri = siteUrl + configServer.get('commandUrl');
|
||||
var headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
}
|
||||
|
||||
urllib.request(uri,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
headers: headers,
|
||||
data: params
|
||||
},
|
||||
callback);
|
||||
};
|
||||
|
||||
documentService.checkJwtHeader = function (req) {
|
||||
var decoded = null;
|
||||
var authorization = req.get(cfgSignatureAuthorizationHeader);
|
||||
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) {
|
||||
var token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length);
|
||||
try {
|
||||
decoded = jwt.verify(token, cfgSignatureSecret);
|
||||
} catch (err) {
|
||||
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token)
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
|
||||
documentService.fillJwtByUrl = function (uri, opt_dataObject, opt_iss, opt_payloadhash) {
|
||||
var parseObject = urlModule.parse(uri, true);
|
||||
var payload = {query: parseObject.query, payload: opt_dataObject, payloadhash: opt_payloadhash};
|
||||
|
||||
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn, issuer: opt_iss};
|
||||
return jwt.sign(payload, cfgSignatureSecret, options);
|
||||
}
|
||||
|
||||
module.exports = documentService;
|
||||
|
||||
@ -14,16 +14,19 @@
|
||||
"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",
|
||||
"jsonwebtoken": "^7.1.9",
|
||||
"jwa": "^1.1.4",
|
||||
"log4js": "^0.6.38",
|
||||
"mime": "^1.3.4",
|
||||
"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",
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -116,6 +116,7 @@ label .checkbox {
|
||||
background-image: url("../images/file_pptx.png");
|
||||
}
|
||||
.create-sample {
|
||||
display: inline-block;
|
||||
margin-left: 75px;
|
||||
}
|
||||
.button, .button:visited, .button:hover, .button:active {
|
||||
|
||||
47
web/documentserver-example/nodejs/views/config.ejs
Normal file
@ -0,0 +1,47 @@
|
||||
"width": "100%",
|
||||
"height": "100%",
|
||||
"type": "<%- editor.type %>",
|
||||
"documentType": "<%- editor.documentType %>",
|
||||
"token": "<%- editor.token %>",
|
||||
"document": {
|
||||
"title": "<%- file.name %>",
|
||||
"url": "<%- file.uri %>",
|
||||
"fileType": "<%- file.ext %>",
|
||||
"key": "<%- editor.key %>",
|
||||
"info": {
|
||||
"author": "Me",
|
||||
"created": "<%- file.created %>"
|
||||
},
|
||||
"permissions": {
|
||||
"download": true,
|
||||
"edit": "<%- editor.isEdit %>",
|
||||
"review": true
|
||||
}
|
||||
},
|
||||
"editorConfig": {
|
||||
"mode": "<%- editor.mode %>",
|
||||
"lang": "<%- editor.lang %>",
|
||||
"callbackUrl": "<%- editor.callbackUrl %>",
|
||||
"user": {
|
||||
"id": "<%- editor.userid %>",
|
||||
"name": "<%- editor.name %>"
|
||||
},
|
||||
"embedded": {
|
||||
"saveUrl": "<%- file.uri %>",
|
||||
"embedUrl": "<%- file.uri %>",
|
||||
"shareUrl": "<%- file.uri %>",
|
||||
"toolbarDocked": "top"
|
||||
},
|
||||
"customization": {
|
||||
"about": true,
|
||||
"chat": true,
|
||||
"comments": true,
|
||||
"feedback": true,
|
||||
"forcesave": false,
|
||||
"goback": {
|
||||
"url": "<%- editor.backUrl %>"
|
||||
}
|
||||
},
|
||||
"fileChoiceUrl": "<%- editor.fileChoiceUrl %>",
|
||||
"plugins": <%- editor.plugins %>
|
||||
}
|
||||
@ -44,8 +44,6 @@
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
var docEditor;
|
||||
var fileName = "<%= file.name %>";
|
||||
var fileType = "<%= file.ext %>";
|
||||
|
||||
var innerAlert = function (message) {
|
||||
if (console && console.log)
|
||||
@ -70,21 +68,16 @@
|
||||
|
||||
docEditor.refreshHistory(
|
||||
{
|
||||
currentVersion: "<%= file.version %>",
|
||||
currentVersion: "<%- file.version %>",
|
||||
history: historyObj
|
||||
});
|
||||
};
|
||||
|
||||
var onRequestHistoryData = function (data) {
|
||||
var version = data.data;
|
||||
var url_arr = "<%= setHistoryData.url %>".split(",");
|
||||
var changesUrl_arr = "<%= setHistoryData.changesUrl %>".split(",");
|
||||
var historyData = <%- JSON.stringify(historyData) %> || null;
|
||||
|
||||
docEditor.setHistoryData({
|
||||
version: version,
|
||||
url: url_arr[version - 1] != "" ? url_arr[version - 1] : null,
|
||||
changesUrl: changesUrl_arr[version - 1] != "" ? changesUrl_arr[version - 1] : null
|
||||
});
|
||||
docEditor.setHistoryData(historyData[version-1]);
|
||||
};
|
||||
|
||||
var onRequestHistoryClose = function (event){
|
||||
@ -102,53 +95,7 @@
|
||||
|
||||
var connectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor",
|
||||
{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
type: "<%= editor.type %>",
|
||||
documentType: "<%= editor.documentType %>",
|
||||
document: {
|
||||
title: fileName,
|
||||
url: "<%= file.uri %>",
|
||||
fileType: fileType,
|
||||
key: "<%= editor.key %>",
|
||||
info: {
|
||||
author: "Me",
|
||||
created: new Date().toDateString()
|
||||
},
|
||||
permissions: {
|
||||
download: true,
|
||||
edit: "<%= editor.isEdit %>" == "true",
|
||||
review: true,
|
||||
}
|
||||
},
|
||||
editorConfig: {
|
||||
mode: "<%= editor.mode %>",
|
||||
lang: "<%= editor.lang %>",
|
||||
callbackUrl: "<%- editor.callbackUrl %>",
|
||||
user: {
|
||||
id: "<%= editor.userid %>",
|
||||
name: "<%= editor.name %>",
|
||||
},
|
||||
embedded: {
|
||||
saveUrl: "<%= file.uri %>",
|
||||
embedUrl: "<%= file.uri %>",
|
||||
shareUrl: "<%= file.uri %>",
|
||||
toolbarDocked: "top"
|
||||
},
|
||||
customization: {
|
||||
about: true,
|
||||
chat: true,
|
||||
comments: true,
|
||||
feedback: true,
|
||||
goback: {
|
||||
url: "<%= editor.getServerUrl %>"
|
||||
}
|
||||
},
|
||||
fileChoiceUrl: "<%= editor.fileChoiceUrl %>",
|
||||
plugins: <%- JSON.stringify(editor.plugins) %>
|
||||
},
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", {<% include config %>,
|
||||
events: {
|
||||
"onReady": onReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
@ -160,12 +107,25 @@
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
}
|
||||
});
|
||||
|
||||
fixSize();
|
||||
};
|
||||
|
||||
var fixSize = function () {
|
||||
var wrapEl = document.getElementsByClassName("form");
|
||||
if (wrapEl.length) {
|
||||
wrapEl[0].style.height = screen.availHeight + "px";
|
||||
window.scrollTo(0, -1);
|
||||
wrapEl[0].style.height = window.innerHeight + "px";
|
||||
}
|
||||
};
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", connectEditor);
|
||||
window.addEventListener("resize", fixSize);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent("onload", connectEditor);
|
||||
window.attachEvent("onresize", fixSize);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -138,14 +138,14 @@
|
||||
<tr class="tableRow" title="<%=storedFiles[i].name%>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<span title="<%= storedFiles[i].url %>"><%= storedFiles[i].name %></span></a>
|
||||
<a href="<%= storedFiles[i].url %>">
|
||||
<span title="<%= storedFiles[i].name %>"><%= storedFiles[i].name %></span></a>
|
||||
<a href="download?fileName=<%= encodeURIComponent(storedFiles[i].name) %>">
|
||||
<img class="icon-download" src="images/download-24.png" alt="Download" title="Download" /></a>
|
||||
<a class="delete-file" data="<%= encodeURIComponent(storedFiles[i].name) %>">
|
||||
<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>© Ascensio Systems Inc 2016. All rights reserved.</footer>
|
||||
<footer>© 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>
|
||||
|
||||
@ -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).
|
||||
@ -232,7 +232,6 @@ function getStoredFiles() {
|
||||
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName);
|
||||
$result[$dat] = (object) array(
|
||||
"name" => $fileName,
|
||||
"url" => FileUri($fileName),
|
||||
"documentType" => getDocumentType($fileName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -71,8 +71,9 @@
|
||||
function getCallbackUrl($fileName) {
|
||||
return serverPath(TRUE) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=track&userAddress=" . getClientIp()
|
||||
. "&fileName=" . urlencode($fileName);
|
||||
. "?type=track"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
|
||||
?>
|
||||
@ -156,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,
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -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).
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
echo ' <a class="stored-edit '.$storeFile->documentType.'" href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'" target="_blank">';
|
||||
echo ' <span title="'.$storeFile->name.'">'.$storeFile->name.'</span>';
|
||||
echo ' </a>';
|
||||
echo ' <a href="'.$storeFile->url.'">';
|
||||
echo ' <a href="webeditor-ajax.php?type=download&filename='.$storeFile->name.'">';
|
||||
echo ' <img class="icon-download" src="css/images/download-24.png" alt="Download" title="Download" /></a>';
|
||||
echo ' </a>';
|
||||
echo ' <a class="delete-file" data="'.$storeFile->name.'">';
|
||||
@ -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>';
|
||||
|
||||
@ -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).
|
||||
@ -58,8 +58,11 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
|
||||
switch($type) { //Switch case for value of type
|
||||
case "upload":
|
||||
$response_array = upload();
|
||||
$response_array['status'] = $response_array['error'] != NULL ? 'error' : 'success';
|
||||
$response_array['status'] = isset($response_array['error']) ? 'error' : 'success';
|
||||
die (json_encode($response_array));
|
||||
case "download":
|
||||
download();
|
||||
exit;
|
||||
case "convert":
|
||||
$response_array = convert();
|
||||
$response_array['status'] = 'success';
|
||||
@ -124,6 +127,21 @@ function upload() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function download() {
|
||||
$fileName = $_GET["filename"];
|
||||
|
||||
$filePath = getStoragePath($fileName);
|
||||
if (!file_exists($filePath)) {
|
||||
http_response_code(404);
|
||||
return;
|
||||
}
|
||||
header("Content-Length: " . filesize($filePath));
|
||||
header("Content-Type: " . mime_content_type($fileName));
|
||||
|
||||
header("Content-Disposition: attachment; filename=\"".basename($filePath)."\"");
|
||||
readfile($filePath);
|
||||
}
|
||||
|
||||
function track() {
|
||||
sendlog("Track START", "logs/webedior-ajax.log");
|
||||
sendlog("_GET params: " . serialize( $_GET ), "logs/webedior-ajax.log");
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -94,7 +94,7 @@ class DocumentHelper
|
||||
|
||||
def get_callback(file_name)
|
||||
|
||||
@@base_url + '/track?type=track&userAddress=' + cur_user_host_address(nil) + '&fileName=' + URI::encode(file_name)
|
||||
@@base_url + '/track?type=track&fileName=' + URI::encode(file_name) + '&userAddress=' + cur_user_host_address(nil)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -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>
|
||||
|
||||