mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
343 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 979391e413 | |||
| df7cfda2fb | |||
| 9ebef04f3d | |||
| a6ed970bca | |||
| 7f659bc95e | |||
| 3c4a1c1c31 | |||
| 2bae0567ad | |||
| 13e2d5b33c | |||
| f208fe1939 | |||
| b3cc35cb5e | |||
| 8b316b0786 | |||
| c57fcbfd90 | |||
| 1939b85c8c | |||
| ee0ac33820 | |||
| c93579d98f | |||
| 61a9e122cd | |||
| e88a9f5bed | |||
| f1ce0fb415 | |||
| 3b142d92fc | |||
| 1898da660e | |||
| 0629cf0797 | |||
| 7737670a6d | |||
| 5bdcac42e3 | |||
| 4b8ffa26cc | |||
| a4b6fcb512 | |||
| 523b10c979 | |||
| 1d4bc95c29 | |||
| e94a4863aa | |||
| edda981ab7 | |||
| 65ebf9a5b1 | |||
| a081cd1f06 | |||
| 04c5ee8cd7 | |||
| 3ebf3fabee | |||
| 403efc1325 | |||
| 7deedcaa5e | |||
| 161e26dd8a | |||
| 09804349fa | |||
| 83a83f4f5d | |||
| 79ee987003 | |||
| 434484cac3 | |||
| a0bafb0e4b | |||
| 184aded727 | |||
| 7db708e559 | |||
| 3b3116f56e | |||
| 15c70f43d7 | |||
| 39af4be045 | |||
| c9dc4862ed | |||
| 122d41e307 | |||
| 2880db7383 | |||
| c0f23a4fc2 | |||
| 1a49d8dd03 | |||
| 180f287c07 | |||
| 37c33965c8 | |||
| 0861732dbe | |||
| d3220c7a91 | |||
| 450cafdae3 | |||
| 62abe3e569 | |||
| 8b2fbff3b7 | |||
| acf243ee3e | |||
| 66c38ded4a | |||
| 58a73190d4 | |||
| ae7a208831 | |||
| 2d83f3f39c | |||
| 2aed1e3a83 | |||
| 001a99b502 | |||
| a7a9f997d5 | |||
| 4c3dc96e30 | |||
| 7fe1ae27b4 | |||
| dce840c627 | |||
| 4f832ac2f7 | |||
| e7623e29d7 | |||
| 16dd8a55e5 | |||
| dca68bf0d1 | |||
| f028f1ba2f | |||
| 5c8867dd20 | |||
| 27eea60fc3 | |||
| c285b49d3b | |||
| 70c86f3054 | |||
| 00e5466a0c | |||
| 12a366a28a | |||
| b4918cf493 | |||
| b2b21980d1 | |||
| 09a97c0f66 | |||
| 5db65ef062 | |||
| 5164380336 | |||
| 26c5cd0a83 | |||
| bff8c83283 | |||
| 827bd3981f | |||
| e8599c7c56 | |||
| 0a3b951eb6 | |||
| 988da27e3f | |||
| a697219dcf | |||
| 7649e7f51e | |||
| 108b5ea317 | |||
| 4ea0760803 | |||
| c558098deb | |||
| 4a61093343 | |||
| 2af1f56aa7 | |||
| 6780feafa6 | |||
| 23b4ffc104 | |||
| 7304166d8f | |||
| 46a9fffb0e | |||
| 0ccc98e83f | |||
| 7f59c15112 | |||
| 455f2ee823 | |||
| 3076a9bc0e | |||
| c605607b5e | |||
| e05afc931a | |||
| 53aeb19e2f | |||
| 14a557be69 | |||
| 666b6f8a03 | |||
| ebddc8114a | |||
| fa76819b2d | |||
| 69aa25880a | |||
| 7cd79280ff | |||
| 4535bfe661 | |||
| 01cabdf1e5 | |||
| 8b15a0e417 | |||
| 451b3b7a38 | |||
| 952b495c4d | |||
| 1cd3642de8 | |||
| a4f49cb86b | |||
| 9ca722329f | |||
| 496a150620 | |||
| 983a92d9e0 | |||
| ad94016a85 | |||
| fcb807471f | |||
| 50a4ddbd11 | |||
| 01d1dc4274 | |||
| 1447b304eb | |||
| 8e79c6448f | |||
| badf3c7d49 | |||
| 342b31f7d7 | |||
| 0ae8f5d396 | |||
| 7a238c2b73 | |||
| 0b4c67e552 | |||
| f5391051b1 | |||
| 01c8a940d4 | |||
| 579992e40b | |||
| 3a2218a466 | |||
| 0ea28f525f | |||
| 33363f6144 | |||
| da8bdca022 | |||
| c4eccc5ee8 | |||
| ab13745cf6 | |||
| 97f07e4275 | |||
| 7c3e250797 | |||
| 32ab794f11 | |||
| 800ef84f84 | |||
| a7e4036667 | |||
| 4f589a7394 | |||
| a3abb58d72 | |||
| 17536df8e5 | |||
| 2e8a483a0c | |||
| a0aa7b4fd0 | |||
| 8b720beffa | |||
| a1c286cbaa | |||
| fc377b967d | |||
| b2de5eff4c | |||
| 02439f3699 | |||
| 2429f21a84 | |||
| aa0a4b5400 | |||
| a28300848b | |||
| fec0e87218 | |||
| efbace1e8b | |||
| 35e479355a | |||
| 32c91b9016 | |||
| 183d165c00 | |||
| a996f2c3c3 | |||
| 782243eb86 | |||
| f058d68126 | |||
| a8f07fce4d | |||
| 025bd1068d | |||
| 75b22614cf | |||
| 6cb15697ab | |||
| 1da93ce071 | |||
| 837e34de37 | |||
| 20c4ec1b78 | |||
| 39bab74422 | |||
| 665ab6a77d | |||
| 5663227c55 | |||
| 42ac89e5e5 | |||
| c95499536d | |||
| 5659756c07 | |||
| 038b3b3049 | |||
| 6b555c4d0d | |||
| 44d49bed62 | |||
| 517b130db6 | |||
| 0ff435b9bd | |||
| 56bc372140 | |||
| 0068b6d87d | |||
| 4679804774 | |||
| d03f74087c | |||
| e3a088ccaf | |||
| 5865fedbe7 | |||
| 68390aa26c | |||
| 744e5203cb | |||
| 7df7af3f47 | |||
| bf40cd1249 | |||
| f3cb5adb22 | |||
| c8d44199c2 | |||
| 12bcc0009b | |||
| be1ea81f82 | |||
| 668df46ec3 | |||
| 43905695e0 | |||
| 4a49becea1 | |||
| c91d3a24b9 | |||
| d6a4984b84 | |||
| f1dae06746 | |||
| 3cf3bcf2c8 | |||
| aa6e19ebaa | |||
| 24a26fd530 | |||
| a5f91bc14f | |||
| d7034c72c9 | |||
| c0437b152f | |||
| b72b2c6619 | |||
| c516631360 | |||
| 5cc8d7c094 | |||
| 5f4764060c | |||
| 44832008a8 | |||
| d86e737493 | |||
| 07a1e3101b | |||
| 1ebfe49916 | |||
| b1d6f8d652 | |||
| 8f0edf90e6 | |||
| 7c77389550 | |||
| 637731a4d7 | |||
| 6fc98a025b | |||
| f123cbcce3 | |||
| 11f166525e | |||
| 68db498dfd | |||
| f914afcc53 | |||
| 8dcf75f3fb | |||
| 3d9e091882 | |||
| a9ca4b3272 | |||
| a722b04226 | |||
| 9a1110a56e | |||
| 707122013f | |||
| f9ed5edf89 | |||
| dbf6766897 | |||
| a60c594505 | |||
| 2d0e6c0d3f | |||
| 63e7461995 | |||
| d2491ae6b7 | |||
| 35798a7916 | |||
| f7000b51a7 | |||
| 7e36939392 | |||
| afec51b296 | |||
| 66faaab294 | |||
| 7be2a5a507 | |||
| 8cf26de5e2 | |||
| 016611ba52 | |||
| 73d1011e8a | |||
| f2a11a5894 | |||
| c6043d4428 | |||
| c37ba28ad3 | |||
| 53f810fc54 | |||
| a55875ae1e | |||
| 707a634823 | |||
| b511fa872a | |||
| 4a2e7d9a9e | |||
| e4d5de2c0e | |||
| 50dca2e2c0 | |||
| 893303c27f | |||
| b543392c62 | |||
| adf52c756e | |||
| 693cc5a951 | |||
| ff9ba7fbf1 | |||
| c2b87959a2 | |||
| 18ee7776ef | |||
| c99efda67a | |||
| d65f970255 | |||
| f5442a8a89 | |||
| e347ea36ce | |||
| f0651dabf0 | |||
| ccf85c1c0f | |||
| 6ea35bf55c | |||
| f6afde346a | |||
| ce4074bcce | |||
| 5697b58aa2 | |||
| d5e6301211 | |||
| 9048082cb7 | |||
| 56e46466b2 | |||
| fa9731ab57 | |||
| c2ba46ce85 | |||
| 4c5780f1d6 | |||
| 0419611a62 | |||
| bcc1011ddd | |||
| 91a4fe1e52 | |||
| 21fed8a81e | |||
| f2fc63c24f | |||
| 521608fa15 | |||
| e16ad4e53d | |||
| 7205e383c8 | |||
| 9bf317b3e0 | |||
| ac668a41c5 | |||
| 606f4255dc | |||
| 22a64dd932 | |||
| dd3255779f | |||
| 89c7e63ab8 | |||
| 447c604fe9 | |||
| dff9602852 | |||
| f4d7915dd6 | |||
| 01204d544e | |||
| a06aa8c8b3 | |||
| 7977427038 | |||
| 0b8d0ed10a | |||
| efec141039 | |||
| 6736555ff3 | |||
| d94fe30a3e | |||
| 3079320534 | |||
| 4f3af51e54 | |||
| d19c81c944 | |||
| bc3cbbbb82 | |||
| 8ee3ddc925 | |||
| 173c05dbf3 | |||
| b13c548c4d | |||
| ef8237adfd | |||
| c80379da31 | |||
| a54c43c0c2 | |||
| 5e524aa148 | |||
| e84ee9e01b | |||
| 27ceb1e6c6 | |||
| 508b0d913c | |||
| 5999b070dc | |||
| 3ed13f3975 | |||
| 1789f7c9fd | |||
| a05ea11dd7 | |||
| c6dd46a004 | |||
| bf04979c31 | |||
| e9274b7303 | |||
| 03022c5b45 | |||
| ce4ccdd5b0 | |||
| 07eba65458 | |||
| 072b082240 | |||
| c664bc4ee9 | |||
| f113d7eeb1 | |||
| 9409bf0785 | |||
| d51e724130 | |||
| 9489b4dcde | |||
| d9c139a42b | |||
| 534f1d8284 | |||
| f177af8791 |
6
.github/workflows/lint-php.yml
vendored
6
.github/workflows/lint-php.yml
vendored
@ -25,7 +25,5 @@ jobs:
|
||||
php-version: '8.2'
|
||||
tools: cs2pr, phpcs
|
||||
|
||||
- name: Run phpcs
|
||||
run: |
|
||||
phpcs --version
|
||||
phpcs -q --extensions=php,module,inc,install,test,profile,theme,info --ignore=node_modules,bower_components,vendor,css,js,lib --standard=./ruleset.xml ./
|
||||
- name: Lint
|
||||
run: phpcs .
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@ -22,8 +22,3 @@
|
||||
/web/documentserver-example/csharp/packages
|
||||
/web/documentserver-example/csharp-mvc/packages
|
||||
/web/documentserver-example/java-spring/documents/
|
||||
/web/documentserver-example/ruby/.bundle
|
||||
/web/documentserver-example/ruby/db/*.sqlite3
|
||||
/web/documentserver-example/ruby/db/*.sqlite3-journal
|
||||
/web/documentserver-example/ruby/log/*
|
||||
/web/documentserver-example/ruby/tmp
|
||||
|
||||
24
.gitmodules
vendored
24
.gitmodules
vendored
@ -1,15 +1,7 @@
|
||||
[submodule "web/documentserver-example/nodejs/public/assets"]
|
||||
path = web/documentserver-example/nodejs/public/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/java/src/main/resources/assets"]
|
||||
path = web/documentserver-example/java/src/main/resources/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/php/assets"]
|
||||
path = web/documentserver-example/php/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/python/assets"]
|
||||
path = web/documentserver-example/python/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
@ -30,3 +22,19 @@
|
||||
path = web/documentserver-example/java-spring/src/main/resources/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/nodejs/public/assets/document-templates"]
|
||||
path = web/documentserver-example/nodejs/public/assets/document-templates
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/nodejs/public/assets/document-formats"]
|
||||
path = web/documentserver-example/nodejs/public/assets/document-formats
|
||||
url = https://github.com/ONLYOFFICE/document-formats
|
||||
branch = master
|
||||
[submodule "web/documentserver-example/php/assets/document-templates"]
|
||||
path = web/documentserver-example/php/assets/document-templates
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/php/assets/document-formats"]
|
||||
path = web/documentserver-example/php/assets/document-formats
|
||||
url = https://github.com/ONLYOFFICE/document-formats
|
||||
branch = master
|
||||
|
||||
@ -3,10 +3,6 @@ Document Server integration example uses code from the following 3rd party proje
|
||||
|
||||
web/documentserver-example/csharp
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -19,14 +15,26 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
|
||||
web/documentserver-example/csharp-mvc
|
||||
|
||||
@ -34,10 +42,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
|
||||
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
|
||||
License File: EntityFramework.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -50,19 +54,27 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
@ -73,10 +85,6 @@ License File: WebGrease.license
|
||||
|
||||
web/documentserver-example/java
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -89,9 +97,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
@ -104,9 +116,17 @@ License File: prime-jwt.license
|
||||
|
||||
web/documentserver-example/java-spring
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -120,14 +140,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
|
||||
License: MIT
|
||||
License File lombok.license
|
||||
|
||||
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
|
||||
License: Apache 2.0
|
||||
License File modelmapper.license
|
||||
|
||||
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: prime-jwt.license
|
||||
@ -148,22 +184,6 @@ Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spr
|
||||
License: Apache 2.0
|
||||
License File: spring-data-jpa.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
|
||||
|
||||
web/documentserver-example/nodejs
|
||||
|
||||
@ -199,10 +219,6 @@ he - a robust HTML entity encoder/decoder written in JavaScript. (htt
|
||||
License: MIT
|
||||
License File: he.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -215,9 +231,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
@ -248,11 +268,8 @@ License: MIT
|
||||
License File: urllib.license
|
||||
|
||||
|
||||
web/documentserver-example/php
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
web/documentserver-example/php
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -266,9 +283,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
@ -282,16 +303,24 @@ PHP_CodeSniffer - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs sc
|
||||
License: BSD-3-Clause
|
||||
License File: PHP_CodeSniffer.license
|
||||
|
||||
PHPUnit - The PHP Unit Testing framework. (https://github.com/sebastianbergmann/phpunit/blob/main/LICENSE)
|
||||
License: BSD 3-Clause
|
||||
License File: phpunit.license
|
||||
|
||||
|
||||
web/documentserver-example/python
|
||||
|
||||
django-stubs - PEP-484 stubs for Django. (https://github.com/typeddjango/django-stubs/blob/master/LICENSE.md)
|
||||
License: MIT
|
||||
License File: django-stubs.license
|
||||
|
||||
Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
License File: Django.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
flake8 - flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code. (https://github.com/PyCQA/flake8/blob/main/LICENSE)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
License File: flake8.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -305,57 +334,22 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: PyJWT.license
|
||||
|
||||
python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: python-magic.license
|
||||
|
||||
requests - Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: requests.license
|
||||
|
||||
|
||||
web/documentserver-example/python
|
||||
|
||||
Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
License File: Django.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
|
||||
jQuery.FileUpload - File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads. (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt)
|
||||
License: MIT
|
||||
License File: jQuery.FileUpload.license
|
||||
|
||||
jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt)
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
mypy - Optional static typing for Python. (https://github.com/python/mypy/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: mypy.license
|
||||
|
||||
PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: PyJWT.license
|
||||
@ -368,6 +362,10 @@ requests - Requests allows you to send HTTP/1.1 requests extremely easily.
|
||||
License: Apache 2.0
|
||||
License File: requests.license
|
||||
|
||||
typeshed - Collection of library stubs for Python, with static types. (https://github.com/python/typeshed/blob/main/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: typeshed.license
|
||||
|
||||
|
||||
web/documentserver-example/ruby
|
||||
|
||||
@ -379,14 +377,14 @@ coffee-rails - CoffeeScript adapter for the Rails asset pipeline. (https://gith
|
||||
License: MIT
|
||||
License File: coffee-rails.license
|
||||
|
||||
dalli - High performance memcached client for Ruby. (https://github.com/petergoldstein/dalli/blob/v3.2.0/LICENSE)
|
||||
License: MIT
|
||||
License File: dalli.license
|
||||
|
||||
jbuilder - Create JSON structures via a Builder-style DSL (https://github.com/rails/jbuilder/blob/master/MIT-LICENSE)
|
||||
License: MIT
|
||||
License File: jbuilder.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -399,9 +397,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
@ -411,10 +413,18 @@ jquery-rails - This gem provides jQuery and the jQuery-ujs driver for your Rail
|
||||
License: MIT
|
||||
License File: jquery-rails.license
|
||||
|
||||
mimemagic - А library to detect the mime type of a file by extension or by content. (https://github.com/mimemagicrb/mimemagic/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: mimemagic.license
|
||||
|
||||
rails - Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern. (https://github.com/rails/rails/blob/v6.0.3.2/MIT-LICENSE)
|
||||
License: MIT
|
||||
License File: rails.license
|
||||
|
||||
rubocop - A Ruby static code analyzer and formatter, based on the community Ruby style guide. (https://github.com/rubocop/rubocop/blob/v1.52.0/LICENSE.txt)
|
||||
License: MIT
|
||||
License File: rubocop.license
|
||||
|
||||
sass-rails - This gem provides official integration for Ruby on Rails projects with the Sass stylesheet language. (https://github.com/rails/sass-rails/blob/master/MIT-LICENSE)
|
||||
License: MIT
|
||||
License File: sass-rails.license
|
||||
@ -423,9 +433,13 @@ sdoc - rdoc generator html with javascript search index. (https://githu
|
||||
License: MIT
|
||||
License File: sdoc.license
|
||||
|
||||
sqlite3 - This module allows Ruby programs to interface with the SQLite3 database engine (www.sqlite.org). (https://github.com/sparklemotion/sqlite3-ruby/blob/master/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
License File: sqlite3.license
|
||||
sorbet - A fast, powerful type checker designed for Ruby. (https://github.com/sorbet/sorbet/blob/0.5.10871.20230607144259-d9000e2ba/LICENSE)
|
||||
License: Apache License 2.0
|
||||
License File: sorbet.license
|
||||
|
||||
tapioca - The swiss army knife of RBI generation. (https://github.com/Shopify/tapioca/blob/v0.11.6/LICENSE.txt)
|
||||
License: MIT
|
||||
License File: tapioca.license
|
||||
|
||||
turbolinks - Rails engine for Turbolinks 5 support (https://github.com/turbolinks/turbolinks-rails/blob/master/LICENSE)
|
||||
License: MIT
|
||||
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,5 +1,18 @@
|
||||
# Change Log
|
||||
|
||||
- nodejs: key in referenceData
|
||||
- nodejs: change reference source
|
||||
- php: using a repo with a list of formats
|
||||
- nodejs: using a repo with a list of formats
|
||||
- nodejs: delete file without reloading the page
|
||||
- nodejs: getting history by a separate request
|
||||
- nodejs: restore from history
|
||||
- python: restore from history
|
||||
- ruby: restore from history
|
||||
- php: restore from history
|
||||
|
||||
## 1.6.0
|
||||
- nodejs: setUsers for region protection
|
||||
- si skin languages
|
||||
- fix "no" skin languages
|
||||
- anonymous can't change viewer to edit
|
||||
|
||||
@ -4,10 +4,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
|
||||
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
|
||||
License File: EntityFramework.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -20,9 +16,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -220,6 +220,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var fileName = GetCorrectName(demoName); // get a file name with an index if the file with such a name already exists
|
||||
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName)); // copy file to the storage directory
|
||||
File.SetLastWriteTime(StoragePath(fileName), DateTime.Now);
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -249,14 +249,14 @@ namespace OnlineEditorsExampleMVC
|
||||
// get the url and file type of the converted file
|
||||
Dictionary<string, string> newFileData;
|
||||
var result = ServiceConverter.GetConvertedData(downloadUri.ToString(), extension, internalExtension, key, true, out newFileData, filePass, lang);
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
if (result != 100)
|
||||
{
|
||||
context.Response.Write("{ \"step\" : \"" + result + "\", \"filename\" : \"" + fileName + "\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
// get a file name of an internal file extension with an index if the file with such a name already exists
|
||||
var correctName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + newFileType);
|
||||
|
||||
@ -659,10 +659,12 @@ namespace OnlineEditorsExampleMVC
|
||||
return;
|
||||
}
|
||||
|
||||
var directUrl = (bool)body["directUrl"];
|
||||
|
||||
var data = new Dictionary<string, object>() {
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
|
||||
{ "url", DocManagerHelper.GetDownloadUrl(fileName)},
|
||||
{ "directUrl", DocManagerHelper.GetDownloadUrl(fileName) },
|
||||
{ "directUrl", directUrl ? DocManagerHelper.GetDownloadUrl(fileName, false) : null },
|
||||
{ "referenceData", new Dictionary<string, string>()
|
||||
{
|
||||
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
|
||||
@ -670,7 +672,7 @@ namespace OnlineEditorsExampleMVC
|
||||
{"userAddress", HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))}
|
||||
})
|
||||
},
|
||||
{"instanceId", DocManagerHelper.GetServerUrl(false) }
|
||||
{ "instanceId", DocManagerHelper.GetServerUrl(false) }
|
||||
}
|
||||
},
|
||||
{ "path", fileName }
|
||||
|
||||
@ -4,10 +4,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
|
||||
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
|
||||
License File: EntityFramework.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -20,9 +16,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.1"/>
|
||||
<add key="version" value="1.6.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -489,13 +489,13 @@ namespace OnlineEditorsExample
|
||||
// get the url and file type of the converted file
|
||||
Dictionary<string, string> newFileData;
|
||||
var result = ServiceConverter.GetConvertedData(fileUrl.ToString() , extension, internalExtension, key, true, out newFileData, filePass, lang);
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
if (result != 100)
|
||||
{
|
||||
return "{ \"step\" : \"" + result + "\", \"filename\" : \"" + _fileName + "\"}";
|
||||
}
|
||||
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
// get a file name of an internal file extension with an index if the file with such a name already exists
|
||||
var fileName = GetCorrectName(Path.GetFileNameWithoutExtension(_fileName) + newFileType);
|
||||
|
||||
|
||||
@ -632,6 +632,7 @@ namespace OnlineEditorsExample
|
||||
|
||||
var filePath = _Default.StoragePath(FileName, null);
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, filePath); // copy this file to the storage directory
|
||||
File.SetLastWriteTime(filePath, DateTime.Now);
|
||||
|
||||
// create a json file with file meta data
|
||||
var id = request.Cookies.GetOrDefault("uid", null);
|
||||
|
||||
@ -477,10 +477,12 @@ namespace OnlineEditorsExample
|
||||
return;
|
||||
}
|
||||
|
||||
var directUrl = (bool) body["directUrl"];
|
||||
|
||||
var data = new Dictionary<string, object>() {
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
|
||||
{ "url", DocEditor.getDownloadUrl(fileName)},
|
||||
{ "directUrl", DocEditor.getDownloadUrl(fileName) },
|
||||
{ "directUrl", directUrl ? DocEditor.getDownloadUrl(fileName, false) : null},
|
||||
{ "referenceData", new Dictionary<string, string>()
|
||||
{
|
||||
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.1"/>
|
||||
<add key="version" value="1.6.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
<add key="files.docservice.token.useforrequest" value="true" />
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -16,14 +25,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
|
||||
License: MIT
|
||||
License File lombok.license
|
||||
|
||||
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
|
||||
License: Apache 2.0
|
||||
License File modelmapper.license
|
||||
|
||||
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: prime-jwt.license
|
||||
@ -43,27 +68,3 @@ License File: spring-boot.license
|
||||
Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate. (https://github.com/spring-projects/spring-data-jpa/blob/main/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: spring-data-jpa.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
|
||||
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
|
||||
License: Apache 2.0
|
||||
License File modelmapper.license
|
||||
|
||||
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
|
||||
License: MIT
|
||||
License File lombok.license
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -16,14 +25,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
|
||||
License: MIT
|
||||
License File lombok.license
|
||||
|
||||
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
|
||||
License: Apache 2.0
|
||||
License File modelmapper.license
|
||||
|
||||
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: prime-jwt.license
|
||||
@ -43,19 +68,3 @@ License File: spring-boot.license
|
||||
Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate. (https://github.com/spring-projects/spring-data-jpa/blob/main/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: spring-data-jpa.license
|
||||
|
||||
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
|
||||
License: MPL 2.0 or EPL 1.0
|
||||
License File: h2database.license
|
||||
|
||||
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
|
||||
License: Apache 2.0
|
||||
License File: JSON.simple.license
|
||||
|
||||
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: gson.license
|
||||
|
||||
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: jackson-databind.license
|
||||
@ -36,6 +36,7 @@ import com.onlyoffice.integration.documentserver.util.service.ServiceConverter;
|
||||
import com.onlyoffice.integration.documentserver.managers.document.DocumentManager;
|
||||
import com.onlyoffice.integration.documentserver.managers.callback.CallbackManager;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
@ -64,6 +65,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -234,6 +236,9 @@ public class FileController {
|
||||
throw new RuntimeException("Input stream is null");
|
||||
}
|
||||
|
||||
// remove source file
|
||||
storageMutator.deleteFile(fileName);
|
||||
|
||||
// create the converted file with input stream
|
||||
storageMutator.createFile(Path.of(storagePathBuilder.getFileLocation(correctedName)), stream);
|
||||
fileName = correctedName;
|
||||
@ -459,18 +464,18 @@ public class FileController {
|
||||
@ResponseBody
|
||||
public String reference(@RequestBody final JSONObject body) {
|
||||
try {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
|
||||
String userAddress = "";
|
||||
String fileName = "";
|
||||
|
||||
if (body.containsKey("referenceData")) {
|
||||
JSONObject referenceDataObj = (JSONObject) body.get("referenceData");
|
||||
LinkedHashMap referenceDataObj = (LinkedHashMap) body.get("referenceData");
|
||||
String instanceId = (String) referenceDataObj.get("instanceId");
|
||||
|
||||
if (instanceId.equals(storagePathBuilder.getServerUrl(false))) {
|
||||
JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey");
|
||||
JSONObject fileKey = (JSONObject) parser.parse((String) referenceDataObj.get("fileKey"));
|
||||
userAddress = (String) fileKey.get("userAddress");
|
||||
if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) {
|
||||
fileName = (String) fileKey.get("fileName");
|
||||
@ -496,18 +501,20 @@ public class FileController {
|
||||
return "{ \"error\": \"File not found\"}";
|
||||
}
|
||||
|
||||
boolean directUrl = (boolean) body.get("directUrl");
|
||||
|
||||
HashMap<String, Object> fileKey = new HashMap<>();
|
||||
fileKey.put("fileName", fileName);
|
||||
fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress());
|
||||
|
||||
HashMap<String, Object> referenceData = new HashMap<>();
|
||||
referenceData.put("instanceId", storagePathBuilder.getServerUrl(true));
|
||||
referenceData.put("fileKey", fileKey);
|
||||
referenceData.put("fileKey", gson.toJson(fileKey));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("fileType", fileUtility.getFileExtension(fileName));
|
||||
data.put("fileType", fileUtility.getFileExtension(fileName).replace(".", ""));
|
||||
data.put("url", documentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", documentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", directUrl ? documentManager.getDownloadUrl(fileName, false) : null);
|
||||
data.put("referenceData", referenceData);
|
||||
data.put("path", fileName);
|
||||
|
||||
|
||||
@ -163,6 +163,8 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
|
||||
storageMutator.createDirectory(ver); // create the file version directory
|
||||
|
||||
lastVersion.toFile().renameTo(new File(versionDir + File.separator + "prev" + curExt));
|
||||
|
||||
saveFile(byteArrayFile, toSave); // save document file
|
||||
|
||||
byte[] byteArrayChanges = getDownloadFile(changesUri); // download file changes
|
||||
|
||||
@ -106,17 +106,17 @@ public class DefaultServiceConverter implements ServiceConverter {
|
||||
|
||||
connection.connect();
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte); // write bytes to the output stream
|
||||
os.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
}
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != HttpStatus.OK.value()) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Convertation service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte); // write bytes to the output stream
|
||||
os.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
}
|
||||
|
||||
response = connection.getInputStream(); // get the input stream
|
||||
jsonString = convertStreamToString(response); // convert the response stream into a string
|
||||
} finally {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
server.version=1.5.1
|
||||
server.version=1.6.0
|
||||
|
||||
server.address=
|
||||
server.port=4000
|
||||
@ -28,7 +28,7 @@ files.docservice.token-use-for-request=true
|
||||
|
||||
files.docservice.verify-peer-off=true
|
||||
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
spring.datasource.url=jdbc:h2:mem:usersdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
@ -38,6 +38,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
hibernate.ddl-auto
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2
|
||||
spring.servlet.multipart.max-file-size=5MB
|
||||
spring.servlet.multipart.max-request-size=5MB
|
||||
|
||||
url.index=/
|
||||
url.converter=/converter
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
|
||||
// the user is trying to switch the document from the viewing into the editing mode
|
||||
var onRequestEditRights = function () {
|
||||
location.href = location.href.replace(RegExp("\&?action=view\&?", "i"), "");
|
||||
location.href = location.href.replace(RegExp("\&?action=view", "i"), "");
|
||||
};
|
||||
|
||||
// an error or some other specific event occurs
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -78,6 +78,11 @@ public class IndexServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
// charset for response headers if upload or convert
|
||||
if (action.matches("upload|convert")) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
}
|
||||
|
||||
DocumentManager.init(request, response);
|
||||
|
||||
// create a variable to display information about the application and error messages
|
||||
@ -310,9 +315,9 @@ public class IndexServlet extends HttpServlet {
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
// remove source file ?
|
||||
// File sourceFile = new File(DocumentManager.StoragePath(fileName, null));
|
||||
// sourceFile.delete();
|
||||
// remove source file
|
||||
File sourceFile = new File(DocumentManager.storagePath(fileName, null));
|
||||
sourceFile.delete();
|
||||
|
||||
fileName = correctName;
|
||||
|
||||
@ -695,6 +700,8 @@ public class IndexServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean directUrl = (boolean) body.get("directUrl");
|
||||
|
||||
HashMap<String, Object> fileKey = new HashMap<>();
|
||||
fileKey.put("fileName", fileName);
|
||||
fileKey.put("userAddress", DocumentManager.curUserHostAddress(null));
|
||||
@ -704,9 +711,9 @@ public class IndexServlet extends HttpServlet {
|
||||
referenceData.put("fileKey", gson.toJson(fileKey));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("fileType", FileUtility.getFileExtension(fileName));
|
||||
data.put("fileType", FileUtility.getFileExtension(fileName).replace(".", ""));
|
||||
data.put("url", DocumentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", DocumentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null);
|
||||
data.put("referenceData", referenceData);
|
||||
data.put("path", fileName);
|
||||
|
||||
|
||||
@ -213,14 +213,15 @@ public final class ServiceConverter {
|
||||
|
||||
connection.connect();
|
||||
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte);
|
||||
}
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != HttpServletResponse.SC_OK) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new Exception("Conversion service returned status: " + statusCode);
|
||||
}
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte);
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
|
||||
@ -86,11 +86,11 @@ public final class Users {
|
||||
true, new ArrayList<String>(), descriptionUserSecond, false));
|
||||
add(new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
|
||||
"group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"),
|
||||
Arrays.asList("group-2"), new ArrayList<String>()), Arrays.asList("group-2"),
|
||||
Arrays.asList("group-2"), null), Arrays.asList("group-2"),
|
||||
false, Arrays.asList("copy", "download", "print"),
|
||||
descriptionUserThird, false));
|
||||
add(new User("uid-0", null, null,
|
||||
"", null, new CommentGroups(), new ArrayList<String>(),
|
||||
"", null, null, null,
|
||||
null, Arrays.asList("protect"), descriptionUserZero, false));
|
||||
}};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
version=1.5.1
|
||||
version=1.6.0
|
||||
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
@ -16,7 +16,7 @@ files.docservice.url.api=web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.example=
|
||||
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
|
||||
@ -11,5 +11,11 @@ module.exports = {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {
|
||||
'max-len': ['error', { code: 120 }],
|
||||
'no-console': 'off',
|
||||
'no-continue': 'off',
|
||||
'no-extend-native': ['error', { exceptions: ['String'] }],
|
||||
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
||||
'no-prototype-builtins': 'off',
|
||||
},
|
||||
};
|
||||
|
||||
@ -32,10 +32,6 @@ he - a robust HTML entity encoder/decoder written in JavaScript. (htt
|
||||
License: MIT
|
||||
License File: he.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -48,9 +44,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
"log": {
|
||||
"appenders": [
|
||||
{
|
||||
@ -22,10 +22,6 @@
|
||||
"apiUrl": "web-apps/apps/api/documents/api.js",
|
||||
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
|
||||
"exampleUrl": null,
|
||||
"viewedDocs": [".djvu", ".oxps", ".pdf", ".xps"],
|
||||
"editedDocs": [".csv", ".docm", ".docx", ".docxf", ".dotm", ".dotx", ".epub", ".fb2", ".html", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".potm", ".potx", ".ppsm", ".ppsx", ".pptm", ".pptx", ".rtf", ".txt", ".xlsm", ".xlsx", ".xltm", ".xltx"],
|
||||
"fillDocs": [".docx", ".oform"],
|
||||
"convertedDocs": [".doc", ".dot", ".dps", ".dpt", ".epub", ".et", ".ett", ".fb2", ".fodp", ".fods", ".fodt", ".htm", ".html", ".mht", ".mhtml", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".pot", ".pps", ".ppt", ".rtf", ".stw", ".sxc", ".sxi", ".sxw", ".wps", ".wpt", ".xls", ".xlsb", ".xlt", ".xml"],
|
||||
"storageFolder": "./files",
|
||||
"storagePath": "/files",
|
||||
"maxFileSize": 1073741824,
|
||||
@ -54,8 +50,8 @@
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh-TW": "Chinese (Taiwan)",
|
||||
"zh": "Chinese (Simplified)",
|
||||
"zh-TW": "Chinese (Traditional)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
@ -16,42 +16,43 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var cache = {};
|
||||
let cache = {};
|
||||
|
||||
// write the key value and its creation time to the cache
|
||||
exports.put = function (key, value) {
|
||||
cache[key] = { value:value, time: new Date().getTime()};
|
||||
}
|
||||
exports.put = function put(key, value) {
|
||||
cache[key] = { value, time: new Date().getTime() };
|
||||
};
|
||||
|
||||
// check if the given key is in the cache
|
||||
exports.containsKey = function (key) {
|
||||
if (typeof cache[key] == "undefined"){
|
||||
return false;
|
||||
}
|
||||
exports.containsKey = function containsKey(key) {
|
||||
if (typeof cache[key] === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var secondsCache = 30;
|
||||
const secondsCache = 30;
|
||||
|
||||
var t1 = new Date(cache[key].time + (1000 * secondsCache)); // get the creation time of the given key and add 30 seconds to it
|
||||
var t2 = new Date(); // get the current time
|
||||
if (t1 < t2 ){ // if the current time is greater
|
||||
delete cache[key]; // delete the given key from the cache
|
||||
return false;
|
||||
}
|
||||
// get the creation time of the given key and add 30 seconds to it
|
||||
const t1 = new Date(cache[key].time + (1000 * secondsCache));
|
||||
const t2 = new Date(); // get the current time
|
||||
if (t1 < t2) { // if the current time is greater
|
||||
delete cache[key]; // delete the given key from the cache
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// get the given key from the cache
|
||||
exports.get = function (key) {
|
||||
return cache[key];
|
||||
}
|
||||
exports.get = function get(key) {
|
||||
return cache[key];
|
||||
};
|
||||
|
||||
// delete the given key from the cache
|
||||
exports.delete = function (key) {
|
||||
delete cache[key];
|
||||
}
|
||||
exports.delete = function deleteKey(key) {
|
||||
delete cache[key];
|
||||
};
|
||||
|
||||
// clear the cache
|
||||
exports.clear = function () {
|
||||
cache = {};
|
||||
}
|
||||
exports.clear = function clear() {
|
||||
cache = {};
|
||||
};
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
@ -17,488 +16,596 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const path = require("path");
|
||||
const fileSystem = require("fs");
|
||||
const fileUtility = require("./fileUtility");
|
||||
const documentService = require("./documentService");
|
||||
const path = require('path');
|
||||
const fileSystem = require('fs');
|
||||
const configServer = require('config').get('server');
|
||||
const storageConfigFolder = configServer.get("storageFolder");
|
||||
const fileUtility = require('./fileUtility');
|
||||
const documentService = require('./documentService');
|
||||
|
||||
function docManager(req, res) {
|
||||
this.req = req;
|
||||
this.res = res;
|
||||
}
|
||||
const storageConfigFolder = configServer.get('storageFolder');
|
||||
|
||||
const DocManager = function DocManager(req, res) {
|
||||
this.req = req;
|
||||
this.res = res;
|
||||
};
|
||||
|
||||
// check if the path exists or not
|
||||
docManager.prototype.existsSync = function(path) {
|
||||
let res = true;
|
||||
try {
|
||||
fileSystem.accessSync(path, fileSystem.F_OK); // synchronously test the user's permissions for the directory specified by path; the directory is visible to the calling process
|
||||
} catch (e) { // the response is set to false, if an error occurs
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
DocManager.prototype.existsSync = function existsSync(directory) {
|
||||
let res = true;
|
||||
try {
|
||||
// synchronously test the user's permissions for the directory specified by path;
|
||||
// the directory is visible to the calling process
|
||||
fileSystem.accessSync(directory, fileSystem.F_OK);
|
||||
} catch (e) { // the response is set to false, if an error occurs
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
// create a new directory if it doesn't exist
|
||||
docManager.prototype.createDirectory = function(path) {
|
||||
if (!this.existsSync(path)) {
|
||||
fileSystem.mkdirSync(path);
|
||||
}
|
||||
DocManager.prototype.createDirectory = function createDirectory(directory) {
|
||||
if (!this.existsSync(directory)) {
|
||||
fileSystem.mkdirSync(directory);
|
||||
}
|
||||
};
|
||||
|
||||
// get the language from the request
|
||||
docManager.prototype.getLang = function () {
|
||||
if (new RegExp("^[a-z]{2}(-[A-Z]{2})?$", "i").test(this.req.query.lang)) {
|
||||
return this.req.query.lang;
|
||||
} else { // the default language value is English
|
||||
return "en"
|
||||
}
|
||||
DocManager.prototype.getLang = function getLang() {
|
||||
if (/^[a-z]{2}(-[A-Z]{2})?$/i.test(this.req.query.lang)) {
|
||||
return this.req.query.lang;
|
||||
} // the default language value is English
|
||||
return 'en';
|
||||
};
|
||||
|
||||
// get customization parameters
|
||||
docManager.prototype.getCustomParams = function () {
|
||||
let params = "";
|
||||
DocManager.prototype.getCustomParams = function getCustomParams() {
|
||||
let params = '';
|
||||
|
||||
const userid = this.req.query.userid; // user id
|
||||
params += (userid ? "&userid=" + userid : "");
|
||||
const { userid } = this.req.query; // user id
|
||||
params += (userid ? `&userid=${userid}` : '');
|
||||
|
||||
const lang = this.req.query.lang; // language
|
||||
params += (lang ? "&lang=" + this.getLang() : "");
|
||||
const { lang } = this.req.query; // language
|
||||
params += (lang ? `&lang=${this.getLang()}` : '');
|
||||
|
||||
const directUrl = this.req.query.directUrl; // directUrl
|
||||
params += (directUrl ? "&directUrl=" + (directUrl == "true") : "");
|
||||
const { directUrl } = this.req.query; // directUrl
|
||||
params += (directUrl ? `&directUrl=${directUrl === 'true'}` : '');
|
||||
|
||||
const fileName = this.req.query.fileName; // file name
|
||||
params += (fileName ? "&fileName=" + fileName : "");
|
||||
const { fileName } = this.req.query; // file name
|
||||
params += (fileName ? `&fileName=${fileName}` : '');
|
||||
|
||||
const mode = this.req.query.mode; // mode: view/edit/review/comment/fillForms/embedded
|
||||
params += (mode ? "&mode=" + mode : "");
|
||||
const { mode } = this.req.query; // mode: view/edit/review/comment/fillForms/embedded
|
||||
params += (mode ? `&mode=${mode}` : '');
|
||||
|
||||
const type = this.req.query.type; // type: embedded/mobile/desktop
|
||||
params += (type ? "&type=" + type : "");
|
||||
const { type } = this.req.query; // type: embedded/mobile/desktop
|
||||
params += (type ? `&type=${type}` : '');
|
||||
|
||||
return params;
|
||||
return params;
|
||||
};
|
||||
|
||||
// get the correct file name if such a name already exists
|
||||
docManager.prototype.getCorrectName = function (fileName, userAddress) {
|
||||
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
|
||||
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
|
||||
let name = baseName + ext; // get full file name
|
||||
let index = 1;
|
||||
DocManager.prototype.getCorrectName = function getCorrectName(fileName, userAddress) {
|
||||
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
|
||||
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
|
||||
let name = baseName + ext; // get full file name
|
||||
let index = 1;
|
||||
|
||||
while (this.existsSync(this.storagePath(name, userAddress))) { // if the file with such a name already exists in this directory
|
||||
name = baseName + " (" + index + ")" + ext; // add an index after its base name
|
||||
index++;
|
||||
}
|
||||
// if the file with such a name already exists in this directory
|
||||
while (this.existsSync(this.storagePath(name, userAddress))) {
|
||||
name = `${baseName} (${index})${ext}`; // add an index after its base name
|
||||
index += 1;
|
||||
}
|
||||
|
||||
return name;
|
||||
return name;
|
||||
};
|
||||
|
||||
// processes a request editnew
|
||||
docManager.prototype.RequestEditnew = function (req, fileName, user) {
|
||||
if (req.params['id'] != fileName){ // processes a repeated request editnew
|
||||
this.fileRemove(req.params['id']);
|
||||
fileName = this.getCorrectName(req.params['id']);
|
||||
}
|
||||
this.fileSizeZero(fileName);
|
||||
this.saveFileData(fileName, user.id, user.name);
|
||||
DocManager.prototype.requestEditnew = function requestEditnew(req, fileName, user) {
|
||||
let correctName = fileName;
|
||||
if (req.params.id !== fileName) { // processes a repeated request editnew
|
||||
this.fileRemove(req.params.id);
|
||||
correctName = this.getCorrectName(req.params.id);
|
||||
}
|
||||
this.fileSizeZero(correctName);
|
||||
this.saveFileData(correctName, user.id, user.name);
|
||||
|
||||
return fileName;
|
||||
}
|
||||
return correctName;
|
||||
};
|
||||
|
||||
// delete a file with its history
|
||||
docManager.prototype.fileRemove = function (fileName) {
|
||||
const filePath = this.storagePath(fileName); // get the path to this file
|
||||
fileSystem.unlinkSync(filePath); // and delete it
|
||||
DocManager.prototype.fileRemove = function fileRemove(fileName) {
|
||||
const filePath = this.storagePath(fileName); // get the path to this file
|
||||
fileSystem.unlinkSync(filePath); // and delete it
|
||||
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const historyPath = this.historyPath(fileName, userAddress, true);
|
||||
this.cleanFolderRecursive(historyPath, true); // clean all the files from the history folder
|
||||
}
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const historyPath = this.historyPath(fileName, userAddress, true);
|
||||
this.cleanFolderRecursive(historyPath, true); // clean all the files from the history folder
|
||||
};
|
||||
|
||||
// create a zero-size file
|
||||
docManager.prototype.fileSizeZero = function (fileName) {
|
||||
var path = this.storagePath(fileName);
|
||||
var fh = fileSystem.openSync(path, 'w');
|
||||
fileSystem.closeSync(fh);
|
||||
}
|
||||
DocManager.prototype.fileSizeZero = function fileSizeZero(fileName) {
|
||||
const storagePath = this.storagePath(fileName);
|
||||
const fh = fileSystem.openSync(storagePath, 'w');
|
||||
fileSystem.closeSync(fh);
|
||||
};
|
||||
|
||||
// create demo document
|
||||
docManager.prototype.createDemo = function (isSample, fileExt, userid, username, wopi) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
DocManager.prototype.createDemo = function createDemo(isSample, fileExt, userid, username, wopi) {
|
||||
const demoName = `${isSample ? 'sample' : 'new'}.${fileExt}`;
|
||||
const fileName = this.getCorrectName(demoName); // get the correct file name if such a name already exists
|
||||
|
||||
const demoName = (isSample ? "sample" : "new") + "." + fileExt;
|
||||
const fileName = this.getCorrectName(demoName); // get the correct file name if such a name already exists
|
||||
// copy sample document of a necessary extension to the storage path
|
||||
this.copyFile(path.join(__dirname, '..', 'public', 'assets', 'document-templates', isSample
|
||||
? 'sample' : 'new', demoName), this.storagePath(fileName));
|
||||
|
||||
this.copyFile(path.join(__dirname, "..","public", "assets", isSample ? "sample" : "new", demoName), this.storagePath(fileName)); // copy sample document of a necessary extension to the storage path
|
||||
this.saveFileData(fileName, userid, username); // save file data to the file
|
||||
|
||||
this.saveFileData(fileName, userid, username); // save file data to the file
|
||||
|
||||
return fileName;
|
||||
return fileName;
|
||||
};
|
||||
|
||||
// save file data to the file
|
||||
docManager.prototype.saveFileData = function (fileName, userid, username, userAddress) {
|
||||
if (!userAddress) {
|
||||
userAddress = this.curUserHostAddress(); // get current user host address
|
||||
}
|
||||
// get full creation date of the document
|
||||
const date_create = fileSystem.statSync(this.storagePath(fileName, userAddress)).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;
|
||||
DocManager.prototype.saveFileData = function saveFileData(fileName, userid, username, userAddress) {
|
||||
let address = userAddress;
|
||||
if (!address) {
|
||||
address = this.curUserHostAddress(); // get current user host address
|
||||
}
|
||||
// get full creation date of the document
|
||||
const dateCreate = fileSystem.statSync(this.storagePath(fileName, address)).mtime;
|
||||
const minutes = (dateCreate.getMinutes() < 10 ? '0' : '') + dateCreate.getMinutes().toString();
|
||||
const month = (dateCreate.getMonth() < 10 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1);
|
||||
const sec = (dateCreate.getSeconds() < 10 ? '0' : '') + dateCreate.getSeconds().toString();
|
||||
const dateFormat = `${dateCreate.getFullYear()}-${month}-${dateCreate.getDate()}`
|
||||
+ `${dateCreate.getHours()}:${minutes}:${sec}`;
|
||||
|
||||
const file_info = this.historyPath(fileName, userAddress, true); // get file history information
|
||||
this.createDirectory(file_info); // create a new history directory if it doesn't exist
|
||||
const fileInfo = this.historyPath(fileName, address, true); // get file history information
|
||||
this.createDirectory(fileInfo); // create a new history directory if it doesn't exist
|
||||
|
||||
fileSystem.writeFileSync(path.join(file_info, fileName + ".txt"), date_format + "," + userid + "," + username); // write all the file information to a new txt file
|
||||
// write all the file information to a new txt file
|
||||
fileSystem.writeFileSync(path.join(fileInfo, `${fileName}.txt`), `${dateFormat},${userid},${username}`);
|
||||
};
|
||||
|
||||
// get file data
|
||||
docManager.prototype.getFileData = function (fileName, userAddress) {
|
||||
const history = path.join(this.historyPath(fileName, userAddress, true), fileName + ".txt"); // get the path to the file with file information
|
||||
if (!this.existsSync(history)) { // if such a file doesn't exist
|
||||
return ["2017-01-01", "uid-1", "John Smith"]; // return default information
|
||||
}
|
||||
DocManager.prototype.getFileData = function getFileData(fileName, userAddress) {
|
||||
// get the path to the file with file information
|
||||
const history = path.join(this.historyPath(fileName, userAddress, true), `${fileName}.txt`);
|
||||
if (!this.existsSync(history)) { // if such a file doesn't exist
|
||||
return ['2017-01-01', 'uid-1', 'John Smith']; // return default information
|
||||
}
|
||||
|
||||
return ((fileSystem.readFileSync(history)).toString()).split(",");
|
||||
return ((fileSystem.readFileSync(history)).toString())
|
||||
.split(',');
|
||||
};
|
||||
|
||||
// get server url
|
||||
docManager.prototype.getServerUrl = function (forDocumentServer) {
|
||||
return (forDocumentServer && !!configServer.get("exampleUrl")) ? configServer.get("exampleUrl") : this.getServerPath();
|
||||
DocManager.prototype.getServerUrl = function getServerUrl(forDocumentServer) {
|
||||
return (forDocumentServer && !!configServer.get('exampleUrl'))
|
||||
? configServer.get('exampleUrl') : this.getServerPath();
|
||||
};
|
||||
|
||||
// get server address from the request
|
||||
docManager.prototype.getServerPath = function () {
|
||||
return this.getServerHost() + (this.req.headers["x-forwarded-path"] || this.req.baseUrl);
|
||||
DocManager.prototype.getServerPath = function getServerPath() {
|
||||
return this.getServerHost() + (this.req.headers['x-forwarded-path'] || this.req.baseUrl);
|
||||
};
|
||||
|
||||
// get host address from the request
|
||||
docManager.prototype.getServerHost = function () {
|
||||
return this.getProtocol() + "://" + (this.req.headers["x-forwarded-host"] || this.req.headers["host"]);
|
||||
DocManager.prototype.getServerHost = function getServerHost() {
|
||||
return `${this.getProtocol()}://${this.req.headers['x-forwarded-host'] || this.req.headers.host}`
|
||||
+ `${this.req.headers['x-forwarded-prefix'] || ''}`;
|
||||
};
|
||||
|
||||
// get protocol from the request
|
||||
docManager.prototype.getProtocol = function () {
|
||||
return this.req.headers["x-forwarded-proto"] || this.req.protocol;
|
||||
DocManager.prototype.getProtocol = function getProtocol() {
|
||||
return this.req.headers['x-forwarded-proto'] || this.req.protocol;
|
||||
};
|
||||
|
||||
// get callback url
|
||||
docManager.prototype.getCallback = function (fileName) {
|
||||
const server = this.getServerUrl(true);
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress); // get callback handler
|
||||
DocManager.prototype.getCallback = function getCallback(fileName) {
|
||||
const server = this.getServerUrl(true);
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
// get callback handler
|
||||
const handler = `/track?filename=${encodeURIComponent(fileName)}&useraddress=${encodeURIComponent(hostAddress)}`;
|
||||
|
||||
return server + handler;
|
||||
return server + handler;
|
||||
};
|
||||
|
||||
// get url to the created file
|
||||
docManager.prototype.getCreateUrl = function (docType, userid, type, lang) {
|
||||
const server = this.getServerUrl();
|
||||
var ext = this.getInternalExtension(docType).replace(".", "");
|
||||
const handler = "/editor?fileExt=" + ext + "&userid=" + userid + "&type=" + type + "&lang=" + lang;
|
||||
DocManager.prototype.getCreateUrl = function getCreateUrl(docType, userid, type, lang) {
|
||||
const server = this.getServerUrl();
|
||||
const ext = this.getInternalExtension(docType).replace('.', '');
|
||||
const handler = `/editor?fileExt=${ext}&userid=${userid}&type=${type}&lang=${lang}`;
|
||||
|
||||
return server + handler;
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
docManager.prototype.getDownloadUrl = function (fileName, forDocumentServer) {
|
||||
const server = this.getServerUrl(forDocumentServer);
|
||||
var handler = "/download?fileName=" + encodeURIComponent(fileName);
|
||||
if (forDocumentServer) {
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
handler += "&useraddress=" + encodeURIComponent(hostAddress);
|
||||
}
|
||||
|
||||
return server + handler;
|
||||
return server + handler;
|
||||
};
|
||||
|
||||
docManager.prototype.storageRootPath = function (userAddress) {
|
||||
return path.join(storageConfigFolder, this.curUserHostAddress(userAddress)); // get the path to the directory for the host address
|
||||
}
|
||||
// get url to download a file
|
||||
DocManager.prototype.getDownloadUrl = function getDownloadUrl(fileName, forDocumentServer) {
|
||||
const server = this.getServerUrl(forDocumentServer);
|
||||
let handler = `/download?fileName=${encodeURIComponent(fileName)}`;
|
||||
if (forDocumentServer) {
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
handler += `&useraddress=${encodeURIComponent(hostAddress)}`;
|
||||
}
|
||||
|
||||
return server + handler;
|
||||
};
|
||||
|
||||
DocManager.prototype.storageRootPath = function storageRootPath(userAddress) {
|
||||
// get the path to the directory for the host address
|
||||
return path.join(storageConfigFolder, this.curUserHostAddress(userAddress));
|
||||
};
|
||||
|
||||
// get the storage path of the given file
|
||||
docManager.prototype.storagePath = function (fileName, userAddress) {
|
||||
fileName = fileUtility.getFileName(fileName); // get the file name with extension
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
this.createDirectory(directory); // create a new directory if it doesn't exist
|
||||
return path.join(directory, fileName); // put the given file to this directory
|
||||
DocManager.prototype.storagePath = function storagePath(fileName, userAddress) {
|
||||
const fileNameExt = fileUtility.getFileName(fileName); // get the file name with extension
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
this.createDirectory(directory); // create a new directory if it doesn't exist
|
||||
return path.join(directory, fileNameExt); // put the given file to this directory
|
||||
};
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
docManager.prototype.forcesavePath = function (fileName, userAddress, create) {
|
||||
let directory = this.storageRootPath(userAddress);
|
||||
if (!this.existsSync(directory)) { // the directory with host address doesn't exist
|
||||
return "";
|
||||
}
|
||||
directory = path.join(directory, fileName + "-history"); // get the path to the history of the given file
|
||||
if (!create && !this.existsSync(directory)) { // the history directory doesn't exist and we are not supposed to create it
|
||||
return "";
|
||||
}
|
||||
this.createDirectory(directory); // create history directory if it doesn't exist
|
||||
directory = path.join(directory, fileName); // and get the path to the given file
|
||||
if (!create && !this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
return directory;
|
||||
DocManager.prototype.forcesavePath = function forcesavePath(fileName, userAddress, create) {
|
||||
let directory = this.storageRootPath(userAddress);
|
||||
if (!this.existsSync(directory)) { // the directory with host address doesn't exist
|
||||
return '';
|
||||
}
|
||||
directory = path.join(directory, `${fileName}-history`); // get the path to the history of the given file
|
||||
// the history directory doesn't exist and we are not supposed to create it
|
||||
if (!create && !this.existsSync(directory)) {
|
||||
return '';
|
||||
}
|
||||
this.createDirectory(directory); // create history directory if it doesn't exist
|
||||
directory = path.join(directory, fileName); // and get the path to the given file
|
||||
if (!create && !this.existsSync(directory)) {
|
||||
return '';
|
||||
}
|
||||
return directory;
|
||||
};
|
||||
|
||||
// create the path to the file history
|
||||
docManager.prototype.historyPath = function (fileName, userAddress, create) {
|
||||
let directory = this.storageRootPath(userAddress);
|
||||
if (!this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
directory = path.join(directory, fileName + "-history");
|
||||
if (!create && !this.existsSync(path.join(directory, "1"))) {
|
||||
return "";
|
||||
}
|
||||
return directory;
|
||||
DocManager.prototype.historyPath = function historyPath(fileName, userAddress, create) {
|
||||
let directory = this.storageRootPath(userAddress);
|
||||
if (!this.existsSync(directory)) {
|
||||
return '';
|
||||
}
|
||||
directory = path.join(directory, `${fileName}-history`);
|
||||
if (!create && !this.existsSync(path.join(directory, '1'))) {
|
||||
return '';
|
||||
}
|
||||
return directory;
|
||||
};
|
||||
|
||||
// get the path to the specified file version
|
||||
docManager.prototype.versionPath = function (fileName, userAddress, version) {
|
||||
const historyPath = this.historyPath(fileName, userAddress, true); // get the path to the history of a given file or create it if it doesn't exist
|
||||
return path.join(historyPath, "" + version);
|
||||
DocManager.prototype.versionPath = function versionPath(fileName, userAddress, version) {
|
||||
// get the path to the history of a given file or create it if it doesn't exist
|
||||
const historyPath = this.historyPath(fileName, userAddress, true);
|
||||
return path.join(historyPath, `${version}`);
|
||||
};
|
||||
|
||||
// get the path to the previous file version
|
||||
docManager.prototype.prevFilePath = function (fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), "prev" + fileUtility.getFileExtension(fileName));
|
||||
DocManager.prototype.prevFilePath = function prevFilePath(fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), `prev${fileUtility.getFileExtension(fileName)}`);
|
||||
};
|
||||
|
||||
// get the path to the file with document versions differences
|
||||
docManager.prototype.diffPath = function (fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), "diff.zip");
|
||||
DocManager.prototype.diffPath = function diffPath(fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), 'diff.zip');
|
||||
};
|
||||
|
||||
// get the path to the file with document changes
|
||||
docManager.prototype.changesPath = function (fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), "changes.txt");
|
||||
DocManager.prototype.changesPath = function changesPath(fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), 'changes.txt');
|
||||
};
|
||||
|
||||
// get the path to the file with key value in it
|
||||
docManager.prototype.keyPath = function (fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), "key.txt");
|
||||
DocManager.prototype.keyPath = function keyPath(fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), 'key.txt');
|
||||
};
|
||||
|
||||
// get the path to the file with the user information
|
||||
docManager.prototype.changesUser = function (fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), "user.txt");
|
||||
DocManager.prototype.changesUser = function changesUser(fileName, userAddress, version) {
|
||||
return path.join(this.versionPath(fileName, userAddress, version), 'user.txt');
|
||||
};
|
||||
|
||||
// get all the stored files
|
||||
docManager.prototype.getStoredFiles = function () {
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
this.createDirectory(directory);
|
||||
const result = [];
|
||||
const storedFiles = fileSystem.readdirSync(directory); // read the user host directory contents
|
||||
for (let i = 0; i < storedFiles.length; i++) { // run through all the elements from the folder
|
||||
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i])); // save element parameters
|
||||
DocManager.prototype.getStoredFiles = function getStoredFiles() {
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
this.createDirectory(directory);
|
||||
const result = [];
|
||||
const storedFiles = fileSystem.readdirSync(directory); // read the user host directory contents
|
||||
for (let i = 0; i < storedFiles.length; i++) { // run through all the elements from the folder
|
||||
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i])); // save element parameters
|
||||
|
||||
if (!stats.isDirectory()) { // if the element isn't a directory
|
||||
let historyPath = this.historyPath(storedFiles[i], userAddress); // get the path to the file history
|
||||
let version = 0;
|
||||
if (historyPath != "") { // if the history path exists
|
||||
version = this.countVersion(historyPath); // get the last file version
|
||||
}
|
||||
if (!stats.isDirectory()) { // if the element isn't a directory
|
||||
const historyPath = this.historyPath(storedFiles[i], userAddress); // get the path to the file history
|
||||
let version = 0;
|
||||
if (historyPath !== '') { // if the history path exists
|
||||
version = this.countVersion(historyPath); // get the last file version
|
||||
}
|
||||
|
||||
const time = stats.mtime.getTime(); // get the time of element modification
|
||||
const item = { // create an object with element data
|
||||
time: time,
|
||||
name: storedFiles[i],
|
||||
documentType: fileUtility.getFileType(storedFiles[i]),
|
||||
canEdit: configServer.get("editedDocs").indexOf(fileUtility.getFileExtension(storedFiles[i])) != -1,
|
||||
version: version+1
|
||||
};
|
||||
const time = stats.mtime.getTime(); // get the time of element modification
|
||||
const item = { // create an object with element data
|
||||
time,
|
||||
name: storedFiles[i],
|
||||
documentType: fileUtility.getFileType(storedFiles[i]),
|
||||
canEdit: fileUtility.getEditExtensions().indexOf(fileUtility.getFileExtension(storedFiles[i], true)) !== -1,
|
||||
version: version + 1,
|
||||
};
|
||||
|
||||
if (!result.length) { // if the result array is empty
|
||||
result.push(item); // push the item object to it
|
||||
} else {
|
||||
let j = 0;
|
||||
for (; j < result.length; j++) {
|
||||
if (time > result[j].time) { // otherwise, run through all the objects from the result array
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.splice(j, 0, item); // and add new object in ascending order of time
|
||||
}
|
||||
if (!result.length) { // if the result array is empty
|
||||
result.push(item); // push the item object to it
|
||||
} else {
|
||||
let j = 0;
|
||||
for (; j < result.length; j++) {
|
||||
if (time > result[j].time) { // otherwise, run through all the objects from the result array
|
||||
break;
|
||||
}
|
||||
}
|
||||
result.splice(j, 0, item); // and add new object in ascending order of time
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// get current user host address
|
||||
docManager.prototype.curUserHostAddress = function (userAddress) {
|
||||
if (!userAddress) // if user address isn't passed to the function
|
||||
userAddress = this.req.headers["x-forwarded-for"] || this.req.connection.remoteAddress; // take it from the header or use the remote address
|
||||
DocManager.prototype.curUserHostAddress = function curUserHostAddress(userAddress) {
|
||||
let address = userAddress;
|
||||
if (!address) { // if user address isn't passed to the function
|
||||
// take it from the header or use the remote address
|
||||
address = this.req.headers['x-forwarded-for'] || this.req.connection.remoteAddress;
|
||||
}
|
||||
|
||||
return userAddress.replace(new RegExp("[^0-9a-zA-Z.=]", "g"), "_");
|
||||
return address.replace(/[^0-9a-zA-Z.=]/g, '_');
|
||||
};
|
||||
|
||||
// copy file
|
||||
docManager.prototype.copyFile = function (exist, target) {
|
||||
fileSystem.writeFileSync(target, fileSystem.readFileSync(exist));
|
||||
DocManager.prototype.copyFile = function copyFile(exist, target) {
|
||||
fileSystem.writeFileSync(target, fileSystem.readFileSync(exist));
|
||||
};
|
||||
|
||||
// get an internal extension
|
||||
docManager.prototype.getInternalExtension = function (fileType) {
|
||||
if (fileType == fileUtility.fileType.word) // .docx for word type
|
||||
return ".docx";
|
||||
DocManager.prototype.getInternalExtension = function getInternalExtension(fileType) {
|
||||
if (fileType === fileUtility.fileType.word) { // .docx for word type
|
||||
return '.docx';
|
||||
}
|
||||
|
||||
if (fileType == fileUtility.fileType.cell) // .xlsx for cell type
|
||||
return ".xlsx";
|
||||
if (fileType === fileUtility.fileType.cell) { // .xlsx for cell type
|
||||
return '.xlsx';
|
||||
}
|
||||
|
||||
if (fileType == fileUtility.fileType.slide) // .pptx for slide type
|
||||
return ".pptx";
|
||||
if (fileType === fileUtility.fileType.slide) { // .pptx for slide type
|
||||
return '.pptx';
|
||||
}
|
||||
|
||||
return ".docx"; // the default value is .docx
|
||||
return '.docx'; // the default value is .docx
|
||||
};
|
||||
|
||||
// get the template image url
|
||||
docManager.prototype.getTemplateImageUrl = function (fileType) {
|
||||
let path = this.getServerUrl(true);
|
||||
if (fileType == fileUtility.fileType.word) // for word type
|
||||
return path + "/images/file_docx.svg";
|
||||
DocManager.prototype.getTemplateImageUrl = function getTemplateImageUrl(fileType) {
|
||||
const serverUrl = this.getServerUrl(true);
|
||||
if (fileType === fileUtility.fileType.word) { // for word type
|
||||
return `${serverUrl}/images/file_docx.svg`;
|
||||
}
|
||||
|
||||
if (fileType == fileUtility.fileType.cell) // for cell type
|
||||
return path + "/images/file_xlsx.svg";
|
||||
if (fileType === fileUtility.fileType.cell) { // for cell type
|
||||
return `${path}/images/file_xlsx.svg`;
|
||||
}
|
||||
|
||||
if (fileType == fileUtility.fileType.slide) // for slide type
|
||||
return path + "/images/file_pptx.svg";
|
||||
if (fileType === fileUtility.fileType.slide) { // for slide type
|
||||
return `${path}/images/file_pptx.svg`;
|
||||
}
|
||||
|
||||
return path + "/images/file_docx.svg"; // the default value
|
||||
}
|
||||
return `${path}/images/file_docx.svg`; // the default value
|
||||
};
|
||||
|
||||
// get document key
|
||||
docManager.prototype.getKey = function (fileName, userAddress) {
|
||||
userAddress = userAddress || this.curUserHostAddress();
|
||||
let key = userAddress + fileName; // get document key by adding local file url to the current user host address
|
||||
DocManager.prototype.getKey = function getKey(fileName, userAddress) {
|
||||
const address = userAddress || this.curUserHostAddress();
|
||||
let key = address + fileName; // get document key by adding local file url to the current user host address
|
||||
|
||||
let historyPath = this.historyPath(fileName, userAddress); // get the path to the file history
|
||||
if (historyPath != ""){ // if the path to the file history exists
|
||||
key += this.countVersion(historyPath); // add file version number to the document key
|
||||
}
|
||||
const historyPath = this.historyPath(fileName, address); // get the path to the file history
|
||||
if (historyPath !== '') { // if the path to the file history exists
|
||||
key += this.countVersion(historyPath); // add file version number to the document key
|
||||
}
|
||||
|
||||
let storagePath = this.storagePath(fileName, userAddress); // get the storage path to the given file
|
||||
const stat = fileSystem.statSync(storagePath); // get file information
|
||||
key += stat.mtime.getTime(); // and add creation time to the document key
|
||||
const storagePath = this.storagePath(fileName, address); // get the storage path to the given file
|
||||
const stat = fileSystem.statSync(storagePath); // get file information
|
||||
key += stat.mtime.getTime(); // and add creation time to the document key
|
||||
|
||||
return documentService.generateRevisionId(key); // generate the document key value
|
||||
return documentService.generateRevisionId(key); // generate the document key value
|
||||
};
|
||||
|
||||
// get current date
|
||||
docManager.prototype.getDate = function (date) {
|
||||
const minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
|
||||
return date.getMonth() + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + minutes;
|
||||
DocManager.prototype.getDate = function getDate(date) {
|
||||
const minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
|
||||
return `${date.getMonth()}/${date.getDate()}/${date.getFullYear()} ${date.getHours()}:${minutes}`;
|
||||
};
|
||||
|
||||
// get changes made in the file
|
||||
docManager.prototype.getChanges = function (fileName) {
|
||||
if (this.existsSync(fileName)) { // if the directory with such a file exists
|
||||
return JSON.parse(fileSystem.readFileSync(fileName)); // read this file and parse it
|
||||
}
|
||||
return null;
|
||||
DocManager.prototype.getChanges = function getChanges(fileName) {
|
||||
if (this.existsSync(fileName)) { // if the directory with such a file exists
|
||||
return JSON.parse(fileSystem.readFileSync(fileName)); // read this file and parse it
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// get the last file version
|
||||
docManager.prototype.countVersion = function(directory) {
|
||||
let i = 0;
|
||||
while (this.existsSync(path.join(directory, '' + (i + 1)))) { // run through all the file versions
|
||||
i++; // and count them
|
||||
}
|
||||
return i;
|
||||
DocManager.prototype.countVersion = function countVersion(directory) {
|
||||
let i = 0;
|
||||
while (this.existsSync(path.join(directory, `${i + 1}`))) { // run through all the file versions
|
||||
i += 1; // and count them
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
// get file history information
|
||||
docManager.prototype.getHistory = function (fileName, content, keyVersion, version) {
|
||||
let oldVersion = false;
|
||||
let contentJson = null;
|
||||
if (content) { // if content is defined
|
||||
if (content.changes && content.changes.length) { // and there are some modifications in the content
|
||||
contentJson = content.changes[0]; // write these modifications to the json content
|
||||
} else if (content.length){
|
||||
contentJson = content[0]; // otherwise, write original content to the json content
|
||||
oldVersion = true; // and note that this is an old version
|
||||
} else {
|
||||
content = false;
|
||||
}
|
||||
DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = null) {
|
||||
const userAddress = userAddr || this.curUserHostAddress();
|
||||
const historyPath = this.historyPath(fileName, userAddress);
|
||||
const key = this.getKey(fileName);
|
||||
const directUrl = this.getDownloadUrl(fileName);
|
||||
const fileExt = fileUtility.getFileExtension(fileName);
|
||||
const url = this.getDownloadUrl(fileName, true);
|
||||
const history = [];
|
||||
const historyData = [];
|
||||
let countVersion = 1;
|
||||
let changes = null;
|
||||
let keyVersion = key;
|
||||
|
||||
if (historyPath !== '') {
|
||||
countVersion = this.countVersion(historyPath) + 1; // get the number of file versions
|
||||
for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions
|
||||
if (i < countVersion) {
|
||||
const keyPath = this.keyPath(fileName, userAddress, i);
|
||||
if (!fileSystem.existsSync(keyPath)) continue;
|
||||
keyVersion = `${fileSystem.readFileSync(keyPath)}`;
|
||||
} else {
|
||||
keyVersion = key;
|
||||
}
|
||||
// write all the file history information
|
||||
history.push(this.getHistory(fileName, changes, keyVersion, i));
|
||||
|
||||
const userUrl = i === countVersion ? directUrl : (`${this.getServerUrl(false)}/history?fileName=`
|
||||
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`);
|
||||
const historyD = {
|
||||
fileType: fileExt.slice(1),
|
||||
version: i,
|
||||
key: keyVersion,
|
||||
url: i === countVersion ? url : (`${this.getServerUrl(true)}/history?fileName=`
|
||||
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
|
||||
directUrl: !userDirectUrl ? null : userUrl,
|
||||
};
|
||||
|
||||
// check if the path to the file with document versions differences exists
|
||||
if (i > 1 && this.existsSync(this.diffPath(fileName, userAddress, i - 1))) {
|
||||
historyD.previous = { // write information about previous file version
|
||||
fileType: historyData[i - 2].fileType,
|
||||
key: historyData[i - 2].key,
|
||||
url: historyData[i - 2].url,
|
||||
directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl,
|
||||
};
|
||||
const changesUrl = `${this.getServerUrl(true)}/history?fileName=`
|
||||
+ `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`;
|
||||
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
|
||||
}
|
||||
|
||||
historyData.push(historyD);
|
||||
|
||||
if (i < countVersion) {
|
||||
// get the path to the file with document changes
|
||||
const changesFile = this.changesPath(fileName, userAddress, i);
|
||||
changes = this.getChanges(changesFile); // get changes made in the file
|
||||
}
|
||||
}
|
||||
} else { // if history path is empty
|
||||
// write the history information about the last file version
|
||||
history.push(this.getHistory(fileName, changes, keyVersion, countVersion));
|
||||
historyData.push({
|
||||
fileType: fileExt.slice(1),
|
||||
version: countVersion,
|
||||
key,
|
||||
url,
|
||||
directUrl: !userDirectUrl ? null : directUrl,
|
||||
});
|
||||
}
|
||||
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const username = content ? (oldVersion ? contentJson.username : contentJson.user.name) : (this.getFileData(fileName, userAddress))[2];
|
||||
const userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (this.getFileData(fileName, userAddress))[1];
|
||||
const created = content ? (oldVersion ? contentJson.date : contentJson.created) : (this.getFileData(fileName, userAddress))[0];
|
||||
const res = (content && !oldVersion) ? content : {changes: content};
|
||||
res.key = keyVersion; // write the information about the user, creation time, key and version to the result object
|
||||
res.version = version;
|
||||
res.created = created;
|
||||
res.user = {
|
||||
id: userid,
|
||||
name: username != "null" ? username : null
|
||||
};
|
||||
return { history, historyData, countVersion };
|
||||
};
|
||||
// get file history information
|
||||
DocManager.prototype.getHistory = function getHistory(fileName, content, keyVersion, version) {
|
||||
let oldVersion = false;
|
||||
let contentJson = null;
|
||||
let fileContent = content;
|
||||
let userNameFromJson = null;
|
||||
let userIdFromJson = null;
|
||||
let createdFromJson = null;
|
||||
if (fileContent) { // if content is defined
|
||||
if (fileContent.changes && fileContent.changes.length) { // and there are some modifications in the content
|
||||
[contentJson] = fileContent.changes; // write these modifications to the json content
|
||||
} else if (fileContent.length) {
|
||||
[contentJson] = fileContent; // otherwise, write original content to the json content
|
||||
oldVersion = true; // and note that this is an old version
|
||||
} else {
|
||||
fileContent = false;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
const userAddress = this.curUserHostAddress();
|
||||
|
||||
if (content && contentJson) {
|
||||
userNameFromJson = oldVersion ? contentJson.username : contentJson.user.name;
|
||||
userIdFromJson = oldVersion ? contentJson.userid : contentJson.user.userid;
|
||||
createdFromJson = oldVersion ? contentJson.date : contentJson.created;
|
||||
}
|
||||
|
||||
const username = userNameFromJson || (this.getFileData(fileName, userAddress))[2];
|
||||
const userid = userIdFromJson || (this.getFileData(fileName, userAddress))[1];
|
||||
const created = createdFromJson || (this.getFileData(fileName, userAddress))[0];
|
||||
const res = (fileContent && !oldVersion) ? fileContent : { changes: fileContent };
|
||||
res.key = keyVersion; // write the information about the user, creation time, key and version to the result object
|
||||
res.version = version;
|
||||
res.created = created;
|
||||
res.user = {
|
||||
id: userid,
|
||||
name: username !== 'null' ? username : null,
|
||||
};
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
// clean folder
|
||||
docManager.prototype.cleanFolderRecursive = function (folder, me) {
|
||||
if (fileSystem.existsSync(folder)) { // if the given folder exists
|
||||
const files = fileSystem.readdirSync(folder);
|
||||
files.forEach((file) => { // for each file from the folder
|
||||
const curPath = path.join(folder, file); // get its current path
|
||||
if (fileSystem.lstatSync(curPath).isDirectory()) {
|
||||
this.cleanFolderRecursive(curPath, true); // for each folder included in this one repeat the same procedure
|
||||
} else {
|
||||
fileSystem.unlinkSync(curPath); // remove the file
|
||||
}
|
||||
});
|
||||
if (me) {
|
||||
fileSystem.rmdirSync(folder);
|
||||
}
|
||||
DocManager.prototype.cleanFolderRecursive = function cleanFolderRecursive(folder, me) {
|
||||
if (fileSystem.existsSync(folder)) { // if the given folder exists
|
||||
const files = fileSystem.readdirSync(folder);
|
||||
files.forEach((file) => { // for each file from the folder
|
||||
const curPath = path.join(folder, file); // get its current path
|
||||
if (fileSystem.lstatSync(curPath).isDirectory()) {
|
||||
this.cleanFolderRecursive(curPath, true); // for each folder included in this one repeat the same procedure
|
||||
} else {
|
||||
fileSystem.unlinkSync(curPath); // remove the file
|
||||
}
|
||||
});
|
||||
if (me) {
|
||||
fileSystem.rmdirSync(folder);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// get files information
|
||||
docManager.prototype.getFilesInfo = function (fileId) {
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
const filesInDirectory = this.getStoredFiles(); // get all the stored files from the folder
|
||||
let responseArray = [];
|
||||
let responseObject;
|
||||
for (let currentFile = 0; currentFile < filesInDirectory.length; currentFile++) { // run through all the files from the directory
|
||||
const file = filesInDirectory[currentFile];
|
||||
const stats = fileSystem.lstatSync(path.join(directory, file.name)); // get file information
|
||||
const fileObject = { // write file parameters to the file object
|
||||
version: file.version,
|
||||
id: this.getKey(file.name),
|
||||
contentLength: `${(stats.size/1024).toFixed(2)} KB`,
|
||||
pureContentLength: stats.size,
|
||||
title: file.name,
|
||||
updated: stats.mtime
|
||||
};
|
||||
if (fileId !== undefined) { // if file id is defined
|
||||
if (this.getKey(file.name) == fileId) { // and it is equal to the document key value
|
||||
responseObject = fileObject; // response object will be equal to the file object
|
||||
break;
|
||||
}
|
||||
}
|
||||
else responseArray.push(fileObject); // otherwise, push file object to the response array
|
||||
DocManager.prototype.getFilesInfo = function getFilesInfo(fileId) {
|
||||
const userAddress = this.curUserHostAddress();
|
||||
const directory = this.storageRootPath(userAddress);
|
||||
const filesInDirectory = this.getStoredFiles(); // get all the stored files from the folder
|
||||
const responseArray = [];
|
||||
let responseObject;
|
||||
// run through all the files from the directory
|
||||
for (let currentFile = 0; currentFile < filesInDirectory.length; currentFile++) {
|
||||
const file = filesInDirectory[currentFile];
|
||||
const stats = fileSystem.lstatSync(path.join(directory, file.name)); // get file information
|
||||
const fileObject = { // write file parameters to the file object
|
||||
version: file.version,
|
||||
id: this.getKey(file.name),
|
||||
contentLength: `${(stats.size / 1024).toFixed(2)} KB`,
|
||||
pureContentLength: stats.size,
|
||||
title: file.name,
|
||||
updated: stats.mtime,
|
||||
};
|
||||
if (fileId !== undefined) {
|
||||
if (responseObject !== undefined) return responseObject;
|
||||
else return "File not found";
|
||||
}
|
||||
else return responseArray;
|
||||
if (fileId !== undefined) { // if file id is defined
|
||||
if (this.getKey(file.name) === fileId) { // and it is equal to the document key value
|
||||
responseObject = fileObject; // response object will be equal to the file object
|
||||
break;
|
||||
}
|
||||
} else responseArray.push(fileObject); // otherwise, push file object to the response array
|
||||
}
|
||||
if (fileId !== undefined) {
|
||||
if (responseObject !== undefined) return responseObject;
|
||||
return 'File not found';
|
||||
} return responseArray;
|
||||
};
|
||||
|
||||
docManager.prototype.getInstanceId = function () {
|
||||
return this.getServerUrl();
|
||||
DocManager.prototype.getInstanceId = function getInstanceId() {
|
||||
return this.getServerUrl();
|
||||
};
|
||||
|
||||
// save all the functions to the docManager module to export it later in other files
|
||||
module.exports = docManager;
|
||||
// save all the functions to the DocManager module to export it later in other files
|
||||
module.exports = DocManager;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
@ -17,229 +17,261 @@
|
||||
*/
|
||||
|
||||
// get all the necessary values and modules
|
||||
var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
var jwt = require("jsonwebtoken");
|
||||
var fileUtility = require("./fileUtility");
|
||||
var guidManager = require("./guidManager");
|
||||
var configServer = require('config').get('server');
|
||||
var siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
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');
|
||||
const urlModule = require('url');
|
||||
const urllib = require('urllib');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const configServer = require('config').get('server');
|
||||
const fileUtility = require('./fileUtility');
|
||||
const guidManager = require('./guidManager');
|
||||
|
||||
var documentService = {};
|
||||
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
const cfgSignatureEnable = configServer.get('token.enable');
|
||||
const cfgSignatureUseForRequest = configServer.get('token.useforrequest');
|
||||
const cfgSignatureAuthorizationHeader = configServer.get('token.authorizationHeader');
|
||||
const cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizationHeaderPrefix');
|
||||
const cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
|
||||
const cfgSignatureSecret = configServer.get('token.secret');
|
||||
const cfgSignatureSecretAlgorithmRequest = configServer.get('token.algorithmRequest');
|
||||
|
||||
const documentService = {};
|
||||
|
||||
documentService.userIp = null;
|
||||
|
||||
// get the url of the converted file (synchronous)
|
||||
documentService.getConvertedUriSync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
|
||||
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, function (err, data) {
|
||||
callback(err, data);
|
||||
});
|
||||
documentService.getConvertedUriSync = function getConvertedUriSync(
|
||||
documentUri,
|
||||
fromExtension,
|
||||
toExtension,
|
||||
documentRevisionId,
|
||||
callback,
|
||||
) {
|
||||
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, (err, data) => {
|
||||
callback(err, data);
|
||||
});
|
||||
};
|
||||
|
||||
// get the url of the converted file
|
||||
documentService.getConvertedUri = function (documentUri, fromExtension, toExtension, documentRevisionId, async, callback, filePass = null, lang = null) {
|
||||
fromExtension = fromExtension || fileUtility.getFileExtension(documentUri); // get the current document extension
|
||||
documentService.getConvertedUri = function getConvertedUri(
|
||||
documentUri,
|
||||
fromExtension,
|
||||
toExtension,
|
||||
documentRevisionId,
|
||||
async,
|
||||
callback,
|
||||
filePass = null,
|
||||
lang = null,
|
||||
) {
|
||||
const fromExt = fromExtension || fileUtility.getFileExtension(documentUri); // get the current document extension
|
||||
|
||||
var title = fileUtility.getFileName(documentUri) || guidManager.newGuid(); // get the current document name or uuid
|
||||
const title = fileUtility.getFileName(documentUri) || guidManager.newGuid(); // get the current document name or uuid
|
||||
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri); // generate the document key value
|
||||
// generate the document key value
|
||||
const revisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
|
||||
|
||||
var params = { // write all the conversion parameters to the params dictionary
|
||||
async: async,
|
||||
url: documentUri,
|
||||
outputtype: toExtension.replace(".", ""),
|
||||
filetype: fromExtension.replace(".", ""),
|
||||
title: title,
|
||||
key: documentRevisionId,
|
||||
password: filePass,
|
||||
region: lang,
|
||||
};
|
||||
const params = { // write all the conversion parameters to the params dictionary
|
||||
async,
|
||||
url: documentUri,
|
||||
outputtype: toExtension.replace('.', ''),
|
||||
filetype: fromExt.replace('.', ''),
|
||||
title,
|
||||
key: revisionId,
|
||||
password: filePass,
|
||||
region: lang,
|
||||
};
|
||||
|
||||
var uri = siteUrl + configServer.get('converterUrl'); // get the absolute converter url
|
||||
var headers = {
|
||||
'Content-Type': 'application/json',
|
||||
"Accept": "application/json"
|
||||
};
|
||||
const uri = siteUrl + configServer.get('converterUrl'); // get the absolute converter url
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) { // if the signature is enabled and it can be used for request
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params); // write signature authorization header
|
||||
params.token = documentService.getToken(params); // get token and save it to the parameters
|
||||
}
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) { // if the signature is enabled and it can be used for request
|
||||
// write signature authorization header
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
params.token = documentService.getToken(params); // get token and save it to the parameters
|
||||
}
|
||||
|
||||
//parse url to allow request by relative url after https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
|
||||
urllib.request(urlModule.parse(uri),
|
||||
{
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
data: params
|
||||
},
|
||||
callback);
|
||||
// parse url to allow request by relative url after
|
||||
// https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
|
||||
urllib.request(
|
||||
urlModule.parse(uri),
|
||||
{
|
||||
method: 'POST',
|
||||
headers,
|
||||
data: params,
|
||||
},
|
||||
callback,
|
||||
);
|
||||
};
|
||||
|
||||
// generate the document key value
|
||||
documentService.generateRevisionId = function (expectedKey) {
|
||||
let maxKeyLength = 128; // the max key length is 128
|
||||
if (expectedKey.length > maxKeyLength) { // if the expected key length is greater than the max key length
|
||||
expectedKey = expectedKey.hashCode().toString(); // the expected key is hashed and a fixed length value is stored in the string format
|
||||
}
|
||||
documentService.generateRevisionId = function generateRevisionId(expectedKey) {
|
||||
const maxKeyLength = 128; // the max key length is 128
|
||||
let expKey = expectedKey;
|
||||
if (expKey.length > maxKeyLength) { // if the expected key length is greater than the max key length
|
||||
// the expected key is hashed and a fixed length value is stored in the string format
|
||||
expKey = expKey.hashCode().toString();
|
||||
}
|
||||
|
||||
var key = expectedKey.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_");
|
||||
const key = expKey.replace(/[^0-9-.a-zA-Z_=]/g, '_');
|
||||
|
||||
return key.substring(0, Math.min(key.length, maxKeyLength)); // the resulting key is of the max key length or less
|
||||
return key.substring(0, Math.min(key.length, maxKeyLength)); // the resulting key is of the max key length or less
|
||||
};
|
||||
|
||||
// create an error message for the error code
|
||||
documentService.processConvertServiceResponceError = function (errorCode) {
|
||||
var errorMessage = "";
|
||||
var errorMessageTemplate = "Error occurred in the ConvertService: ";
|
||||
documentService.processConvertServiceResponceError = function processConvertServiceResponceError(errorCode) {
|
||||
let errorMessage = '';
|
||||
const errorMessageTemplate = 'Error occurred in the ConvertService: ';
|
||||
|
||||
// add the error message to the error message template depending on the error code
|
||||
switch (errorCode) {
|
||||
case -20:
|
||||
errorMessage = errorMessageTemplate + "Error encrypt signature";
|
||||
break;
|
||||
case -8:
|
||||
errorMessage = errorMessageTemplate + "Error document signature";
|
||||
break;
|
||||
case -7:
|
||||
errorMessage = errorMessageTemplate + "Error document request";
|
||||
break;
|
||||
case -6:
|
||||
errorMessage = errorMessageTemplate + "Error database";
|
||||
break;
|
||||
case -5:
|
||||
errorMessage = errorMessageTemplate + "Incorrect password";
|
||||
break;
|
||||
case -4:
|
||||
errorMessage = errorMessageTemplate + "Error download error";
|
||||
break;
|
||||
case -3:
|
||||
errorMessage = errorMessageTemplate + "Error convertation error";
|
||||
break;
|
||||
case -2:
|
||||
errorMessage = errorMessageTemplate + "Error convertation timeout";
|
||||
break;
|
||||
case -1:
|
||||
errorMessage = errorMessageTemplate + "Error convertation unknown";
|
||||
break;
|
||||
case 0: // if the error code is equal to 0, the error message is empty
|
||||
break;
|
||||
default:
|
||||
errorMessage = "ErrorCode = " + errorCode; // default value for the error message
|
||||
break;
|
||||
}
|
||||
// add the error message to the error message template depending on the error code
|
||||
switch (errorCode) {
|
||||
case -20:
|
||||
errorMessage = `${errorMessageTemplate}Error encrypt signature`;
|
||||
break;
|
||||
case -8:
|
||||
errorMessage = `${errorMessageTemplate}Error document signature`;
|
||||
break;
|
||||
case -7:
|
||||
errorMessage = `${errorMessageTemplate}Error document request`;
|
||||
break;
|
||||
case -6:
|
||||
errorMessage = `${errorMessageTemplate}Error database`;
|
||||
break;
|
||||
case -5:
|
||||
errorMessage = `${errorMessageTemplate}Incorrect password`;
|
||||
break;
|
||||
case -4:
|
||||
errorMessage = `${errorMessageTemplate}Error download error`;
|
||||
break;
|
||||
case -3:
|
||||
errorMessage = `${errorMessageTemplate}Error convertation error`;
|
||||
break;
|
||||
case -2:
|
||||
errorMessage = `${errorMessageTemplate}Error convertation timeout`;
|
||||
break;
|
||||
case -1:
|
||||
errorMessage = `${errorMessageTemplate}Error convertation unknown`;
|
||||
break;
|
||||
case 0: // if the error code is equal to 0, the error message is empty
|
||||
break;
|
||||
default:
|
||||
errorMessage = `ErrorCode = ${errorCode}`; // default value for the error message
|
||||
break;
|
||||
}
|
||||
|
||||
throw { message: errorMessage };
|
||||
throw new Error(errorMessage);
|
||||
};
|
||||
|
||||
// get the response url
|
||||
documentService.getResponseUri = function (json) {
|
||||
var fileResult = JSON.parse(json);
|
||||
documentService.getResponseUri = function getResponseUri(json) {
|
||||
const fileResult = JSON.parse(json);
|
||||
|
||||
if (fileResult.error) // if an error occurs
|
||||
documentService.processConvertServiceResponceError(parseInt(fileResult.error)); // get an error message
|
||||
if (fileResult.error) { // if an error occurs
|
||||
documentService.processConvertServiceResponceError(parseInt(fileResult.error, 10)); // get an error message
|
||||
}
|
||||
|
||||
var isEndConvert = fileResult.endConvert // check if the conversion is completed
|
||||
const isEndConvert = fileResult.endConvert; // check if the conversion is completed
|
||||
|
||||
var percent = parseInt(fileResult.percent); // get the conversion percentage
|
||||
var uri = null;
|
||||
var fileType = null;
|
||||
let percent = parseInt(fileResult.percent, 10); // get the conversion percentage
|
||||
let uri = null;
|
||||
let fileType = null;
|
||||
|
||||
if (isEndConvert) { // if the conversion is completed
|
||||
if (!fileResult.fileUrl) // and the file url doesn't exist
|
||||
throw { message: "FileUrl is null" }; // the file url is null
|
||||
|
||||
uri = fileResult.fileUrl; // otherwise, get the file url
|
||||
fileType = fileResult.fileType; // get the file type
|
||||
percent = 100;
|
||||
} else { // if the conversion isn't completed
|
||||
percent = percent >= 100 ? 99 : percent; // get the percentage value
|
||||
if (isEndConvert) { // if the conversion is completed
|
||||
if (!fileResult.fileUrl) { // and the file url doesn't exist
|
||||
throw new Error('FileUrl is null'); // the file url is null
|
||||
}
|
||||
|
||||
return {
|
||||
percent : percent,
|
||||
uri : uri,
|
||||
fileType : fileType
|
||||
};
|
||||
uri = fileResult.fileUrl; // otherwise, get the file url
|
||||
({ fileType } = fileResult); // get the file type
|
||||
percent = 100;
|
||||
} else { // if the conversion isn't completed
|
||||
percent = percent >= 100 ? 99 : percent; // get the percentage value
|
||||
}
|
||||
|
||||
return {
|
||||
percent,
|
||||
uri,
|
||||
fileType,
|
||||
};
|
||||
};
|
||||
|
||||
// create a command request
|
||||
documentService.commandRequest = function (method, documentRevisionId, meta = null, callback) {
|
||||
documentService.commandRequest = function commandRequest(method, documentRevisionId, callback, meta = null) {
|
||||
const revisionId = documentService.generateRevisionId(documentRevisionId); // generate the document key value
|
||||
const params = { // create a parameter object with command method and the document key value in it
|
||||
c: method,
|
||||
key: revisionId,
|
||||
};
|
||||
|
||||
documentRevisionId = documentService.generateRevisionId(documentRevisionId); // generate the document key value
|
||||
params = { // create a parameter object with command method and the document key value in it
|
||||
c: method,
|
||||
key: documentRevisionId
|
||||
};
|
||||
if (meta) {
|
||||
params.meta = meta;
|
||||
}
|
||||
|
||||
if (meta) {
|
||||
params.meta = meta;
|
||||
}
|
||||
const uri = siteUrl + configServer.get('commandUrl'); // get the absolute command url
|
||||
const headers = { // create a headers object
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
params.token = documentService.getToken(params);
|
||||
}
|
||||
|
||||
var uri = siteUrl + configServer.get('commandUrl'); // get the absolute command url
|
||||
var headers = { // create a headers object
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
|
||||
params.token = documentService.getToken(params);
|
||||
}
|
||||
|
||||
//parse url to allow request by relative url after https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
|
||||
urllib.request(urlModule.parse(uri),
|
||||
{
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
data: params
|
||||
},
|
||||
callback);
|
||||
// parse url to allow request by relative url after
|
||||
// https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
|
||||
urllib.request(
|
||||
urlModule.parse(uri),
|
||||
{
|
||||
method: 'POST',
|
||||
headers,
|
||||
data: params,
|
||||
},
|
||||
callback,
|
||||
);
|
||||
};
|
||||
|
||||
// check jwt token headers
|
||||
documentService.checkJwtHeader = function (req) {
|
||||
var decoded = null;
|
||||
var authorization = req.get(cfgSignatureAuthorizationHeader); // get signature authorization header from the request
|
||||
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) { // if authorization header exists and it starts with the authorization header prefix
|
||||
var token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length); // the resulting token starts after the authorization header prefix
|
||||
documentService.checkJwtHeader = function checkJwtHeader(req) {
|
||||
let decoded = null;
|
||||
const authorization = req.get(cfgSignatureAuthorizationHeader); // get signature authorization header from the request
|
||||
// if authorization header exists and it starts with the authorization header prefix
|
||||
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) {
|
||||
// the resulting token starts after the authorization header prefix
|
||||
const token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length);
|
||||
try {
|
||||
decoded = jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
|
||||
decoded = jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
|
||||
} catch (err) {
|
||||
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token) // print debug information to the console
|
||||
// print debug information to the console
|
||||
console.log(`checkJwtHeader error: name = ${err.name} message = ${err.message} token = ${token}`);
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
};
|
||||
|
||||
// get jwt token using url information
|
||||
documentService.fillJwtByUrl = function (uri, opt_dataObject) {
|
||||
var parseObject = urlModule.parse(uri, true); // get parse object from the url
|
||||
var payload = {query: parseObject.query, payload: opt_dataObject}; // create payload object
|
||||
documentService.fillJwtByUrl = function fillJwtByUrl(uri, optDataObject) {
|
||||
const parseObject = urlModule.parse(uri, true); // get parse object from the url
|
||||
const payload = { query: parseObject.query, payload: optDataObject }; // create payload object
|
||||
|
||||
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn};
|
||||
return jwt.sign(payload, cfgSignatureSecret, options); // sign token with given data using signature secret and options parameters
|
||||
}
|
||||
const options = { algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn };
|
||||
// sign token with given data using signature secret and options parameters
|
||||
return jwt.sign(payload, cfgSignatureSecret, options);
|
||||
};
|
||||
|
||||
// get token
|
||||
documentService.getToken = function (data) {
|
||||
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn};
|
||||
return jwt.sign(data, cfgSignatureSecret, options); // sign token with given data using signature secret and options parameters
|
||||
documentService.getToken = function getToken(data) {
|
||||
const options = { algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn };
|
||||
// sign token with given data using signature secret and options parameters
|
||||
return jwt.sign(data, cfgSignatureSecret, options);
|
||||
};
|
||||
|
||||
// read and verify token
|
||||
documentService.readToken = function (token) {
|
||||
try {
|
||||
return jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
|
||||
} catch (err) {
|
||||
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token)
|
||||
}
|
||||
return null;
|
||||
documentService.readToken = function readToken(token) {
|
||||
try {
|
||||
return jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
|
||||
} catch (err) {
|
||||
console.log(`checkJwtHeader error: name = ${err.name} message = ${err.message} token = ${token}`);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// save all the functions to the documentService module to export it later in other files
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
@ -16,79 +16,103 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var fileUtility = {};
|
||||
const supportedFormats = require('../public/assets/document-formats/onlyoffice-docs-formats.json'); // eslint-disable-line
|
||||
|
||||
const fileUtility = {};
|
||||
|
||||
// get file name from the given url
|
||||
fileUtility.getFileName = function (url, withoutExtension) {
|
||||
if (!url) return "";
|
||||
fileUtility.getFileName = function getFileName(url, withoutExtension) {
|
||||
if (!url) return '';
|
||||
|
||||
var parts = url.split("\\");
|
||||
parts = parts.pop();
|
||||
parts = parts.split("/");
|
||||
var fileName = parts.pop(); // get the file name from the last part of the url
|
||||
fileName = fileName.split("?")[0];
|
||||
let parts = url.split('\\');
|
||||
parts = parts.pop();
|
||||
parts = parts.split('/');
|
||||
let fileName = parts.pop(); // get the file name from the last part of the url
|
||||
[fileName] = fileName.split('?');
|
||||
|
||||
// get file name without extension
|
||||
if (withoutExtension) {
|
||||
return fileName.substring(0, fileName.lastIndexOf("."));
|
||||
}
|
||||
// get file name without extension
|
||||
if (withoutExtension) {
|
||||
return fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
return fileName;
|
||||
return fileName;
|
||||
};
|
||||
|
||||
// get file extension from the given url
|
||||
fileUtility.getFileExtension = function (url, withoutDot) {
|
||||
if (!url) return null;
|
||||
fileUtility.getFileExtension = function getFileExtension(url, withoutDot) {
|
||||
if (!url) return null;
|
||||
|
||||
var fileName = fileUtility.getFileName(url); // get file name from the given url
|
||||
const fileName = fileUtility.getFileName(url); // get file name from the given url
|
||||
|
||||
var parts = fileName.toLowerCase().split(".");
|
||||
const parts = fileName.toLowerCase().split('.');
|
||||
|
||||
return withoutDot ? parts.pop() : "." + parts.pop(); // get the extension from the file name with or without dot
|
||||
return withoutDot ? parts.pop() : `.${parts.pop()}`; // get the extension from the file name with or without dot
|
||||
};
|
||||
|
||||
// get file type from the given url
|
||||
fileUtility.getFileType = function (url) {
|
||||
var ext = fileUtility.getFileExtension(url); // get the file extension from the given url
|
||||
fileUtility.getFileType = function getFileType(url) {
|
||||
const ext = fileUtility.getFileExtension(url, true); // get the file extension from the given url
|
||||
|
||||
if (fileUtility.documentExts.indexOf(ext) != -1) return fileUtility.fileType.word; // word type for document extensions
|
||||
if (fileUtility.spreadsheetExts.indexOf(ext) != -1) return fileUtility.fileType.cell; // cell type for spreadsheet extensions
|
||||
if (fileUtility.presentationExts.indexOf(ext) != -1) return fileUtility.fileType.slide; // slide type for presentation extensions
|
||||
for (let i = 0; i < supportedFormats.length; i++) {
|
||||
if (supportedFormats[i].name === ext) return supportedFormats[i].type;
|
||||
}
|
||||
|
||||
return fileUtility.fileType.word; // the default file type is word
|
||||
}
|
||||
return fileUtility.fileType.word; // the default file type is word
|
||||
};
|
||||
|
||||
fileUtility.fileType = {
|
||||
word: "word",
|
||||
cell: "cell",
|
||||
slide: "slide"
|
||||
}
|
||||
word: 'word',
|
||||
cell: 'cell',
|
||||
slide: 'slide',
|
||||
};
|
||||
|
||||
// the document extension list
|
||||
fileUtility.documentExts = [".doc", ".docx", ".oform", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".xml", ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps"];
|
||||
fileUtility.getSuppotredExtensions = function getSuppotredExtensions() {
|
||||
return supportedFormats.reduce((extensions, format) => [...extensions, format.name], []);
|
||||
};
|
||||
|
||||
// the spreadsheet extension list
|
||||
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".xlsm", ".xlsb", ".xlt", ".xltx", ".xltm", ".ods", ".fods", ".ots", ".csv"];
|
||||
fileUtility.getViewExtensions = function getViewExtensions() {
|
||||
return supportedFormats.filter(
|
||||
(format) => format.actions.includes('view'),
|
||||
).reduce((extensions, format) => [...extensions, format.name], []);
|
||||
};
|
||||
|
||||
// the presentation extension list
|
||||
fileUtility.presentationExts = [".pps", ".ppsx", ".ppsm", ".ppt", ".pptx", ".pptm", ".pot", ".potx", ".potm", ".odp", ".fodp", ".otp"];
|
||||
fileUtility.getEditExtensions = function getEditExtensions() {
|
||||
return supportedFormats.filter(
|
||||
(format) => format.actions.includes('edit') || format.actions.includes('lossy-edit'),
|
||||
).reduce((extensions, format) => [...extensions, format.name], []);
|
||||
};
|
||||
|
||||
fileUtility.getFillExtensions = function getFillExtensions() {
|
||||
return supportedFormats.filter(
|
||||
(format) => format.actions.includes('fill'),
|
||||
).reduce((extensions, format) => [...extensions, format.name], []);
|
||||
};
|
||||
|
||||
fileUtility.getConvertExtensions = function getConvertExtensions() {
|
||||
return supportedFormats.filter(
|
||||
(format) => (format.type === 'word' && format.convert.includes('docx'))
|
||||
|| (format.type === 'cell' && format.convert.includes('xlsx'))
|
||||
|| (format.type === 'slide' && format.convert.includes('pptx')),
|
||||
).reduce((extensions, format) => [...extensions, format.name], []);
|
||||
};
|
||||
|
||||
// get url parameters
|
||||
function getUrlParams(url) {
|
||||
try {
|
||||
var query = url.split("?").pop(); // take all the parameters which are placed after ? sign in the file url
|
||||
var params = query.split("&"); // parameters are separated by & sign
|
||||
var map = {}; // write parameters and their values to the map dictionary
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var parts = param.split("=");
|
||||
map[parts[0]] = parts[1];
|
||||
}
|
||||
return map;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const getUrlParams = function getUrlParams(url) {
|
||||
try {
|
||||
const query = url.split('?').pop(); // take all the parameters which are placed after ? sign in the file url
|
||||
const params = query.split('&'); // parameters are separated by & sign
|
||||
const map = {}; // write parameters and their values to the map dictionary
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const parts = param.split('=');
|
||||
[, map[parts[0]]] = parts;
|
||||
}
|
||||
catch (ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// save all the functions to the fileUtility module to export it later in other files
|
||||
module.exports = fileUtility;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
@ -17,11 +17,12 @@
|
||||
*/
|
||||
|
||||
// generate 16 octet
|
||||
var s4 = function () {
|
||||
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
||||
const s4 = function s4() {
|
||||
return Math.trunc((1 + Math.random()) * 0x10000).toString(16)
|
||||
.substring(1);
|
||||
};
|
||||
|
||||
// create uuid v4
|
||||
exports.newGuid = function () {
|
||||
return (s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4());
|
||||
};
|
||||
exports.newGuid = function newGuid() {
|
||||
return (`${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`);
|
||||
};
|
||||
|
||||
@ -16,80 +16,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var descr_user_1 = [
|
||||
"File author by default",
|
||||
"Doesn’t belong to any group",
|
||||
"Can review all the changes",
|
||||
"Can perform all actions with comments",
|
||||
"The file favorite state is undefined",
|
||||
"Can create files from templates using data from the editor",
|
||||
"Can see the information about all users",
|
||||
//"Can submit forms"
|
||||
];
|
||||
|
||||
var descr_user_2 = [
|
||||
"Belongs to Group2",
|
||||
"Can review only his own changes or changes made by users with no group",
|
||||
"Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only",
|
||||
"This file is marked as favorite",
|
||||
"Can create new files from the editor",
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group",
|
||||
//"Can’t submit forms"
|
||||
];
|
||||
|
||||
var descr_user_3 = [
|
||||
"Belongs to Group3",
|
||||
"Can review changes made by Group2 users",
|
||||
"Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users",
|
||||
"This file isn’t marked as favorite",
|
||||
"Can’t copy data from the file to clipboard",
|
||||
"Can’t download the file",
|
||||
"Can’t print the file",
|
||||
"Can create new files from the editor",
|
||||
"Can see the information about Group2 users",
|
||||
//"Can’t submit forms"
|
||||
];
|
||||
|
||||
var descr_user_0 = [
|
||||
"The name is requested when the editor is opened",
|
||||
"Doesn’t belong to any group",
|
||||
"Can review all the changes",
|
||||
"Can perform all actions with comments",
|
||||
"The file favorite state is undefined",
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"Can't protect file",
|
||||
"View file without collaboration",
|
||||
//"Can’t submit forms"
|
||||
];
|
||||
|
||||
var users = [
|
||||
new User("uid-1", "John Smith", "smith@example.com",
|
||||
null, null, {}, null,
|
||||
null, [], descr_user_1, true),
|
||||
new User("uid-2", "Mark Pottato", "pottato@example.com",
|
||||
"group-2", ["group-2", ""], {
|
||||
view: "",
|
||||
edit: ["group-2", ""],
|
||||
remove: ["group-2"]
|
||||
}, ["group-2", ""],
|
||||
true, [], descr_user_2, false), // own and without group
|
||||
new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
|
||||
"group-3", ["group-2"], {
|
||||
view: ["group-3", "group-2"],
|
||||
edit: ["group-2"],
|
||||
remove: []
|
||||
}, ["group-2"],
|
||||
false, ["copy", "download", "print"], descr_user_3, false), // other group only
|
||||
new User("uid-0", null, null,
|
||||
null, null, {}, [],
|
||||
null, ["protect"], descr_user_0, false),
|
||||
];
|
||||
|
||||
function User(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates) {
|
||||
class User {
|
||||
constructor(
|
||||
id,
|
||||
name,
|
||||
email,
|
||||
group,
|
||||
reviewGroups,
|
||||
commentGroups,
|
||||
userInfoGroups,
|
||||
favorite,
|
||||
deniedPermissions,
|
||||
descriptions,
|
||||
templates,
|
||||
) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
@ -101,36 +41,117 @@ function User(id, name, email, group, reviewGroups, commentGroups, userInfoGroup
|
||||
this.deniedPermissions = deniedPermissions;
|
||||
this.descriptions = descriptions;
|
||||
this.templates = templates;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const descrUser1 = [
|
||||
'File author by default',
|
||||
'Doesn’t belong to any group',
|
||||
'Can review all the changes',
|
||||
'Can perform all actions with comments',
|
||||
'The file favorite state is undefined',
|
||||
'Can create files from templates using data from the editor',
|
||||
'Can see the information about all users',
|
||||
// "Can submit forms"
|
||||
];
|
||||
|
||||
const descrUser2 = [
|
||||
'Belongs to Group2',
|
||||
'Can review only his own changes or changes made by users with no group',
|
||||
'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only',
|
||||
'This file is marked as favorite',
|
||||
'Can create new files from the editor',
|
||||
'Can see the information about users from Group2 and users who don’t belong to any group',
|
||||
// "Can’t submit forms"
|
||||
];
|
||||
|
||||
const descrUser3 = [
|
||||
'Belongs to Group3',
|
||||
'Can review changes made by Group2 users',
|
||||
'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users',
|
||||
'This file isn’t marked as favorite',
|
||||
'Can’t copy data from the file to clipboard',
|
||||
'Can’t download the file',
|
||||
'Can’t print the file',
|
||||
'Can create new files from the editor',
|
||||
'Can see the information about Group2 users',
|
||||
// "Can’t submit forms"
|
||||
];
|
||||
|
||||
const descrUser0 = [
|
||||
'The name is requested when the editor is opened',
|
||||
'Doesn’t belong to any group',
|
||||
'Can review all the changes',
|
||||
'Can perform all actions with comments',
|
||||
'The file favorite state is undefined',
|
||||
'Can\'t mention others in comments',
|
||||
'Can\'t create new files from the editor',
|
||||
'Can’t see anyone’s information',
|
||||
'Can\'t rename files from the editor',
|
||||
'Can\'t view chat',
|
||||
'Can\'t protect file',
|
||||
'View file without collaboration',
|
||||
// "Can’t submit forms"
|
||||
];
|
||||
|
||||
const users = [
|
||||
new User('uid-1', 'John Smith', 'smith@example.com', null, null, {}, null, null, [], descrUser1, true),
|
||||
new User('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], {
|
||||
view: '',
|
||||
edit: ['group-2', ''],
|
||||
remove: ['group-2'],
|
||||
}, ['group-2', ''], true, [], descrUser2, false), // own and without group
|
||||
new User('uid-3', 'Hamish Mitchell', 'mitchell@example.com', 'group-3', ['group-2'], {
|
||||
view: ['group-3', 'group-2'],
|
||||
edit: ['group-2'],
|
||||
remove: [],
|
||||
}, ['group-2'], false, ['copy', 'download', 'print'], descrUser3, false), // other group only
|
||||
new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false),
|
||||
];
|
||||
|
||||
// get a list of all the users
|
||||
users.getAllUsers = function () {
|
||||
return users;
|
||||
users.getAllUsers = function getAllUsers() {
|
||||
return users;
|
||||
};
|
||||
|
||||
// get a user by id specified
|
||||
users.getUser = function (id) {
|
||||
var result = null;
|
||||
this.forEach(user => {
|
||||
if (user.id == id) {
|
||||
result = user;
|
||||
}
|
||||
});
|
||||
return result ? result : this[0];
|
||||
users.getUser = function getUser(id) {
|
||||
let result = null;
|
||||
this.forEach((user) => {
|
||||
if (user.id === id) {
|
||||
result = user;
|
||||
}
|
||||
});
|
||||
return result || this[0];
|
||||
};
|
||||
|
||||
// get a list of users with their name and email
|
||||
users.getUsersForMentions = function (id) {
|
||||
var result = [];
|
||||
this.forEach(user => {
|
||||
if (user.id != id && user.name != null && user.email != null) {
|
||||
result.push({
|
||||
email: user.email,
|
||||
name: user.name
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
// get a list of users with their name and email for mentions
|
||||
users.getUsersForMentions = function getUsersForMentions(id) {
|
||||
const result = [];
|
||||
this.forEach((user) => {
|
||||
if (user.id !== id && user.name && user.email) {
|
||||
result.push({
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// get a list of users with their name, id and email for protect
|
||||
users.getUsersForProtect = function getUsersForProtect(id) {
|
||||
const result = [];
|
||||
this.forEach((user) => {
|
||||
if (user.id !== id && user.name != null) {
|
||||
result.push({
|
||||
email: user.email,
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = users;
|
||||
|
||||
@ -16,14 +16,343 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const fileSystem = require('fs');
|
||||
const mime = require('mime');
|
||||
const path = require('path');
|
||||
const reqConsts = require('./request');
|
||||
const fileUtility = require("../fileUtility");
|
||||
const lockManager = require("./lockManager");
|
||||
const fileSystem = require("fs");
|
||||
const mime = require("mime");
|
||||
const path = require("path");
|
||||
const users = require("../users");
|
||||
const docManager = require("../docManager");
|
||||
const fileUtility = require('../fileUtility');
|
||||
const lockManager = require('./lockManager');
|
||||
const users = require('../users');
|
||||
const DocManager = require('../docManager');
|
||||
|
||||
// return lock mismatch
|
||||
const returnLockMismatch = function returnLockMismatch(res, lock, reason) {
|
||||
res.setHeader(reqConsts.requestHeaders.Lock, lock || ''); // set the X-WOPI-Lock header
|
||||
if (reason) { // if there is a reason for lock mismatch
|
||||
res.setHeader(reqConsts.requestHeaders.LockFailureReason, reason); // set it as the X-WOPI-LockFailureReason header
|
||||
}
|
||||
res.sendStatus(409); // conflict
|
||||
};
|
||||
|
||||
// lock file editing
|
||||
const lock = function lock(wopi, req, res, userHost) {
|
||||
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost); // get current user host address
|
||||
const filePath = req.DocManager.storagePath(wopi.id, userAddress); // get the storage path of the given file
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => lock
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else if (lockManager.getLock(filePath) === requestLock) {
|
||||
// lock matches current lock => extend duration
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// file locked by someone else => return lock mismatch
|
||||
const locked = lockManager.getLock(filePath);
|
||||
returnLockMismatch(res, lock, `File already locked by ${locked}`);
|
||||
}
|
||||
};
|
||||
|
||||
const saveFileFromBody = function saveFileFromBody(req, filename, userAddress, isNewVersion, callback) {
|
||||
if (req.body) {
|
||||
const storagePath = req.DocManager.storagePath(filename, userAddress);
|
||||
let historyPath = req.DocManager.historyPath(filename, userAddress); // get the path to the file history
|
||||
if (historyPath === '') { // if it is empty
|
||||
historyPath = req.DocManager.historyPath(filename, userAddress, true); // create it
|
||||
req.DocManager.createDirectory(historyPath); // and create a new directory for the history
|
||||
}
|
||||
|
||||
let version = 0;
|
||||
if (isNewVersion) {
|
||||
const countVersion = req.DocManager.countVersion(historyPath); // get the last file version
|
||||
version = countVersion + 1; // get a number of a new file version
|
||||
// get the path to the specified file version
|
||||
const versionPath = req.DocManager.versionPath(filename, userAddress, version);
|
||||
req.DocManager.createDirectory(versionPath); // and create a new directory for the specified version
|
||||
|
||||
// get the path to the previous file version
|
||||
const pathPrev = path.join(versionPath, `prev${fileUtility.getFileExtension(filename)}`);
|
||||
fileSystem.renameSync(storagePath, pathPrev); // synchronously rename the given file as the previous file version
|
||||
}
|
||||
|
||||
const filestream = fileSystem.createWriteStream(storagePath);
|
||||
req.pipe(filestream);
|
||||
req.on('end', () => {
|
||||
filestream.close();
|
||||
callback(null, version);
|
||||
});
|
||||
} else {
|
||||
callback('empty body');
|
||||
}
|
||||
};
|
||||
|
||||
// return name that wopi-client can use as the value of X-WOPI-RelativeTarget in a future PutRelativeFile operation
|
||||
const returnValidRelativeTarget = function returnValidRelativeTarget(res, filename) {
|
||||
res.setHeader(reqConsts.requestHeaders.ValidRelativeTarget, filename); // set the X-WOPI-ValidRelativeTarget header
|
||||
res.sendStatus(409); // file with that name already exists
|
||||
};
|
||||
|
||||
// retrieve a lock on a file
|
||||
const getLock = function getLock(wopi, req, res, userHost) {
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
// get the lock of the specified file and set it as the X-WOPI-Lock header
|
||||
res.setHeader(reqConsts.requestHeaders.lock, lockManager.getLock(filePath));
|
||||
res.sendStatus(200);
|
||||
};
|
||||
|
||||
// refresh the lock on a file by resetting its automatic expiration timer to 30 minutes
|
||||
const refreshLock = function refreshLock(wopi, req, res, userHost) {
|
||||
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, '', 'File isn\'t locked');
|
||||
} else if (lockManager.getLock(filePath) === requestLock) {
|
||||
// lock matches current lock => extend duration
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
|
||||
}
|
||||
};
|
||||
|
||||
// allow for file editing
|
||||
const unlock = function unlock(wopi, req, res, userHost) {
|
||||
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, '', 'File isn\'t locked');
|
||||
} else if (lockManager.getLock(filePath) === requestLock) {
|
||||
// lock matches current lock => unlock
|
||||
lockManager.unlock(filePath);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
|
||||
}
|
||||
};
|
||||
|
||||
// allow for file editing, and then immediately take a new lock on the file
|
||||
const unlockAndRelock = function unlockAndRelock(wopi, req, res, userHost) {
|
||||
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
const oldLock = req.headers[reqConsts.requestHeaders.oldLock.toLowerCase()]; // get the X-WOPI-OldLock header
|
||||
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, '', 'File isn\'t locked');
|
||||
} else if (lockManager.getLock(filePath) === oldLock) {
|
||||
// lock matches current lock => lock with new key
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
|
||||
}
|
||||
};
|
||||
|
||||
// request a message to retrieve a file
|
||||
const getFile = function getFile(wopi, req, res, userHost) {
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
|
||||
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
res.setHeader('Content-Length', fileSystem.statSync(storagePath).size);
|
||||
res.setHeader('Content-Type', mime.getType(storagePath));
|
||||
|
||||
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${encodeURIComponent(wopi.id)}`);
|
||||
|
||||
const filestream = fileSystem.createReadStream(storagePath); // open a file as a readable stream
|
||||
filestream.pipe(res); // retrieve data from file stream and output it to the response object
|
||||
};
|
||||
|
||||
// request a message to update a file
|
||||
const putFile = function putFile(wopi, req, res, userHost) {
|
||||
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(storagePath)) {
|
||||
// ToDo: if body length is 0 bytes => handle document creation
|
||||
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, '', 'File isn\'t locked');
|
||||
} else if (lockManager.getLock(storagePath) === requestLock) {
|
||||
// lock matches current lock => put file
|
||||
saveFileFromBody(req, wopi.id, userAddress, true, (err, version) => {
|
||||
if (!err) {
|
||||
res.setHeader(reqConsts.requestHeaders.ItemVersion, version); // set the X-WOPI-ItemVersion header
|
||||
}
|
||||
res.sendStatus(err ? 404 : 200);
|
||||
});
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(storagePath), 'Lock mismatch');
|
||||
}
|
||||
};
|
||||
|
||||
const putRelativeFile = function putRelativeFile(wopi, req, res, userHost) {
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
let filename = req.headers[reqConsts.requestHeaders.RelativeTarget.toLowerCase()]; // we cannot modify this filename
|
||||
if (filename) {
|
||||
if (req.DocManager.existsSync(storagePath)) { // check if already exists
|
||||
const overwrite = req.headers[reqConsts.requestHeaders.OverwriteRelativeTarget.toLowerCase()]; // overwrite header
|
||||
if (overwrite && overwrite === 'true') { // check if we can overwrite
|
||||
if (lockManager.hasLock(storagePath)) { // check if file locked
|
||||
// file is locked, cannot overwrite
|
||||
returnValidRelativeTarget(res, req.DocManager.getCorrectName(wopi.id, userAddress));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// file exists and overwrite header is false
|
||||
returnValidRelativeTarget(res, req.DocManager.getCorrectName(wopi.id, userAddress));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filename = req.headers[reqConsts.requestHeaders.SuggestedTarget.toLowerCase()]; // we can modify this filename
|
||||
|
||||
if (filename.startsWith('.')) { // check if extension
|
||||
filename = fileUtility.getFileName(wopi.id, true) + filename; // get original filename with new extension
|
||||
}
|
||||
|
||||
filename = req.DocManager.getCorrectName(filename, userAddress); // get correct filename if already exists
|
||||
}
|
||||
|
||||
const isConverted = req.headers[reqConsts.requestHeaders.FileConversion.toLowerCase()];
|
||||
console.log(`putRelativeFile after conversation: ${isConverted}`);
|
||||
|
||||
// if we got here, then we can save a file
|
||||
saveFileFromBody(req, filename, userAddress, false, (err) => {
|
||||
if (err) {
|
||||
res.sendStatus(404);
|
||||
return;
|
||||
}
|
||||
|
||||
const serverUrl = req.DocManager.getServerUrl(true);
|
||||
const fileActionUrl = `${serverUrl}/wopi-action/${filename}?action=`;
|
||||
|
||||
const fileInfo = {
|
||||
Name: filename,
|
||||
Url: `${serverUrl}/wopi/files/${filename}`,
|
||||
HostViewUrl: `${fileActionUrl}view`,
|
||||
HostEditNewUrl: `${fileActionUrl}editnew`,
|
||||
HostEditUrl: `${fileActionUrl}edit`,
|
||||
};
|
||||
res.status(200).send(fileInfo);
|
||||
});
|
||||
};
|
||||
|
||||
// return information about the file properties, access rights and editor settings
|
||||
const checkFileInfo = function checkFileInfo(wopi, req, res, userHost) {
|
||||
const userAddress = req.DocManager.curUserHostAddress(userHost);
|
||||
const version = req.DocManager.getKey(wopi.id, userAddress);
|
||||
|
||||
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
|
||||
// add wopi query
|
||||
const query = new URLSearchParams(wopi.accessToken);
|
||||
const user = users.getUser(query.get('userid'));
|
||||
|
||||
// create the file information object
|
||||
const fileInfo = {
|
||||
BaseFileName: wopi.id,
|
||||
OwnerId: req.DocManager.getFileData(wopi.id, userAddress)[1],
|
||||
Size: fileSystem.statSync(storagePath).size,
|
||||
UserId: user.id,
|
||||
UserFriendlyName: user.name,
|
||||
Version: version,
|
||||
UserCanWrite: true,
|
||||
SupportsGetLock: true,
|
||||
SupportsLocks: true,
|
||||
SupportsUpdate: true,
|
||||
};
|
||||
res.status(200).send(fileInfo);
|
||||
};
|
||||
|
||||
// parse wopi request
|
||||
const parseWopiRequest = function parseWopiRequest(req) {
|
||||
const wopiData = {
|
||||
requestType: reqConsts.requestType.None,
|
||||
accessToken: req.query.access_token,
|
||||
id: req.params.id,
|
||||
};
|
||||
|
||||
// get the request path
|
||||
const reqPath = req.path.substring('/wopi/'.length);
|
||||
|
||||
if (reqPath.startsWith('files')) { // if it starts with "files"
|
||||
if (reqPath.endsWith('/contents')) { // ends with "/contents"
|
||||
if (req.method === 'GET') { // and the request method is GET
|
||||
wopiData.requestType = reqConsts.requestType.GetFile; // then the request type is GetFile
|
||||
} else if (req.method === 'POST') { // if the request method is POST
|
||||
wopiData.requestType = reqConsts.requestType.PutFile; // then the request type is PutFile
|
||||
}
|
||||
} else if (req.method === 'GET') { // otherwise, if the request method is GET
|
||||
wopiData.requestType = reqConsts.requestType.CheckFileInfo; // the request type is CheckFileInfo
|
||||
} else if (req.method === 'POST') { // if the request method is POST
|
||||
// get the X-WOPI-Override header which determines the request type
|
||||
const wopiOverride = req.headers[reqConsts.requestHeaders.RequestType.toLowerCase()];
|
||||
switch (wopiOverride) {
|
||||
case 'LOCK': // if it is equal to LOCK
|
||||
// check if the request sends the X-WOPI-OldLock header
|
||||
if (req.headers[reqConsts.requestHeaders.OldLock.toLowerCase()]) {
|
||||
// if yes, then the request type is UnlockAndRelock
|
||||
wopiData.requestType = reqConsts.requestType.UnlockAndRelock;
|
||||
} else {
|
||||
wopiData.requestType = reqConsts.requestType.Lock; // otherwise, it is Lock
|
||||
}
|
||||
break;
|
||||
|
||||
case 'GET_LOCK': // if it is equal to GET_LOCK
|
||||
wopiData.requestType = reqConsts.requestType.GetLock; // the request type is GetLock
|
||||
break;
|
||||
|
||||
case 'REFRESH_LOCK': // if it is equal to REFRESH_LOCK
|
||||
wopiData.requestType = reqConsts.requestType.RefreshLock; // the request type is RefreshLock
|
||||
break;
|
||||
|
||||
case 'UNLOCK': // if it is equal to UNLOCK
|
||||
wopiData.requestType = reqConsts.requestType.Unlock; // the request type is Unlock
|
||||
break;
|
||||
|
||||
case 'PUT_RELATIVE': // if it is equal to PUT_RELATIVE
|
||||
// the request type is PutRelativeFile (creates a new file on the host based on the current file)
|
||||
wopiData.requestType = reqConsts.requestType.PutRelativeFile;
|
||||
break;
|
||||
|
||||
case 'RENAME_FILE': // if it is equal to RENAME_FILE
|
||||
wopiData.requestType = reqConsts.requestType.RenameFile; // the request type is RenameFile (renames a file)
|
||||
break;
|
||||
|
||||
case 'PUT_USER_INFO': // if it is equal to PUT_USER_INFO
|
||||
// the request type is PutUserInfo (stores some basic user information on the host)
|
||||
wopiData.requestType = reqConsts.requestType.PutUserInfo;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wopiData;
|
||||
};
|
||||
|
||||
const actionMapping = {};
|
||||
actionMapping[reqConsts.requestType.GetFile] = getFile;
|
||||
@ -36,352 +365,33 @@ actionMapping[reqConsts.requestType.GetLock] = getLock;
|
||||
actionMapping[reqConsts.requestType.RefreshLock] = refreshLock;
|
||||
actionMapping[reqConsts.requestType.Unlock] = unlock;
|
||||
|
||||
// parse wopi request
|
||||
function parseWopiRequest(req) {
|
||||
let wopiData = {
|
||||
requestType: reqConsts.requestType.None,
|
||||
accessToken: req.query["access_token"],
|
||||
id: req.params['id']
|
||||
}
|
||||
|
||||
// get the request path
|
||||
let reqPath = req.path.substring("/wopi/".length)
|
||||
|
||||
if (reqPath.startsWith("files")) { // if it starts with "files"
|
||||
if (reqPath.endsWith("/contents")) { // ends with "/contents"
|
||||
if (req.method == "GET") { // and the request method is GET
|
||||
wopiData.requestType = reqConsts.requestType.GetFile; // then the request type is GetFile
|
||||
} else if (req.method == "POST") { // if the request method is POST
|
||||
wopiData.requestType = reqConsts.requestType.PutFile; // then the request type is PutFile
|
||||
}
|
||||
} else {
|
||||
if (req.method == "GET") { // otherwise, if the request method is GET
|
||||
wopiData.requestType = reqConsts.requestType.CheckFileInfo; // the request type is CheckFileInfo
|
||||
} else if (req.method == "POST") { // if the request method is POST
|
||||
let wopiOverride = req.headers[reqConsts.requestHeaders.RequestType.toLowerCase()]; // get the X-WOPI-Override header which determines the request type
|
||||
switch (wopiOverride) {
|
||||
case "LOCK": // if it is equal to LOCK
|
||||
if (req.headers[reqConsts.requestHeaders.OldLock.toLowerCase()]) { // check if the request sends the X-WOPI-OldLock header
|
||||
wopiData.requestType = reqConsts.requestType.UnlockAndRelock; // if yes, then the request type is UnlockAndRelock
|
||||
} else {
|
||||
wopiData.requestType = reqConsts.requestType.Lock; // otherwise, it is Lock
|
||||
}
|
||||
break;
|
||||
|
||||
case "GET_LOCK": // if it is equal to GET_LOCK
|
||||
wopiData.requestType = reqConsts.requestType.GetLock; // the request type is GetLock
|
||||
break;
|
||||
|
||||
case "REFRESH_LOCK": // if it is equal to REFRESH_LOCK
|
||||
wopiData.requestType = reqConsts.requestType.RefreshLock; // the request type is RefreshLock
|
||||
break;
|
||||
|
||||
case "UNLOCK": // if it is equal to UNLOCK
|
||||
wopiData.requestType = reqConsts.requestType.Unlock; // the request type is Unlock
|
||||
break;
|
||||
|
||||
case "PUT_RELATIVE": // if it is equal to PUT_RELATIVE
|
||||
wopiData.requestType = reqConsts.requestType.PutRelativeFile; // the request type is PutRelativeFile (creates a new file on the host based on the current file)
|
||||
break;
|
||||
|
||||
case "RENAME_FILE": // if it is equal to RENAME_FILE
|
||||
wopiData.requestType = reqConsts.requestType.RenameFile; // the request type is RenameFile (renames a file)
|
||||
break;
|
||||
|
||||
case "PUT_USER_INFO": // if it is equal to PUT_USER_INFO
|
||||
wopiData.requestType = reqConsts.requestType.PutUserInfo; // the request type is PutUserInfo (stores some basic user information on the host)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (reqPath.startsWith("folders")) {
|
||||
|
||||
}
|
||||
|
||||
return wopiData;
|
||||
}
|
||||
|
||||
// lock file editing
|
||||
function lock(wopi, req, res, userHost) {
|
||||
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost); // get current user host address
|
||||
let filePath = req.docManager.storagePath(wopi.id, userAddress); // get the storage path of the given file
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => lock
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else if (lockManager.getLock(filePath) == requestLock) {
|
||||
// lock matches current lock => extend duration
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// file locked by someone else => return lock mismatch
|
||||
let lock = lockManager.getLock(filePath);
|
||||
returnLockMismatch(res, lock, "File already locked by " + lock)
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve a lock on a file
|
||||
function getLock(wopi, req, res, userHost) {
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let filePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
// get the lock of the specified file and set it as the X-WOPI-Lock header
|
||||
res.setHeader(reqConsts.requestHeaders.lock, lockManager.getLock(filePath));
|
||||
res.sendStatus(200);
|
||||
}
|
||||
|
||||
// refresh the lock on a file by resetting its automatic expiration timer to 30 minutes
|
||||
function refreshLock(wopi, req, res, userHost) {
|
||||
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let filePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, "", "File isn't locked");
|
||||
} else if (lockManager.getLock(filePath) == requestLock) {
|
||||
// lock matches current lock => extend duration
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
// allow for file editing
|
||||
function unlock(wopi, req, res, userHost) {
|
||||
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let filePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, "", "File isn't locked");
|
||||
} else if (lockManager.getLock(filePath) == requestLock) {
|
||||
// lock matches current lock => unlock
|
||||
lockManager.unlock(filePath);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
// allow for file editing, and then immediately take a new lock on the file
|
||||
function unlockAndRelock(wopi, req, res, userHost) {
|
||||
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
let oldLock = req.headers[reqConsts.requestHeaders.oldLock.toLowerCase()]; // get the X-WOPI-OldLock header
|
||||
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let filePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(filePath)) {
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, "", "File isn't locked");
|
||||
} else if (lockManager.getLock(filePath) == oldLock) {
|
||||
// lock matches current lock => lock with new key
|
||||
lockManager.lock(filePath, requestLock);
|
||||
res.sendStatus(200);
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
// request a message to retrieve a file
|
||||
function getFile(wopi, req, res, userHost) {
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
|
||||
let path = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
res.setHeader("Content-Length", fileSystem.statSync(path).size);
|
||||
res.setHeader("Content-Type", mime.getType(path));
|
||||
|
||||
res.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + encodeURIComponent(wopi.id));
|
||||
|
||||
let filestream = fileSystem.createReadStream(path); // open a file as a readable stream
|
||||
filestream.pipe(res); // retrieve data from file stream and output it to the response object
|
||||
}
|
||||
|
||||
// request a message to update a file
|
||||
function putFile(wopi, req, res, userHost) {
|
||||
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
|
||||
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let storagePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
if (!lockManager.hasLock(storagePath)) {
|
||||
// ToDo: if body length is 0 bytes => handle document creation
|
||||
|
||||
// file isn't locked => mismatch
|
||||
returnLockMismatch(res, "", "File isn't locked");
|
||||
} else if (lockManager.getLock(storagePath) == requestLock) {
|
||||
// lock matches current lock => put file
|
||||
saveFileFromBody(req, wopi.id, userAddress, true, (err, version) => {
|
||||
if (!err) {
|
||||
res.setHeader(reqConsts.requestHeaders.ItemVersion, version); // set the X-WOPI-ItemVersion header
|
||||
}
|
||||
res.sendStatus(err ? 404 : 200);
|
||||
});
|
||||
} else {
|
||||
// lock mismatch
|
||||
returnLockMismatch(res, lockManager.getLock(storagePath), "Lock mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
function putRelativeFile(wopi, req, res, userHost) {
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let storagePath = req.docManager.storagePath(wopi.id, userAddress);
|
||||
|
||||
let filename = req.headers[reqConsts.requestHeaders.RelativeTarget.toLowerCase()]; // we cannot modify this filename
|
||||
if (filename) {
|
||||
if (req.docManager.existsSync(storagePath)) { // check if already exists
|
||||
let overwrite = req.headers[reqConsts.requestHeaders.OverwriteRelativeTarget.toLowerCase()]; // overwrite header
|
||||
if (overwrite && overwrite === "true") { // check if we can overwrite
|
||||
if (lockManager.hasLock(storagePath)) { // check if file locked
|
||||
returnValidRelativeTarget(res, req.docManager.getCorrectName(wopi.id, userAddress)); // file is locked, cannot overwrite
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
returnValidRelativeTarget(res, req.docManager.getCorrectName(wopi.id, userAddress)); // file exists and overwrite header is false
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filename = req.headers[reqConsts.requestHeaders.SuggestedTarget.toLowerCase()]; // we can modify this filename
|
||||
|
||||
if (filename.startsWith(".")) { // check if extension
|
||||
filename = fileUtility.getFileName(wopi.id, true) + filename; // get original filename with new extension
|
||||
}
|
||||
|
||||
filename = req.docManager.getCorrectName(filename, userAddress); // get correct filename if already exists
|
||||
}
|
||||
|
||||
let isConverted = req.headers[reqConsts.requestHeaders.FileConversion.toLowerCase()];
|
||||
console.log("putRelativeFile after conversation: " + isConverted);
|
||||
|
||||
// if we got here, then we can save a file
|
||||
saveFileFromBody(req, filename, userAddress, false, (err) => {
|
||||
if (err) {
|
||||
res.sendStatus(404);
|
||||
return;
|
||||
}
|
||||
|
||||
let serverUrl = req.docManager.getServerUrl(true);
|
||||
let fileActionUrl = serverUrl + "/wopi-action/" + filename + "?action=";
|
||||
|
||||
let fileInfo = {
|
||||
"Name": filename,
|
||||
"Url": serverUrl + "/wopi/files/" + filename,
|
||||
"HostViewUrl": fileActionUrl + "view",
|
||||
"HostEditNewUrl": fileActionUrl + "editnew",
|
||||
"HostEditUrl": fileActionUrl + "edit",
|
||||
};
|
||||
res.status(200).send(fileInfo);
|
||||
});
|
||||
}
|
||||
|
||||
// return information about the file properties, access rights and editor settings
|
||||
function checkFileInfo(wopi, req, res, userHost) {
|
||||
let userAddress = req.docManager.curUserHostAddress(userHost);
|
||||
let version = req.docManager.getKey(wopi.id, userAddress);
|
||||
|
||||
let path = req.docManager.storagePath(wopi.id, userAddress);
|
||||
// add wopi query
|
||||
var query = new URLSearchParams(wopi.accessToken);
|
||||
let user = users.getUser(query.get("userid"));
|
||||
|
||||
// create the file information object
|
||||
let fileInfo = {
|
||||
"BaseFileName": wopi.id,
|
||||
"OwnerId": req.docManager.getFileData(wopi.id, userAddress)[1],
|
||||
"Size": fileSystem.statSync(path).size,
|
||||
"UserId": user.id,
|
||||
"UserFriendlyName": user.name,
|
||||
"Version": version,
|
||||
"UserCanWrite": true,
|
||||
"SupportsGetLock": true,
|
||||
"SupportsLocks": true,
|
||||
"SupportsUpdate": true,
|
||||
};
|
||||
res.status(200).send(fileInfo);
|
||||
}
|
||||
|
||||
function saveFileFromBody(req, filename, userAddress, isNewVersion, callback) {
|
||||
if (req.body) {
|
||||
var storagePath = req.docManager.storagePath(filename, userAddress);
|
||||
var historyPath = req.docManager.historyPath(filename, userAddress); // get the path to the file history
|
||||
if (historyPath == "") { // if it is empty
|
||||
historyPath = req.docManager.historyPath(filename, userAddress, true); // create it
|
||||
req.docManager.createDirectory(historyPath); // and create a new directory for the history
|
||||
}
|
||||
|
||||
var version = 0;
|
||||
if (isNewVersion) {
|
||||
var count_version = req.docManager.countVersion(historyPath); // get the last file version
|
||||
version = count_version + 1; // get a number of a new file version
|
||||
var versionPath = req.docManager.versionPath(filename, userAddress, version); // get the path to the specified file version
|
||||
req.docManager.createDirectory(versionPath); // and create a new directory for the specified version
|
||||
|
||||
var path_prev = path.join(versionPath, "prev" + fileUtility.getFileExtension(filename)); // get the path to the previous file version
|
||||
fileSystem.renameSync(storagePath, path_prev); // synchronously rename the given file as the previous file version
|
||||
}
|
||||
|
||||
let filestream = fileSystem.createWriteStream(storagePath);
|
||||
req.pipe(filestream);
|
||||
req.on('end', () => {
|
||||
filestream.close();
|
||||
callback(null, version);
|
||||
})
|
||||
} else {
|
||||
callback("empty body");
|
||||
}
|
||||
}
|
||||
|
||||
// return name that wopi-client can use as the value of X-WOPI-RelativeTarget in a future PutRelativeFile operation
|
||||
function returnValidRelativeTarget(res, filename) {
|
||||
res.setHeader(reqConsts.requestHeaders.ValidRelativeTarget, filename); // set the X-WOPI-ValidRelativeTarget header
|
||||
res.sendStatus(409); // file with that name already exists
|
||||
}
|
||||
|
||||
// return lock mismatch
|
||||
function returnLockMismatch(res, lock, reason) {
|
||||
res.setHeader(reqConsts.requestHeaders.Lock, lock || ""); // set the X-WOPI-Lock header
|
||||
if (reason) { // if there is a reason for lock mismatch
|
||||
res.setHeader(reqConsts.requestHeaders.LockFailureReason, reason); // set it as the X-WOPI-LockFailureReason header
|
||||
}
|
||||
res.sendStatus(409); // conflict
|
||||
}
|
||||
|
||||
exports.fileRequestHandler = (req, res) => {
|
||||
let userAddress = null;
|
||||
req.docManager = new docManager(req, res);
|
||||
if (req.params['id'].includes("@")) { // if there is the "@" sign in the id parameter
|
||||
let split = req.params['id'].split("@"); // split this parameter by "@"
|
||||
req.params['id'] = split[0]; // rewrite id with the first part of the split parameter
|
||||
userAddress = split[1]; // save the second part as the user address
|
||||
}
|
||||
let userAddress = null;
|
||||
req.DocManager = new DocManager(req, res);
|
||||
if (req.params.id.includes('@')) { // if there is the "@" sign in the id parameter
|
||||
const split = req.params.id.split('@'); // split this parameter by "@"
|
||||
[req.params.id] = split; // rewrite id with the first part of the split parameter
|
||||
[, userAddress] = split; // save the second part as the user address
|
||||
}
|
||||
|
||||
let wopiData = parseWopiRequest(req); // get the wopi data
|
||||
const wopiData = parseWopiRequest(req); // get the wopi data
|
||||
|
||||
// an error of the unknown request type
|
||||
if (wopiData.requestType == reqConsts.requestType.None) {
|
||||
res.status(500).send({ 'title': 'fileHandler', 'method': req.method, 'id': req.params['id'], 'error': "unknown" });
|
||||
return;
|
||||
}
|
||||
// an error of the unknown request type
|
||||
if (wopiData.requestType === reqConsts.requestType.None) {
|
||||
res.status(500).send({
|
||||
title: 'fileHandler', method: req.method, id: req.params.id, error: 'unknown',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// an error of the unsupported request type
|
||||
let action = actionMapping[wopiData.requestType];
|
||||
if (!action) {
|
||||
res.status(501).send({ 'title': 'fileHandler', 'method': req.method, 'id': req.params['id'], 'error': "unsupported" });
|
||||
return;
|
||||
}
|
||||
// an error of the unsupported request type
|
||||
const action = actionMapping[wopiData.requestType];
|
||||
if (!action) {
|
||||
res.status(501).send({
|
||||
title: 'fileHandler', method: req.method, id: req.params.id, error: 'unsupported',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
action(wopiData, req, res, userAddress);
|
||||
}
|
||||
action(wopiData, req, res, userAddress);
|
||||
};
|
||||
|
||||
@ -16,54 +16,54 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var lockDict = {};
|
||||
const lockDict = {};
|
||||
|
||||
// get the lock object of the specified file
|
||||
function getLockObject(filePath) {
|
||||
return lockDict[filePath];
|
||||
}
|
||||
const getLockObject = function getLockObject(filePath) {
|
||||
return lockDict[filePath];
|
||||
};
|
||||
|
||||
// clear the lock timeout
|
||||
function clearLockTimeout(lockObject) {
|
||||
if (lockObject && lockObject.timeout) {
|
||||
clearTimeout(lockObject.timeout);
|
||||
}
|
||||
}
|
||||
const clearLockTimeout = function clearLockTimeout(lockObject) {
|
||||
if (lockObject && lockObject.timeout) {
|
||||
clearTimeout(lockObject.timeout);
|
||||
}
|
||||
};
|
||||
|
||||
// get the lock value of the specified file
|
||||
function getLockValue(filePath) {
|
||||
let lock = getLockObject(filePath); // get the lock object of the specified file
|
||||
if (lock) return lock.value; // if it exists, get the lock value from it
|
||||
return "";
|
||||
}
|
||||
const getLockValue = function getLockValue(filePath) {
|
||||
const lock = getLockObject(filePath); // get the lock object of the specified file
|
||||
if (lock) return lock.value; // if it exists, get the lock value from it
|
||||
return '';
|
||||
};
|
||||
|
||||
// check if the specified file path has lock or not
|
||||
function hasLock(filePath) {
|
||||
return !!getLockObject(filePath);
|
||||
}
|
||||
|
||||
// lock file editing
|
||||
function lock(filePath, lockValue) {
|
||||
let oldLock = getLockObject(filePath); // get the old lock of the specified file
|
||||
clearLockTimeout(oldLock); // clear its timeout
|
||||
|
||||
// create a new lock object
|
||||
lockDict[filePath] = {
|
||||
value: lockValue,
|
||||
timeout: setTimeout(unlock, 1000 * 60 * 30, filePath) // set lock for 30 minutes
|
||||
}
|
||||
}
|
||||
const hasLock = function hasLock(filePath) {
|
||||
return !!getLockObject(filePath);
|
||||
};
|
||||
|
||||
// allow for file editing
|
||||
function unlock(filePath) {
|
||||
let lock = getLockObject(filePath); // get the lock of the specified file
|
||||
clearLockTimeout(lock); // clear its timeout
|
||||
delete lockDict[filePath]; // delete the lock
|
||||
}
|
||||
const unlock = function unlock(filePath) {
|
||||
const lock = getLockObject(filePath); // get the lock of the specified file
|
||||
clearLockTimeout(lock); // clear its timeout
|
||||
delete lockDict[filePath]; // delete the lock
|
||||
};
|
||||
|
||||
// lock file editing
|
||||
const lock = function lock(filePath, lockValue) {
|
||||
const oldLock = getLockObject(filePath); // get the old lock of the specified file
|
||||
clearLockTimeout(oldLock); // clear its timeout
|
||||
|
||||
// create a new lock object
|
||||
lockDict[filePath] = {
|
||||
value: lockValue,
|
||||
timeout: setTimeout(unlock, 1000 * 60 * 30, filePath), // set lock for 30 minutes
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
hasLock: hasLock,
|
||||
getLock: getLockValue,
|
||||
lock: lock,
|
||||
unlock: unlock
|
||||
}
|
||||
hasLock,
|
||||
getLock: getLockValue,
|
||||
lock,
|
||||
unlock,
|
||||
};
|
||||
|
||||
@ -18,55 +18,55 @@
|
||||
|
||||
// request types
|
||||
const requestType = Object.freeze({
|
||||
"None": 0,
|
||||
None: 0,
|
||||
|
||||
"CheckFileInfo": 1,
|
||||
"PutRelativeFile": 2,
|
||||
CheckFileInfo: 1,
|
||||
PutRelativeFile: 2,
|
||||
|
||||
"Lock": 3,
|
||||
"GetLock": 4,
|
||||
"Unlock": 5,
|
||||
"RefreshLock": 6,
|
||||
"UnlockAndRelock": 7,
|
||||
Lock: 3,
|
||||
GetLock: 4,
|
||||
Unlock: 5,
|
||||
RefreshLock: 6,
|
||||
UnlockAndRelock: 7,
|
||||
|
||||
"ExecuteCobaltRequest": 8,
|
||||
ExecuteCobaltRequest: 8,
|
||||
|
||||
"DeleteFile": 9,
|
||||
"ReadSecureStore": 10,
|
||||
"GetRestrictedLink": 11,
|
||||
"RevokeRestrictedLink": 12,
|
||||
DeleteFile: 9,
|
||||
ReadSecureStore: 10,
|
||||
GetRestrictedLink: 11,
|
||||
RevokeRestrictedLink: 12,
|
||||
|
||||
"CheckFolderInfo": 13,
|
||||
CheckFolderInfo: 13,
|
||||
|
||||
"GetFile": 14,
|
||||
"PutFile": 16,
|
||||
GetFile: 14,
|
||||
PutFile: 16,
|
||||
|
||||
"EnumerateChildren": 16,
|
||||
EnumerateChildren: 16,
|
||||
|
||||
"RenameFile": 17,
|
||||
"PutUserInfo": 18,
|
||||
RenameFile: 17,
|
||||
PutUserInfo: 18,
|
||||
});
|
||||
|
||||
// request headers
|
||||
const requestHeaders = Object.freeze({
|
||||
"RequestType": "X-WOPI-Override",
|
||||
"ItemVersion": "X-WOPI-ItemVersion",
|
||||
RequestType: 'X-WOPI-Override',
|
||||
ItemVersion: 'X-WOPI-ItemVersion',
|
||||
|
||||
"Lock": "X-WOPI-Lock",
|
||||
"OldLock": "X-WOPI-OldLock",
|
||||
"LockFailureReason": "X-WOPI-LockFailureReason",
|
||||
"LockedByOtherInterface": "X-WOPI-LockedByOtherInterface",
|
||||
Lock: 'X-WOPI-Lock',
|
||||
OldLock: 'X-WOPI-OldLock',
|
||||
LockFailureReason: 'X-WOPI-LockFailureReason',
|
||||
LockedByOtherInterface: 'X-WOPI-LockedByOtherInterface',
|
||||
|
||||
"FileConversion": "X-WOPI-FileConversion",
|
||||
FileConversion: 'X-WOPI-FileConversion',
|
||||
|
||||
"SuggestedTarget": "X-WOPI-SuggestedTarget",
|
||||
"RelativeTarget": "X-WOPI-RelativeTarget",
|
||||
"OverwriteRelativeTarget": "X-WOPI-OverwriteRelativeTarget",
|
||||
SuggestedTarget: 'X-WOPI-SuggestedTarget',
|
||||
RelativeTarget: 'X-WOPI-RelativeTarget',
|
||||
OverwriteRelativeTarget: 'X-WOPI-OverwriteRelativeTarget',
|
||||
|
||||
"ValidRelativeTarget": "X-WOPI-ValidRelativeTarget",
|
||||
ValidRelativeTarget: 'X-WOPI-ValidRelativeTarget',
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
requestType: requestType,
|
||||
requestHeaders: requestHeaders,
|
||||
}
|
||||
requestType,
|
||||
requestHeaders,
|
||||
};
|
||||
|
||||
@ -16,8 +16,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
exports.isValidToken = (req, res, next) => {
|
||||
if (true) {
|
||||
return next();
|
||||
}
|
||||
}
|
||||
exports.isValidToken = (req, res, next) => next();
|
||||
|
||||
@ -16,129 +16,139 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const config = require("config");
|
||||
const configServer = config.get("server");
|
||||
var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
const xmlParser = require("fast-xml-parser");
|
||||
const he = require("he");
|
||||
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
|
||||
const config = require('config');
|
||||
const urlModule = require('url');
|
||||
const urllib = require('urllib');
|
||||
const xmlParser = require('fast-xml-parser');
|
||||
const he = require('he');
|
||||
|
||||
var cache = null;
|
||||
const configServer = config.get('server');
|
||||
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
|
||||
async function initWopi(docManager) {
|
||||
let absSiteUrl = siteUrl;
|
||||
if (absSiteUrl.indexOf("/") === 0) {
|
||||
absSiteUrl = docManager.getServerHost() + siteUrl;
|
||||
}
|
||||
let cache = null;
|
||||
|
||||
// get the wopi discovery information
|
||||
await getDiscoveryInfo(absSiteUrl);
|
||||
}
|
||||
const requestDiscovery = async function requestDiscovery(url) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
return new Promise((resolve, reject) => {
|
||||
const actions = [];
|
||||
urllib.request(urlModule.parse(url + configServer.get('wopi.discovery')), { method: 'GET' }, (err, data) => {
|
||||
if (data) {
|
||||
// create the discovery XML file with the parameters from the response
|
||||
const discovery = xmlParser.parse(data.toString(), {
|
||||
attributeNamePrefix: '',
|
||||
ignoreAttributes: false,
|
||||
parseAttributeValue: true,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
attrValueProcessor: (val, attrName) => he.decode(val, { isAttributeValue: true }),
|
||||
});
|
||||
if (discovery['wopi-discovery']) {
|
||||
discovery['wopi-discovery']['net-zone'].app.forEach((app) => {
|
||||
let appAction = app.action;
|
||||
if (!Array.isArray(appAction)) {
|
||||
appAction = [appAction];
|
||||
}
|
||||
appAction.forEach((action) => {
|
||||
actions.push({ // write all the parameters to the actions element
|
||||
app: app.name,
|
||||
favIconUrl: app.favIconUrl,
|
||||
checkLicense: app.checkLicense === 'true',
|
||||
name: action.name,
|
||||
ext: action.ext || '',
|
||||
progid: action.progid || '',
|
||||
isDefault: !!action.default,
|
||||
urlsrc: action.urlsrc,
|
||||
requires: action.requires || '',
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
resolve(actions);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// get the wopi discovery information
|
||||
async function getDiscoveryInfo(siteUrl) {
|
||||
let actions = [];
|
||||
const getDiscoveryInfo = async function getDiscoveryInfo(url) {
|
||||
let actions = [];
|
||||
|
||||
if (cache) return cache;
|
||||
|
||||
try {
|
||||
actions = await requestDiscovery(siteUrl);
|
||||
} catch (e) {
|
||||
return actions;
|
||||
}
|
||||
|
||||
cache = actions;
|
||||
setTimeout(() => cache = null, 1000 * 60 * 60); // 1 hour
|
||||
if (cache) return cache;
|
||||
|
||||
try {
|
||||
actions = await requestDiscovery(url);
|
||||
} catch (e) {
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
|
||||
async function requestDiscovery(siteUrl) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var actions = [];
|
||||
urllib.request(urlModule.parse(siteUrl + configServer.get("wopi.discovery")), {method: "GET"}, (err, data) => {
|
||||
if (data) {
|
||||
let discovery = xmlParser.parse(data.toString(), { // create the discovery XML file with the parameters from the response
|
||||
attributeNamePrefix: "",
|
||||
ignoreAttributes: false,
|
||||
parseAttributeValue: true,
|
||||
attrValueProcessor: (val, attrName) => he.decode(val, {isAttributeValue: true})
|
||||
});
|
||||
if (discovery["wopi-discovery"]) {
|
||||
for (let app of discovery["wopi-discovery"]["net-zone"].app) {
|
||||
if (!Array.isArray(app.action)) {
|
||||
app.action = [app.action];
|
||||
}
|
||||
for (let action of app.action) {
|
||||
actions.push({ // write all the parameters to the actions element
|
||||
app: app.name,
|
||||
favIconUrl: app.favIconUrl,
|
||||
checkLicense: app.checkLicense == 'true',
|
||||
name: action.name,
|
||||
ext: action.ext || "",
|
||||
progid: action.progid || "",
|
||||
isDefault: action.default ? true : false,
|
||||
urlsrc: action.urlsrc,
|
||||
requires: action.requires || ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve(actions);
|
||||
});
|
||||
})
|
||||
}
|
||||
cache = actions;
|
||||
setTimeout(() => {
|
||||
cache = null;
|
||||
return cache;
|
||||
}, 1000 * 60 * 60); // 1 hour
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
const initWopi = async function initWopi(DocManager) {
|
||||
let absSiteUrl = siteUrl;
|
||||
if (absSiteUrl.indexOf('/') === 0) {
|
||||
absSiteUrl = DocManager.getServerHost() + siteUrl;
|
||||
}
|
||||
|
||||
// get the wopi discovery information
|
||||
await getDiscoveryInfo(absSiteUrl);
|
||||
};
|
||||
|
||||
// get actions of the specified extension
|
||||
async function getActions(ext) {
|
||||
let actions = await getDiscoveryInfo(); // get the wopi discovery information
|
||||
let filtered = [];
|
||||
const getActions = async function getActions(ext) {
|
||||
const actions = await getDiscoveryInfo(); // get the wopi discovery information
|
||||
const filtered = [];
|
||||
|
||||
for (let action of actions) { // and filter it by the specified extention
|
||||
if (action.ext == ext) {
|
||||
filtered.push(action);
|
||||
}
|
||||
actions.forEach((action) => { // and filter it by the specified extention
|
||||
if (action.ext === ext) {
|
||||
filtered.push(action);
|
||||
}
|
||||
});
|
||||
|
||||
return filtered;
|
||||
}
|
||||
return filtered;
|
||||
};
|
||||
|
||||
// get an action for the specified extension and name
|
||||
async function getAction(ext, name) {
|
||||
let actions = await getDiscoveryInfo();
|
||||
const getAction = async function getAction(ext, name) {
|
||||
const actions = await getDiscoveryInfo();
|
||||
let act = null;
|
||||
|
||||
for (let action of actions) {
|
||||
if (action.ext == ext && action.name == name) {
|
||||
return action;
|
||||
}
|
||||
actions.forEach((action) => {
|
||||
if (action.ext === ext && action.name === name) {
|
||||
act = action;
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
return act;
|
||||
};
|
||||
|
||||
// get the default action for the specified extension
|
||||
async function getDefaultAction(ext) {
|
||||
let actions = await getDiscoveryInfo();
|
||||
const getDefaultAction = async function getDefaultAction(ext) {
|
||||
const actions = await getDiscoveryInfo();
|
||||
let act = null;
|
||||
|
||||
for (let action of actions) {
|
||||
if (action.ext == ext && action.isDefault) {
|
||||
return action;
|
||||
}
|
||||
actions.forEach((action) => {
|
||||
if (action.ext === ext && action.isDefault) {
|
||||
act = action;
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
return act;
|
||||
};
|
||||
|
||||
// get the action url
|
||||
function getActionUrl(host, userAddress, action, filename) {
|
||||
return action.urlsrc.replace(/<.*&>/g, "") + "WOPISrc=" + host + "/wopi/files/" + filename + "@" + userAddress;
|
||||
}
|
||||
const getActionUrl = function getActionUrl(host, userAddress, action, filename) {
|
||||
return `${action.urlsrc.replace(/<.*&>/g, '')}WOPISrc=${host}/wopi/files/${filename}@${userAddress}`;
|
||||
};
|
||||
|
||||
exports.initWopi = initWopi;
|
||||
exports.getDiscoveryInfo = getDiscoveryInfo;
|
||||
exports.getAction = getAction;
|
||||
exports.getActions = getActions;
|
||||
exports.getActionUrl = getActionUrl;
|
||||
exports.getDefaultAction = getDefaultAction;
|
||||
exports.getDefaultAction = getDefaultAction;
|
||||
|
||||
@ -16,157 +16,160 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const tokenValidator = require("./tokenValidator");
|
||||
const filesController = require("./filesController");
|
||||
const utils = require("./utils");
|
||||
const docManager = require("../docManager");
|
||||
const fileUtility = require("../fileUtility");
|
||||
const config = require('config');
|
||||
const tokenValidator = require('./tokenValidator');
|
||||
const filesController = require('./filesController');
|
||||
const utils = require('./utils');
|
||||
const DocManager = require('../docManager');
|
||||
const fileUtility = require('../fileUtility');
|
||||
const users = require('../users');
|
||||
|
||||
const configServer = config.get('server');
|
||||
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
|
||||
const users = require("../users");
|
||||
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
|
||||
getCustomWopiParams = function (query) {
|
||||
let tokenParams = "";
|
||||
let actionParams = "";
|
||||
const getCustomWopiParams = function getCustomWopiParams(query) {
|
||||
let tokenParams = '';
|
||||
let actionParams = '';
|
||||
|
||||
const userid = query.userid; // user id
|
||||
tokenParams += (userid ? "&userid=" + userid : "");
|
||||
const { userid } = query; // user id
|
||||
tokenParams += (userid ? `&userid=${userid}` : '');
|
||||
|
||||
const lang = query.lang; // language
|
||||
actionParams += (lang ? "&ui=" + lang : "");
|
||||
const { lang } = query; // language
|
||||
actionParams += (lang ? `&ui=${lang}` : '');
|
||||
|
||||
return { "tokenParams": tokenParams, "actionParams": actionParams };
|
||||
return { tokenParams, actionParams };
|
||||
};
|
||||
|
||||
exports.registerRoutes = function(app) {
|
||||
exports.registerRoutes = function registerRoutes(app) {
|
||||
// define a handler for the default wopi page
|
||||
app.get('/wopi', async (req, res) => {
|
||||
req.DocManager = new DocManager(req, res);
|
||||
|
||||
// define a handler for the default wopi page
|
||||
app.get("/wopi", async function(req, res) {
|
||||
await utils.initWopi(req.DocManager);
|
||||
|
||||
req.docManager = new docManager(req, res);
|
||||
// get the wopi discovery information
|
||||
const actions = await utils.getDiscoveryInfo();
|
||||
const wopiEnable = actions.length !== 0;
|
||||
const docsExtEdit = []; // Supported extensions for WOPI
|
||||
|
||||
await utils.initWopi(req.docManager);
|
||||
|
||||
// get the wopi discovery information
|
||||
let actions = await utils.getDiscoveryInfo();
|
||||
let wopiEnable = actions.length != 0 ? true : false;
|
||||
let docsExtEdit = []; // Supported extensions for WOPI
|
||||
|
||||
actions.forEach(el => {
|
||||
if (el.name == "edit") docsExtEdit.push("."+el.ext);
|
||||
});
|
||||
|
||||
let editedExts = configServer.get('editedDocs').filter(i => docsExtEdit.includes(i)); // Checking supported extensions
|
||||
let fillExts = configServer.get("fillDocs").filter(i => docsExtEdit.includes(i));
|
||||
|
||||
try {
|
||||
// get all the stored files
|
||||
let files = req.docManager.getStoredFiles();
|
||||
|
||||
// run through all the files and write the corresponding information to each file
|
||||
for (var file of files) {
|
||||
let ext = fileUtility.getFileExtension(file.name, true); // get an extension of each file
|
||||
file.actions = await utils.getActions(ext); // get actions of the specified extension
|
||||
file.defaultAction = await utils.getDefaultAction(ext); // get the default action of the specified extension
|
||||
}
|
||||
|
||||
// render wopiIndex template with the parameters specified
|
||||
res.render("wopiIndex", {
|
||||
wopiEnable : wopiEnable,
|
||||
storedFiles: wopiEnable ? files : [],
|
||||
params: req.docManager.getCustomParams(),
|
||||
users: users,
|
||||
serverUrl: req.docManager.getServerUrl(),
|
||||
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
|
||||
convertExts: configServer.get('convertedDocs'),
|
||||
editedExts: editedExts,
|
||||
fillExts: fillExts,
|
||||
languages: configServer.get('languages'),
|
||||
});
|
||||
|
||||
} catch (ex) {
|
||||
console.log(ex); // display error message in the console
|
||||
res.status(500); // write status parameter to the response
|
||||
res.render("error", { message: "Server error" }); // render error template with the message parameter specified
|
||||
return;
|
||||
}
|
||||
});
|
||||
// define a handler for creating a new wopi editing session
|
||||
app.get("/wopi-new", function(req, res) {
|
||||
var fileExt = req.query.fileExt; // get the file extension from the request
|
||||
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
if (fileExt != null) { // if the file extension exists
|
||||
var fileName = req.docManager.getCorrectName("new." + fileExt)
|
||||
var redirectPath = req.docManager.getServerUrl(true) + "/wopi-action/" + encodeURIComponent(fileName) + "?action=editnew" + req.docManager.getCustomParams(); // get the redirect path
|
||||
res.redirect(redirectPath);
|
||||
return;
|
||||
}
|
||||
});
|
||||
// define a handler for getting wopi action information by its id
|
||||
app.get("/wopi-action/:id", async function(req, res) {
|
||||
try {
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
await utils.initWopi(req.docManager);
|
||||
|
||||
var fileName = req.docManager.getCorrectName(req.params['id'])
|
||||
var fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
|
||||
var user = users.getUser(req.query.userid); // get a user by the id
|
||||
|
||||
// get an action for the specified extension and name
|
||||
let action = await utils.getAction(fileExt, req.query["action"]);
|
||||
|
||||
if (action != null && req.query["action"] == "editnew") {
|
||||
fileName = req.docManager.RequestEditnew(req, fileName, user);
|
||||
}
|
||||
|
||||
// render wopiAction template with the parameters specified
|
||||
res.render("wopiAction", {
|
||||
actionUrl: utils.getActionUrl(req.docManager.getServerUrl(true), req.docManager.curUserHostAddress(), action, req.params['id']),
|
||||
token: "test",
|
||||
tokenTtl: Date.now() + 1000 * 60 * 60 * 10,
|
||||
params: getCustomWopiParams(req.query),
|
||||
});
|
||||
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
res.status(500);
|
||||
res.render("error", { message: "Server error" });
|
||||
return;
|
||||
}
|
||||
actions.forEach((el) => {
|
||||
if (el.name === 'edit') docsExtEdit.push(`.${el.ext}`);
|
||||
});
|
||||
|
||||
// define a handler for getting file information by its id
|
||||
app.route('/wopi/files/:id')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
// Checking supported extensions
|
||||
const editedExts = fileUtility.getEditExtensions().filter((i) => docsExtEdit.includes(i));
|
||||
const fillExts = fileUtility.getFillExtensions().filter((i) => docsExtEdit.includes(i));
|
||||
|
||||
// define a handler for reading/writing the file contents
|
||||
app.route('/wopi/files/:id/contents')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
try {
|
||||
// get all the stored files
|
||||
const files = req.DocManager.getStoredFiles();
|
||||
|
||||
// define a handler for getting folder information by its id
|
||||
app.route('/wopi/folders/:id')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
// run through all the files and write the corresponding information to each file
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const file of files) {
|
||||
const ext = fileUtility.getFileExtension(file.name, true); // get an extension of each file
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
file.actions = await utils.getActions(ext); // get actions of the specified extension
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
file.defaultAction = await utils.getDefaultAction(ext);// get the default action of the specified extension
|
||||
}
|
||||
|
||||
// define a handler for reading/writing the folder contents
|
||||
app.route('/wopi/folders/:id/contents')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
// render wopiIndex template with the parameters specified
|
||||
res.render('wopiIndex', {
|
||||
wopiEnable,
|
||||
storedFiles: wopiEnable ? files : [],
|
||||
params: req.DocManager.getCustomParams(),
|
||||
users,
|
||||
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
|
||||
convertExts: fileUtility.getConvertExtensions(),
|
||||
editedExts,
|
||||
fillExts,
|
||||
languages: configServer.get('languages'),
|
||||
});
|
||||
} catch (ex) {
|
||||
console.log(ex); // display error message in the console
|
||||
res.status(500); // write status parameter to the response
|
||||
// render error template with the message parameter specified
|
||||
res.render('error', { message: 'Server error' });
|
||||
}
|
||||
});
|
||||
// define a handler for creating a new wopi editing session
|
||||
app.get('/wopi-new', (req, res) => {
|
||||
const { fileExt } = req.query; // get the file extension from the request
|
||||
|
||||
// define a handler for upload files
|
||||
app.route('/wopi/upload')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
req.DocManager = new DocManager(req, res);
|
||||
|
||||
if (fileExt) { // if the file extension exists
|
||||
const fileName = req.DocManager.getCorrectName(`new.${fileExt}`);
|
||||
const redirectPath = `${req.DocManager.getServerUrl(true)}/wopi-action/`
|
||||
+ `${encodeURIComponent(fileName)}?action=editnew${req.DocManager.getCustomParams()}`; // get the redirect path
|
||||
res.redirect(redirectPath);
|
||||
}
|
||||
});
|
||||
// define a handler for getting wopi action information by its id
|
||||
app.get('/wopi-action/:id', async (req, res) => {
|
||||
try {
|
||||
req.DocManager = new DocManager(req, res);
|
||||
|
||||
await utils.initWopi(req.DocManager);
|
||||
|
||||
let fileName = req.DocManager.getCorrectName(req.params.id);
|
||||
const fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
|
||||
const user = users.getUser(req.query.userid); // get a user by the id
|
||||
|
||||
// get an action for the specified extension and name
|
||||
const action = await utils.getAction(fileExt, req.query.action);
|
||||
|
||||
if (action && req.query.action === 'editnew') {
|
||||
fileName = req.DocManager.requestEditnew(req, fileName, user);
|
||||
}
|
||||
|
||||
// render wopiAction template with the parameters specified
|
||||
res.render('wopiAction', {
|
||||
actionUrl: utils.getActionUrl(
|
||||
req.DocManager.getServerUrl(true),
|
||||
req.DocManager.curUserHostAddress(),
|
||||
action,
|
||||
req.params.id,
|
||||
),
|
||||
token: 'test',
|
||||
tokenTtl: Date.now() + 1000 * 60 * 60 * 10,
|
||||
params: getCustomWopiParams(req.query),
|
||||
});
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
res.status(500);
|
||||
res.render('error', { message: 'Server error' });
|
||||
}
|
||||
});
|
||||
|
||||
// define a handler for getting file information by its id
|
||||
app.route('/wopi/files/:id')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
|
||||
// define a handler for reading/writing the file contents
|
||||
app.route('/wopi/files/:id/contents')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
|
||||
// define a handler for getting folder information by its id
|
||||
app.route('/wopi/folders/:id')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
|
||||
// define a handler for reading/writing the folder contents
|
||||
app.route('/wopi/folders/:id/contents')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
|
||||
// define a handler for upload files
|
||||
app.route('/wopi/upload')
|
||||
.all(tokenValidator.isValidToken)
|
||||
.get(filesController.fileRequestHandler)
|
||||
.post(filesController.fileRequestHandler);
|
||||
};
|
||||
|
||||
@ -20,13 +20,17 @@ express - Fast, unopinionated, minimalist web framework for node. (https:/
|
||||
License: MIT
|
||||
License File: express.license
|
||||
|
||||
fast-xml-parser - Validate XML, Parse XML to JS/JSON and vice versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback. (https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: fast-xml-parser.license
|
||||
|
||||
formidable - A Node.js module for parsing form data, especially file uploads. (https://github.com/node-formidable/formidable/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: formidable.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
he - a robust HTML entity encoder/decoder written in JavaScript. (https://github.com/mathiasbynens/he/blob/master/LICENSE-MIT.txt)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
License File: he.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
@ -40,9 +44,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "OnlineEditorsExampleNodeJS",
|
||||
"version": "4.1.0",
|
||||
"version": "1.6.0",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www",
|
||||
|
||||
Submodule web/documentserver-example/nodejs/public/assets/document-formats added at 6e38b17679
@ -34,30 +34,17 @@ if (typeof jQuery != "undefined") {
|
||||
else
|
||||
language = jq("#language").val();
|
||||
|
||||
|
||||
jq("#language").change(function() {
|
||||
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
});
|
||||
|
||||
if ("" != userid && undefined != userid)
|
||||
jq("#user").val(userid);
|
||||
else
|
||||
userid = jq("#user").val();
|
||||
|
||||
jq("#user").change(function() {
|
||||
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&directUrl=" + directUrl;
|
||||
});
|
||||
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function() {
|
||||
window.location = "?lang=" + language + "&userid=" + userid + "&directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
@ -111,7 +98,7 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var timer = null;
|
||||
var checkConvert = function (filePass) {
|
||||
filePass = filePass ? filePass : null;
|
||||
@ -126,7 +113,7 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#filePass").val("");
|
||||
|
||||
var fileName = jq("#hiddenFileName").val();
|
||||
var posExt = fileName.lastIndexOf('.');
|
||||
var posExt = fileName.lastIndexOf('.') + 1;
|
||||
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
|
||||
|
||||
if (ConverExtList.indexOf(posExt) == -1) {
|
||||
@ -207,7 +194,7 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#beginView, #beginEmbedded").removeClass("disable");
|
||||
|
||||
var fileName = jq("#hiddenFileName").val();
|
||||
var posExt = fileName.lastIndexOf('.');
|
||||
var posExt = fileName.lastIndexOf('.') + 1;
|
||||
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
|
||||
|
||||
var checkEdited = EditedExtList.split(",").filter(function(ext) { return ext == posExt;});
|
||||
@ -230,6 +217,20 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
});
|
||||
|
||||
jq(document).on("click", ".action-link", function (e) {
|
||||
e.preventDefault();
|
||||
let url = this.href + collectParams(true);
|
||||
let target = null;
|
||||
|
||||
if (e.target.hasAttribute("target")) {
|
||||
target = e.target.getAttribute("target");
|
||||
} else if (e.target.parentNode.hasAttribute("target")) {
|
||||
target = e.target.parentNode.getAttribute("target");
|
||||
}
|
||||
|
||||
target !== null ? window.open(url, target) : window.location = url;
|
||||
});
|
||||
|
||||
jq(document).on("click", "#skipPass", function () {
|
||||
jq("#blockPassword").hide();
|
||||
loadScripts();
|
||||
@ -238,32 +239,32 @@ if (typeof jQuery != "undefined") {
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
if (UrlEditor == "wopi-action"){
|
||||
var url = UrlEditor + "/" + fileId + "?action=edit";
|
||||
var url = UrlEditor + "/" + fileId + "?action=edit" + collectParams(true);
|
||||
}else{
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
var url = UrlEditor + "?fileName=" + fileId + collectParams(true);
|
||||
}
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload(true);
|
||||
window.location = collectParams();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
if (UrlEditor == "wopi-action"){
|
||||
var url = UrlEditor + "/" + fileId + "?action=view";
|
||||
var url = UrlEditor + "/" + fileId + "?action=view" + collectParams(true);
|
||||
}else{
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + collectParams(true);
|
||||
}
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload(true);
|
||||
window.location = collectParams();
|
||||
});
|
||||
|
||||
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 + "&directUrl=" + directUrl;
|
||||
var url = UrlEditor + "?type=embedded&fileName=" + fileId + collectParams(true);
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -272,13 +273,13 @@ if (typeof jQuery != "undefined") {
|
||||
});
|
||||
|
||||
jq(document).on("click", ".reload-page", function () {
|
||||
setTimeout(function () { document.location.reload(true); }, 1000);
|
||||
setTimeout(function () { window.location = collectParams(); }, 1000);
|
||||
return true;
|
||||
});
|
||||
|
||||
jq(document).on("mouseup", ".reload-page", function (event) {
|
||||
if (event.which == 2) {
|
||||
setTimeout(function () { document.location.reload(true); }, 1000);
|
||||
setTimeout(function () { window.location = collectParams(); }, 1000);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -288,12 +289,13 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#embeddedView").remove();
|
||||
jq.unblockUI();
|
||||
if (mustReload) {
|
||||
document.location.reload(true);
|
||||
window.location = collectParams();
|
||||
}
|
||||
});
|
||||
|
||||
jq(document).on("click", ".delete-file", function () {
|
||||
var fileName = jq(this).attr("data");
|
||||
const currentElement = jq(this);
|
||||
var fileName = currentElement.attr("data");
|
||||
|
||||
var requestAddress = "file?filename=" + fileName;
|
||||
|
||||
@ -303,7 +305,16 @@ if (typeof jQuery != "undefined") {
|
||||
type: "delete",
|
||||
url: requestAddress,
|
||||
complete: function (data) {
|
||||
document.location.reload(true);
|
||||
if (JSON.parse(data.responseText).success) {
|
||||
const parentRow = currentElement.parents('tr')[0];
|
||||
if (parentRow) {
|
||||
jq(parentRow).remove();
|
||||
}
|
||||
const remainingRows = jq('tr.tableRow');
|
||||
if (remainingRows.length === 0) {
|
||||
window.location = collectParams();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -394,4 +405,32 @@ function getUrlVars() {
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
};
|
||||
|
||||
function collectParams(startParams) {
|
||||
let paramsObjects = Array.prototype.slice.call(document.getElementsByClassName('collectable'));
|
||||
let params = [];
|
||||
let startChar = startParams ? "&" : "?";
|
||||
paramsObjects.forEach( function (element) {
|
||||
if (element.name) {
|
||||
switch (element.type) {
|
||||
case "select-one":
|
||||
case "text":
|
||||
if (element.value) {
|
||||
params.push(element.name + "=" + element.value);
|
||||
}
|
||||
break;
|
||||
case "checkbox":
|
||||
params.push(element.name + "=" + element.checked);
|
||||
break;
|
||||
case "radio":
|
||||
if (element.checked) {
|
||||
params.push(element.name + "=" + element.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
});
|
||||
return startChar + params.join("&");
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
|
||||
var docEditor;
|
||||
var config;
|
||||
let historyObject;
|
||||
|
||||
var innerAlert = function (message, inEditor) {
|
||||
if (console && console.log)
|
||||
@ -72,26 +73,72 @@
|
||||
};
|
||||
|
||||
var onRequestHistory = function (event) { // the user is trying to show the document version history
|
||||
var historyObj = <%- JSON.stringify(history) %> || null;
|
||||
|
||||
docEditor.refreshHistory( // show the document version history
|
||||
const fileName = "<%- file.name %>" || null;
|
||||
const directUrl = "<%- file.directUrl %>" || null;
|
||||
const data = {
|
||||
fileName: fileName,
|
||||
directUrl: directUrl
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "historyObj");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify(data));
|
||||
xhr.onload = function () {
|
||||
historyObject = JSON.parse(xhr.responseText);
|
||||
docEditor.refreshHistory( // show the document version history
|
||||
{
|
||||
currentVersion: "<%- file.version %>",
|
||||
history: historyObj
|
||||
currentVersion: historyObject.countVersion,
|
||||
history: historyObject.history
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var onRequestHistoryData = function (data) { // the user is trying to click the specific document version in the document version history
|
||||
var version = data.data;
|
||||
var historyData = <%- JSON.stringify(historyData) %> || null;
|
||||
|
||||
docEditor.setHistoryData(historyData[version-1]); // send the link to the document for viewing the version history
|
||||
var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history
|
||||
const version = event.data;
|
||||
docEditor.setHistoryData(historyObject.historyData[version-1]); // send the link to the document for viewing the version history
|
||||
};
|
||||
|
||||
var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history
|
||||
document.location.reload();
|
||||
};
|
||||
|
||||
var onRequestRestore = function (event) { // the user is trying to restore file version
|
||||
const version = event.data.version;
|
||||
const fileName = "<%- file.name %>" || null;
|
||||
const directUrl = "<%- file.directUrl %>" || null;
|
||||
const restoreData = {
|
||||
version: version,
|
||||
fileName: fileName,
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", "restore");
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify(restoreData));
|
||||
xhr.onload = function () {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success && !response.error) {
|
||||
const dataForHistory = {
|
||||
fileName: fileName,
|
||||
directUrl: directUrl
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "historyObj");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify(dataForHistory));
|
||||
xhr.onload = function () {
|
||||
historyObject = JSON.parse(xhr.responseText);
|
||||
docEditor.refreshHistory( // show the document version history
|
||||
{
|
||||
currentVersion: historyObject.countVersion,
|
||||
history: historyObject.history
|
||||
});
|
||||
}
|
||||
} else {
|
||||
innerAlert(response.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var onError = function (event) { // an error or some other specific event occurs
|
||||
if (event)
|
||||
innerAlert(event.data);
|
||||
@ -139,9 +186,22 @@
|
||||
docEditor.setMailMergeRecipients(<%- JSON.stringify(dataMailMergeRecipients) %>); // insert recipient data for mail merge into the file
|
||||
};
|
||||
|
||||
var onRequestUsers = function () {
|
||||
docEditor.setUsers({ // set a list of users to mention in the comments
|
||||
"users": <%- JSON.stringify(usersForMentions) %>
|
||||
var onRequestUsers = function (event) {
|
||||
if (event && event.data){
|
||||
var c = event.data.c;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case "protect":
|
||||
var users = <%- JSON.stringify(usersForProtect) %>;
|
||||
break;
|
||||
default:
|
||||
users = <%- JSON.stringify(usersForMentions) %>;
|
||||
}
|
||||
|
||||
docEditor.setUsers({
|
||||
"c": c,
|
||||
"users": users,
|
||||
});
|
||||
};
|
||||
|
||||
@ -167,6 +227,53 @@
|
||||
}
|
||||
};
|
||||
|
||||
var onRequestReferenceSource = function (event) {
|
||||
innerAlert("onRequestReferenceSource");
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "files");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send();
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 200) {
|
||||
innerAlert(JSON.parse(xhr.responseText));
|
||||
let fileList = JSON.parse(xhr.responseText);
|
||||
let firstXlsxName;
|
||||
let file;
|
||||
for (var i = 0; i < fileList.length; i++) {
|
||||
file = fileList[i];
|
||||
if (file["title"]) {
|
||||
if (getFileExt(file["title"]) === "xlsx")
|
||||
{
|
||||
firstXlsxName = file["title"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (firstXlsxName) {
|
||||
let data = {
|
||||
directUrl : "<%- file.directUrl %>" || false,
|
||||
path : firstXlsxName
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "reference");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify(data));
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 200) {
|
||||
docEditor.setReferenceSource(JSON.parse(xhr.responseText));
|
||||
} else {
|
||||
innerAlert("/reference - bad status");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
innerAlert("No *.xlsx files");
|
||||
}
|
||||
} else {
|
||||
innerAlert("/files - bad status");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var onRequestSaveAs = function (event) { // the user is trying to save file by clicking Save Copy as... button
|
||||
var title = event.data.title;
|
||||
var url = event.data.url;
|
||||
@ -222,10 +329,12 @@
|
||||
config.events.onRequestHistory = onRequestHistory;
|
||||
config.events.onRequestHistoryData = onRequestHistoryData;
|
||||
config.events.onRequestHistoryClose = onRequestHistoryClose;
|
||||
config.events.onRequestRestore = onRequestRestore;
|
||||
config.events.onRequestRename = onRequestRename;
|
||||
config.events.onRequestUsers = onRequestUsers;
|
||||
config.events.onRequestSendNotify = onRequestSendNotify;
|
||||
config.events.onRequestReferenceData = onRequestReferenceData;
|
||||
config.events.onRequestReferenceSource = onRequestReferenceSource;
|
||||
}
|
||||
|
||||
if (config.editorConfig.createUrl) {
|
||||
@ -265,6 +374,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
const getFileExt = function (fileName) {
|
||||
if (fileName.indexOf(".")) {
|
||||
return fileName.split('.').reverse()[0];
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", connectEditor);
|
||||
window.addEventListener("resize", fixSize);
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<body>
|
||||
<header>
|
||||
<div class="center">
|
||||
<a href="">
|
||||
<a href="./">
|
||||
<img src ="images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
@ -48,16 +48,16 @@
|
||||
<div class="create-panel clearFix">
|
||||
<ul class="try-editor-list clearFix">
|
||||
<li>
|
||||
<a class="try-editor word reload-page" target="_blank" href="editor?fileExt=docx<%= params %>" title="Create new document">Document</a>
|
||||
<a class="try-editor word reload-page action-link" target="_blank" href="editor?fileExt=docx" title="Create new document">Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor cell reload-page" target="_blank" href="editor?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
|
||||
<a class="try-editor cell reload-page action-link" target="_blank" href="editor?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor slide reload-page" target="_blank" href="editor?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
|
||||
<a class="try-editor slide reload-page action-link" target="_blank" href="editor?fileExt=pptx" title="Create new presentation">Presentation</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
|
||||
<a class="try-editor form reload-page action-link" target="_blank" href="editor?fileExt=docxf" title="Create new form template">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="side-option">
|
||||
@ -67,7 +67,7 @@
|
||||
|
||||
<div class="upload-panel clearFix">
|
||||
<a class="file-upload">Upload file
|
||||
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
|
||||
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img id="info" class="info" src="images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<select class="select-user collectable" name="userid" id="user">
|
||||
<% users.forEach(user => { %>
|
||||
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
|
||||
<% }) %>
|
||||
@ -88,7 +88,7 @@
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<select class="select-user collectable" name="lang" id="language">
|
||||
<% Object.keys(languages).forEach(key => { %>
|
||||
<option value="<%= key %>"><%= languages[key] %></option>
|
||||
<% }) %>
|
||||
@ -98,7 +98,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<input id="directUrl" type="checkbox" class="checkbox collectable" name="directUrl" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
@ -107,7 +107,7 @@
|
||||
</table>
|
||||
|
||||
<div class="links-panel links-panel-border clearFix">
|
||||
<a href="<%= serverUrl %>/wopi" class="">Go to WOPI page</a>
|
||||
<a href="wopi" class="">Go to WOPI page</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -154,33 +154,33 @@
|
||||
<% for (var i = 0; i < storedFiles.length; i++) { %>
|
||||
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<span><%= storedFiles[i].name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (storedFiles[i].canEdit) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/desktop.svg" 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=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment" /></a>
|
||||
</td>
|
||||
<% if (storedFiles[i].documentType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/review.svg" alt="Open in editor for review" title="Open in editor for review" /></a>
|
||||
</td>
|
||||
<% } else if (storedFiles[i].documentType == "cell") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (storedFiles[i].documentType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification" /></a>
|
||||
</td>
|
||||
<% } else { %>
|
||||
@ -189,44 +189,44 @@
|
||||
<% if (storedFiles[i].documentType !== "word" && storedFiles[i].documentType !== "cell") {%>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<% } %>
|
||||
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
|
||||
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
|
||||
</td>
|
||||
<% } else {%>
|
||||
<td class="contentCells contentCells-icon"></td>
|
||||
<%}%>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>
|
||||
</td>
|
||||
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
|
||||
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" /></a>
|
||||
</td>
|
||||
<% } else { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon firstContentCellViewers">
|
||||
<a href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/desktop.svg" 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">
|
||||
<a class="action-link" href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
<a class="action-link" href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
|
||||
<img src="images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift downloadContentCellShift">
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
<body>
|
||||
<header>
|
||||
<div class="center">
|
||||
<a href="">
|
||||
<a href="wopi">
|
||||
<img src="images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
@ -51,16 +51,16 @@
|
||||
<div class="create-panel clearFix">
|
||||
<ul class="try-editor-list clearFix">
|
||||
<li>
|
||||
<a class="try-editor word reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=docx<%= params %>" title="Create new document">Document</a>
|
||||
<a class="try-editor word reload-page action-link" target="_blank" href="wopi-new?fileExt=docx" title="Create new document">Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor cell reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
|
||||
<a class="try-editor cell reload-page action-link" target="_blank" href="wopi-new?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor slide reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
|
||||
<a class="try-editor slide reload-page action-link" target="_blank" href="wopi-new?fileExt=pptx" title="Create new presentation">Presentation</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor form reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
|
||||
<a class="try-editor form reload-page action-link" target="_blank" href="wopi-new?fileExt=docxf" title="Create new form template">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
<div class="upload-panel clearFix">
|
||||
<a class="file-upload">Upload file
|
||||
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
|
||||
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img id="info" class="info" data-id="user" src="images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<select class="select-user collectable" name="userid" id="user">
|
||||
<% users.forEach(user => { %>
|
||||
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
|
||||
<% }) %>
|
||||
@ -89,7 +89,7 @@
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<select class="select-user collectable" name="lang" id="language">
|
||||
<% Object.keys(languages).forEach(key => { %>
|
||||
<option value="<%= key %>"><%= languages[key] %></option>
|
||||
<% }) %>
|
||||
@ -100,7 +100,7 @@
|
||||
</table>
|
||||
|
||||
<div class="links-panel links-panel-border clearFix">
|
||||
<a href="<%= serverUrl %>/" class="">Go to Index page</a>
|
||||
<a href="./" class="">Go to Index page</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -148,7 +148,7 @@
|
||||
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
|
||||
<td class="contentCells">
|
||||
<% if (storedFiles[i].defaultAction) { %>
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="<%= serverUrl %>/wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %><%= params %>" target="_blank">
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %>" target="_blank">
|
||||
<%} else { %>
|
||||
<a class="stored-edit <%= storedFiles[i].documentType %>" href="#">
|
||||
<% } %>
|
||||
@ -158,7 +158,7 @@
|
||||
<% if (storedFiles[i].actions && storedFiles[i].actions.length > 0) { %>
|
||||
<td class="contentCells contentCells-wopi contentCells-shift">
|
||||
<% for (var j = 0; j < storedFiles[i].actions.length; j++) { %>
|
||||
<a href="<%= serverUrl %>/wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %><%= params %>" target="_blank">
|
||||
<a class="action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %>" target="_blank">
|
||||
<img
|
||||
src="images/wopi-<%= storedFiles[i].actions[j].name %>.svg"
|
||||
alt="<%= storedFiles[i].actions[j].name %>" title="<%= storedFiles[i].actions[j].name %>" />
|
||||
@ -167,7 +167,7 @@
|
||||
</td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon contentCells-shift downloadContentCells">
|
||||
<a href="<%= serverUrl %>/wopi/files/<%= encodeURIComponent(storedFiles[i].name) %>/contents">
|
||||
<a href="wopi/files/<%= encodeURIComponent(storedFiles[i].name) %>/contents">
|
||||
<img class="icon-download" src="images/download.svg" alt="Download" title="Download" /></a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
@ -252,7 +252,8 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.iframe-transport.js"></script>
|
||||
|
||||
2
web/documentserver-example/php/.gitignore
vendored
Normal file
2
web/documentserver-example/php/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
logs
|
||||
vendor
|
||||
1
web/documentserver-example/php/.php-version
Normal file
1
web/documentserver-example/php/.php-version
Normal file
@ -0,0 +1 @@
|
||||
8.1.21
|
||||
@ -1,9 +1,5 @@
|
||||
ONLYOFFICE Applications example uses code from the following 3rd party projects:
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
|
||||
License: MIT, GPL
|
||||
License File: jQuery.BlockUI.license
|
||||
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
|
||||
License: MIT
|
||||
License File: jQuery.iframe-transport.license
|
||||
|
||||
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.license
|
||||
|
||||
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
License: OpenJS
|
||||
License File: jQuery.Migrate.license
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
@ -31,3 +31,7 @@ License File: jwt.license
|
||||
PHP_CodeSniffer - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. (https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)
|
||||
License: BSD-3-Clause
|
||||
License File: PHP_CodeSniffer.license
|
||||
|
||||
PHPUnit - The PHP Unit Testing framework. (https://github.com/sebastianbergmann/phpunit/blob/main/LICENSE)
|
||||
License: BSD 3-Clause
|
||||
License File: phpunit.license
|
||||
|
||||
80
web/documentserver-example/php/Makefile
Normal file
80
web/documentserver-example/php/Makefile
Normal file
@ -0,0 +1,80 @@
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
ADDRESS := $(ADDRESS)
|
||||
PORT := $(PORT)
|
||||
|
||||
.PHONY: help
|
||||
help: # Show help message for each of the Makefile recipes.
|
||||
@grep -E "^[a-z-]+: #" $(MAKEFILE_LIST) | \
|
||||
awk 'BEGIN {FS = ": # "}; {printf "%s: %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: dev
|
||||
dev: # Install development dependencies.
|
||||
@composer install
|
||||
|
||||
.PHONY: prod
|
||||
prod: # Install production dependencies.
|
||||
@composer install --no-dev
|
||||
|
||||
ifeq ($(ADDRESS),)
|
||||
server-dev: \
|
||||
export ADDRESS := localhost
|
||||
else
|
||||
server-dev: \
|
||||
export ADDRESS := $(ADDRESS)
|
||||
endif
|
||||
|
||||
ifeq ($(PORT),)
|
||||
server-dev: \
|
||||
export PORT := 9000
|
||||
else
|
||||
server-dev: \
|
||||
export PORT := $(PORT)
|
||||
endif
|
||||
|
||||
.PHONY: server-dev
|
||||
server-dev: # Start the development server on localhost at $PORT (default: 9000).
|
||||
@php --server $(ADDRESS):$(PORT)
|
||||
|
||||
ifeq ($(ADDRESS),)
|
||||
server-prod: \
|
||||
export ADDRESS := 0.0.0.0
|
||||
else
|
||||
server-prod: \
|
||||
export ADDRESS := $(ADDRESS)
|
||||
endif
|
||||
|
||||
ifeq ($(PORT),)
|
||||
server-prod: \
|
||||
export PORT := 9000
|
||||
else
|
||||
server-prod: \
|
||||
export PORT := $(PORT)
|
||||
endif
|
||||
|
||||
.PHONY: server-prod
|
||||
server-prod: # Start the production server on 0.0.0.0 at $PORT (default: 9000).
|
||||
@php-fpm --fpm-config php-fpm.conf
|
||||
|
||||
.PHONY: lint
|
||||
lint: # Lint the source code for the style.
|
||||
@./vendor/bin/phpcs .
|
||||
|
||||
.PHONY: test
|
||||
test: # Run tests recursively.
|
||||
@./vendor/bin/phpunit \
|
||||
--test-suffix "Tests.php" \
|
||||
--display-incomplete \
|
||||
--display-deprecations \
|
||||
--display-errors \
|
||||
--display-notices \
|
||||
--display-warnings \
|
||||
common
|
||||
@./vendor/bin/phpunit \
|
||||
--test-suffix "Tests.php" \
|
||||
--display-incomplete \
|
||||
--display-deprecations \
|
||||
--display-errors \
|
||||
--display-notices \
|
||||
--display-warnings \
|
||||
configuration
|
||||
@ -34,6 +34,7 @@ You can use any web server capable of running PHP code to run the example. We wi
|
||||
* **IIS**: version 7 or later (refer to [Microsoft official website](https://www.iis.net/learn/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php) to learn how to install IIS);
|
||||
* **PHP** (download it from the [http://php.net](https://php.net/downloads.php) site);
|
||||
* **PHP Manager for IIS** (download it from the [Microsoft open source site](https://phpmanager.codeplex.com/releases/view/69115)).
|
||||
* **Composer** (download it from the [Composer official website](https://getcomposer.org/download/)).
|
||||
|
||||
### Step 4. IIS configuration
|
||||
|
||||
@ -78,7 +79,13 @@ You can use any web server capable of running PHP code to run the example. We wi
|
||||
|
||||
After IIS manager configuration is complete, everything is ready for running the PHP example.
|
||||
|
||||
### Step 5. Run your website with the editors
|
||||
### Step 5. Run *composer install*:
|
||||
|
||||
```
|
||||
php composer.phar install
|
||||
```
|
||||
|
||||
### Step 6. Run your website with the editors
|
||||
|
||||
1. Add your website in the IIS Manager.
|
||||
|
||||
@ -100,7 +107,7 @@ You can use any web server capable of running PHP code to run the example. We wi
|
||||
|
||||

|
||||
|
||||
### Step 6. Check accessibility
|
||||
### Step 7. Check accessibility
|
||||
|
||||
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
|
||||
|
||||
@ -124,8 +131,11 @@ See the detailed guide to learn how to [install Document Server for Linux](https
|
||||
|
||||
2. Install **Composer**:
|
||||
|
||||
To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
|
||||
|
||||
```
|
||||
instructions should be here
|
||||
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
|
||||
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||
```
|
||||
|
||||
3. Download the archive with the PHP example and unpack the archive:
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
namespace OnlineEditorsExamplePhp;
|
||||
|
||||
use Exception;
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\ConfigManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\ExampleUsers;
|
||||
use OnlineEditorsExamplePhp\Helpers\JwtManager;
|
||||
@ -47,41 +49,6 @@ function getHttpOrigin()
|
||||
return $origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set headers that prevent caching in all the browsers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function nocacheHeaders()
|
||||
{
|
||||
$headers = [
|
||||
'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
|
||||
'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
|
||||
'Pragma' => 'no-cache',
|
||||
];
|
||||
$headers['Last-Modified'] = false;
|
||||
|
||||
unset($headers['Last-Modified']);
|
||||
|
||||
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
|
||||
if (function_exists('header_remove')) {
|
||||
@header_remove('Last-Modified');
|
||||
} else {
|
||||
// In PHP 5.2, send an empty Last-Modified header, but only as a
|
||||
// last resort to override a header already sent. #WP23021
|
||||
foreach (headers_list() as $header) {
|
||||
if (0 === mb_stripos($header, 'Last-Modified')) {
|
||||
$headers['Last-Modified'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($headers as $name => $field_value) {
|
||||
@header("{$name}: {$field_value}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save copy as...
|
||||
*
|
||||
@ -90,20 +57,17 @@ function nocacheHeaders()
|
||||
function saveas()
|
||||
{
|
||||
try {
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$post = json_decode(file_get_contents('php://input'), true);
|
||||
$fileurl = $post["url"];
|
||||
$title = $post["title"];
|
||||
$extension = mb_strtolower(pathinfo($title, PATHINFO_EXTENSION));
|
||||
$configManager = new ConfigManager();
|
||||
$allexts = array_merge(
|
||||
$configManager->getConfig("docServConvert"),
|
||||
$configManager->getConfig("docServEdited"),
|
||||
$configManager->getConfig("docServViewd"),
|
||||
$configManager->getConfig("docServFillforms")
|
||||
);
|
||||
$allexts = $configManager->getSuppotredExtensions();
|
||||
$filename = GetCorrectName($title);
|
||||
|
||||
if (!in_array("." . $extension, $allexts)) {
|
||||
if (!in_array($extension, $allexts)) {
|
||||
$result["error"] = "File type is not supported";
|
||||
return $result;
|
||||
}
|
||||
@ -111,8 +75,7 @@ function saveas()
|
||||
$content_length = $headers["Content-Length"];
|
||||
$data = file_get_contents(str_replace(" ", "%20", $fileurl));
|
||||
|
||||
if ($data === false || $content_length <= 0 || $content_length >
|
||||
$configManager->getConfig("fileSizeMax")) {
|
||||
if ($data === false || $content_length <= 0 || $content_length > $config_manager->maximum_file_size()) {
|
||||
$result["error"] = "File size is incorrect";
|
||||
return $result;
|
||||
}
|
||||
@ -138,6 +101,8 @@ function saveas()
|
||||
*/
|
||||
function upload()
|
||||
{
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$configManager = new ConfigManager();
|
||||
if ($_FILES['files']['error'] > 0) {
|
||||
$result["error"] = 'Error ' . json_encode($_FILES['files']['error']);
|
||||
@ -156,16 +121,16 @@ function upload()
|
||||
// check if the file was uploaded using HTTP POST
|
||||
if (is_uploaded_file($tmp)) {
|
||||
$filesize = $_FILES['files']['size']; // get the file size
|
||||
$ext = mb_strtolower('.' . pathinfo($_FILES['files']['name'], PATHINFO_EXTENSION)); // get file extension
|
||||
$ext = mb_strtolower(pathinfo($_FILES['files']['name'], PATHINFO_EXTENSION)); // get file extension
|
||||
|
||||
// check if the file size is correct (it should be less than the max file size, but greater than 0)
|
||||
if ($filesize <= 0 || $filesize > $configManager->getConfig("fileSizeMax")) {
|
||||
if ($filesize <= 0 || $filesize > $config_manager->maximum_file_size()) {
|
||||
$result["error"] = 'File size is incorrect'; // if not, then an error occurs
|
||||
return $result;
|
||||
}
|
||||
|
||||
// check if the file extension is supported by the editor
|
||||
if (!in_array($ext, getFileExts())) {
|
||||
if (!in_array($ext, $configManager->getSuppotredExtensions())) {
|
||||
$result["error"] = 'File type is not supported'; // if not, then an error occurs
|
||||
return $result;
|
||||
}
|
||||
@ -208,7 +173,15 @@ function track()
|
||||
return $data;
|
||||
}
|
||||
|
||||
global $_trackerStatus;
|
||||
$_trackerStatus = [
|
||||
0 => 'NotFound',
|
||||
1 => 'Editing',
|
||||
2 => 'MustSave',
|
||||
3 => 'Corrupted',
|
||||
4 => 'Closed',
|
||||
6 => 'MustForceSave',
|
||||
7 => 'CorruptedForceSave',
|
||||
];
|
||||
$status = $_trackerStatus[$data->status]; // get status from the request body
|
||||
|
||||
$userAddress = $_GET["userAddress"];
|
||||
@ -250,20 +223,19 @@ function convert()
|
||||
$post = json_decode(file_get_contents('php://input'), true);
|
||||
$fileName = basename($post["filename"]);
|
||||
$filePass = $post["filePass"];
|
||||
$lang = $_COOKIE["ulang"];
|
||||
$lang = $_COOKIE["ulang"] ?? "";
|
||||
$extension = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$internalExtension = "ooxml";
|
||||
$configManager = new ConfigManager();
|
||||
|
||||
// check if the file with such an extension can be converted
|
||||
if (in_array("." . $extension, $configManager->getConfig("docServConvert")) &&
|
||||
if (in_array($extension, $configManager->getConvertExtensions()) &&
|
||||
$internalExtension != "") {
|
||||
$fileUri = $post["fileUri"];
|
||||
if ($fileUri == null || $fileUri == "") {
|
||||
$fileUri = serverPath(true) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=download"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "download"
|
||||
. "?fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
$key = getDocEditorKey($fileName);
|
||||
@ -369,7 +341,8 @@ function assets()
|
||||
{
|
||||
$fileName = basename($_GET["name"]);
|
||||
$filePath = dirname(__FILE__) .
|
||||
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
|
||||
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates"
|
||||
. DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
|
||||
downloadFile($filePath);
|
||||
}
|
||||
|
||||
@ -382,7 +355,8 @@ function csv()
|
||||
{
|
||||
$fileName = "csv.csv";
|
||||
$filePath = dirname(__FILE__) .
|
||||
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
|
||||
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates"
|
||||
. DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
|
||||
downloadFile($filePath);
|
||||
}
|
||||
|
||||
@ -394,6 +368,8 @@ function csv()
|
||||
function historyDownload()
|
||||
{
|
||||
try {
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$fileName = basename($_GET["fileName"]); // get the file name
|
||||
$userAddress = $_GET["userAddress"];
|
||||
|
||||
@ -403,8 +379,7 @@ function historyDownload()
|
||||
$jwtManager = new JwtManager();
|
||||
if ($jwtManager->isJwtEnabled()) {
|
||||
$configManager = new ConfigManager();
|
||||
$jwtHeader = $configManager->getConfig("docServJwtHeader") == "" ?
|
||||
"Authorization" : $configManager->getConfig("docServJwtHeader");
|
||||
$jwtHeader = $config_manager->jwt_header();
|
||||
if (!empty(apache_request_headers()[$jwtHeader])) {
|
||||
$token = $jwtManager->jwtDecode(mb_substr(
|
||||
apache_request_headers()[$jwtHeader],
|
||||
@ -441,17 +416,15 @@ function historyDownload()
|
||||
function download()
|
||||
{
|
||||
try {
|
||||
$configManager = new ConfigManager();
|
||||
$fileName = realpath($configManager->getConfig("storagePath"))
|
||||
=== $configManager->getConfig("storagePath") ?
|
||||
$_GET["fileName"] : basename($_GET["fileName"]); // get the file name
|
||||
$userAddress = $_GET["userAddress"];
|
||||
$isEmbedded = $_GET["&dmode"];
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$fileName = $_GET["fileName"];
|
||||
$userAddress = $_GET["userAddress"] ?? null;
|
||||
$isEmbedded = $_GET["&dmode"] ?? null;
|
||||
$jwtManager = new JwtManager();
|
||||
|
||||
if ($jwtManager->isJwtEnabled() && $isEmbedded == null && $userAddress) {
|
||||
$jwtHeader = $configManager->getConfig("docServJwtHeader") == "" ?
|
||||
"Authorization" : $configManager->getConfig("docServJwtHeader");
|
||||
$jwtHeader = $config_manager->jwt_header();
|
||||
if (!empty(apache_request_headers()[$jwtHeader])) {
|
||||
$token = $jwtManager->jwtDecode(mb_substr(
|
||||
apache_request_headers()[$jwtHeader],
|
||||
@ -491,8 +464,9 @@ function downloadFile($filePath)
|
||||
|
||||
// write headers to the response object
|
||||
@header('Content-Length: ' . filesize($filePath));
|
||||
@header('Content-Disposition: attachment; filename*=UTF-8\'\'' . urldecode(basename($filePath)));
|
||||
@header('Content-Disposition: attachment; filename*=UTF-8\'\'' . str_replace("+", "%20", urlencode(basename($filePath))));
|
||||
@header('Content-Type: ' . mime_content_type($filePath));
|
||||
@header('Access-Control-Allow-Origin: *');
|
||||
|
||||
if ($fd = fopen($filePath, 'rb')) {
|
||||
while (!feof($fd)) {
|
||||
@ -588,9 +562,9 @@ function reference()
|
||||
}
|
||||
|
||||
$data = [
|
||||
"fileType" => getInternalExtension($fileName),
|
||||
"fileType" => trim(getInternalExtension($fileName), '.'),
|
||||
"url" => getDownloadUrl($fileName),
|
||||
"directUrl" => $post["directUrl"] ? getDownloadUrl($fileName) : getDownloadUrl($fileName, false),
|
||||
"directUrl" => $post["directUrl"] ? getDownloadUrl($fileName, false) : null,
|
||||
"referenceData" => [
|
||||
"fileKey" => json_encode([
|
||||
"fileName" => $fileName,
|
||||
@ -607,3 +581,74 @@ function reference()
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function restore()
|
||||
{
|
||||
try {
|
||||
$input = file_get_contents('php://input');
|
||||
$body = json_decode($input);
|
||||
|
||||
$source_basename = $body->fileName;
|
||||
$version = $body->version;
|
||||
$user_id = $body->userId;
|
||||
|
||||
$source_file = getStoragePath($source_basename);
|
||||
$history_directory = getHistoryDir($source_file);
|
||||
|
||||
$bumped_version = getFileVersion($history_directory);
|
||||
$bumped_version_string_directory = getVersionDir($history_directory, $bumped_version);
|
||||
if (!file_exists($bumped_version_string_directory)) {
|
||||
mkdir($bumped_version_string_directory);
|
||||
}
|
||||
$bumped_version_directory = new Path($bumped_version_string_directory);
|
||||
|
||||
$bumped_key_file = $bumped_version_directory->join_path('key.txt');
|
||||
$bumped_key_string_file = $bumped_key_file->string();
|
||||
$bumped_key = getDocEditorKey($source_basename);
|
||||
file_put_contents($bumped_key_string_file, $bumped_key, LOCK_EX);
|
||||
|
||||
$users = new ExampleUsers();
|
||||
$user = $users->getUser($user_id);
|
||||
|
||||
$bumped_changes_file = $bumped_version_directory->join_path('changes.json');
|
||||
$bumped_changes_string_file = $bumped_changes_file->string();
|
||||
$bumped_changes = [
|
||||
'serverVersion' => null,
|
||||
'changes' => array(
|
||||
[
|
||||
'created' => date('Y-m-d H:i:s'),
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name
|
||||
]
|
||||
]
|
||||
)
|
||||
];
|
||||
$bumped_changes_content = json_encode($bumped_changes, JSON_PRETTY_PRINT);
|
||||
file_put_contents($bumped_changes_string_file, $bumped_changes_content, LOCK_EX);
|
||||
|
||||
$source_extension = pathinfo($source_basename, PATHINFO_EXTENSION);
|
||||
$previous_basename = "prev.{$source_extension}";
|
||||
|
||||
$bumped_file = $bumped_version_directory->join_path($previous_basename);
|
||||
$bumped_string_file = $bumped_file->string();
|
||||
copy($source_file, $bumped_string_file);
|
||||
|
||||
$recovery_version_string_directory = getVersionDir($history_directory, $version);
|
||||
$recovery_version_directory = new Path($recovery_version_string_directory);
|
||||
$recovery_file = $recovery_version_directory->join_path($previous_basename);
|
||||
$recovery_string_file = $recovery_file->string();
|
||||
copy($recovery_string_file, $source_file);
|
||||
|
||||
return [
|
||||
'error' => null,
|
||||
'success' => true
|
||||
];
|
||||
} catch (Exception $error) {
|
||||
$message = $error->getMessage();
|
||||
return [
|
||||
'error' => $message,
|
||||
'success' => false
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Submodule web/documentserver-example/php/assets/document-formats added at 6e38b17679
22
web/documentserver-example/php/common/HTTPStatus.php
Normal file
22
web/documentserver-example/php/common/HTTPStatus.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Common;
|
||||
|
||||
enum HTTPStatus: int {
|
||||
case not_found = 404;
|
||||
}
|
||||
127
web/documentserver-example/php/common/Path.php
Normal file
127
web/documentserver-example/php/common/Path.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Common;
|
||||
|
||||
final class Path {
|
||||
private string $separator = DIRECTORY_SEPARATOR;
|
||||
private string $string;
|
||||
|
||||
public function __construct(string $path) {
|
||||
$this->string = $path;
|
||||
}
|
||||
|
||||
public function string(): string {
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public function dirname(): ?string {
|
||||
$string = $this->string();
|
||||
$parsed = pathinfo($string, PATHINFO_DIRNAME);
|
||||
return $parsed ?: null;
|
||||
}
|
||||
|
||||
public function basename(): ?string {
|
||||
$string = $this->string();
|
||||
$parsed = pathinfo($string, PATHINFO_BASENAME);
|
||||
return $parsed ?: null;
|
||||
}
|
||||
|
||||
public function extension(): ?string {
|
||||
$string = $this->string();
|
||||
$parsed = pathinfo($string, PATHINFO_EXTENSION);
|
||||
return $parsed ?: null;
|
||||
}
|
||||
|
||||
public function filename(): ?string {
|
||||
$string = $this->string();
|
||||
$parsed = pathinfo($string, PATHINFO_FILENAME);
|
||||
return $parsed ?: null;
|
||||
}
|
||||
|
||||
public function normalize(): self {
|
||||
$string = $this->string();
|
||||
$filtered = array();
|
||||
$slugs = explode($this->separator, $string);
|
||||
foreach ($slugs as $slug) {
|
||||
if ($slug === '.') {
|
||||
continue;
|
||||
}
|
||||
if ($slug === '..') {
|
||||
array_pop($filtered);
|
||||
continue;
|
||||
}
|
||||
$filtered[] = $slug;
|
||||
}
|
||||
$joined = implode($this->separator, $filtered);
|
||||
$escaped_separator = preg_quote($this->separator, $this->separator);
|
||||
$separator_regex = "/{$escaped_separator}{2,}/";
|
||||
$separated = preg_replace($separator_regex, $this->separator, $joined);
|
||||
return new Path($separated);
|
||||
}
|
||||
|
||||
public function join_path(string $path): self {
|
||||
$string = $this->string();
|
||||
$separator =
|
||||
str_ends_with($string, $this->separator) ||
|
||||
str_starts_with($path, $this->separator)
|
||||
? ''
|
||||
: $this->separator;
|
||||
return new Path("{$string}{$separator}{$path}");
|
||||
}
|
||||
|
||||
public function absolute(): bool {
|
||||
$string = $this->string();
|
||||
|
||||
$nt_regex = '/^[A-Za-z]:\\\\/';
|
||||
if (preg_match($nt_regex, $string)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$nt_separator = '\\';
|
||||
if (str_starts_with($string, $nt_separator)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$posix_separator = '/';
|
||||
if (str_starts_with($string, $posix_separator)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function exists(): bool {
|
||||
$string = $this->string();
|
||||
return file_exists($string);
|
||||
}
|
||||
|
||||
public function contents(): string {
|
||||
$string = $this->string();
|
||||
return file_get_contents($string);
|
||||
}
|
||||
|
||||
public function directory(): bool {
|
||||
$string = $this->string();
|
||||
return is_dir($string);
|
||||
}
|
||||
|
||||
public function make_directory(): bool {
|
||||
$string = $this->string();
|
||||
return mkdir($string);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
|
||||
final class PathAbsolutePOSIXTests extends TestCase {
|
||||
public function test_recognizes_an_empty_as_a_non_absolute() {
|
||||
$path = new Path('');
|
||||
$absolute = $path->absolute();
|
||||
$this->assertFalse($absolute);
|
||||
}
|
||||
|
||||
public function test_recognizes_a_relative_as_a_non_absolute() {
|
||||
$path = new Path('.');
|
||||
$absolute = $path->absolute();
|
||||
$this->assertFalse($absolute);
|
||||
}
|
||||
|
||||
public function test_recognizes_an_absolute_as_an_absolute() {
|
||||
$path = new Path('/');
|
||||
$absolute = $path->absolute();
|
||||
$this->assertTrue($absolute);
|
||||
}
|
||||
}
|
||||
84
web/documentserver-example/php/common/PathJoinPOSIXTests.php
Normal file
84
web/documentserver-example/php/common/PathJoinPOSIXTests.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
|
||||
final class PathJoinPOSIXTests extends TestCase {
|
||||
public function test_joins_a_relative_to_an_empty_one() {
|
||||
$path = new Path('');
|
||||
$joined = $path->join_path('srv');
|
||||
$this->assertEquals($joined->dirname(), '/');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_a_relative_to_a_relative_one() {
|
||||
$path = new Path('.');
|
||||
$joined = $path->join_path('srv');
|
||||
$this->assertEquals($joined->dirname(), '.');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_a_relative_to_an_absolute_one() {
|
||||
$path = new Path('/');
|
||||
$joined = $path->join_path('srv');
|
||||
$this->assertEquals($joined->dirname(), '/');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_an_absolute_to_an_empty_one() {
|
||||
$path = new Path('');
|
||||
$joined = $path->join_path('/srv');
|
||||
$this->assertEquals($joined->dirname(), '/');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_an_absolute_to_a_relative_one() {
|
||||
$path = new Path('.');
|
||||
$joined = $path->join_path('/srv');
|
||||
$this->assertEquals($joined->dirname(), '.');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_an_absolute_to_an_absolute_one() {
|
||||
$path = new Path('/');
|
||||
$joined = $path->join_path('/srv');
|
||||
$this->assertEquals($joined->dirname(), '/');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
|
||||
public function test_joins_an_unnormalized() {
|
||||
$path = new Path('');
|
||||
$joined = $path->join_path('../srv');
|
||||
$this->assertEquals($joined->dirname(), '/..');
|
||||
$this->assertEquals($joined->basename(), 'srv');
|
||||
$this->assertEquals($joined->extension(), null);
|
||||
$this->assertEquals($joined->filename(), 'srv');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
|
||||
final class PathNormalizePOSIXTests extends TestCase {
|
||||
public function test_normalizes() {
|
||||
$path = new Path('./srv///sub/.././sub/file.docx');
|
||||
$normalized = $path->normalize();
|
||||
$this->assertEquals($normalized->dirname(), 'srv/sub');
|
||||
$this->assertEquals($normalized->basename(), 'file.docx');
|
||||
$this->assertEquals($normalized->extension(), 'docx');
|
||||
$this->assertEquals($normalized->filename(), 'file');
|
||||
}
|
||||
}
|
||||
150
web/documentserver-example/php/common/PathStringPOSIXTests.php
Normal file
150
web/documentserver-example/php/common/PathStringPOSIXTests.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
|
||||
final class PathStringPOSIXTests extends TestCase {
|
||||
public function test_generates_with_an_empty() {
|
||||
$path = new Path('');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_empty_relative() {
|
||||
$path = new Path('.');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '.');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_empty_absolute() {
|
||||
$path = new Path('/');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/');
|
||||
}
|
||||
|
||||
public function test_generates_with_a_relative() {
|
||||
$path = new Path('srv');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, 'srv');
|
||||
}
|
||||
|
||||
public function test_generates_with_a_relative_containing_a_directory() {
|
||||
$path = new Path('srv/sub');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, 'srv/sub');
|
||||
}
|
||||
|
||||
public function test_generates_with_a_relative_containing_a_file() {
|
||||
$path = new Path('srv/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, 'srv/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_a_relative_containing_a_directory_with_a_file() {
|
||||
$path = new Path('srv/sub/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, 'srv/sub/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_unnormalized_relative() {
|
||||
$path = new Path('srv////sub///file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, 'srv////sub///file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_normalized_relative() {
|
||||
$path = new Path('srv////sub///file.json');
|
||||
$normalized = $path->normalize();
|
||||
$string = $normalized->string();
|
||||
$this->assertEquals($string, 'srv/sub/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_relative() {
|
||||
$path = new Path('./srv');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, './srv');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_relative_containing_a_directory() {
|
||||
$path = new Path('./srv/sub');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, './srv/sub');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_relative_containing_a_file() {
|
||||
$path = new Path('./srv/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, './srv/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_relative_containing_a_directory_with_a_file() {
|
||||
$path = new Path('./srv/sub/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, './srv/sub/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_unnormalized_relative() {
|
||||
$path = new Path('./srv////sub///file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, './srv////sub///file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_explicit_normalized_relative() {
|
||||
$path = new Path('./srv////sub///file.json');
|
||||
$normalized = $path->normalize();
|
||||
$string = $normalized->string();
|
||||
$this->assertEquals($string, 'srv/sub/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_absolute() {
|
||||
$path = new Path('/srv');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/srv');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_absolute_containing_a_directory() {
|
||||
$path = new Path('/srv/sub');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/srv/sub');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_absolute_containing_a_file() {
|
||||
$path = new Path('/srv/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/srv/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_absolute_containing_a_directory_with_a_file() {
|
||||
$path = new Path('/srv/sub/file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/srv/sub/file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_unnormalized_absolute() {
|
||||
$path = new Path('/srv////sub///file.json');
|
||||
$string = $path->string();
|
||||
$this->assertEquals($string, '/srv////sub///file.json');
|
||||
}
|
||||
|
||||
public function test_generates_with_an_normalized_absolute() {
|
||||
$path = new Path('/srv////sub///file.json');
|
||||
$normalized = $path->normalize();
|
||||
$string = $normalized->string();
|
||||
$this->assertEquals($string, '/srv/sub/file.json');
|
||||
}
|
||||
}
|
||||
132
web/documentserver-example/php/common/URL.php
Normal file
132
web/documentserver-example/php/common/URL.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Common;
|
||||
|
||||
final class URL {
|
||||
private string $string;
|
||||
|
||||
public function __construct(string $url) {
|
||||
$this->string = $url;
|
||||
}
|
||||
|
||||
public function string(): string {
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public function scheme(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_SCHEME) ?: null;
|
||||
}
|
||||
|
||||
public function host(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_HOST) ?: null;
|
||||
}
|
||||
|
||||
public function port(): ?int {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_PORT) ?: null;
|
||||
}
|
||||
|
||||
public function user(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_USER) ?: null;
|
||||
}
|
||||
|
||||
public function pass(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_PASS) ?: null;
|
||||
}
|
||||
|
||||
public function path(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_PATH) ?: null;
|
||||
}
|
||||
|
||||
public function query(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_QUERY) ?: null;
|
||||
}
|
||||
|
||||
public function fragment(): ?string {
|
||||
$string = $this->string();
|
||||
return parse_url($string, PHP_URL_FRAGMENT) ?: null;
|
||||
}
|
||||
|
||||
public static function from_components(
|
||||
?string $scheme,
|
||||
?string $host,
|
||||
?int $port,
|
||||
?string $user,
|
||||
?string $pass,
|
||||
?string $path,
|
||||
?string $query,
|
||||
?string $fragment
|
||||
): URL {
|
||||
$string = '';
|
||||
if ($scheme) {
|
||||
$string .= "{$scheme}://";
|
||||
}
|
||||
if ($user) {
|
||||
$string .= $user;
|
||||
}
|
||||
if ($pass) {
|
||||
$string .= ":{$pass}@";
|
||||
}
|
||||
if ($host) {
|
||||
$string .= $host;
|
||||
}
|
||||
if ($port) {
|
||||
$string .= ":{$port}";
|
||||
}
|
||||
if ($path) {
|
||||
$string .= $path;
|
||||
}
|
||||
if ($query) {
|
||||
$string .= "?{$query}";
|
||||
}
|
||||
if ($fragment) {
|
||||
$string .= "#{$fragment}";
|
||||
}
|
||||
return new URL($string);
|
||||
}
|
||||
|
||||
public function join_path(string $path): self {
|
||||
$current_path = $this->path();
|
||||
$separator =
|
||||
$current_path &&
|
||||
(
|
||||
str_ends_with($current_path, '/') ||
|
||||
str_starts_with($path, '/')
|
||||
) ||
|
||||
!$current_path && str_starts_with($path, '/')
|
||||
? ''
|
||||
: '/';
|
||||
$separated = "{$current_path}{$separator}{$path}";
|
||||
return URL::from_components(
|
||||
$this->scheme(),
|
||||
$this->host(),
|
||||
$this->port(),
|
||||
$this->user(),
|
||||
$this->pass(),
|
||||
$separated,
|
||||
$this->query(),
|
||||
$this->fragment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\URL;
|
||||
|
||||
final class URLFromComponentsTests extends TestCase {
|
||||
public function test_creates() {
|
||||
$url = URL::from_components(
|
||||
'http',
|
||||
'localhost',
|
||||
8080,
|
||||
'user',
|
||||
'password',
|
||||
'/path',
|
||||
'q=value',
|
||||
'fragment'
|
||||
);
|
||||
$this->assertEquals('http', $url->scheme());
|
||||
$this->assertEquals('localhost', $url->host());
|
||||
$this->assertEquals(8080, $url->port());
|
||||
$this->assertEquals('user', $url->user());
|
||||
$this->assertEquals('password', $url->pass());
|
||||
$this->assertEquals('/path', $url->path());
|
||||
$this->assertEquals('q=value', $url->query());
|
||||
$this->assertEquals('fragment', $url->fragment());
|
||||
}
|
||||
}
|
||||
73
web/documentserver-example/php/common/URLJoinPathTests.php
Normal file
73
web/documentserver-example/php/common/URLJoinPathTests.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\URL;
|
||||
|
||||
final class URLJoinPathTests extends TestCase {
|
||||
public function test_joins_a_relative_to_an_empty_one() {
|
||||
$url = new URL('http://localhost');
|
||||
$joined = $url->join_path('first');
|
||||
$this->assertEquals('http', $joined->scheme());
|
||||
$this->assertEquals('localhost', $joined->host());
|
||||
$this->assertEquals(null, $joined->port());
|
||||
$this->assertEquals(null, $joined->user());
|
||||
$this->assertEquals(null, $joined->pass());
|
||||
$this->assertEquals('/first', $joined->path());
|
||||
$this->assertEquals(null, $joined->query());
|
||||
$this->assertEquals(null, $joined->fragment());
|
||||
}
|
||||
|
||||
public function test_joins_a_relative() {
|
||||
$url = new URL('http://localhost/first');
|
||||
$joined = $url->join_path('second');
|
||||
$this->assertEquals('http', $joined->scheme());
|
||||
$this->assertEquals('localhost', $joined->host());
|
||||
$this->assertEquals(null, $joined->port());
|
||||
$this->assertEquals(null, $joined->user());
|
||||
$this->assertEquals(null, $joined->pass());
|
||||
$this->assertEquals('/first/second', $joined->path());
|
||||
$this->assertEquals(null, $joined->query());
|
||||
$this->assertEquals(null, $joined->fragment());
|
||||
}
|
||||
|
||||
public function test_joins_an_absolute_to_an_empty_one() {
|
||||
$url = new URL('http://localhost');
|
||||
$joined = $url->join_path('/first');
|
||||
$this->assertEquals('http', $joined->scheme());
|
||||
$this->assertEquals('localhost', $joined->host());
|
||||
$this->assertEquals(null, $joined->port());
|
||||
$this->assertEquals(null, $joined->user());
|
||||
$this->assertEquals(null, $joined->pass());
|
||||
$this->assertEquals('/first', $joined->path());
|
||||
$this->assertEquals(null, $joined->query());
|
||||
$this->assertEquals(null, $joined->fragment());
|
||||
}
|
||||
|
||||
public function test_joins_an_absolute() {
|
||||
$url = new URL('http://localhost/first');
|
||||
$joined = $url->join_path('/second');
|
||||
$this->assertEquals('http', $joined->scheme());
|
||||
$this->assertEquals('localhost', $joined->host());
|
||||
$this->assertEquals(null, $joined->port());
|
||||
$this->assertEquals(null, $joined->user());
|
||||
$this->assertEquals(null, $joined->pass());
|
||||
$this->assertEquals('/first/second', $joined->path());
|
||||
$this->assertEquals(null, $joined->query());
|
||||
$this->assertEquals(null, $joined->fragment());
|
||||
}
|
||||
}
|
||||
30
web/documentserver-example/php/common/URLStringTests.php
Normal file
30
web/documentserver-example/php/common/URLStringTests.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Common\URL;
|
||||
|
||||
final class URLStringTests extends TestCase {
|
||||
public function test_generates() {
|
||||
$url = new URL('http://user:password@localhost:8080/path?q=value#fragment');
|
||||
$string = $url->string();
|
||||
$this->assertEquals(
|
||||
'http://user:password@localhost:8080/path?q=value#fragment',
|
||||
$string
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,26 +1,19 @@
|
||||
{
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"firebase/php-jwt": "^6.8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "*",
|
||||
"ext-mbstring": "*"
|
||||
"squizlabs/php_codesniffer": "^3.7.2",
|
||||
"phpunit/phpunit": "^10.2.6"
|
||||
},
|
||||
"scripts": {
|
||||
"code-sniffer": [
|
||||
"./vendor/bin/phpcs --config-set default_standard ruleset.xml",
|
||||
"./vendor/bin/phpcs --config-set colors 1"
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"@code-sniffer"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@code-sniffer"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OnlineEditorsExamplePhp\\" : "",
|
||||
"OnlineEditorsExamplePhp\\Common\\": "common/",
|
||||
"OnlineEditorsExamplePhp\\Configuration\\" : "configuration/",
|
||||
"OnlineEditorsExamplePhp\\Helpers\\" : "helpers/",
|
||||
"OnlineEditorsExamplePhp\\Views\\" : "views/",
|
||||
"Firebase\\JWT\\" : "lib/jwt/"
|
||||
"OnlineEditorsExamplePhp\\Views\\" : "views/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1701
web/documentserver-example/php/composer.lock
generated
1701
web/documentserver-example/php/composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,88 +0,0 @@
|
||||
{
|
||||
"version": "1.5.1",
|
||||
|
||||
"fileSizeMax": 5242880,
|
||||
"storagePath": "",
|
||||
"alone": false,
|
||||
|
||||
"docServFillforms": [".docx", ".oform"],
|
||||
"docServViewd": [".djvu", ".oxps", ".pdf", ".xps"],
|
||||
"docServEdited": [".csv", ".docm", ".docx", ".docxf", ".dotm", ".dotx", ".epub",
|
||||
".fb2", ".html", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".potm", ".potx",
|
||||
".ppsm", ".ppsx", ".pptm", ".pptx", ".rtf", ".txt", ".xlsm", ".xlsx", ".xltm", ".xltx"],
|
||||
"docServConvert": [".doc", ".dot", ".dps", ".dpt", ".epub",
|
||||
".et", ".ett", ".fb2", ".fodp", ".fods", ".fodt", ".htm", ".html",
|
||||
".mht", ".mhtml", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".pot",
|
||||
".pps", ".ppt", ".rtf", ".stw", ".sxc", ".sxi", ".sxw", ".wps", ".wpt", ".xls", ".xlsb", ".xlt", ".xml"],
|
||||
|
||||
"docServTimeout": "120000",
|
||||
"docServSiteUrl": "https://documentserver/",
|
||||
|
||||
"docServConverterUrl": "ConvertService.ashx",
|
||||
"docServApiUrl": "web-apps/apps/api/documents/api.js",
|
||||
"docServPreloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
|
||||
"docServCommandUrl": "coauthoring/CommandService.ashx",
|
||||
|
||||
"docServJwtSecret": "",
|
||||
"docServJwtHeader": "Authorization",
|
||||
"docServJwtUseForRequest": true,
|
||||
|
||||
"docServVerifyPeerOff": true,
|
||||
|
||||
"exampleUrl": "",
|
||||
"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",
|
||||
"extsSpreadsheet": [".xls", ".xlsx", ".xlsm", ".xlsb",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"],
|
||||
"extsPresentation": [".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"],
|
||||
"extsDocument": [".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".xml",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"],
|
||||
"languages": {
|
||||
"en": "English",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"eu": "Basque",
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh-TW": "Chinese (Taiwan)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"gl": "Galego",
|
||||
"de": "German",
|
||||
"el": "Greek",
|
||||
"hu": "Hungarian",
|
||||
"id": "Indonesian",
|
||||
"it": "Italian",
|
||||
"ja": "Japanese",
|
||||
"ko": "Korean",
|
||||
"lo": "Lao",
|
||||
"lv": "Latvian",
|
||||
"ms": "Malay (Malaysia)",
|
||||
"no": "Norwegian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese (Brazil)",
|
||||
"pt-PT": "Portuguese (Portugal)",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"si": "Sinhala (Sri Lanka)",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"es": "Spanish",
|
||||
"sv": "Swedish",
|
||||
"tr": "Turkish",
|
||||
"uk": "Ukrainian",
|
||||
"vi": "Vietnamese",
|
||||
"aa-AA": "Test Language"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
namespace OnlineEditorsExamplePhp\Configuration;
|
||||
|
||||
use OnlineEditorsExamplePhp\Common\Path;
|
||||
use OnlineEditorsExamplePhp\Common\URL;
|
||||
|
||||
final class ConfigurationManager {
|
||||
public string $version = '1.6.0';
|
||||
|
||||
public function example_url(): ?URL {
|
||||
$url = getenv('EXAMPLE_URL');
|
||||
if (!$url) {
|
||||
return null;
|
||||
}
|
||||
return new URL($url);
|
||||
}
|
||||
|
||||
public function document_server_url(): URL {
|
||||
$url = getenv('DOCUMENT_SERVER_URL') ?: 'http://document-server';
|
||||
return new URL($url);
|
||||
}
|
||||
|
||||
public function document_server_api_url(): URL {
|
||||
$server_url = $this->document_server_url();
|
||||
$path = getenv('DOCUMENT_SERVER_API_PATH')
|
||||
?: 'web-apps/apps/api/documents/api.js';
|
||||
return $server_url->join_path($path);
|
||||
}
|
||||
|
||||
public function document_server_preloader_url(): URL {
|
||||
$server_url = $this->document_server_url();
|
||||
$path = getenv('DOCUMENT_SERVER_PRELOADER_PATH')
|
||||
?: 'web-apps/apps/api/documents/cache-scripts.html';
|
||||
return $server_url->join_path($path);
|
||||
}
|
||||
|
||||
public function document_server_command_url(): URL {
|
||||
$server_url = $this->document_server_url();
|
||||
$path = getenv('DOCUMENT_SERVER_COMMAND_PATH')
|
||||
?: 'coauthoring/CommandService.ashx';
|
||||
return $server_url->join_path($path);
|
||||
}
|
||||
|
||||
public function document_server_converter_url(): URL {
|
||||
$server_url = $this->document_server_url();
|
||||
$path = getenv('DOCUMENT_SERVER_CONVERTER_PATH')
|
||||
?: 'ConvertService.ashx';
|
||||
return $server_url->join_path($path);
|
||||
}
|
||||
|
||||
public function jwt_secret(): string {
|
||||
return getenv('JWT_SECRET') ?: '';
|
||||
}
|
||||
|
||||
public function jwt_header(): string {
|
||||
return getenv('JWT_HEADER') ?: 'Authorization';
|
||||
}
|
||||
|
||||
public function jwt_use_for_request(): bool {
|
||||
$use = getenv('JWT_USE_FOR_REQUEST');
|
||||
if (!$use) {
|
||||
return true;
|
||||
}
|
||||
return filter_var($use, FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
public function ssl_verify_peer_mode_enabled(): bool {
|
||||
$enabled = getenv('SSL_VERIFY_PEER_MODE_ENABLED');
|
||||
if (!$enabled) {
|
||||
return false;
|
||||
}
|
||||
return filter_var($enabled, FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
public function storage_path(): Path {
|
||||
$storage_path = getenv('STORAGE_PATH') ?: 'storage';
|
||||
$storage_directory = new Path($storage_path);
|
||||
if ($storage_directory->absolute()) {
|
||||
return $storage_directory;
|
||||
}
|
||||
|
||||
$storage_string_directory = $storage_directory->string();
|
||||
$current_directory = new Path(__DIR__);
|
||||
$directory = $current_directory
|
||||
->join_path('..')
|
||||
->join_path($storage_string_directory);
|
||||
return $directory->normalize();
|
||||
}
|
||||
|
||||
public function single_user(): bool {
|
||||
$single = getenv('SINGLE_USER');
|
||||
if (!$single) {
|
||||
return false;
|
||||
}
|
||||
return filter_var($single, FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
public function maximum_file_size(): int {
|
||||
$size = getenv('MAXIMUM_FILE_SIZE');
|
||||
if (!$size) {
|
||||
return 5 * 1024 * 1024;
|
||||
}
|
||||
return intval($size);
|
||||
}
|
||||
|
||||
public function conversion_timeout(): int {
|
||||
$timeout = getenv('CONVERSION_TIMEOUT');
|
||||
if (!$timeout) {
|
||||
return 120 * 1000;
|
||||
}
|
||||
return intval($timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function languages(): array {
|
||||
return [
|
||||
'en' => "English",
|
||||
'hy' => 'Armenian',
|
||||
'az' => 'Azerbaijani',
|
||||
'eu' => 'Basque',
|
||||
'be' => 'Belarusian',
|
||||
'bg' => 'Bulgarian',
|
||||
'ca' => 'Catalan',
|
||||
'zh' => 'Chinese (Simplified)',
|
||||
'zh-TW' => 'Chinese (Traditional)',
|
||||
'cs' => 'Czech',
|
||||
'da' => 'Danish',
|
||||
'nl' => 'Dutch',
|
||||
'fi' => 'Finnish',
|
||||
'fr' => 'French',
|
||||
'gl' => 'Galego',
|
||||
'de' => 'German',
|
||||
'el' => 'Greek',
|
||||
'hu' => 'Hungarian',
|
||||
'id' => 'Indonesian',
|
||||
'it' => 'Italian',
|
||||
'ja' => 'Japanese',
|
||||
'ko' => 'Korean',
|
||||
'lo' => 'Lao',
|
||||
'lv' => 'Latvian',
|
||||
'ms' => 'Malay (Malaysia)',
|
||||
'no' => 'Norwegian',
|
||||
'pl' => 'Polish',
|
||||
'pt' => 'Portuguese (Brazil)',
|
||||
'pt-PT' => 'Portuguese (Portugal)',
|
||||
'ro' => 'Romanian',
|
||||
'ru' => 'Russian',
|
||||
'si' => 'Sinhala (Sri Lanka)',
|
||||
'sk' => 'Slovak',
|
||||
'sl' => 'Slovenian',
|
||||
'es' => 'Spanish',
|
||||
'sv' => 'Swedish',
|
||||
'tr' => 'Turkish',
|
||||
'uk' => 'Ukrainian',
|
||||
'vi' => 'Vietnamese',
|
||||
'aa-AA' => 'Test Language'
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerConversionTimeoutTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$timeout = $config_manager->conversion_timeout();
|
||||
$this->assertEquals(120_000, $timeout);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('CONVERSION_TIMEOUT=10');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$timeout = $config_manager->conversion_timeout();
|
||||
$this->assertEquals(10, $timeout);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerDocumentServerAPIURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_api_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/web-apps/apps/api/documents/api.js',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('DOCUMENT_SERVER_API_PATH=/api');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_api_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/api',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerDocumentServerCommandURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_command_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/coauthoring/CommandService.ashx',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('DOCUMENT_SERVER_COMMAND_PATH=/command');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_command_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/command',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerDocumentServerConverterURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_converter_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/ConvertService.ashx',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('DOCUMENT_SERVER_CONVERTER_PATH=/converter');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_converter_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/converter',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerDocumentServerPreloaderURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_preloader_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/web-apps/apps/api/documents/cache-scripts.html',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('DOCUMENT_SERVER_PRELOADER_PATH=/preloader');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_preloader_url();
|
||||
$this->assertEquals(
|
||||
'http://document-server/preloader',
|
||||
$url->string()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerDocumentServerURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_url();
|
||||
$this->assertEquals('http://document-server', $url->string());
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('DOCUMENT_SERVER_URL=http://localhost');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->document_server_url();
|
||||
$this->assertEquals('http://localhost', $url->string());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerExampleURLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->example_url();
|
||||
$this->assertNull($url);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('EXAMPLE_URL=http://localhost');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$url = $config_manager->example_url();
|
||||
$this->assertEquals('http://localhost', $url->string());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerJWTHeaderTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$header = $config_manager->jwt_header();
|
||||
$this->assertEquals('Authorization', $header);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('JWT_HEADER=Proxy-Authorization');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$header = $config_manager->jwt_header();
|
||||
$this->assertEquals('Proxy-Authorization', $header);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerJWTSecretTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$secret = $config_manager->jwt_secret();
|
||||
$this->assertEquals('', $secret);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('JWT_SECRET=your-256-bit-secret');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$secret = $config_manager->jwt_secret();
|
||||
$this->assertEquals('your-256-bit-secret', $secret);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerJWTUseForRequest extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$use = $config_manager->jwt_use_for_request();
|
||||
$this->assertTrue($use);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('JWT_USE_FOR_REQUEST=false');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$use = $config_manager->jwt_use_for_request();
|
||||
$this->assertFalse($use);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerMaximumFileSizeTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$size = $config_manager->maximum_file_size();
|
||||
$this->assertEquals(5_242_880, $size);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('MAXIMUM_FILE_SIZE=10');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$size = $config_manager->maximum_file_size();
|
||||
$this->assertEquals(10, $size);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerSSLTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$enabled = $config_manager->ssl_verify_peer_mode_enabled();
|
||||
$this->assertFalse($enabled);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('SSL_VERIFY_PEER_MODE_ENABLED=true');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$enabled = $config_manager->ssl_verify_peer_mode_enabled();
|
||||
$this->assertTrue($enabled);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerSingleUserTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$single = $config_manager->single_user();
|
||||
$this->assertFalse($single);
|
||||
}
|
||||
|
||||
public function test_assigns_a_value_from_the_environment() {
|
||||
putenv('SINGLE_USER=true');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$single = $config_manager->single_user();
|
||||
$this->assertTrue($single);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerStoragePathTests extends TestCase {
|
||||
public array $env;
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->env = getenv();
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function setUp(): void {
|
||||
foreach ($this->env as $key => $value) {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_assigns_a_default_value() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$path = $config_manager->storage_path();
|
||||
$this->assertTrue($path->absolute());
|
||||
$this->assertEquals($path->basename(), 'storage');
|
||||
}
|
||||
|
||||
public function test_assigns_a_relative_path_from_the_environment() {
|
||||
putenv('STORAGE_PATH=directory');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$path = $config_manager->storage_path();
|
||||
$this->assertTrue($path->absolute());
|
||||
$this->assertEquals($path->basename(), 'directory');
|
||||
}
|
||||
|
||||
public function test_assigns_an_absolute_path_from_the_environment() {
|
||||
putenv('STORAGE_PATH=/directory');
|
||||
$config_manager = new ConfigurationManager();
|
||||
$path = $config_manager->storage_path();
|
||||
$this->assertEquals($path->string(), '/directory');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
//
|
||||
// (c) Copyright Ascensio System SIA 2023
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class ConfigurationManagerTests extends TestCase {
|
||||
public function test_corresponds_the_latest_version() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
$this->assertEquals('1.6.0', $config_manager->version);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace OnlineEditorsExamplePhp;
|
||||
|
||||
use OnlineEditorsExamplePhp\Views\DocEditorView;
|
||||
|
||||
require_once dirname(__FILE__) . '/functions.php';
|
||||
require_once dirname(__FILE__) . '/vendor/autoload.php';
|
||||
|
||||
$docEditorView = new DocEditorView($_REQUEST);
|
||||
$docEditorView->render();
|
||||
@ -18,6 +18,7 @@
|
||||
namespace OnlineEditorsExamplePhp;
|
||||
|
||||
use Exception;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\ConfigManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\ExampleUsers;
|
||||
use OnlineEditorsExamplePhp\Helpers\JwtManager;
|
||||
@ -92,10 +93,10 @@ function getClientIp()
|
||||
*/
|
||||
function serverPath($forDocumentServer = null)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
return $forDocumentServer && $configManager->getConfig("storagePath") != null
|
||||
&& $configManager->getConfig("exampleUrl") != ""
|
||||
? $configManager->getConfig("exampleUrl")
|
||||
$config_manager = new ConfigurationManager();
|
||||
$example_url = $config_manager->example_url();
|
||||
return $forDocumentServer && $example_url
|
||||
? $example_url->string()
|
||||
: (getScheme() . '://' . $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
@ -108,11 +109,8 @@ function serverPath($forDocumentServer = null)
|
||||
*/
|
||||
function getCurUserHostAddress($userAddress = null)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
if ($configManager->getConfig("alone")) {
|
||||
if (empty($configManager->getConfig("storagePath"))) {
|
||||
return "Storage";
|
||||
}
|
||||
$config_manager = new ConfigurationManager();
|
||||
if ($config_manager->single_user()) {
|
||||
return "";
|
||||
}
|
||||
if (is_null($userAddress)) {
|
||||
@ -130,18 +128,24 @@ function getCurUserHostAddress($userAddress = null)
|
||||
*/
|
||||
function getInternalExtension($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$ext = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
$configManager = new ConfigManager();
|
||||
if (in_array($ext, $configManager->getConfig("extsDocument"))) {
|
||||
return ".docx";
|
||||
} // .docx for text document extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsSpreadsheet"))) {
|
||||
return ".xlsx";
|
||||
} // .xlsx for spreadsheet extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsPresentation"))) {
|
||||
return ".pptx";
|
||||
} // .pptx for presentation extensions
|
||||
|
||||
foreach ($configManager->getSuppotredFormats() as $format) {
|
||||
if ($format->name === $ext) {
|
||||
if ($format->type === "word") {
|
||||
return ".docx";
|
||||
}
|
||||
if ($format->type === "cell") {
|
||||
return ".xlsx";
|
||||
}
|
||||
if ($format->type === "slide") {
|
||||
return ".pptx";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -154,19 +158,24 @@ function getInternalExtension($filename)
|
||||
*/
|
||||
function getTemplateImageUrl($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$ext = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$path = serverPath(true) . "/css/images/";
|
||||
|
||||
$configManager = new ConfigManager();
|
||||
if (in_array($ext, $configManager->getConfig("extsDocument"))) {
|
||||
return $path . "file_docx.svg";
|
||||
} // for text document extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsSpreadsheet"))) {
|
||||
return $path . "file_xlsx.svg";
|
||||
} // for spreadsheet extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsPresentation"))) {
|
||||
return $path . "file_pptx.svg";
|
||||
} // for presentation extensions
|
||||
foreach ($configManager->getSuppotredFormats() as $format) {
|
||||
if ($format->name === $ext) {
|
||||
if ($format->type === "word") {
|
||||
return $path . "file_docx.svg";
|
||||
}
|
||||
if ($format->type === "cell") {
|
||||
return $path . "file_xlsx.svg";
|
||||
}
|
||||
if ($format->type === "slide") {
|
||||
return $path . "file_pptx.svg";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $path . "file_docx.svg";
|
||||
}
|
||||
|
||||
@ -179,18 +188,15 @@ function getTemplateImageUrl($filename)
|
||||
*/
|
||||
function getDocumentType($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$ext = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
$configManager = new ConfigManager();
|
||||
if (in_array($ext, $configManager->getConfig("extsDocument"))) {
|
||||
return "word";
|
||||
} // word for text document extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsSpreadsheet"))) {
|
||||
return "cell";
|
||||
} // cell for spreadsheet extensions
|
||||
if (in_array($ext, $configManager->getConfig("extsPresentation"))) {
|
||||
return "slide";
|
||||
} // slide for presentation extensions
|
||||
foreach ($configManager->getSuppotredFormats() as $format) {
|
||||
if ($format->name === $ext) {
|
||||
return $format->type;
|
||||
}
|
||||
}
|
||||
|
||||
return "word";
|
||||
}
|
||||
|
||||
@ -214,39 +220,21 @@ function getScheme()
|
||||
*/
|
||||
function getStoragePath($fileName, $userAddress = null)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$storagePath = trim(
|
||||
str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $configManager->getConfig("storagePath")),
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
$config_manager = new ConfigurationManager();
|
||||
$storage_path = $config_manager->storage_path();
|
||||
|
||||
if (!$storage_path->exists()) {
|
||||
$storage_path->make_directory();
|
||||
}
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
$user_ip = getCurUserHostAddress($userAddress);
|
||||
$user_directory = $storage_path->join_path($user_ip);
|
||||
if (!$user_directory->exists()) {
|
||||
$user_directory->make_directory();
|
||||
}
|
||||
|
||||
if ($storagePath != "") {
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
// if the file directory doesn't exist, make it
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
}
|
||||
|
||||
if (realpath($storagePath) !== $storagePath) {
|
||||
$directory = $directory . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
sendlog("getStoragePath result: " . $directory . basename($fileName), "common.log");
|
||||
return realpath($storagePath) === $storagePath ? $directory . $fileName : $directory . basename($fileName);
|
||||
$file = $user_directory->join_path($fileName);
|
||||
return $file->string();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -260,43 +248,30 @@ function getStoragePath($fileName, $userAddress = null)
|
||||
*/
|
||||
function getForcesavePath($fileName, $userAddress, $create)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$storagePath = trim(
|
||||
str_replace(
|
||||
['/', '\\'],
|
||||
DIRECTORY_SEPARATOR,
|
||||
$configManager->getConfig("storagePath")
|
||||
),
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
$config_manager = new ConfigurationManager();
|
||||
$storage_path = $config_manager->storage_path();
|
||||
|
||||
// create the directory to this file version
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath . DIRECTORY_SEPARATOR;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath . getCurUserHostAddress($userAddress) .
|
||||
DIRECTORY_SEPARATOR;
|
||||
$user_ip = getCurUserHostAddress($userAddress);
|
||||
$user_directory = $storage_path->join_path($user_ip);
|
||||
if (!$user_directory->exists()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
return "";
|
||||
$history_directory = $user_directory->join_path("{$fileName}-hist");
|
||||
if (!$history_directory->exists()) {
|
||||
if ($create) {
|
||||
$history_directory->make_directory();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// create the directory to the history of this file version
|
||||
$directory = $directory . $fileName . "-hist" . DIRECTORY_SEPARATOR;
|
||||
if (!$create && !is_dir($directory)) {
|
||||
return "";
|
||||
$file = $history_directory->join_path($fileName);
|
||||
if (!$file->exists() && !$create) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
$directory = $directory . $fileName;
|
||||
if (!$create && !file_exists($directory)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return $directory;
|
||||
return $file->string();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,51 +337,34 @@ function getFileVersion($histDir)
|
||||
function getStoredFiles()
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$storagePath = trim(str_replace(
|
||||
['/', '\\'],
|
||||
DIRECTORY_SEPARATOR,
|
||||
$configManager->getConfig("storagePath")
|
||||
), DIRECTORY_SEPARATOR);
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
|
||||
$config_manager = new ConfigurationManager();
|
||||
$storage_path = $config_manager->storage_path();
|
||||
|
||||
if (!$storage_path->exists()) {
|
||||
$storage_path->make_directory();
|
||||
}
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
$user_ip = getCurUserHostAddress();
|
||||
$user_directory = $storage_path->join_path($user_ip);
|
||||
if (!$user_directory->exists()) {
|
||||
$user_directory->make_directory();
|
||||
}
|
||||
|
||||
// get the storage path and check if it exists
|
||||
$result = [];
|
||||
if ($storagePath != "") {
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (realpath($storagePath) !== $storagePath) {
|
||||
$directory = $directory . getCurUserHostAddress() . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
}
|
||||
$directory = $user_directory->string();
|
||||
|
||||
$cdir = scandir($directory); // get all the files and folders from the directory
|
||||
$result = [];
|
||||
foreach ($cdir as $key => $fileName) { // run through all the file and folder names
|
||||
if (!in_array($fileName, [".", ".."])) {
|
||||
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) { // if an element isn't a directory
|
||||
$ext = mb_strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$ext = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName); // get the time of element modification
|
||||
$result[$dat] = (object) [ // and write the file to the result
|
||||
"name" => $fileName,
|
||||
"documentType" => getDocumentType($fileName),
|
||||
"canEdit" => in_array($ext, $configManager->getConfig("docServEdited")),
|
||||
"isFillFormDoc" => in_array($ext, $configManager->getConfig("docServFillforms")),
|
||||
"canEdit" => in_array($ext, $configManager->getEditExtensions()),
|
||||
"isFillFormDoc" => in_array($ext, $configManager->getFillExtensions()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -424,21 +382,8 @@ function getStoredFiles()
|
||||
*/
|
||||
function getVirtualPath($forDocumentServer)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$storagePath = trim(str_replace(
|
||||
['/', '\\'],
|
||||
'/',
|
||||
$configManager->getConfig("storagePath")
|
||||
), '/');
|
||||
$storagePath = $storagePath != "" ? $storagePath . '/' : "";
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . '/';
|
||||
} else {
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
}
|
||||
sendlog("getVirtualPath virtPath: " . $virtPath, "common.log");
|
||||
return $virtPath;
|
||||
$server_url = serverPath($forDocumentServer);
|
||||
return $server_url . '/' . getCurUserHostAddress() . '/';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -521,22 +466,6 @@ function getFileInfo($fileId)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the supported file extensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getFileExts()
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
return array_merge(
|
||||
$configManager->getConfig("docServViewd"),
|
||||
$configManager->getConfig("docServEdited"),
|
||||
$configManager->getConfig("docServConvert"),
|
||||
$configManager->getConfig("docServFillforms")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct file name if such a name already exists
|
||||
*
|
||||
@ -590,10 +519,11 @@ function getDocEditorKey($fileName)
|
||||
function doUpload($fileUri)
|
||||
{
|
||||
$_fileName = GetCorrectName($fileUri);
|
||||
$configManager = new ConfigManager();
|
||||
|
||||
// check if file extension is supported by the editor
|
||||
$ext = mb_strtolower('.' . pathinfo($_fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, getFileExts())) {
|
||||
$ext = mb_strtolower(pathinfo($_fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, $configManager->getSuppotredExtensions())) {
|
||||
throw new Exception("File type is not supported");
|
||||
}
|
||||
|
||||
@ -696,6 +626,8 @@ function sendRequestToConvertService(
|
||||
$filePass,
|
||||
$lang
|
||||
) {
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
if (empty($from_extension)) {
|
||||
$path_parts = pathinfo($document_uri);
|
||||
$from_extension = mb_strtolower($path_parts['extension']);
|
||||
@ -714,9 +646,7 @@ function sendRequestToConvertService(
|
||||
// generate document token
|
||||
$document_revision_id = generateRevisionId($document_revision_id);
|
||||
|
||||
$configManager = new ConfigManager();
|
||||
$urlToConverter = $configManager->getConfig("docServSiteUrl").
|
||||
$configManager->getConfig("docServConverterUrl");
|
||||
$urlToConverter = $config_manager->document_server_converter_url()->string();
|
||||
|
||||
$arr = [
|
||||
"async" => $is_async,
|
||||
@ -731,8 +661,7 @@ function sendRequestToConvertService(
|
||||
|
||||
// add header token
|
||||
$headerToken = "";
|
||||
$jwtHeader = $configManager->getConfig("docServJwtHeader") ==
|
||||
"" ? "Authorization" : $configManager->getConfig("docServJwtHeader");
|
||||
$jwtHeader = $config_manager->jwt_header();
|
||||
|
||||
$jwtManager = new JwtManager();
|
||||
if ($jwtManager->isJwtEnabled() && $jwtManager->tokenUseForRequest()) {
|
||||
@ -745,7 +674,7 @@ function sendRequestToConvertService(
|
||||
// request parameters
|
||||
$opts = ['http' => [
|
||||
'method' => 'POST',
|
||||
'timeout' => $configManager->getConfig("docServTimeout"),
|
||||
'timeout' => $config_manager->conversion_timeout(),
|
||||
'header' => "Content-type: application/json\r\n" .
|
||||
"Accept: application/json\r\n" .
|
||||
(empty($headerToken) ? "" : $jwtHeader.": Bearer $headerToken\r\n"),
|
||||
@ -754,7 +683,7 @@ function sendRequestToConvertService(
|
||||
];
|
||||
|
||||
if (mb_substr($urlToConverter, 0, mb_strlen("https")) === "https") {
|
||||
if ($configManager->getConfig("docServVerifyPeerOff") === true) {
|
||||
if ($config_manager->ssl_verify_peer_mode_enabled()) {
|
||||
$opts['ssl'] = ['verify_peer' => false, 'verify_peer_name' => false];
|
||||
}
|
||||
}
|
||||
@ -895,8 +824,12 @@ function getResponseUri($document_response, &$response_uri)
|
||||
*/
|
||||
function tryGetDefaultByType($createExt, $user)
|
||||
{
|
||||
$demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$sample = isset($_GET["sample"]) && $_GET["sample"];
|
||||
$demoName = ($sample ? "sample." : "new.") . $createExt;
|
||||
$demoPath =
|
||||
"assets" . DIRECTORY_SEPARATOR .
|
||||
"document-templates" . DIRECTORY_SEPARATOR .
|
||||
($sample ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . $demoPath . $demoName, getStoragePath($demoFilename))) {
|
||||
@ -920,9 +853,8 @@ function tryGetDefaultByType($createExt, $user)
|
||||
function getCallbackUrl($fileName)
|
||||
{
|
||||
return serverPath(true) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=track"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "track"
|
||||
. "?fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
|
||||
@ -939,10 +871,9 @@ function getCreateUrl($fileName, $uid, $type)
|
||||
{
|
||||
$ext = trim(getInternalExtension($fileName), '.');
|
||||
return serverPath(false) . '/'
|
||||
. "doceditor.php"
|
||||
. "editor"
|
||||
. "?fileExt=" . $ext
|
||||
. "&user=" . $uid
|
||||
. "&type=" . $type;
|
||||
. "&user=" . $uid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -959,9 +890,8 @@ function getHistoryDownloadUrl($fileName, $version, $file, $isServer = true)
|
||||
{
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=history"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "history"
|
||||
. "?fileName=" . urlencode($fileName)
|
||||
. "&ver=" . $version
|
||||
. "&file=" . urlencode($file)
|
||||
. $userAddress;
|
||||
@ -979,9 +909,8 @@ function getDownloadUrl($fileName, $isServer = true)
|
||||
{
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=download"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "download"
|
||||
. "?fileName=" . urlencode($fileName)
|
||||
. $userAddress;
|
||||
}
|
||||
|
||||
@ -998,8 +927,6 @@ function getDownloadUrl($fileName, $isServer = true)
|
||||
*/
|
||||
function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$storagePath = $configManager->getConfig("storagePath");
|
||||
$histDir = getHistoryDir(getStoragePath($filename)); // get the path to the file history
|
||||
|
||||
if (getFileVersion($histDir) > 0) { // check if the file was modified (the file version is greater than 0)
|
||||
@ -1040,13 +967,11 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
$directUrl = $i == $curVer ? fileUri($filename, false) :
|
||||
getHistoryDownloadUrl($filename, $i, "prev.".$fileExe, false);
|
||||
$prevFileUrl = $i == $curVer ? $fileuri : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) :
|
||||
getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
if ($isEnableDirectUrl) {
|
||||
$directUrl = $i == $curVer ? getDownloadUrl($filename, false) :
|
||||
getHistoryDownloadUrl($filename, $i, "prev.".$fileExe, false);
|
||||
}
|
||||
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) :
|
||||
getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
if ($isEnableDirectUrl) {
|
||||
$directUrl = $i == $curVer ? getDownloadUrl($filename, false) :
|
||||
getHistoryDownloadUrl($filename, $i, "prev.".$fileExe, false);
|
||||
}
|
||||
|
||||
$dataObj["url"] = $prevFileUrl; // write file url to the data object
|
||||
|
||||
@ -20,27 +20,87 @@ namespace OnlineEditorsExamplePhp\Helpers;
|
||||
|
||||
final class ConfigManager
|
||||
{
|
||||
private mixed $config;
|
||||
private mixed $configFormats;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = json_decode($this->getConfigurationJson());
|
||||
$this->configFormats = json_decode($this->getConfigurationFromatsJson());
|
||||
}
|
||||
|
||||
private function getConfigurationJson(): bool|string
|
||||
private function getConfigurationFromatsJson(): bool|string
|
||||
{
|
||||
return file_exists("./config.json") ? file_get_contents("./config.json") : false;
|
||||
return file_exists("./assets/document-formats/onlyoffice-docs-formats.json")
|
||||
? file_get_contents("./assets/document-formats/onlyoffice-docs-formats.json")
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $configName
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $configName = null): mixed
|
||||
public function getSuppotredFormats(): mixed
|
||||
{
|
||||
if ($configName) {
|
||||
return $this->config->$configName ?? "";
|
||||
}
|
||||
return $this->config;
|
||||
return $this->configFormats;
|
||||
}
|
||||
|
||||
public function getSuppotredExtensions(): mixed
|
||||
{
|
||||
return array_reduce(
|
||||
$this->configFormats,
|
||||
function ($extensions, $format) {
|
||||
$extensions[] = $format->name;
|
||||
return $extensions;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getViewExtensions(): mixed
|
||||
{
|
||||
return array_reduce(
|
||||
$this->configFormats,
|
||||
function ($extensions, $format) {
|
||||
if (in_array("view", $format->actions)) {
|
||||
$extensions[] = $format->name;
|
||||
}
|
||||
return $extensions;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getEditExtensions(): mixed
|
||||
{
|
||||
return array_reduce(
|
||||
$this->configFormats,
|
||||
function ($extensions, $format) {
|
||||
if (in_array("edit", $format->actions) || in_array("lossy-edit", $format->actions)) {
|
||||
$extensions[] = $format->name;
|
||||
}
|
||||
return $extensions;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getFillExtensions(): mixed
|
||||
{
|
||||
return array_reduce(
|
||||
$this->configFormats,
|
||||
function ($extensions, $format) {
|
||||
if (in_array("fill", $format->actions)) {
|
||||
$extensions[] = $format->name;
|
||||
}
|
||||
return $extensions;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getConvertExtensions(): mixed
|
||||
{
|
||||
return array_reduce(
|
||||
$this->configFormats,
|
||||
function ($extensions, $format) {
|
||||
if ($format->type === "word" && in_array("docx", $format->convert)
|
||||
|| $format->type === "cell" && in_array("xlsx", $format->convert)
|
||||
|| $format->type === "slide" && in_array("pptx", $format->convert)) {
|
||||
$extensions[] = $format->name;
|
||||
}
|
||||
return $extensions;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,10 @@ namespace OnlineEditorsExamplePhp\Helpers;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
|
||||
final class JwtManager
|
||||
{
|
||||
/**
|
||||
@ -27,8 +31,8 @@ final class JwtManager
|
||||
*/
|
||||
public function isJwtEnabled(): bool
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
return !empty($configManager->getConfig("docServJwtSecret"));
|
||||
$config_manager = new ConfigurationManager();
|
||||
return !empty($config_manager->jwt_secret());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,8 +42,8 @@ final class JwtManager
|
||||
*/
|
||||
public function tokenUseForRequest(): bool
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
return $configManager->getConfig("docServJwtUseForRequest") ?: false;
|
||||
$config_manager = new ConfigurationManager();
|
||||
return $config_manager->jwt_use_for_request() ?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,8 +55,8 @@ final class JwtManager
|
||||
*/
|
||||
public function jwtEncode($payload)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
return \Firebase\JWT\JWT::encode($payload, $configManager->getConfig("docServJwtSecret"));
|
||||
$config_manager = new ConfigurationManager();
|
||||
return JWT::encode($payload, $config_manager->jwt_secret(), 'HS256');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,12 +68,11 @@ final class JwtManager
|
||||
*/
|
||||
public function jwtDecode($token)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$config_manager = new ConfigurationManager();
|
||||
try {
|
||||
$payload = \Firebase\JWT\JWT::decode(
|
||||
$payload = JWT::decode(
|
||||
$token,
|
||||
$configManager->getConfig("docServJwtSecret"),
|
||||
["HS256"]
|
||||
new Key($config_manager->jwt_secret(), 'HS256')
|
||||
);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$payload = "";
|
||||
|
||||
@ -17,10 +17,140 @@
|
||||
|
||||
namespace OnlineEditorsExamplePhp;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/ajax.php';
|
||||
require_once __DIR__ . '/functions.php';
|
||||
require_once __DIR__ . '/trackmanager.php';
|
||||
|
||||
use OnlineEditorsExamplePhp\Common\HTTPStatus;
|
||||
use OnlineEditorsExamplePhp\Common\URL;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
use OnlineEditorsExamplePhp\Views\DocEditorView;
|
||||
use OnlineEditorsExamplePhp\Views\IndexView;
|
||||
|
||||
require_once dirname(__FILE__) . '/functions.php';
|
||||
require_once dirname(__FILE__) . '/vendor/autoload.php';
|
||||
function configure() {
|
||||
$config_manager = new ConfigurationManager();
|
||||
if ($config_manager->ssl_verify_peer_mode_enabled()) {
|
||||
// Ignore self-signed certificate.
|
||||
stream_context_set_default([
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$indexView = new IndexView($_REQUEST);
|
||||
$indexView->render();
|
||||
function routers() {
|
||||
// TODO: delete fallback.
|
||||
// In theory, the content type of the response should be declared inside the
|
||||
// router function. However, this statement isn't true for all routers, and
|
||||
// it's also not true for all branches in all routers. Therefore, we are
|
||||
// setting the default content type for all routers here.
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
||||
header('Pragma: no-cache');
|
||||
@header_remove('Last-Modified');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
header('X-Robots-Tag: noindex');
|
||||
|
||||
$url = new URL($_SERVER['REQUEST_URI']);
|
||||
sendlog($url->string(), 'webedior-ajax.log');
|
||||
|
||||
$path = $url->path();
|
||||
if (!$path || $path === '/') {
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
$view = new IndexView($_REQUEST);
|
||||
$view->render();
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/editor')) {
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
$view = new DocEditorView($_REQUEST);
|
||||
$view->render();
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/assets')) {
|
||||
$response = assets();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/convert')) {
|
||||
$response = convert();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/csv')) {
|
||||
$response = csv();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/delete')) {
|
||||
$response = delete();
|
||||
$response['status'] = isset($response['error']) ? 'error' : 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/download')) {
|
||||
$response = download();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/files')) {
|
||||
$response = files();
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/history')) {
|
||||
$response = historyDownload();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/reference')) {
|
||||
$response = reference();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/rename')) {
|
||||
$response = renamefile();
|
||||
$content = json_encode($response);
|
||||
echo $content;
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/restore')) {
|
||||
$response = restore();
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/saveas')) {
|
||||
$response = saveas();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/track')) {
|
||||
$response = track();
|
||||
$response['status'] = 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
if (str_starts_with($path, '/upload')) {
|
||||
$response = upload();
|
||||
$response['status'] = isset($response['error']) ? 'error' : 'success';
|
||||
echo json_encode($response);
|
||||
return;
|
||||
}
|
||||
|
||||
http_response_code(HTTPStatus::not_found->value);
|
||||
}
|
||||
|
||||
configure();
|
||||
routers();
|
||||
|
||||
@ -125,7 +125,7 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#filePass").val("");
|
||||
|
||||
timer = setTimeout(function () {
|
||||
var requestAddress = "webeditor-ajax.php?type=convert&user=" + user;
|
||||
var requestAddress = "convert?user=" + user;
|
||||
|
||||
jq.ajax({
|
||||
async: true,
|
||||
@ -247,7 +247,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
var url = "editor?fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -256,7 +256,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?action=view&fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
var url = "editor?action=view&fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -265,7 +265,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.php?type=embedded&fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
var url = "editor?type=embedded&fileID=" + fileId + "&user=" + user + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -297,7 +297,7 @@ if (typeof jQuery != "undefined") {
|
||||
jq(document).on("click", ".delete-file", function () {
|
||||
var fileName = jq(this).attr("data");
|
||||
|
||||
var requestAddress = "webeditor-ajax.php?type=delete&fileName=" + fileName;
|
||||
var requestAddress = "delete?fileName=" + fileName;
|
||||
|
||||
jq.ajax({
|
||||
async: true,
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace Firebase\JWT;
|
||||
|
||||
class BeforeValidException extends \UnexpectedValueException
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace Firebase\JWT;
|
||||
|
||||
class ExpiredException extends \UnexpectedValueException
|
||||
{
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user