mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
243 Commits
v99.99.99.
...
feature/py
| Author | SHA1 | Date | |
|---|---|---|---|
| c9baa474be | |||
| 48185674d4 | |||
| dbca11e85c | |||
| d21a732859 | |||
| b96a6fac53 | |||
| b01af348a7 | |||
| c2443d3106 | |||
| 5fa3f4c57f | |||
| efd7e1b6e7 | |||
| 259ee63eea | |||
| 453b9835b7 | |||
| 89e6544b79 | |||
| 32a60c09aa | |||
| 5a03024cd3 | |||
| cb6416c481 | |||
| 55e4247687 | |||
| a0620905b2 | |||
| 3fcef4096a | |||
| 4e5349c1c4 | |||
| 538eec1ff3 | |||
| df7cfda2fb | |||
| 9ebef04f3d | |||
| a6ed970bca | |||
| 7f659bc95e | |||
| 3c4a1c1c31 | |||
| 2bae0567ad | |||
| c06f2a5a29 | |||
| 8aed04753c | |||
| 15ed02e556 | |||
| fb66dc8423 | |||
| 541ace8132 | |||
| 8b5cebeb3f | |||
| 419fbf90f9 | |||
| 2d637b88df | |||
| 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 | |||
| 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 | |||
| c8d44199c2 | |||
| 12bcc0009b | |||
| be1ea81f82 | |||
| 43905695e0 | |||
| 4a49becea1 | |||
| c91d3a24b9 | |||
| 24a26fd530 | |||
| a5f91bc14f | |||
| c6043d4428 | |||
| c37ba28ad3 | |||
| 53f810fc54 | |||
| a55875ae1e | |||
| 707a634823 | |||
| b511fa872a | |||
| 4a2e7d9a9e | |||
| e4d5de2c0e | |||
| 50dca2e2c0 | |||
| 893303c27f |
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
|
||||
|
||||
36
.gitmodules
vendored
36
.gitmodules
vendored
@ -1,19 +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
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/csharp-mvc/assets"]
|
||||
path = web/documentserver-example/csharp-mvc/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
@ -30,3 +18,27 @@
|
||||
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
|
||||
[submodule "web/documentserver-example/python/assets/document-templates"]
|
||||
path = web/documentserver-example/python/assets/document-templates
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/python/assets/document-formats"]
|
||||
path = web/documentserver-example/python/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
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
# Change Log
|
||||
|
||||
- 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
|
||||
|
||||
@ -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=""/>
|
||||
|
||||
@ -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=""/>
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -100,9 +100,9 @@ app.get('/', (req, res) => { // define a handler for default page
|
||||
|
||||
res.render('index', { // render index template with the parameters specified
|
||||
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
|
||||
convertExts: configServer.get('convertedDocs'),
|
||||
editedExts: configServer.get('editedDocs'),
|
||||
fillExts: configServer.get('fillDocs'),
|
||||
convertExts: fileUtility.getConvertExtensions(),
|
||||
editedExts: fileUtility.getEditExtensions(),
|
||||
fillExts: fileUtility.getFillExtensions(),
|
||||
storedFiles: req.DocManager.getStoredFiles(),
|
||||
params: req.DocManager.getCustomParams(),
|
||||
users,
|
||||
@ -239,13 +239,8 @@ app.post('/upload', (req, res) => { // define a handler for uploading files
|
||||
return;
|
||||
}
|
||||
|
||||
const exts = [].concat(
|
||||
configServer.get('viewedDocs'),
|
||||
configServer.get('editedDocs'),
|
||||
configServer.get('convertedDocs'),
|
||||
configServer.get('fillDocs'),
|
||||
); // all the supported file extensions
|
||||
const curExt = fileUtility.getFileExtension(file.name);
|
||||
const exts = fileUtility.getSuppotredExtensions(); // all the supported file extensions
|
||||
const curExt = fileUtility.getFileExtension(file.name, true);
|
||||
const documentType = fileUtility.getFileType(file.name);
|
||||
|
||||
if (exts.indexOf(curExt) === -1) { // check if the file extension is supported
|
||||
@ -296,13 +291,8 @@ app.post('/create', (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const exts = [].concat(
|
||||
configServer.get('viewedDocs'),
|
||||
configServer.get('editedDocs'),
|
||||
configServer.get('convertedDocs'),
|
||||
configServer.get('fillDocs'),
|
||||
); // all the supported file extensions
|
||||
const curExt = fileUtility.getFileExtension(fileName);
|
||||
const exts = fileUtility.getSuppotredExtensions(); // all the supported file extensions
|
||||
const curExt = fileUtility.getFileExtension(fileName, true);
|
||||
|
||||
if (exts.indexOf(curExt) === -1) { // check if the file extension is supported
|
||||
// and write the error status and message to the response
|
||||
@ -335,7 +325,7 @@ app.post('/convert', (req, res) => { // define a handler for converting files
|
||||
const filePass = req.body.filePass ? req.body.filePass : null;
|
||||
const lang = req.body.lang ? req.body.lang : null;
|
||||
const fileUri = req.DocManager.getDownloadUrl(fileName, true);
|
||||
const fileExt = fileUtility.getFileExtension(fileName);
|
||||
const fileExt = fileUtility.getFileExtension(fileName, true);
|
||||
const internalFileExt = 'ooxml';
|
||||
const response = res;
|
||||
|
||||
@ -408,7 +398,7 @@ app.post('/convert', (req, res) => { // define a handler for converting files
|
||||
|
||||
try {
|
||||
// check if the file with such an extension can be converted
|
||||
if (configServer.get('convertedDocs').indexOf(fileExt) !== -1) {
|
||||
if (fileUtility.getConvertExtensions().indexOf(fileExt) !== -1) {
|
||||
const storagePath = req.DocManager.storagePath(fileName);
|
||||
const stat = fileSystem.statSync(storagePath);
|
||||
let key = fileUri + stat.mtime.getTime();
|
||||
@ -478,7 +468,7 @@ app.delete('/file', (req, res) => { // define a handler for removing file
|
||||
|
||||
app.get('/csv', (req, res) => { // define a handler for downloading csv files
|
||||
const fileName = 'csv.csv';
|
||||
const csvPath = path.join(__dirname, 'public', 'assets', 'sample', fileName);
|
||||
const csvPath = path.join(__dirname, 'public', 'assets', 'document-templates', 'sample', fileName);
|
||||
|
||||
// add headers to the response to specify the page parameters
|
||||
res.setHeader('Content-Length', fileSystem.statSync(csvPath).size);
|
||||
@ -948,9 +938,9 @@ app.get('/editor', (req, res) => { // define a handler for editing document
|
||||
const directUrl = req.DocManager.getDownloadUrl(fileName);
|
||||
let mode = req.query.mode || 'edit'; // mode: view/edit/review/comment/fillForms/embedded
|
||||
|
||||
let canEdit = configServer.get('editedDocs').indexOf(fileExt) !== -1; // check if this file can be edited
|
||||
let canEdit = fileUtility.getEditExtensions().indexOf(fileExt.slice(1)) !== -1; // check if this file can be edited
|
||||
if (((!canEdit && mode === 'edit') || mode === 'fillForms')
|
||||
&& configServer.get('fillDocs').indexOf(fileExt) !== -1) {
|
||||
&& fileUtility.getFillExtensions().indexOf(fileExt.slice(1)) !== -1) {
|
||||
mode = 'fillForms';
|
||||
canEdit = true;
|
||||
}
|
||||
@ -1017,8 +1007,10 @@ app.get('/editor', (req, res) => { // define a handler for editing document
|
||||
},
|
||||
dataCompareFile: {
|
||||
fileType: 'docx',
|
||||
url: `${req.DocManager.getServerUrl(true)}/assets/sample/sample.docx`,
|
||||
directUrl: !userDirectUrl ? null : `${req.DocManager.getServerUrl()}/assets/sample/sample.docx`,
|
||||
url: `${req.DocManager.getServerUrl(true)}/assets/document-templates/sample/sample.docx`,
|
||||
directUrl: !userDirectUrl
|
||||
? null
|
||||
: `${req.DocManager.getServerUrl()}/assets/document-templates/sample/sample.docx`,
|
||||
},
|
||||
dataMailMergeRecipients: {
|
||||
fileType: 'csv',
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -135,7 +135,7 @@ DocManager.prototype.createDemo = function createDemo(isSample, fileExt, userid,
|
||||
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', isSample
|
||||
this.copyFile(path.join(__dirname, '..', 'public', 'assets', 'document-templates', isSample
|
||||
? 'sample' : 'new', demoName), this.storagePath(fileName));
|
||||
|
||||
this.saveFileData(fileName, userid, username); // save file data to the file
|
||||
@ -189,7 +189,8 @@ DocManager.prototype.getServerPath = function getServerPath() {
|
||||
|
||||
// get host address from the request
|
||||
DocManager.prototype.getServerHost = function getServerHost() {
|
||||
return `${this.getProtocol()}://${this.req.headers['x-forwarded-host'] || this.req.headers.host}`;
|
||||
return `${this.getProtocol()}://${this.req.headers['x-forwarded-host'] || this.req.headers.host}`
|
||||
+ `${this.req.headers['x-forwarded-prefix'] || ''}`;
|
||||
};
|
||||
|
||||
// get protocol from the request
|
||||
@ -327,7 +328,7 @@ DocManager.prototype.getStoredFiles = function getStoredFiles() {
|
||||
time,
|
||||
name: storedFiles[i],
|
||||
documentType: fileUtility.getFileType(storedFiles[i]),
|
||||
canEdit: configServer.get('editedDocs').indexOf(fileUtility.getFileExtension(storedFiles[i])) !== -1,
|
||||
canEdit: fileUtility.getEditExtensions().indexOf(fileUtility.getFileExtension(storedFiles[i], true)) !== -1,
|
||||
version: version + 1,
|
||||
};
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const supportedFormats = require('../public/assets/document-formats/onlyoffice-docs-formats.json'); // eslint-disable-line
|
||||
|
||||
const fileUtility = {};
|
||||
|
||||
// get file name from the given url
|
||||
@ -49,14 +51,11 @@ fileUtility.getFileExtension = function getFileExtension(url, withoutDot) {
|
||||
|
||||
// get file type from the given url
|
||||
fileUtility.getFileType = function getFileType(url) {
|
||||
const ext = fileUtility.getFileExtension(url); // get the file extension from the given url
|
||||
const ext = fileUtility.getFileExtension(url, true); // get the file extension from the given url
|
||||
|
||||
// word type for document extensions
|
||||
if (fileUtility.documentExts.indexOf(ext) !== -1) return fileUtility.fileType.word;
|
||||
// cell type for spreadsheet extensions
|
||||
if (fileUtility.spreadsheetExts.indexOf(ext) !== -1) return fileUtility.fileType.cell;
|
||||
// slide type for presentation extensions
|
||||
if (fileUtility.presentationExts.indexOf(ext) !== -1) return fileUtility.fileType.slide;
|
||||
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
|
||||
};
|
||||
@ -67,17 +66,35 @@ fileUtility.fileType = {
|
||||
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
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
@ -57,8 +57,8 @@ exports.registerRoutes = function registerRoutes(app) {
|
||||
});
|
||||
|
||||
// Checking supported extensions
|
||||
const editedExts = configServer.get('editedDocs').filter((i) => docsExtEdit.includes(i));
|
||||
const fillExts = configServer.get('fillDocs').filter((i) => docsExtEdit.includes(i));
|
||||
const editedExts = fileUtility.getEditExtensions().filter((i) => docsExtEdit.includes(i));
|
||||
const fillExts = fileUtility.getFillExtensions().filter((i) => docsExtEdit.includes(i));
|
||||
|
||||
try {
|
||||
// get all the stored files
|
||||
@ -81,7 +81,7 @@ exports.registerRoutes = function registerRoutes(app) {
|
||||
params: req.DocManager.getCustomParams(),
|
||||
users,
|
||||
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
|
||||
convertExts: configServer.get('convertedDocs'),
|
||||
convertExts: fileUtility.getConvertExtensions(),
|
||||
editedExts,
|
||||
fillExts,
|
||||
languages: configServer.get('languages'),
|
||||
@ -89,7 +89,8 @@ exports.registerRoutes = function registerRoutes(app) {
|
||||
} 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
|
||||
// render error template with the message parameter specified
|
||||
res.render('error', { message: 'Server error' });
|
||||
}
|
||||
});
|
||||
// define a handler for creating a new wopi editing session
|
||||
|
||||
@ -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
@ -113,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) {
|
||||
@ -194,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;});
|
||||
|
||||
@ -227,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;
|
||||
@ -287,6 +334,7 @@
|
||||
config.events.onRequestUsers = onRequestUsers;
|
||||
config.events.onRequestSendNotify = onRequestSendNotify;
|
||||
config.events.onRequestReferenceData = onRequestReferenceData;
|
||||
config.events.onRequestReferenceSource = onRequestReferenceSource;
|
||||
}
|
||||
|
||||
if (config.editorConfig.createUrl) {
|
||||
@ -326,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);
|
||||
|
||||
@ -189,7 +189,7 @@
|
||||
<% 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 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>
|
||||
@ -201,7 +201,7 @@
|
||||
<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>
|
||||
|
||||
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 (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,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 = (isset($_GET["sample"]) ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . (isset($_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
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,370 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Firebase\JWT;
|
||||
use \DomainException;
|
||||
use \InvalidArgumentException;
|
||||
use \UnexpectedValueException;
|
||||
use \DateTime;
|
||||
|
||||
/**
|
||||
* JSON Web Token implementation, based on this spec:
|
||||
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Authentication
|
||||
* @package Authentication_JWT
|
||||
* @author Neuman Vong <neuman@twilio.com>
|
||||
* @author Anant Narayanan <anant@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
|
||||
* @link https://github.com/firebase/php-jwt
|
||||
*/
|
||||
class JWT
|
||||
{
|
||||
|
||||
/**
|
||||
* When checking nbf, iat or expiration times,
|
||||
* we want to provide some extra leeway time to
|
||||
* account for clock skew.
|
||||
*/
|
||||
public static $leeway = 0;
|
||||
|
||||
/**
|
||||
* Allow the current timestamp to be specified.
|
||||
* Useful for fixing a value within unit testing.
|
||||
*
|
||||
* Will default to PHP time() value if null.
|
||||
*/
|
||||
public static $timestamp = null;
|
||||
|
||||
public static $supported_algs = array(
|
||||
'HS256' => array('hash_hmac', 'SHA256'),
|
||||
'HS512' => array('hash_hmac', 'SHA512'),
|
||||
'HS384' => array('hash_hmac', 'SHA384'),
|
||||
'RS256' => array('openssl', 'SHA256'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Decodes a JWT string into a PHP object.
|
||||
*
|
||||
* @param string $jwt The JWT
|
||||
* @param string|array $key The key, or map of keys.
|
||||
* If the algorithm used is asymmetric, this is the public key
|
||||
* @param array $allowed_algs List of supported verification algorithms
|
||||
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||
*
|
||||
* @return object The JWT's payload as a PHP object
|
||||
*
|
||||
* @throws UnexpectedValueException Provided JWT was invalid
|
||||
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
|
||||
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
|
||||
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
|
||||
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
|
||||
*
|
||||
* @uses jsonDecode
|
||||
* @uses urlsafeB64Decode
|
||||
*/
|
||||
public static function decode($jwt, $key, $allowed_algs = array())
|
||||
{
|
||||
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
|
||||
|
||||
if (empty($key)) {
|
||||
throw new InvalidArgumentException('Key may not be empty');
|
||||
}
|
||||
if (!is_array($allowed_algs)) {
|
||||
throw new InvalidArgumentException('Algorithm not allowed');
|
||||
}
|
||||
$tks = explode('.', $jwt);
|
||||
if (count($tks) != 3) {
|
||||
throw new UnexpectedValueException('Wrong number of segments');
|
||||
}
|
||||
list($headb64, $bodyb64, $cryptob64) = $tks;
|
||||
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
|
||||
throw new UnexpectedValueException('Invalid header encoding');
|
||||
}
|
||||
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
|
||||
throw new UnexpectedValueException('Invalid claims encoding');
|
||||
}
|
||||
$sig = static::urlsafeB64Decode($cryptob64);
|
||||
|
||||
if (empty($header->alg)) {
|
||||
throw new UnexpectedValueException('Empty algorithm');
|
||||
}
|
||||
if (empty(static::$supported_algs[$header->alg])) {
|
||||
throw new UnexpectedValueException('Algorithm not supported');
|
||||
}
|
||||
if (!in_array($header->alg, $allowed_algs)) {
|
||||
throw new UnexpectedValueException('Algorithm not allowed');
|
||||
}
|
||||
if (is_array($key) || $key instanceof \ArrayAccess) {
|
||||
if (isset($header->kid)) {
|
||||
$key = $key[$header->kid];
|
||||
} else {
|
||||
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
|
||||
}
|
||||
}
|
||||
|
||||
// Check the signature
|
||||
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
|
||||
throw new SignatureInvalidException('Signature verification failed');
|
||||
}
|
||||
|
||||
// Check if the nbf if it is defined. This is the time that the
|
||||
// token can actually be used. If it's not yet that time, abort.
|
||||
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
|
||||
throw new BeforeValidException(
|
||||
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
|
||||
);
|
||||
}
|
||||
|
||||
// Check that this token has been created before 'now'. This prevents
|
||||
// using tokens that have been created for later use (and haven't
|
||||
// correctly used the nbf claim).
|
||||
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
|
||||
throw new BeforeValidException(
|
||||
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
|
||||
);
|
||||
}
|
||||
|
||||
// Check if this token has expired.
|
||||
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
|
||||
throw new ExpiredException('Expired token');
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts and signs a PHP object or array into a JWT string.
|
||||
*
|
||||
* @param object|array $payload PHP object or array
|
||||
* @param string $key The secret key.
|
||||
* If the algorithm used is asymmetric, this is the private key
|
||||
* @param string $alg The signing algorithm.
|
||||
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||
* @param mixed $keyId
|
||||
* @param array $head An array with header elements to attach
|
||||
*
|
||||
* @return string A signed JWT
|
||||
*
|
||||
* @uses jsonEncode
|
||||
* @uses urlsafeB64Encode
|
||||
*/
|
||||
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
|
||||
{
|
||||
$header = array('typ' => 'JWT', 'alg' => $alg);
|
||||
if ($keyId !== null) {
|
||||
$header['kid'] = $keyId;
|
||||
}
|
||||
if ( isset($head) && is_array($head) ) {
|
||||
$header = array_merge($head, $header);
|
||||
}
|
||||
$segments = array();
|
||||
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
|
||||
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
|
||||
$signing_input = implode('.', $segments);
|
||||
|
||||
$signature = static::sign($signing_input, $key, $alg);
|
||||
$segments[] = static::urlsafeB64Encode($signature);
|
||||
|
||||
return implode('.', $segments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign a string with a given key and algorithm.
|
||||
*
|
||||
* @param string $msg The message to sign
|
||||
* @param string|resource $key The secret key
|
||||
* @param string $alg The signing algorithm.
|
||||
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||
*
|
||||
* @return string An encrypted message
|
||||
*
|
||||
* @throws DomainException Unsupported algorithm was specified
|
||||
*/
|
||||
public static function sign($msg, $key, $alg = 'HS256')
|
||||
{
|
||||
if (empty(static::$supported_algs[$alg])) {
|
||||
throw new DomainException('Algorithm not supported');
|
||||
}
|
||||
list($function, $algorithm) = static::$supported_algs[$alg];
|
||||
switch($function) {
|
||||
case 'hash_hmac':
|
||||
return hash_hmac($algorithm, $msg, $key, true);
|
||||
case 'openssl':
|
||||
$signature = '';
|
||||
$success = openssl_sign($msg, $signature, $key, $algorithm);
|
||||
if (!$success) {
|
||||
throw new DomainException("OpenSSL unable to sign data");
|
||||
} else {
|
||||
return $signature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a signature with the message, key and method. Not all methods
|
||||
* are symmetric, so we must have a separate verify and sign method.
|
||||
*
|
||||
* @param string $msg The original message (header and body)
|
||||
* @param string $signature The original signature
|
||||
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
|
||||
* @param string $alg The algorithm
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws DomainException Invalid Algorithm or OpenSSL failure
|
||||
*/
|
||||
private static function verify($msg, $signature, $key, $alg)
|
||||
{
|
||||
if (empty(static::$supported_algs[$alg])) {
|
||||
throw new DomainException('Algorithm not supported');
|
||||
}
|
||||
|
||||
list($function, $algorithm) = static::$supported_algs[$alg];
|
||||
switch($function) {
|
||||
case 'openssl':
|
||||
$success = openssl_verify($msg, $signature, $key, $algorithm);
|
||||
if (!$success) {
|
||||
throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string());
|
||||
} else {
|
||||
return $signature;
|
||||
}
|
||||
case 'hash_hmac':
|
||||
default:
|
||||
$hash = hash_hmac($algorithm, $msg, $key, true);
|
||||
if (function_exists('hash_equals')) {
|
||||
return hash_equals($signature, $hash);
|
||||
}
|
||||
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
|
||||
|
||||
$status = 0;
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$status |= (ord($signature[$i]) ^ ord($hash[$i]));
|
||||
}
|
||||
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
|
||||
|
||||
return ($status === 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a JSON string into a PHP object.
|
||||
*
|
||||
* @param string $input JSON string
|
||||
*
|
||||
* @return object Object representation of JSON string
|
||||
*
|
||||
* @throws DomainException Provided string was invalid JSON
|
||||
*/
|
||||
public static function jsonDecode($input)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
|
||||
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
|
||||
* to specify that large ints (like Steam Transaction IDs) should be treated as
|
||||
* strings, rather than the PHP default behaviour of converting them to floats.
|
||||
*/
|
||||
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
|
||||
} else {
|
||||
/** Not all servers will support that, however, so for older versions we must
|
||||
* manually detect large ints in the JSON string and quote them (thus converting
|
||||
*them to strings) before decoding, hence the preg_replace() call.
|
||||
*/
|
||||
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
|
||||
$json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
|
||||
$obj = json_decode($json_without_bigints);
|
||||
}
|
||||
|
||||
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||
static::handleJsonError($errno);
|
||||
} elseif ($obj === null && $input !== 'null') {
|
||||
throw new DomainException('Null result with non-null input');
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a PHP object into a JSON string.
|
||||
*
|
||||
* @param object|array $input A PHP object or array
|
||||
*
|
||||
* @return string JSON representation of the PHP object or array
|
||||
*
|
||||
* @throws DomainException Provided object could not be encoded to valid JSON
|
||||
*/
|
||||
public static function jsonEncode($input)
|
||||
{
|
||||
$json = json_encode($input);
|
||||
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||
static::handleJsonError($errno);
|
||||
} elseif ($json === 'null' && $input !== null) {
|
||||
throw new DomainException('Null result with non-null input');
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a string with URL-safe Base64.
|
||||
*
|
||||
* @param string $input A Base64 encoded string
|
||||
*
|
||||
* @return string A decoded string
|
||||
*/
|
||||
public static function urlsafeB64Decode($input)
|
||||
{
|
||||
$remainder = strlen($input) % 4;
|
||||
if ($remainder) {
|
||||
$padlen = 4 - $remainder;
|
||||
$input .= str_repeat('=', $padlen);
|
||||
}
|
||||
return base64_decode(strtr($input, '-_', '+/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a string with URL-safe Base64.
|
||||
*
|
||||
* @param string $input The string you want encoded
|
||||
*
|
||||
* @return string The base64 encode of what you passed in
|
||||
*/
|
||||
public static function urlsafeB64Encode($input)
|
||||
{
|
||||
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a JSON error.
|
||||
*
|
||||
* @param int $errno An error number from json_last_error()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function handleJsonError($errno)
|
||||
{
|
||||
$messages = array(
|
||||
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
|
||||
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
|
||||
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
|
||||
);
|
||||
throw new DomainException(
|
||||
isset($messages[$errno])
|
||||
? $messages[$errno]
|
||||
: 'Unknown JSON error: ' . $errno
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of bytes in cryptographic strings.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function safeStrlen($str)
|
||||
{
|
||||
if (function_exists('mb_strlen')) {
|
||||
return mb_strlen($str, '8bit');
|
||||
}
|
||||
return strlen($str);
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
Copyright (c) 2011, Neuman Vong
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Neuman Vong nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace Firebase\JWT;
|
||||
|
||||
class SignatureInvalidException extends \UnexpectedValueException
|
||||
{
|
||||
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
Copyright (c) 2004, Jamis Buck (jamis@jamisbuck.org)
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2001-2023, Sebastian Bergmann
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The names of its contributors may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
13
web/documentserver-example/php/php-fpm.conf
Normal file
13
web/documentserver-example/php/php-fpm.conf
Normal file
@ -0,0 +1,13 @@
|
||||
[global]
|
||||
daemonize = no
|
||||
|
||||
[www]
|
||||
user = www-data
|
||||
group = www-data
|
||||
listen = ${ADDRESS}:${PORT}
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
clear_env = no
|
||||
13
web/documentserver-example/php/phpcs.xml
Normal file
13
web/documentserver-example/php/phpcs.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Custom Standard">
|
||||
<description>A custom coding standard</description>
|
||||
|
||||
<rule ref="PSR2"/>
|
||||
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="120"/>
|
||||
<property name="absoluteLineLimit" value="0"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="CustomRuleset">
|
||||
<description>This standard changes the line length</description>
|
||||
|
||||
<!-- Insert all sniff from PSR2 standard -->
|
||||
<rule ref="PSR2"/>
|
||||
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="120"/>
|
||||
<property name="absoluteLineLimit" value="0"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
@ -103,7 +103,7 @@
|
||||
|
||||
event.data.directUrl = !!config.document.directUrl;
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "webeditor-ajax.php?type=reference");
|
||||
xhr.open("POST", "reference");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify(event.data));
|
||||
xhr.onload = function () {
|
||||
@ -161,7 +161,7 @@
|
||||
url: url
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "webeditor-ajax.php?type=saveas");
|
||||
xhr.open("POST", "saveas");
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify(data));
|
||||
xhr.onload = function () {
|
||||
@ -181,7 +181,7 @@
|
||||
};
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "webeditor-ajax.php?type=rename");
|
||||
xhr.open("POST", "rename");
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify(data));
|
||||
xhr.onload = function () {
|
||||
@ -189,6 +189,27 @@
|
||||
}
|
||||
};
|
||||
|
||||
function onRequestRestore(event) {
|
||||
const query = new URLSearchParams(window.location.search)
|
||||
const config = {config}
|
||||
const payload = {
|
||||
fileName: query.get('fileID'),
|
||||
version: event.data.version,
|
||||
userId: query.get('user') || config.editorConfig.user.id
|
||||
}
|
||||
const request = new XMLHttpRequest()
|
||||
request.open("PUT", 'restore')
|
||||
request.send(JSON.stringify(payload))
|
||||
request.onload = function () {
|
||||
if (request.status != 200) {
|
||||
response = JSON.parse(request.response)
|
||||
innerAlert(response.error)
|
||||
return
|
||||
}
|
||||
document.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
var сonnectEditor = function () {
|
||||
{fileNotFoundAlert}
|
||||
|
||||
@ -208,6 +229,7 @@
|
||||
'onRequestCompareFile': onRequestCompareFile,
|
||||
'onRequestMailMergeRecipients': onRequestMailMergeRecipients,
|
||||
'onRequestReferenceData': onRequestReferenceData,
|
||||
'onRequestRestore': onRequestRestore
|
||||
};
|
||||
|
||||
{history}
|
||||
|
||||
@ -35,19 +35,19 @@
|
||||
<ul class="try-editor-list clearFix">
|
||||
<li>
|
||||
<a class="try-editor word reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=docx&user={user}">Document</a>
|
||||
href="editor?fileExt=docx&user={user}">Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor cell reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=xlsx&user={user}">Spreadsheet</a>
|
||||
href="editor?fileExt=xlsx&user={user}">Spreadsheet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor slide reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=pptx&user={user}">Presentation</a>
|
||||
href="editor?fileExt=pptx&user={user}">Presentation</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor form reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=docxf&user={user}">Form template</a>
|
||||
href="editor?fileExt=docxf&user={user}">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="side-option">
|
||||
@ -58,7 +58,7 @@
|
||||
<div class="upload-panel clearFix">
|
||||
<a class="file-upload">Upload file
|
||||
<input type="file" id="fileupload" name="files"
|
||||
data-url="webeditor-ajax.php?type=upload&user={user}" />
|
||||
data-url="upload?user={user}" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -212,7 +212,7 @@
|
||||
<script type="text/javascript" src="js/jquery.dropdownToggle.js"></script>
|
||||
<script type="text/javascript" src="js/jscript.js"></script>
|
||||
<script type="text/javascript">
|
||||
var FillFormsExtList = '{docServFillforms}';
|
||||
var FillFormsExtList = '{fillFormsExtList}';
|
||||
var ConverExtList = '{converExtList}';
|
||||
var EditedExtList = '{editedExtList}';
|
||||
</script>
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
namespace OnlineEditorsExamplePhp;
|
||||
|
||||
use Exception;
|
||||
use OnlineEditorsExamplePhp\Configuration\ConfigurationManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\ConfigManager;
|
||||
use OnlineEditorsExamplePhp\Helpers\JwtManager;
|
||||
|
||||
@ -28,6 +29,8 @@ use OnlineEditorsExamplePhp\Helpers\JwtManager;
|
||||
*/
|
||||
function readBody()
|
||||
{
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$result["error"] = 0;
|
||||
$configManager = new ConfigManager();
|
||||
$jwtManager = new JwtManager();
|
||||
@ -53,8 +56,7 @@ function readBody()
|
||||
|
||||
$inHeader = false;
|
||||
$data = "";
|
||||
$jwtHeader = $configManager->getConfig("docServJwtHeader") ==
|
||||
"" ? "Authorization" : $configManager->getConfig("docServJwtHeader");
|
||||
$jwtHeader = $config_manager->jwt_header();
|
||||
|
||||
if (!empty($data["token"])) { // if the document token is in the data
|
||||
$data = $jwtManager->jwtDecode($data["token"]); // decode it
|
||||
@ -290,10 +292,10 @@ function processForceSave($data, $fileName, $userAddress)
|
||||
*/
|
||||
function commandRequest($method, $key, $meta = null)
|
||||
{
|
||||
$configManager = new ConfigManager();
|
||||
$config_manager = new ConfigurationManager();
|
||||
|
||||
$jwtManager = new JwtManager();
|
||||
$documentCommandUrl = $configManager->getConfig("docServSiteUrl").
|
||||
$configManager->getConfig("docServCommandUrl");
|
||||
$documentCommandUrl = $config_manager->document_server_command_url()->string();
|
||||
|
||||
$arr = [
|
||||
"c" => $method,
|
||||
@ -305,8 +307,7 @@ function commandRequest($method, $key, $meta = null)
|
||||
}
|
||||
|
||||
$headerToken = "";
|
||||
$jwtHeader = $configManager->getConfig("docServJwtHeader") == "" ? "Authorization" :
|
||||
$configManager->getConfig("docServJwtHeader");
|
||||
$jwtHeader = $config_manager->jwt_header();
|
||||
|
||||
// check if a secret key to generate token exists or not
|
||||
if ($jwtManager->isJwtEnabled() && $jwtManager->tokenUseForRequest()) {
|
||||
@ -326,7 +327,7 @@ function commandRequest($method, $key, $meta = null)
|
||||
]];
|
||||
|
||||
if (mb_substr($documentCommandUrl, 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];
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user