Compare commits
91 Commits
v4.2.0.203
...
v4.4.0.138
| Author | SHA1 | Date | |
|---|---|---|---|
| bbd8305ad9 | |||
| c5b6b7ab1b | |||
| 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 | |||
| 63cea1cecb | |||
| 2e6e8ccfd1 | |||
| bc5bb0d142 | |||
| 0e3b5a4fc9 | |||
| 7e26d068a5 | |||
| 13c8530cfd | |||
| c0f47f892b | |||
| ca142cc2cd | |||
| f8ebb4af10 | |||
| 4f21721901 | |||
| 5ccef87a38 | |||
| 4ab35107d0 | |||
| 1599022776 | |||
| 7b9e4e7fde | |||
| a5703b663c | |||
| 4e7586cd2a | |||
| a6c74e62ca | |||
| cb5324381e | |||
| a255a21361 | |||
| 567d24e004 | |||
| b52350ce75 | |||
| c319be9751 | |||
| 4211056907 | |||
| 615e4b78bb | |||
| 65f973371c | |||
| 73791ee71e | |||
| cea433733f | |||
| 85e6de27d3 | |||
| a1adfd784f | |||
| 48ae10ca05 | |||
| 517bcec8cf | |||
| 148cd92792 | |||
| 7aca28cbca | |||
| eac8c96d60 | |||
| 663fc997f1 | |||
| ab089e3052 | |||
| 4b1e588b07 | |||
| 6826aea262 | |||
| 7b4e737139 | |||
| ed58fc3ebd | |||
| d014eeae3f | |||
| 529b76013d | |||
| e8af9379f4 | |||
| 8eaa1af0a3 | |||
| 741076c36a | |||
| f42dc78f6e | |||
| b223ce6e6b | |||
| bce32192af |
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,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
4
Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
.PHONY: all
|
||||
|
||||
all:
|
||||
cd web/documentserver-example/nodejs && npm install
|
||||
@ -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" />
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -26,6 +26,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
@ -213,20 +214,26 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
|
||||
var urlDocumentService = DocumentConverterUrl + ConvertParams;
|
||||
var urlToConverter = String.Format(urlDocumentService,
|
||||
HttpUtility.UrlEncode(documentUri),
|
||||
toExtension.Trim('.'),
|
||||
fromExtension.Trim('.'),
|
||||
title,
|
||||
documentRevisionId);
|
||||
|
||||
if (isAsync)
|
||||
urlToConverter += "&async=true";
|
||||
|
||||
var req = (HttpWebRequest) WebRequest.Create(urlToConverter);
|
||||
var req = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "text/json";
|
||||
req.Timeout = ConvertTimeout;
|
||||
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
req.ContentLength = bytes.Length;
|
||||
using (var requestStream = req.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
Stream stream = null;
|
||||
var countTry = 0;
|
||||
while (countTry < MaxTry)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
For the ONLYOFFICE<EFBFBD> Applications example to work properly you need to do the following:
|
||||
For the ONLYOFFICE Applications example to work properly you need to do the following:
|
||||
|
||||
1. Download and extract the Example.zip into a directory selected for it, for instance, C:\OnlyofficeExample
|
||||
|
||||
@ -10,7 +10,7 @@ For the ONLYOFFICE
|
||||
|
||||
5. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
6. Make the created ONLYOFFICE<EFBFBD> Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
6. Make the created ONLYOFFIC<49> Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -23,7 +23,7 @@
|
||||
*
|
||||
*-->
|
||||
|
||||
<%@ Page Title="ONLYOFFICE™" Language="C#" Inherits="System.Web.Mvc.ViewPage<OnlineEditorsExampleMVC.Models.FileModel>" %>
|
||||
<%@ Page Title="ONLYOFFICE" Language="C#" Inherits="System.Web.Mvc.ViewPage<OnlineEditorsExampleMVC.Models.FileModel>" %>
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Import Namespace="System.Web.Configuration" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVC.Helpers" %>
|
||||
@ -36,7 +36,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
|
||||
<title><%= Model.FileName + " - ONLYOFFICE™" %></title>
|
||||
<title><%= Model.FileName + " - ONLYOFFICE" %></title>
|
||||
|
||||
<%: Styles.Render("~/Content/editor") %>
|
||||
|
||||
@ -78,6 +78,10 @@
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor",
|
||||
@ -112,8 +116,7 @@
|
||||
|
||||
user: {
|
||||
id: "<%= DocManagerHelper.CurUserHostAddress() %>",
|
||||
firstname: 'John',
|
||||
lastname: 'Smith',
|
||||
name: "John Smith",
|
||||
},
|
||||
|
||||
embedded: {
|
||||
@ -136,6 +139,7 @@
|
||||
'onDocumentStateChange': onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -23,7 +23,7 @@
|
||||
*
|
||||
*-->
|
||||
|
||||
<%@ Page Title="ONLYOFFICE™" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
<%@ Page Title="ONLYOFFICE" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
|
||||
<%@ Import Namespace="System.Web.Configuration" %>
|
||||
<%@ Import Namespace="OnlineEditorsExampleMVC.Helpers" %>
|
||||
@ -35,7 +35,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
|
||||
<link href="<%: Url.Content("~/favicon.ico") %>" rel="shortcut icon" type="image/x-icon" />
|
||||
|
||||
@ -46,10 +46,10 @@
|
||||
<body>
|
||||
<div class="top-panel"></div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OnlineEditorsExample._Default" Title="ONLYOFFICE™" %>
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OnlineEditorsExample._Default" Title="ONLYOFFICE" %>
|
||||
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Import Namespace="System.Linq" %>
|
||||
@ -9,7 +9,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
|
||||
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
|
||||
|
||||
@ -43,10 +43,10 @@
|
||||
|
||||
<div class="top-panel"></div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
@ -99,7 +99,7 @@
|
||||
if (examples.Any())
|
||||
{ %>
|
||||
<br />
|
||||
Download the code for the sample of ONLYOFFICE™ Online Editors to find out the details.
|
||||
Download the code for the sample of ONLYOFFICE Online Editors to find out the details.
|
||||
<br />
|
||||
<br />
|
||||
<% foreach (var example in examples)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocEditor.aspx.cs" Inherits="OnlineEditorsExample.DocEditor" Title="ONLYOFFICE™" %>
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocEditor.aspx.cs" Inherits="OnlineEditorsExample.DocEditor" Title="ONLYOFFICE" %>
|
||||
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Import Namespace="OnlineEditorsExample" %>
|
||||
@ -9,7 +9,7 @@
|
||||
<head runat="server">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
@ -71,6 +71,10 @@
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor",
|
||||
@ -105,8 +109,7 @@
|
||||
|
||||
user: {
|
||||
id: "<%= _Default.CurUserHostAddress(null) %>",
|
||||
firstname: "John",
|
||||
lastname: "Smith",
|
||||
name: "John Smith",
|
||||
},
|
||||
|
||||
embedded: {
|
||||
@ -128,7 +131,8 @@
|
||||
'onReady': onReady,
|
||||
'onDocumentStateChange': onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System.Text;
|
||||
using OnlineEditorsExample;
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -220,22 +221,28 @@ namespace ASC.Api.DocumentConverter
|
||||
: documentRevisionId;
|
||||
documentRevisionId = GenerateRevisionId(documentRevisionId);
|
||||
|
||||
var urlDocumentService = DocumentConverterUrl + ConvertParams;
|
||||
var urlToConverter = String.Format(urlDocumentService,
|
||||
HttpUtility.UrlEncode(documentUri),
|
||||
toExtension.Trim('.'),
|
||||
fromExtension.Trim('.'),
|
||||
title,
|
||||
documentRevisionId);
|
||||
|
||||
if (isAsync)
|
||||
urlToConverter += "&async=true";
|
||||
|
||||
var req = (HttpWebRequest) WebRequest.Create(urlToConverter);
|
||||
var req = (HttpWebRequest)WebRequest.Create(DocumentConverterUrl);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "text/json";
|
||||
req.Timeout = ConvertTimeout;
|
||||
|
||||
Stream stream = null;
|
||||
var bodyString = string.Format("{{\"async\": {0},\"filetype\": \"{1}\",\"key\": \"{2}\",\"outputtype\": \"{3}\",\"title\": \"{4}\",\"url\": \"{5}\"}}",
|
||||
isAsync.ToString().ToLower(),
|
||||
fromExtension.Trim('.'),
|
||||
documentRevisionId,
|
||||
toExtension.Trim('.'),
|
||||
title,
|
||||
documentUri);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(bodyString);
|
||||
req.ContentLength = bytes.Length;
|
||||
using (var requestStream = req.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
var countTry = 0;
|
||||
Stream stream = null;
|
||||
|
||||
// hack. http://ubuntuforums.org/showthread.php?t=1841740
|
||||
if (_Default.IsMono)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
For the ONLYOFFICE<EFBFBD> Applications example to work properly you need to do the following:
|
||||
For the ONLYOFFICE Applications example to work properly you need to do the following:
|
||||
|
||||
1. Download and extract the Example.zip into a directory selected for it, for instance, C:\OnlyofficeExample
|
||||
|
||||
@ -10,7 +10,7 @@ For the ONLYOFFICE
|
||||
|
||||
5. Make sure that the user account under which the IIS NetworkService process is executed has the write access rights for the C:\OnlyofficeExample\App_Data folder (this is significant for the IIS later than 6.0).
|
||||
|
||||
6. Make the created ONLYOFFICE<EFBFBD> Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
6. Make the created ONLYOFFICE Applications example available through IP or domain name so that it could be connected from the web by the document service for proper document rendering.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -35,7 +35,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="css/editor.css" />
|
||||
|
||||
@ -72,6 +72,10 @@
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor",
|
||||
@ -106,8 +110,7 @@
|
||||
|
||||
user: {
|
||||
id: "<%= Model.CurUserHostAddress() %>",
|
||||
firstname: "John",
|
||||
lastname: "Smith",
|
||||
name: "John Smith",
|
||||
},
|
||||
|
||||
embedded: {
|
||||
@ -130,6 +133,7 @@
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
"onError": onError,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 466 B |
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -32,7 +32,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
|
||||
@ -43,10 +43,10 @@
|
||||
<div class="top-panel"></div>
|
||||
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -27,11 +27,11 @@
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
||||
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
|
||||
<link href="stylesheet.css" type="text/css" rel="stylesheet">
|
||||
|
||||
<!--Change the address on installed ONLYOFFICE™ Online Editors-->
|
||||
<!--Change the address on installed ONLYOFFICE Online Editors-->
|
||||
<script id="scriptApi" type="text/javascript" src="https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js"></script>
|
||||
|
||||
|
||||
@ -42,10 +42,10 @@
|
||||
<div id="page">
|
||||
<div class="top-panel"></div>
|
||||
<div id="mainPanel" class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Online Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may enter url your own document for testing.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Online Editors, the first html5-based editors. You may enter url your own document for testing.</span>
|
||||
<textarea id="documentUrl" class="document-url">http://onlyo.co/1x5REbq?demo.docx</textarea>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -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) {
|
||||
@ -74,6 +80,13 @@ app.use(function (req, res, next) {
|
||||
});
|
||||
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
if (config.has('server.static')) {
|
||||
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']));
|
||||
}
|
||||
}
|
||||
app.use(favicon(__dirname + "/public/images/favicon.ico"));
|
||||
|
||||
|
||||
@ -103,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();
|
||||
@ -141,17 +190,17 @@ 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 firstname = req.query.firstname ? req.query.firstname : "Jonn";
|
||||
var lastname = req.query.lastname ? req.query.lastname : "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, firstname + " " + lastname);
|
||||
docManager.saveFileData(file.name, userid, name);
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
@ -227,8 +276,8 @@ app.get("/convert", function (req, res) {
|
||||
|
||||
try {
|
||||
if (configServer.get('convertedDocs').indexOf(fileExt) != -1) {
|
||||
var key = documentService.generateRevisionId(fileUri);
|
||||
documentService.getConvertedUriAsync(fileUri, fileExt, internalFileExt, key, callback);
|
||||
const key = documentService.generateRevisionId(fileUri);
|
||||
documentService.getConvertedUri(fileUri, fileExt, internalFileExt, key, true, callback);
|
||||
} else {
|
||||
writeResult(fileName, null, null);
|
||||
}
|
||||
@ -240,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) {
|
||||
@ -284,9 +322,7 @@ app.post("/track", function (req, res) {
|
||||
|
||||
var processTrack = function (response, body, fileName, userAddress) {
|
||||
|
||||
var processSave = function (body, fileName, userAddress, newVersion) {
|
||||
|
||||
var downloadUri = body.url;
|
||||
var processSave = function (downloadUri, body, fileName, userAddress, resp) {
|
||||
var curExt = fileUtility.getFileExtension(fileName);
|
||||
var downloadExt = fileUtility.getFileExtension(downloadUri);
|
||||
|
||||
@ -294,7 +330,10 @@ app.post("/track", function (req, res) {
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
|
||||
try {
|
||||
downloadUri = documentService.getConvertedUri(downloadUri, downloadExt, curExt, key);
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
|
||||
processSave(dUri, body, fileName, userAddress, resp)
|
||||
});
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
fileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress)
|
||||
@ -305,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);
|
||||
@ -335,14 +374,59 @@ 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 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(forcesavePath, file.getBody());
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
}
|
||||
|
||||
response.write("{\"error\":0}");
|
||||
response.end();
|
||||
};
|
||||
|
||||
if (body.status == 1) { //Editing
|
||||
if (body.actions && body.actions[0].type == 0) { //finished edit
|
||||
@ -356,15 +440,18 @@ app.post("/track", function (req, res) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (body.status == 2 || body.status == 3) { //MustSave, Corrupted
|
||||
processSave(body, fileName, userAddress, true);
|
||||
processSave(body.url, body, fileName, userAddress, response);
|
||||
return;
|
||||
} else if (body.status == 6 || body.status == 7) { //MustForceSave, CorruptedForceSave
|
||||
processSave(body, fileName, userAddress);
|
||||
processForceSave(body.url, body, fileName, userAddress, response);
|
||||
return;
|
||||
}
|
||||
|
||||
response.write("{\"error\":0}");
|
||||
response.end();
|
||||
}
|
||||
};
|
||||
|
||||
var readbody = function (request, response, fileName, userAddress) {
|
||||
var content = "";
|
||||
@ -375,6 +462,29 @@ app.post("/track", function (req, res) {
|
||||
var body = JSON.parse(content);
|
||||
processTrack(response, body, fileName, userAddress);
|
||||
});
|
||||
};
|
||||
|
||||
//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")) {
|
||||
@ -391,59 +501,83 @@ 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 firstname = req.query.firstname ? req.query.firstname : "Jonn";
|
||||
var lastname = req.query.lastname ? req.query.lastname : "Smith";
|
||||
var name = req.query.name ? req.query.name : "Jonn Smith";
|
||||
|
||||
if (fileExt != null) {
|
||||
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, firstname + " " + lastname);
|
||||
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
|
||||
|
||||
var redirectPath = docManager.getProtocol() + "://" + docManager.req.get("host") + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
|
||||
var redirectPath = docManager.getServerUrl() + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
|
||||
res.redirect(redirectPath);
|
||||
return;
|
||||
}
|
||||
|
||||
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'),
|
||||
@ -451,33 +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,
|
||||
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,
|
||||
firstname: firstname,
|
||||
lastname: lastname,
|
||||
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);
|
||||
@ -487,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,22 +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
|
||||
"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": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,22 +1,6 @@
|
||||
{
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,5 @@
|
||||
"server": {
|
||||
"siteUrl": "/",
|
||||
"maxFileSize": 104857600
|
||||
},
|
||||
"plugins": {
|
||||
"url": "/sdkjs-plugins/"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
{
|
||||
"server": {
|
||||
"siteUrl": "/",
|
||||
"maxFileSize": 104857600
|
||||
},
|
||||
"plugins": {
|
||||
"url": "/sdkjs-plugins/"
|
||||
"maxFileSize": 104857600,
|
||||
"static":[
|
||||
{
|
||||
"name": "/public",
|
||||
"path": "public",
|
||||
"options": {"maxAge": "7d"}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -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,37 +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 firstname = docManager.req.query.firstname;
|
||||
params += (firstname ? "&firstname=" + firstname : "");
|
||||
const name = docManager.req.query.name;
|
||||
params += (name ? "&name=" + name : "");
|
||||
|
||||
var lastname = docManager.req.query.lastname;
|
||||
params += (lastname ? "&lastname=" + lastname : "");
|
||||
|
||||
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;
|
||||
@ -118,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));
|
||||
|
||||
@ -128,64 +125,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.getProtocol() + "://" + docManager.req.get("host");
|
||||
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.getProtocol() + "://" + docManager.req.get("host");
|
||||
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 "";
|
||||
}
|
||||
@ -197,7 +211,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);
|
||||
};
|
||||
|
||||
@ -222,27 +236,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;
|
||||
}
|
||||
@ -283,23 +297,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;
|
||||
};
|
||||
|
||||
@ -308,7 +322,7 @@ docManager.getChanges = function (fileName) {
|
||||
};
|
||||
|
||||
docManager.countVersion = function(directory) {
|
||||
var i = 0;
|
||||
let i = 0;
|
||||
while (this.existsSync(path.join(directory, '' + (i + 1)))) {
|
||||
i++;
|
||||
}
|
||||
@ -316,8 +330,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];
|
||||
@ -327,11 +341,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;
|
||||
@ -343,4 +357,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;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -24,62 +24,104 @@
|
||||
*/
|
||||
|
||||
var path = require("path");
|
||||
var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
var syncRequest = require("sync-request");
|
||||
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 = {};
|
||||
|
||||
documentService.convertParams = "?url={0}&outputtype={1}&filetype={2}&title={3}&key={4}";
|
||||
documentService.commandParams = "?c={0}&key={1}";
|
||||
documentService.userIp = null;
|
||||
|
||||
documentService.getConvertedUri = function (documentUri, fromExtension, toExtension, documentRevisionId) {
|
||||
var xml = documentService.sendRequestToConvertService(documentUri, fromExtension, toExtension, documentRevisionId);
|
||||
documentService.getConvertedUriSync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
|
||||
|
||||
var res = documentService.getResponseUri(xml);
|
||||
|
||||
return res.value;
|
||||
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, function (err, data) {
|
||||
if (err) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
var res = documentService.getResponseUri(data);
|
||||
callback(res.value);
|
||||
});
|
||||
};
|
||||
|
||||
documentService.getConvertedUriAsync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
|
||||
documentService.getConvertedUri = function (documentUri, fromExtension, toExtension, documentRevisionId, async, callback) {
|
||||
fromExtension = fromExtension || fileUtility.getFileExtension(documentUri);
|
||||
|
||||
var title = fileUtility.getFileName(documentUri) || guidManager.newGuid();
|
||||
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
|
||||
|
||||
var params = documentService.convertParams.format(
|
||||
encodeURIComponent(documentUri),
|
||||
toExtension.replace(".", ""),
|
||||
fromExtension.replace(".", ""),
|
||||
title,
|
||||
documentRevisionId);
|
||||
var params = {
|
||||
async: async,
|
||||
url: documentUri,
|
||||
outputtype: toExtension.replace(".", ""),
|
||||
filetype: fromExtension.replace(".", ""),
|
||||
title: title,
|
||||
key: documentRevisionId
|
||||
};
|
||||
|
||||
urllib.request(siteUrl + configServer.get('converterUrl') + params, callback);
|
||||
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: headers,
|
||||
data: params
|
||||
},
|
||||
callback);
|
||||
};
|
||||
|
||||
documentService.getExternalUri = function (fileStream, contentLength, contentType, documentRevisionId) {
|
||||
var params = documentService.convertParams.format("", "", "", "", documentRevisionId);
|
||||
documentService.getExternalUri = function (fileStream, contentLength, contentType, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId);
|
||||
|
||||
var urlTostorage = siteUrl + configServer.get('storageUrl') + params;
|
||||
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"
|
||||
};
|
||||
|
||||
var response = syncRequest("POST", urlTostorage, {
|
||||
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: headers,
|
||||
data: fileStream
|
||||
},
|
||||
body: fileStream
|
||||
});
|
||||
|
||||
var res = documentService.getResponseUri(response.body.toString());
|
||||
|
||||
return res.value;
|
||||
function (err, data) {
|
||||
if (err) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
var res = documentService.getResponseUri(data);
|
||||
callback(res.value);
|
||||
});
|
||||
};
|
||||
|
||||
documentService.generateRevisionId = function (expectedKey) {
|
||||
@ -92,34 +134,16 @@ documentService.generateRevisionId = function (expectedKey) {
|
||||
return key.substring(0, Math.min(key.length, 20));
|
||||
};
|
||||
|
||||
documentService.sendRequestToConvertService = function (documentUri, fromExtension, toExtension, documentRevisionId) {
|
||||
fromExtension = fromExtension || fileUtility.getFileExtension(documentUri);
|
||||
|
||||
var title = fileUtility.getFileName(documentUri) || guidManager.newGuid();
|
||||
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
|
||||
|
||||
var params = documentService.convertParams.format(
|
||||
encodeURIComponent(documentUri),
|
||||
toExtension.replace(".", ""),
|
||||
fromExtension.replace(".", ""),
|
||||
title,
|
||||
documentRevisionId);
|
||||
|
||||
var res = syncRequest("GET", siteUrl + configServer.get('converterUrl') + params);
|
||||
return res.getBody("utf8");
|
||||
};
|
||||
|
||||
documentService.processConvertServiceResponceError = function (errorCode) {
|
||||
var errorMessage = "";
|
||||
var errorMessageTemplate = "Error occurred in the ConvertService: ";
|
||||
|
||||
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";
|
||||
@ -200,14 +224,50 @@ documentService.convertXmlStringToJson = function (xml) {
|
||||
return res;
|
||||
};
|
||||
|
||||
documentService.commandRequest = function (method, documentRevisionId) {
|
||||
documentService.commandRequest = function (method, documentRevisionId, callback) {
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId);
|
||||
var params = documentService.commandParams.format(
|
||||
method,
|
||||
documentRevisionId);
|
||||
var params = {
|
||||
c: method,
|
||||
key: documentRevisionId
|
||||
};
|
||||
|
||||
var res = syncRequest("GET", siteUrl + configServer.get('commandUrl') + params).getBody("utf8");
|
||||
return JSON.parse(res).error;
|
||||
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: 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;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -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 |
BIN
web/documentserver-example/nodejs/public/images/review-24.png
Normal file
|
After Width: | Height: | Size: 127 B |
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -25,14 +25,12 @@
|
||||
|
||||
var language;
|
||||
var userid;
|
||||
var firstname;
|
||||
var lastname;
|
||||
var username;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
firstname = getUrlVars()["firstname"];
|
||||
lastname = getUrlVars()["lastname"];
|
||||
username = getUrlVars()["name"];
|
||||
userid = getUrlVars()["userid"];
|
||||
language = getUrlVars()["lang"];
|
||||
|
||||
@ -43,43 +41,26 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
|
||||
jq("#language").change(function() {
|
||||
var user = jq('#user option:selected').text();
|
||||
var arUser = user.split(' ');
|
||||
firstname = arUser[0];
|
||||
//alert(language);
|
||||
lastname = arUser[1];
|
||||
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&firstname=" + firstname + "&lastname=" + lastname;
|
||||
var username = jq('#user option:selected').text();
|
||||
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&name=" + username;
|
||||
});
|
||||
|
||||
|
||||
|
||||
if ("" != userid && undefined != userid)
|
||||
jq("#user").val(userid);
|
||||
else
|
||||
userid = jq("#user").val();
|
||||
|
||||
if ("" != firstname && undefined != firstname)
|
||||
firstname=getUrlVars()["firstname"];
|
||||
else{
|
||||
var user = jq('#user option:selected').text();
|
||||
var arUser = user.split(' ');
|
||||
firstname = arUser[0];
|
||||
if ("" != username && undefined != username) {
|
||||
username = getUrlVars()["name"];
|
||||
}
|
||||
if ("" != lastname && undefined != lastname)
|
||||
lastname=getUrlVars()["lastname"];
|
||||
else{
|
||||
var user = jq('#user option:selected').text();
|
||||
var arUser = user.split(' ');
|
||||
lastname = arUser[1];
|
||||
else {
|
||||
username = jq('#user option:selected').text();
|
||||
}
|
||||
|
||||
jq("#user").change(function() {
|
||||
var user = jq('#user option:selected').text();
|
||||
var arUser = user.split(' ');
|
||||
firstname = arUser[0];
|
||||
lastname = arUser[1];
|
||||
|
||||
//var fn = jq('#user option:selected').attr('value-fn');
|
||||
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&firstname=" + arUser[0] + "&lastname=" + arUser[1];
|
||||
var username = jq('#user option:selected').text();
|
||||
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&name=" + username;
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
@ -217,7 +198,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&firstname=" +firstname +"&lastname=" + lastname;
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&name=" + username;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -226,7 +207,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&firstname=" +firstname +"&lastname=" + lastname;
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&name=" + username;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -235,7 +216,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&firstname=" +firstname +"&lastname=" + lastname;
|
||||
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&name=" + username;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -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 {
|
||||
@ -288,7 +289,7 @@ footer {
|
||||
background-repeat: no-repeat;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
max-width: 450px;
|
||||
max-width: 250px;
|
||||
margin-bottom: -6px;
|
||||
overflow: hidden;
|
||||
padding: 8px 0 1px 34px;
|
||||
|
||||
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 %>
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -28,8 +28,10 @@
|
||||
<head runat="server">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<title>ONLYOFFICE</title>
|
||||
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/editor.css" />
|
||||
</head>
|
||||
@ -42,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)
|
||||
@ -68,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){
|
||||
@ -94,55 +89,13 @@
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
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: {
|
||||
edit: "<%= editor.isEdit %>" == "true",
|
||||
download: true
|
||||
}
|
||||
},
|
||||
editorConfig: {
|
||||
mode: "<%= editor.mode %>",
|
||||
lang: "<%= editor.lang %>",
|
||||
callbackUrl: "<%- editor.callbackUrl %>",
|
||||
user: {
|
||||
id: "<%= editor.userid %>",
|
||||
firstname: "<%= editor.firstname %>",
|
||||
lastname: "<%= editor.lastname %>"
|
||||
},
|
||||
embedded: {
|
||||
saveUrl: "<%= file.uri %>",
|
||||
embedUrl: "<%= file.uri %>",
|
||||
shareUrl: "<%= file.uri %>",
|
||||
toolbarDocked: "top"
|
||||
},
|
||||
customization: {
|
||||
about: true,
|
||||
chat: true,
|
||||
comments: true,
|
||||
feedback: true,
|
||||
goback: {
|
||||
url: ("<%= editor.type %>" == "embedded" ? null : "<%= editor.getServerUrl %>")
|
||||
}
|
||||
},
|
||||
fileChoiceUrl: "<%= editor.fileChoiceUrl %>",
|
||||
plugins: <%- JSON.stringify(editor.plugins) %>
|
||||
},
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", {<% include config %>,
|
||||
events: {
|
||||
"onReady": onReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
@ -150,15 +103,29 @@
|
||||
"onError": onError,
|
||||
"onRequestHistory": onRequestHistory,
|
||||
"onRequestHistoryData": onRequestHistoryData,
|
||||
"onRequestHistoryClose": onRequestHistoryClose
|
||||
"onRequestHistoryClose": onRequestHistoryClose,
|
||||
"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>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (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).
|
||||
@ -30,7 +30,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>ONLYOFFICE™ Integration Edition</title>
|
||||
<title>ONLYOFFICE Integration Edition</title>
|
||||
<link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" />
|
||||
@ -39,14 +39,14 @@
|
||||
<body>
|
||||
<header>
|
||||
<a href="/">
|
||||
<img src ='images/logo.png' alt="ONLYOFFICE™" />
|
||||
<img src ='images/logo.png' alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Integration Edition – Welcome!</span>
|
||||
<span class="portal-name">ONLYOFFICE Integration Edition – Welcome!</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Integration Edition, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Integration Edition, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
<table class="user-block-table" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="middle" width="30%">
|
||||
@ -129,7 +129,7 @@
|
||||
<thead>
|
||||
<tr class="tableHeader">
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
|
||||
<td colspan="2" class="tableHeaderCell contentCells-shift">Editors</td>
|
||||
<td colspan="3" class="tableHeaderCell contentCells-shift">Editors</td>
|
||||
<td colspan="3" class="tableHeaderCell">Viewers</td>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -137,32 +137,38 @@
|
||||
<% for (var i = 0; i < storedFiles.length; i++) { %>
|
||||
<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 %>">
|
||||
<img class="icon-download" src="images/download-24.png" alt="download" /></a>
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<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" /></a>
|
||||
<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">
|
||||
<img src="images/desktop-24.png" alt="editor" /></a>
|
||||
<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">
|
||||
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon">
|
||||
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/mobile-24.png" alt="mobile editor" /></a>
|
||||
<% if (storedFiles[i].documentType == "text") { %>
|
||||
<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">
|
||||
<img src="images/desktop-24.png" alt="viewer" /></a>
|
||||
<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">
|
||||
<a href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/mobile-24.png" alt="mobile viewer" /></a>
|
||||
<img src="images/mobile-24.png" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<img src="images/embeded-24.png" alt="embedded" /></a>
|
||||
<img src="images/embeded-24.png" alt="Open in embedded mode" title="Open in embedded mode" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
@ -177,7 +183,7 @@
|
||||
<div class="help-block">
|
||||
<span>Want to learn the magic?</span>
|
||||
<br />
|
||||
Explore ONLYOFFICE™ Integration Edition <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
Explore ONLYOFFICE Integration Edition <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
@ -221,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,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
BIN
web/documentserver-example/php/app_data/new.docx
Normal file
BIN
web/documentserver-example/php/app_data/new.pptx
Normal file
BIN
web/documentserver-example/php/app_data/new.xlsx
Normal 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).
|
||||
@ -28,6 +28,7 @@
|
||||
<?php
|
||||
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
|
||||
function sendlog($msg, $logFileName) {
|
||||
file_put_contents($logFileName, $msg . PHP_EOL, FILE_APPEND);
|
||||
@ -134,16 +135,27 @@ function getClientIp() {
|
||||
getenv('HTTP_FORWARDED_FOR')?:
|
||||
getenv('HTTP_FORWARDED')?:
|
||||
getenv('REMOTE_ADDR')?:
|
||||
'';
|
||||
'Storage';
|
||||
|
||||
$ipaddress = preg_replace("/[^0-9a-zA-Z.=]/", "_", $ipaddress);
|
||||
|
||||
return $ipaddress;
|
||||
}
|
||||
|
||||
function serverPath() {
|
||||
return 'http://' . $_SERVER['HTTP_HOST'];
|
||||
function serverPath($forDocumentServer) {
|
||||
return $forDocumentServer && isset($GLOBALS['EXAMPLE_URL']) && $GLOBALS['EXAMPLE_URL'] != ""
|
||||
? $GLOBALS['EXAMPLE_URL']
|
||||
: ('http://' . $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
function getCurUserHostAddress($userAddress = NULL) {
|
||||
if ($GLOBALS['ALONE']) {
|
||||
if (empty($GLOBALS['STORAGE_PATH'])) {
|
||||
return "Storage";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
if (is_null($userAddress)) {$userAddress = getClientIp();}
|
||||
return preg_replace("[^0-9a-zA-Z.=]", '_', $userAddress);
|
||||
}
|
||||
@ -192,21 +204,62 @@ function getStoragePath($fileName, $userAddress = NULL) {
|
||||
return $directory . $fileName;
|
||||
}
|
||||
|
||||
function getVirtualPath() {
|
||||
function getStoredFiles() {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
|
||||
$result = array();
|
||||
if ($storagePath != "")
|
||||
{
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$directory = $directory . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$cdir = scandir($directory);
|
||||
$result = array();
|
||||
foreach($cdir as $key => $fileName) {
|
||||
if (!in_array($fileName,array(".", ".."))) {
|
||||
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName);
|
||||
$result[$dat] = (object) array(
|
||||
"name" => $fileName,
|
||||
"documentType" => getDocumentType($fileName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($result);
|
||||
return array_reverse($result);
|
||||
}
|
||||
|
||||
function getVirtualPath($forDocumentServer) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), '/', $GLOBALS['STORAGE_PATH']), '/');
|
||||
$storagePath = $storagePath != "" ? $storagePath . '/' : "";
|
||||
|
||||
|
||||
$virtPath = serverPath() . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
sendlog("getVirtualPath virtPath: " . $virtPath, "logs/common.log");
|
||||
return $virtPath;
|
||||
}
|
||||
|
||||
function FileUri($file_name, $forDocumentServer) {
|
||||
$uri = getVirtualPath($forDocumentServer) . $file_name;
|
||||
return $uri;
|
||||
}
|
||||
|
||||
function getFileExts() {
|
||||
return array_merge($GLOBALS['DOC_SERV_VIEWD'], $GLOBALS['DOC_SERV_EDITED'], $GLOBALS['DOC_SERV_CONVERT']);
|
||||
}
|
||||
|
||||
|
||||
function GetCorrectName($fileName) {
|
||||
$path_parts = pathinfo($fileName);
|
||||
|
||||
@ -221,4 +274,11 @@ function GetCorrectName($fileName) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
function getDocEditorKey($fileName) {
|
||||
$key = getCurUserHostAddress() . FileUri($fileName);
|
||||
$stat = filemtime(getStoragePath($fileName));
|
||||
$key = $key . $stat;
|
||||
return GenerateRevisionId($key);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
$GLOBALS['FILE_SIZE_MAX'] = 5242880;
|
||||
$GLOBALS['STORAGE_PATH'] = "";
|
||||
$GLOBALS['ALONE'] = FALSE;
|
||||
|
||||
$GLOBALS['MODE'] = "";
|
||||
|
||||
@ -17,6 +18,10 @@ $GLOBALS['DOC_SERV_API_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/doc
|
||||
|
||||
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://doc.onlyoffice.com/web-apps/apps/api/documents/cache-scripts.html";
|
||||
|
||||
$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");
|
||||
|
||||
|
Before Width: | Height: | Size: 232 B |
BIN
web/documentserver-example/php/css/images/delete-24.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
web/documentserver-example/php/css/images/desktop-24.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
web/documentserver-example/php/css/images/download-24.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/documentserver-example/php/css/images/embeded-24.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/documentserver-example/php/css/images/file_upload.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
web/documentserver-example/php/css/images/icon_docx.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/documentserver-example/php/css/images/icon_pptx.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/documentserver-example/php/css/images/icon_xlsx.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/documentserver-example/php/css/images/mobile-24.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
BIN
web/documentserver-example/php/css/images/review-24.png
Normal file
|
After Width: | Height: | Size: 127 B |
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -48,15 +48,21 @@ div {
|
||||
a, a:hover, a:visited {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
.top-panel {
|
||||
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
|
||||
header {
|
||||
height: 44px;
|
||||
background: #3D4A6B;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
min-width: 600px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
header img {
|
||||
margin: 12px 0 0 16px;
|
||||
}
|
||||
|
||||
.main-panel {
|
||||
margin: 80px auto;
|
||||
margin: 80px auto 16px;
|
||||
width: 600px;
|
||||
}
|
||||
.portal-name {
|
||||
@ -69,41 +75,13 @@ a, a:hover, a:visited {
|
||||
width: 600px;
|
||||
}
|
||||
.save-original {
|
||||
color: #929597;
|
||||
line-height: 20px;
|
||||
margin-left: 16px;
|
||||
white-space: nowrap;
|
||||
width: 272px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
label .checkbox {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.question {
|
||||
background: url("images/question_small.png") no-repeat center center transparent;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
#hint {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #8E908F;
|
||||
display: none;
|
||||
margin: 4px 0 0 -32px;
|
||||
max-width: 415px;
|
||||
padding: 10px 15px 15px;
|
||||
word-wrap: break-word;
|
||||
z-index: 255;
|
||||
}
|
||||
.corner {
|
||||
background: url("images/corner.png") no-repeat scroll 0 0 transparent;
|
||||
height: 6px;
|
||||
left: 35px;
|
||||
margin-top: -15px;
|
||||
position: absolute;
|
||||
width: 9px;
|
||||
z-index: 261;
|
||||
}
|
||||
|
||||
|
||||
.try-descr {
|
||||
font-size: 16px;
|
||||
white-space : nowrap;
|
||||
@ -111,13 +89,13 @@ label .checkbox {
|
||||
|
||||
.try-editor-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
margin: 0 0 16px;
|
||||
padding: 0;
|
||||
}
|
||||
.try-editor-list li {
|
||||
float: left;
|
||||
margin: 25px;
|
||||
width: 150px;
|
||||
margin: 0 15px;
|
||||
width: 100px;
|
||||
}
|
||||
.try-editor {
|
||||
background-color: transparent;
|
||||
@ -140,6 +118,9 @@ label .checkbox {
|
||||
.try-editor.presentation {
|
||||
background-image: url("images/file_pptx.png");
|
||||
}
|
||||
.create-sample {
|
||||
margin-left: 75px;
|
||||
}
|
||||
|
||||
.button, .button:visited, .button:hover, .button:active {
|
||||
display: inline-block;
|
||||
@ -183,25 +164,39 @@ label .checkbox {
|
||||
border: 1px solid #E9EAEA;
|
||||
}
|
||||
|
||||
.file-upload {
|
||||
cursor: pointer;
|
||||
margin-bottom: 8px;
|
||||
padding: 0 !important;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
.upload-panel {
|
||||
border-right: 1px solid #D1D1D1;
|
||||
float: left;
|
||||
margin-right: 25px;
|
||||
}
|
||||
.file-upload span {
|
||||
line-height: 21px;
|
||||
margin: 2px 12px;
|
||||
.file-upload {
|
||||
background: url("images/file_upload.png") no-repeat center 0 transparent;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
height: 45px;
|
||||
margin: 0 40px 16px;
|
||||
overflow: hidden;
|
||||
padding-top: 100px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
}
|
||||
.file-upload input {
|
||||
cursor: pointer;
|
||||
font-size: 23px;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
transform: translate(-300px, 0) scale(4);
|
||||
transform: translate(555px, 60px) scale(8);
|
||||
}
|
||||
.create-panel {
|
||||
float: left;
|
||||
}
|
||||
.upload-panel,
|
||||
.create-panel {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
#mainProgress {
|
||||
@ -268,17 +263,68 @@ label .checkbox {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
}
|
||||
.bottom-panel {
|
||||
bottom: 0;
|
||||
position: fixed;
|
||||
footer {
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
width: auto;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.help-block span {
|
||||
font-size: 16px;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.stored-list {
|
||||
border-top: 1px solid #D1D1D1;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.stored-list li {
|
||||
border-bottom: 1px solid #D1D1D1;
|
||||
line-height: 28px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
.stored-edit {
|
||||
background-color: transparent;
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
max-width: 250px;
|
||||
margin-bottom: -6px;
|
||||
overflow: hidden;
|
||||
padding: 8px 0 1px 34px;
|
||||
text-decoration: none;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.stored-edit.text {
|
||||
background-image: url("images/icon_docx.png");
|
||||
}
|
||||
.stored-edit.spreadsheet {
|
||||
background-image: url("images/icon_xlsx.png");
|
||||
}
|
||||
.stored-edit.presentation {
|
||||
background-image: url("images/icon_pptx.png");
|
||||
}
|
||||
.stored-edit span {
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.stored-edit:hover span {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.stored-download {
|
||||
color: #787878;
|
||||
float: right;
|
||||
text-decoration: none;
|
||||
}
|
||||
.stored-download:hover {
|
||||
color: #787878;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -310,4 +356,110 @@ label .checkbox {
|
||||
-moz-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
|
||||
-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.5);
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.clearFix:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.td100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block-lang {
|
||||
padding-right: 10px;
|
||||
padding-top: 9px;
|
||||
}
|
||||
/*Icon table*/
|
||||
#tableRow {
|
||||
vertical-align: top;
|
||||
}
|
||||
.tableRow {
|
||||
background: transparent;
|
||||
|
||||
-moz-transition: all 0.2s ease-in-out;
|
||||
-webkit-transition: all 0.2s ease-in-out;
|
||||
-o-transition: all 0.2s ease-in-out;
|
||||
-ms-transition: all 0.2s ease-in-out;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
.tableRow:hover {
|
||||
background-color: #ebebeb;
|
||||
}
|
||||
|
||||
.tableHeader {
|
||||
background: transparent;
|
||||
color: #333;
|
||||
cursor: default;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-size: 13px;
|
||||
height: 40px;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.tableHeaderCell {
|
||||
padding: 2px 1px 2px 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.tableHeaderCellFileName {
|
||||
text-align: left;
|
||||
}
|
||||
.contentCells {
|
||||
padding: 4px 1px 4px 5px;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
white-space: nowrap;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.contentCells-shift {
|
||||
padding-right: 30px;
|
||||
}
|
||||
.contentCells-icon {
|
||||
width: 6%;
|
||||
}
|
||||
.contentCellsSmall {
|
||||
padding: 5px 1px 5px 6px;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-size: 13px;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
.primaryRow {
|
||||
background-color: #e9e9e9;
|
||||
}
|
||||
.secondaryRow {
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
.select-user {
|
||||
margin-left: 15px;
|
||||
}
|
||||
.user-block-table {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.user-block-table td {
|
||||
background-color: #F4F4F4;
|
||||
border-bottom: 1px solid white;
|
||||
padding: 12px 0;
|
||||
}
|
||||
#user, #language {
|
||||
width: 130px;
|
||||
}
|
||||
.icon-download {
|
||||
margin-bottom: -5px;
|
||||
}
|
||||
.icon-delete {
|
||||
cursor: pointer;
|
||||
margin-bottom: -6px;
|
||||
}
|
||||
|
||||
@ -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).
|
||||
@ -31,7 +31,6 @@
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
|
||||
$filename;
|
||||
$fileuri;
|
||||
|
||||
$externalUrl = $_GET["fileUrl"];
|
||||
if (!empty($externalUrl))
|
||||
@ -40,40 +39,24 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename = $_GET["fileID"];
|
||||
$filename = basename($_GET["fileID"]);
|
||||
}
|
||||
$type = $_GET["type"];
|
||||
$createExt = $_GET["fileExt"];
|
||||
|
||||
if (!empty($type))
|
||||
if (!empty($createExt))
|
||||
{
|
||||
$filename = tryGetDefaultByType($type);
|
||||
$filename = tryGetDefaultByType($createExt);
|
||||
|
||||
$new_url = "doceditor.php?fileID=" . $filename;
|
||||
$new_url = "doceditor.php?fileID=" . $filename . "&user=" . $_GET["user"];
|
||||
header('Location: ' . $new_url, true);
|
||||
exit;
|
||||
}
|
||||
|
||||
$fileuri = FileUri($filename);
|
||||
$fileuri = FileUri($filename, true);
|
||||
$fileuriUser = FileUri($filename);
|
||||
|
||||
|
||||
function tryGetDefaultByType($type) {
|
||||
$ext;
|
||||
switch ($type)
|
||||
{
|
||||
case "document":
|
||||
$ext = ".docx";
|
||||
break;
|
||||
case "spreadsheet":
|
||||
$ext = ".xlsx";
|
||||
break;
|
||||
case "presentation":
|
||||
$ext = ".pptx";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$demoName = "demo" . $ext;
|
||||
function tryGetDefaultByType($createExt) {
|
||||
$demoName = ($_GET["sample"] ? "demo." : "new.") . $createExt;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
if(!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . "app_data" . DIRECTORY_SEPARATOR . $demoName, getStoragePath($demoFilename)))
|
||||
@ -85,15 +68,12 @@
|
||||
return $demoFilename;
|
||||
}
|
||||
|
||||
function getDocEditorKey($fileUri) {
|
||||
return GenerateRevisionId(getCurUserHostAddress() . "/" . basename($fileUri));
|
||||
}
|
||||
|
||||
function getCallbackUrl($fileName) {
|
||||
return serverPath() . '/'
|
||||
return serverPath(TRUE) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=track&userAddress=" . getClientIp()
|
||||
. "&fileName=" . urlencode($fileName);
|
||||
. "?type=track"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
|
||||
?>
|
||||
@ -103,7 +83,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE</title>
|
||||
|
||||
<style>
|
||||
html {
|
||||
@ -165,20 +145,36 @@
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
<?php
|
||||
if (!file_exists(getStoragePath($filename))) {
|
||||
echo "alert('File not found'); return;";
|
||||
}
|
||||
?>
|
||||
|
||||
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["action"] != "embedded" ? "desktop" : "embedded") ?>",
|
||||
type: type,
|
||||
documentType: "<?php echo getDocumentType($filename) ?>",
|
||||
document: {
|
||||
title: fileName,
|
||||
url: "<?php echo $fileuri ?>",
|
||||
fileType: fileType,
|
||||
key: "<?php echo getDocEditorKey($fileuri) ?>",
|
||||
key: "<?php echo getDocEditorKey($filename) ?>",
|
||||
|
||||
info: {
|
||||
author: "Me",
|
||||
@ -186,8 +182,9 @@
|
||||
},
|
||||
|
||||
permissions: {
|
||||
edit: <?php echo (in_array(strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION)), $GLOBALS['DOC_SERV_EDITED']) ? "true" : "false") ?>,
|
||||
download: true,
|
||||
edit: <?php echo (in_array(strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION)), $GLOBALS['DOC_SERV_EDITED']) && $_GET["action"] != "review" ? "true" : "false") ?>,
|
||||
review: true
|
||||
}
|
||||
},
|
||||
editorConfig: {
|
||||
@ -197,16 +194,12 @@
|
||||
|
||||
callbackUrl: "<?php echo getCallbackUrl($filename) ?>",
|
||||
|
||||
user: {
|
||||
id: "<?php echo getClientIp() ?>",
|
||||
firstname: "John",
|
||||
lastname: "Smith",
|
||||
},
|
||||
user: user,
|
||||
|
||||
embedded: {
|
||||
saveUrl: "<?php echo $fileuri ?>",
|
||||
embedUrl: "<?php echo $fileuri ?>",
|
||||
shareUrl: "<?php echo $fileuri ?>",
|
||||
saveUrl: "<?php echo $fileuriUser ?>",
|
||||
embedUrl: "<?php echo $fileuriUser ?>",
|
||||
shareUrl: "<?php echo $fileuriUser ?>",
|
||||
toolbarDocked: "top",
|
||||
},
|
||||
|
||||
@ -214,7 +207,7 @@
|
||||
about: true,
|
||||
feedback: true,
|
||||
goback: {
|
||||
url: "<?php echo serverPath() ?>/index.php",
|
||||
url: "<?php echo serverPath() ?>",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -223,6 +216,7 @@
|
||||
'onDocumentStateChange': onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
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).
|
||||
@ -28,14 +28,8 @@
|
||||
<?php
|
||||
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/common.php' );
|
||||
|
||||
|
||||
function FileUri($file_name) {
|
||||
$uri = getVirtualPath() . $file_name;
|
||||
return $uri;
|
||||
}
|
||||
|
||||
function GetExternalFileUri($local_uri) {
|
||||
$externalUri = '';
|
||||
|
||||
@ -106,23 +100,6 @@ function DoUpload($fileUri) {
|
||||
}
|
||||
|
||||
|
||||
function generateUrlToConverter($document_uri, $from_extension, $to_extension, $title, $document_revision_id, $is_async) {
|
||||
$urlToConverterParams = array(
|
||||
"url" => $document_uri,
|
||||
"outputtype" => trim($to_extension,'.'),
|
||||
"filetype" => trim($from_extension, '.'),
|
||||
"title" => $title,
|
||||
"key" => $document_revision_id);
|
||||
|
||||
$urlToConverter = $GLOBALS['DOC_SERV_CONVERTER_URL'] . "?" . http_build_query($urlToConverterParams);
|
||||
|
||||
if ($is_async)
|
||||
$urlToConverter = $urlToConverter . "&async=true";
|
||||
|
||||
return $urlToConverter;
|
||||
}
|
||||
|
||||
|
||||
function generateUrlToStorage($document_uri, $from_extension, $to_extension, $title, $document_revision_id) {
|
||||
|
||||
return $GLOBALS['DOC_SERV_STORAGE_URL'] . "?" . http_build_query(
|
||||
@ -227,16 +204,29 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
|
||||
$document_revision_id = GenerateRevisionId($document_revision_id);
|
||||
|
||||
$urlToConverter = generateUrlToConverter($document_uri, $from_extension, $to_extension, $title, $document_revision_id, $is_async);
|
||||
$urlToConverter = $GLOBALS['DOC_SERV_CONVERTER_URL'];
|
||||
|
||||
$data = json_encode(
|
||||
array(
|
||||
"async" => $is_async,
|
||||
"url" => $document_uri,
|
||||
"outputtype" => trim($to_extension,'.'),
|
||||
"filetype" => trim($from_extension, '.'),
|
||||
"title" => $title,
|
||||
"key" => $document_revision_id
|
||||
)
|
||||
);
|
||||
|
||||
$response_xml_data;
|
||||
$countTry = 0;
|
||||
|
||||
$opts = array('http' => array(
|
||||
'method' => 'GET',
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT']
|
||||
)
|
||||
);
|
||||
'method' => 'POST',
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
|
||||
'header'=> "Content-type: application/json\r\n",
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
if (substr($urlToConverter, 0, strlen("https")) === "https") {
|
||||
$opts['ssl'] = array( 'verify_peer' => FALSE );
|
||||
@ -256,8 +246,11 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
}
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$data = simplexml_load_string($response_xml_data);
|
||||
if (!$data) {
|
||||
if (!function_exists('simplexml_load_file')){
|
||||
throw new Exception("Server can't read xml");
|
||||
}
|
||||
$response_data = simplexml_load_string($response_xml_data);
|
||||
if (!$response_data) {
|
||||
$exc = "Bad Response. Errors: ";
|
||||
foreach(libxml_get_errors() as $error) {
|
||||
$exc = $exc . "\t" . $error->message;
|
||||
@ -265,7 +258,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
throw new Exception ($exc);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $response_data;
|
||||
}
|
||||
|
||||
|
||||
@ -320,6 +313,9 @@ function GetResponseUri($x_document_response, &$response_uri) {
|
||||
$resultPercent = 0;
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
if (!function_exists('simplexml_load_file')){
|
||||
throw new Exception("Server can't read xml");
|
||||
}
|
||||
$data = simplexml_load_string($x_document_response);
|
||||
|
||||
if (!$data) {
|
||||
|
||||
@ -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).
|
||||
@ -29,6 +29,8 @@
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/common.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
|
||||
$user = $_GET["user"];
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@ -36,7 +38,7 @@
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>ONLYOFFICE™</title>
|
||||
<title>ONLYOFFICE Integration Edition</title>
|
||||
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
|
||||
@ -58,8 +60,6 @@
|
||||
|
||||
<script type="text/javascript" src="js/jquery.dropdownToggle.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/jscript.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var ConverExtList = '<?php echo implode(",", $GLOBALS["DOC_SERV_CONVERT"]) ?>';
|
||||
var EditedExtList = '<?php echo implode(",", $GLOBALS["DOC_SERV_EDITED"]) ?>';
|
||||
@ -67,39 +67,170 @@
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1">
|
||||
|
||||
<div class="top-panel"></div>
|
||||
<header>
|
||||
<a href="/">
|
||||
<img src ="css/images/logo.png" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
|
||||
<span class="portal-name">ONLYOFFICE Integration Edition – Welcome!</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.</span>
|
||||
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE Integration Edition, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.</span>
|
||||
|
||||
<div class="file-upload button gray">
|
||||
<span>Choose file</span>
|
||||
<input type="file" id="fileupload" name="files" data-url="webeditor-ajax.php?type=upload" />
|
||||
<table class="user-block-table" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="middle" width="30%">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="0">Jonn Smith</option>
|
||||
<option value="1">Mark Pottato</option>
|
||||
<option value="2">Hamish Mitchell</option>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="middle" width="70%">Select user name before opening the document; you can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.</td>
|
||||
</tr>
|
||||
<!--<tr>
|
||||
<td valign="middle" width="30%">
|
||||
<select class="select-user" id="language">
|
||||
<option value="en" selected>English</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="es">Espanol</option>
|
||||
<option value="fr">Francais</option>
|
||||
<option value="it">Italiano</option>
|
||||
<option value="pt">Portuguese</option>
|
||||
<option value="ru">Русский</option>
|
||||
<option value="sl">Slovenian</option>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="middle" width="70%">Choose the language for ONLYOFFICE™ editors interface.</td>
|
||||
</tr>-->
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="help-block">
|
||||
<span>Upload your file or create new file</span>
|
||||
<br />
|
||||
<br />
|
||||
<div class="clearFix">
|
||||
<div class="upload-panel clearFix">
|
||||
<a class="file-upload">Upload
|
||||
<br />
|
||||
File
|
||||
<input type="file" id="fileupload" name="files" data-url="webeditor-ajax.php?type=upload" />
|
||||
</a>
|
||||
<br />
|
||||
<label class="save-original">
|
||||
<input type="checkbox" id="checkOriginalFormat" class="checkbox" />Keep file format
|
||||
</label>
|
||||
</div>
|
||||
<div class="create-panel clearFix">
|
||||
<ul class="try-editor-list clearFix">
|
||||
<li>
|
||||
<a class="try-editor document reload-page" target="_blank" href="doceditor.php?fileExt=docx&user=<?php echo $user; ?>">Create
|
||||
<br />
|
||||
Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor spreadsheet reload-page" target="_blank" href="doceditor.php?fileExt=xlsx&user=<?php echo $user; ?>">Create
|
||||
<br />
|
||||
Spreadsheet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor presentation reload-page" target="_blank" href="doceditor.php?fileExt=pptx&user=<?php echo $user; ?>">Create
|
||||
<br />
|
||||
Presentation</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<input type="checkbox" id="createSample" class="checkbox" />Create a file filled with sample content
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label class="save-original">
|
||||
<input type="checkbox" id="checkOriginalFormat" class="checkbox" />Save document in original format
|
||||
</label>
|
||||
<span class="question"></span>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<span class="try-descr">You are also enabled to view and edit documents pre-uploaded to the portal.</span>
|
||||
<ul class="try-editor-list">
|
||||
<li><a class="try-editor document" href="doceditor.php?type=document" target="_blank">Create<br />Sample Document</a></li>
|
||||
<li><a class="try-editor spreadsheet" href="doceditor.php?type=spreadsheet" target="_blank">Create<br />Sample Spreadsheet</a></li>
|
||||
<li><a class="try-editor presentation" href="doceditor.php?type=presentation" target="_blank">Create<br />Sample Presentation</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="help-block">
|
||||
<span>Your documents</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="stored-list">
|
||||
<div id="UserFiles">
|
||||
<table cellspacing="0" cellpadding="0" width="100%">
|
||||
<thead>
|
||||
<tr class="tableHeader">
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
|
||||
<td colspan="3" class="tableHeaderCell contentCells-shift">Editors</td>
|
||||
<td colspan="3" class="tableHeaderCell">Viewers</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $storedFiles = getStoredFiles();
|
||||
foreach ($storedFiles as &$storeFile)
|
||||
{
|
||||
echo '<tr class="tableRow" title="'.$storeFile->name.'">';
|
||||
echo ' <td class="contentCells">';
|
||||
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="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.'">';
|
||||
echo ' <img class="icon-delete" src="css/images/delete-24.png" alt="Delete" title="Delete" /></a>';
|
||||
echo ' </a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
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>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>';
|
||||
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&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&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>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&action=view&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile-24.png" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>';
|
||||
echo ' </a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.$user.'&type=embedded" target="_blank">';
|
||||
echo ' <img src="css/images/embeded-24.png" alt="Open in embedded mode" title="Open in embedded mode" /></a>';
|
||||
echo ' </a>';
|
||||
echo ' </td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<div class="help-block">
|
||||
<span>Want to learn how it works?</span>
|
||||
|
||||
<span>Want to learn the magic?</span>
|
||||
<br />
|
||||
Read the editor <a href="http://api.onlyoffice.com/editors/howitworks">API Documentation</a>
|
||||
Explore ONLYOFFICE Integration Edition <a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation.</a>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
@ -107,15 +238,10 @@
|
||||
<div class="help-block">
|
||||
<span>Any questions?</span>
|
||||
<br />
|
||||
Please, <a href="mailto:sales@onlyoffice.com">submit your request</a> and we'll help you shortly.
|
||||
Please, <a href="mailto:sales@onlyoffice.com">submit your request here</a>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="hint">
|
||||
<div class="corner"></div>
|
||||
If you check this option the file will be saved both in the original and converted into Office Open XML format for faster viewing and editing. In other case the document will be overwritten by its copy in Office Open XML format.
|
||||
</div>
|
||||
|
||||
<div id="mainProgress">
|
||||
<div id="uploadSteps">
|
||||
<span id="step1" class="step">1. Loading the file</span>
|
||||
@ -150,8 +276,9 @@
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="<?php echo $GLOBALS['DOC_SERV_PRELOADER_URL'] ?>"></span>
|
||||
<div class="bottom-panel">© Ascensio System SIA <?php echo date("Y") ?>. All rights reserved.</div>
|
||||
<footer>© Ascensio Systems Inc <?php echo date("Y") ?>. All rights reserved.</footer>
|
||||
|
||||
<script type="text/javascript" src="js/jscript.js"></script>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (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).
|
||||
@ -26,6 +26,16 @@
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
user = getUrlVars()["user"];
|
||||
if ("" != user && undefined != user)
|
||||
jq("#user").val(user);
|
||||
else
|
||||
user = jq("#user").val();
|
||||
|
||||
jq(document).on("change", "#user", function() {
|
||||
window.location = "?user=" + jq(this).val();
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -108,7 +118,11 @@ if (typeof jQuery != "undefined") {
|
||||
url: requestAddress,
|
||||
complete: function (data) {
|
||||
var responseText = data.responseText;
|
||||
var response = jq.parseJSON(responseText);
|
||||
try {
|
||||
var response = jq.parseJSON(responseText);
|
||||
} catch (e) {
|
||||
response = { error: e };
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
jq(".current").removeClass("current");
|
||||
@ -166,23 +180,25 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?fileID=" + fileId;
|
||||
var url = "doceditor.php?fileID=" + fileId + "&user=" + user;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?action=view&fileID=" + fileId;
|
||||
var url = "doceditor.php?action=view&fileID=" + fileId + "&user=" + user;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?action=embedded&fileID=" + fileId;
|
||||
var url = "doceditor.php?type=embedded&fileID=" + fileId + "&user=" + user;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -190,14 +206,60 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#embeddedView").attr("src", url);
|
||||
});
|
||||
|
||||
jq(document).on("click", ".reload-page", function () {
|
||||
setTimeout(function () { document.location.reload(); }, 1000);
|
||||
return true;
|
||||
});
|
||||
|
||||
jq(document).on("mouseup", ".reload-page", function (event) {
|
||||
if (event.which == 2) {
|
||||
setTimeout(function () { document.location.reload(); }, 1000);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
jq(document).on("click", "#cancelEdit, .dialog-close", function () {
|
||||
jq('#hiddenFileName').val("");
|
||||
jq("#embeddedView").attr("src", "");
|
||||
jq.unblockUI();
|
||||
});
|
||||
|
||||
jq.dropdownToggle({
|
||||
switcherSelector: ".question",
|
||||
dropdownID: "hint"
|
||||
jq(document).on("click", ".delete-file", function () {
|
||||
var fileName = jq(this).attr("data");
|
||||
|
||||
var requestAddress = "webeditor-ajax.php?type=delete&fileName=" + fileName;
|
||||
|
||||
jq.ajax({
|
||||
async: true,
|
||||
contentType: "text/xml",
|
||||
type: "get",
|
||||
url: requestAddress,
|
||||
complete: function (data) {
|
||||
document.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
jq(document).on("click", "#createSample", function () {
|
||||
jq(".try-editor").each(function () {
|
||||
var href = jq(this).attr("href");
|
||||
if (jq("#createSample").is(":checked")) {
|
||||
href += "&sample=true";
|
||||
} else {
|
||||
href = href.replace("&sample=true", "");
|
||||
}
|
||||
jq(this).attr("href", href);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
@ -1,19 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<compilation debug="false" targetFramework="4.5">
|
||||
<assemblies>
|
||||
<remove assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
</assemblies>
|
||||
</compilation>
|
||||
<system.web>
|
||||
<customErrors mode="Off"/>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Cache-Control" value="max-age=300, must-revalidate"/>
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<requestLimits maxAllowedContentLength="300000000">
|
||||
@ -23,13 +13,9 @@
|
||||
</requestLimits>
|
||||
</requestFiltering>
|
||||
</security>
|
||||
<modules>
|
||||
|
||||
</modules>
|
||||
<defaultDocument enabled="true">
|
||||
</defaultDocument>
|
||||
<modules/>
|
||||
<defaultDocument enabled="true" />
|
||||
<httpErrors errorMode="Detailed"/>
|
||||
|
||||
<urlCompression doDynamicCompression="false"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -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';
|
||||
@ -68,6 +71,10 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
|
||||
$response_array = track();
|
||||
$response_array['status'] = 'success';
|
||||
die (json_encode($response_array));
|
||||
case "delete":
|
||||
$response_array = delete();
|
||||
$response_array['status'] = 'success';
|
||||
die (json_encode($response_array));
|
||||
default:
|
||||
$response_array['status'] = 'error';
|
||||
$response_array['error'] = '404 Method not found';
|
||||
@ -120,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");
|
||||
@ -150,14 +172,33 @@ function track() {
|
||||
|
||||
$userAddress = $_GET["userAddress"];
|
||||
$fileName = $_GET["fileName"];
|
||||
$storagePath = getStoragePath($fileName, $userAddress);
|
||||
|
||||
$downloadUri = $data["url"];
|
||||
|
||||
$curExt = strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$downloadExt = strtolower('.' . pathinfo($downloadUri, PATHINFO_EXTENSION));
|
||||
|
||||
if ($downloadExt != $curExt) {
|
||||
$key = getDocEditorKey(downloadUri);
|
||||
|
||||
try {
|
||||
sendlog("Convert " . $downloadUri . " from " . $downloadExt . " to " . $curExt, "logs/webedior-ajax.log");
|
||||
$convertedUri;
|
||||
$percent = GetConvertedUri($downloadUri, $downloadExt, $curExt, $key, FALSE, $convertedUri);
|
||||
$downloadUri = $convertedUri;
|
||||
} catch (Exception $e) {
|
||||
sendlog("Convert after save ".$e->getMessage(), "logs/webedior-ajax.log");
|
||||
$result["error"] = "error: " . $e->getMessage();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$saved = 1;
|
||||
|
||||
if (($new_data = file_get_contents($downloadUri))===FALSE){
|
||||
$saved = 0;
|
||||
} else {
|
||||
$storagePath = getStoragePath($fileName, $userAddress);
|
||||
file_put_contents($storagePath, $new_data, LOCK_EX);
|
||||
}
|
||||
|
||||
@ -178,10 +219,10 @@ function convert() {
|
||||
if (in_array("." + $extension, $GLOBALS['DOC_SERV_CONVERT']) && $internalExtension != "") {
|
||||
|
||||
$fileUri = $_GET["fileUri"];
|
||||
if ($fileUri == "") {
|
||||
$fileUri = FileUri($fileName);
|
||||
if ($fileUri == NULL || $fileUri == "") {
|
||||
$fileUri = FileUri($fileName, TRUE);
|
||||
}
|
||||
$key = GenerateRevisionId($fileUri);
|
||||
$key = getDocEditorKey($fileName);
|
||||
|
||||
$newFileUri;
|
||||
$result;
|
||||
@ -223,4 +264,19 @@ function convert() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function delete() {
|
||||
try {
|
||||
$fileName = $_GET["fileName"];
|
||||
|
||||
$filePath = getStoragePath($fileName);
|
||||
|
||||
unlink($filePath);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
sendlog("Deletion ".$e->getMessage(), "logs/webedior-ajax.log");
|
||||
$result["error"] = "error: " . $e->getMessage();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ONLYOFFICE
|
||||
Copyright (c) 2017 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||