Compare commits

..

279 Commits

Author SHA1 Message Date
c9baa474be python-raw: add sr-only 2023-08-11 18:42:23 +04:00
48185674d4 python-raw: up html 2023-08-11 18:42:12 +04:00
dbca11e85c python-raw: move js 2023-08-11 18:41:45 +04:00
d21a732859 python-raw: move css 2023-08-11 18:40:57 +04:00
b96a6fac53 python-raw: add js 2023-08-08 14:43:34 +04:00
b01af348a7 python-raw: add html 2023-08-08 14:43:17 +04:00
c2443d3106 python-raw: add styles 2023-08-08 14:42:56 +04:00
5fa3f4c57f python-raw: add formats endpoint 2023-08-08 14:41:58 +04:00
efd7e1b6e7 python-raw: add format methods 2023-08-08 14:41:20 +04:00
259ee63eea python-raw: temp hide server 2023-08-08 14:41:00 +04:00
453b9835b7 python-raw: fix formats 2023-08-08 14:40:27 +04:00
89e6544b79 Merge branch 'feature/python-matrix-formats' into feature/python-conversion 2023-08-04 12:31:53 +04:00
32a60c09aa python: add public and private document-server urls to the compose 2023-08-02 10:49:34 +04:00
5a03024cd3 python: add support for the internal network for the track endpoint 2023-08-02 10:49:34 +04:00
cb6416c481 python: sort imports 2023-08-02 10:49:34 +04:00
55e4247687 python: add tests for proxy manager 2023-08-02 10:49:34 +04:00
a0620905b2 python: add proxy manager to resolve the document-server url 2023-08-02 10:49:34 +04:00
3fcef4096a python: remove the strict CORS hint 2023-08-02 10:49:34 +04:00
4e5349c1c4 python: add tests for specifying public and private document-server urls 2023-08-02 10:49:34 +04:00
538eec1ff3 python: add support for specifying public and private document-server urls 2023-08-02 10:49:34 +04:00
df7cfda2fb Merge pull request #429 from ONLYOFFICE/fix/java-spring-save-previous
java-spring: add a step to save the previous version of the file during processing save
2023-07-31 15:37:55 +03:00
9ebef04f3d Merge pull request #415 from ONLYOFFICE/feature/ruby-docker
ruby: add support for containerization
2023-07-31 15:36:46 +03:00
a6ed970bca Merge pull request #413 from ONLYOFFICE/feature/python-docker
python: add support for containerization
2023-07-31 15:36:06 +03:00
7f659bc95e Merge pull request #428 from ONLYOFFICE/fix/php-lint-action
php: update php lint action to latest changes
2023-07-31 09:46:00 +03:00
3c4a1c1c31 Merge pull request #425 from ONLYOFFICE/feature/php-server-configuration
php: simplify server configuration
2023-07-29 15:42:55 +03:00
2bae0567ad nodejs: fix for ie (496a150620) 2023-07-28 17:26:53 +03:00
c06f2a5a29 python: replace the previous implementation of formats 2023-07-28 18:01:05 +04:00
8aed04753c python: add tests for the format module 2023-07-28 18:01:01 +04:00
15ed02e556 python: add format module 2023-07-28 12:06:30 +04:00
fb66dc8423 python: add tests for the codable module 2023-07-28 12:06:30 +04:00
541ace8132 python: add codable module 2023-07-28 12:06:30 +04:00
8b5cebeb3f python: add document-formats submodule 2023-07-28 12:06:30 +04:00
419fbf90f9 python: update paths to the new location of templates 2023-07-27 17:10:50 +04:00
2d637b88df python: move document-templates to the assets directory 2023-07-27 17:10:50 +04:00
13e2d5b33c python: add recipes to work with docker 2023-07-27 16:12:43 +04:00
f208fe1939 python: add docker files 2023-07-27 16:12:43 +04:00
b3cc35cb5e python: add support for the ADDRESS env variable 2023-07-27 16:12:43 +04:00
8b316b0786 python: move the lint recipe to the bottom of file 2023-07-27 16:12:43 +04:00
c57fcbfd90 python: delete recipes sorting in the help recipe 2023-07-27 16:12:43 +04:00
1939b85c8c ruby: disable strict hosts policy 2023-07-27 11:26:40 +04:00
ee0ac33820 ruby: add recipes to work with docker 2023-07-27 11:26:40 +04:00
c93579d98f ruby: add docker files 2023-07-27 11:26:40 +04:00
61a9e122cd ruby: move the lint recipe to the bottom of file 2023-07-27 11:26:40 +04:00
e88a9f5bed ruby: delete recipes sorting in the help recipe 2023-07-27 11:26:40 +04:00
f1ce0fb415 ruby: rename server recipes 2023-07-27 11:26:40 +04:00
3b142d92fc php: update urls to new endpoints 2023-07-26 17:42:48 +04:00
1898da660e php: simplify server configuration 2023-07-26 17:42:48 +04:00
0629cf0797 php: add HTTPStatus enum 2023-07-26 17:42:48 +04:00
7737670a6d php: delete IIS config 2023-07-26 17:42:48 +04:00
5bdcac42e3 php: add recipes to start the server 2023-07-26 17:42:48 +04:00
4b8ffa26cc php: add fpm config 2023-07-26 17:41:53 +04:00
a4b6fcb512 java-spring: add a step to save the previous version of the file during processing save 2023-07-26 17:34:07 +04:00
523b10c979 php: update php lint action to latest changes 2023-07-26 17:03:50 +04:00
1d4bc95c29 Merge pull request #424 from ONLYOFFICE/feature/php-configuration-manager
php: add support for configuration via environment variables
2023-07-26 15:31:05 +03:00
e94a4863aa php: replace json config with configuration manager 2023-07-26 12:07:58 +04:00
edda981ab7 php: append configuration directory to test recipe 2023-07-26 12:07:55 +04:00
65ebf9a5b1 php: add configuration manager tests 2023-07-26 12:07:55 +04:00
a081cd1f06 php: add configuration manager 2023-07-26 12:07:55 +04:00
04c5ee8cd7 php: add URL tests 2023-07-26 12:07:55 +04:00
3ebf3fabee php: add URL class 2023-07-26 12:07:52 +04:00
403efc1325 php: add tests for the path absolute function 2023-07-26 11:27:50 +04:00
7deedcaa5e php: enrich Path with new methods 2023-07-26 11:27:50 +04:00
161e26dd8a Merge pull request #423 from ONLYOFFICE/feature/php-missed-tests
php: add missed path tests and rewrite path methods a bit
2023-07-26 10:21:30 +03:00
09804349fa php: update path instances due to new methods 2023-07-24 14:22:28 +04:00
83a83f4f5d php: fix make test receipt 2023-07-24 14:22:28 +04:00
79ee987003 php: add path tests 2023-07-24 14:22:28 +04:00
434484cac3 php: separate path normalization from join 2023-07-24 14:22:25 +04:00
a0bafb0e4b php: simplify path string generation 2023-07-24 12:41:43 +04:00
184aded727 php: remove path separator from constructor options 2023-07-24 12:41:40 +04:00
7db708e559 Merge pull request #422 from ONLYOFFICE/feature/php-normalize-dependencies
php: pin and normalize existing dependencies, add new ones
2023-07-21 14:42:41 +03:00
3b3116f56e php: license link 2023-07-21 14:42:18 +03:00
15c70f43d7 Merge pull request #421 from ONLYOFFICE/feature/php-restore-endpoint
php: add restore endpoint
2023-07-21 09:49:00 +03:00
39af4be045 php: restore to changelog 2023-07-21 09:48:35 +03:00
c9dc4862ed php: add ignore file 2023-07-20 16:15:46 +04:00
122d41e307 php: add lint and test recieps 2023-07-20 16:15:44 +04:00
2880db7383 php: add install recipes 2023-07-20 16:14:24 +04:00
c0f23a4fc2 php: add makefile 2023-07-20 16:14:24 +04:00
1a49d8dd03 php: normalize codesniffer config file 2023-07-20 16:14:24 +04:00
180f287c07 php: delete composer scripts 2023-07-20 16:14:24 +04:00
37c33965c8 php: move autoload to the production section 2023-07-20 16:14:24 +04:00
0861732dbe php: replace local jwt with jwt as a dependency 2023-07-20 16:14:24 +04:00
d3220c7a91 php: add phpunit 2023-07-20 16:14:24 +04:00
450cafdae3 php: move mbstring extension to production dependencies 2023-07-20 16:14:24 +04:00
62abe3e569 php: pin dependency versions 2023-07-20 16:14:24 +04:00
8b2fbff3b7 php: update lock file 2023-07-20 16:14:24 +04:00
acf243ee3e php: add restore endpoint 2023-07-19 15:29:27 +04:00
66c38ded4a php: add the common module with Path class 2023-07-19 15:29:27 +04:00
58a73190d4 Merge pull request #420 from ONLYOFFICE/fix/php-assets-path
php: fix a new path to the assets directory
2023-07-19 09:41:21 +03:00
ae7a208831 php: fix a new path to the assets directory 2023-07-18 13:52:13 +04:00
2d83f3f39c Merge pull request #419 from ONLYOFFICE/feature/ruby-restore-endpoint
ruby: add restore endpoint
2023-07-18 12:20:46 +03:00
2aed1e3a83 ruby: restore to changelog 2023-07-18 12:19:57 +03:00
001a99b502 Merge pull request #418 from ONLYOFFICE/fix/ruby-sorbet-commands
ruby: hide sorbet commands for unsupported platforms
2023-07-18 12:18:26 +03:00
a7a9f997d5 ruby: add restore endpoint 2023-07-18 10:35:31 +04:00
4c3dc96e30 Merge pull request #417 from ONLYOFFICE/fix/ruby-config-manager-typo
ruby: fix typo in config manager name
2023-07-18 09:19:46 +03:00
7fe1ae27b4 Merge pull request #416 from ONLYOFFICE/feature/ruby-configuration-manager-tests
ruby: add missed configuration manager tests
2023-07-18 09:19:09 +03:00
dce840c627 ruby: hide sorbet commands for unsupported platforms 2023-07-17 18:50:17 +04:00
4f832ac2f7 ruby: fix typo in config manager name 2023-07-17 18:42:59 +04:00
e7623e29d7 ruby: add test recipe 2023-07-17 18:26:09 +04:00
16dd8a55e5 ruby: add missed configuration manager tests 2023-07-17 18:26:09 +04:00
dca68bf0d1 ruby: add missed imports 2023-07-17 18:26:09 +04:00
f028f1ba2f ruby: add test-unit as a dependency to satisfy rake 2023-07-17 18:26:09 +04:00
5c8867dd20 ruby: move the configuration to its directory 2023-07-17 18:26:09 +04:00
27eea60fc3 Merge pull request #414 from ONLYOFFICE/feature/python-restore-endpoint
python: add restore endpoint
2023-07-17 15:12:00 +03:00
c285b49d3b python: restore to changelog 2023-07-17 15:11:28 +03:00
70c86f3054 python: add onRequestRestore callback 2023-07-14 14:55:57 +04:00
00e5466a0c python: add restore endpoint 2023-07-14 14:55:57 +04:00
12a366a28a python: sort imports 2023-07-14 14:55:12 +04:00
b4918cf493 python: delete unused imports 2023-07-14 14:55:12 +04:00
b2b21980d1 python: add error response 2023-07-14 14:55:12 +04:00
09a97c0f66 python: add tests for the http functions 2023-07-14 14:55:12 +04:00
5db65ef062 python: add functions to declare the http method for the endpoint 2023-07-14 14:55:12 +04:00
5164380336 python: add a function to find a user by his ID 2023-07-14 14:55:12 +04:00
26c5cd0a83 python: remove unused import 2023-07-14 14:55:12 +04:00
bff8c83283 Merge pull request #410 from ONLYOFFICE/feature/python-server-configuration
python: simplify server configuration
2023-07-14 10:43:29 +03:00
827bd3981f python: add missed django_settings_module 2023-07-13 17:10:10 +04:00
e8599c7c56 python: add recipes to start the server 2023-07-13 17:10:06 +04:00
0a3b951eb6 Merge pull request #412 from ONLYOFFICE/feature/ruby-respect-gitignore
ruby: respect gitignore
2023-07-13 15:25:59 +03:00
988da27e3f python: simplify server configuration 2023-07-13 16:23:09 +04:00
a697219dcf ruby: add receipt stages to generate bin files 2023-07-13 16:04:54 +04:00
7649e7f51e ruby: delete files that should be ignored 2023-07-13 16:02:24 +04:00
108b5ea317 ruby: move example-specific ignored files to the root of the example 2023-07-13 16:02:24 +04:00
4ea0760803 Merge pull request #411 from ONLYOFFICE/feature/ruby-server-configuration
ruby: simplify server configuration
2023-07-13 14:51:07 +03:00
c558098deb ruby: delete sqlite3 2023-07-13 14:48:57 +03:00
4a61093343 Merge pull request #409 from ONLYOFFICE/feature/python-configuration-manager
python: add support for configuration via environment variables
2023-07-13 14:46:34 +03:00
2af1f56aa7 ruby: delete sqlite3 as it's not used 2023-07-13 14:02:30 +04:00
6780feafa6 ruby: add recipes to start the server 2023-07-13 14:02:26 +04:00
23b4ffc104 ruby: simplify server configuration 2023-07-12 13:44:20 +04:00
46a9fffb0e 7.4 formats 2023-07-12 11:46:15 +03:00
0ccc98e83f python: standardize the format of URLs 2023-07-10 16:29:59 +04:00
7f59c15112 python: replace the global config with the configuration manager 2023-07-10 16:29:59 +04:00
455f2ee823 python: add tests for the configuration manager 2023-07-10 16:29:51 +04:00
3076a9bc0e python: add configuration manager 2023-07-10 16:05:30 +04:00
c605607b5e python: add test recipe 2023-07-10 14:52:21 +04:00
e05afc931a python: add tests for the string boolean function 2023-07-10 14:49:25 +04:00
53aeb19e2f python: add the common module with string boolean function 2023-07-10 14:46:33 +04:00
14a557be69 Merge pull request #396 from ONLYOFFICE/feature/ruby-configuration-environment
ruby: support for configuration via environment variables
2023-07-10 10:28:24 +03:00
666b6f8a03 Merge pull request #408 from ONLYOFFICE/fix/ruby-sorbet-platforms
ruby: fix sorbet installation on unsupported platforms
2023-07-07 15:33:10 +03:00
ebddc8114a ruby: fix sorbet installation on unsupported platforms 2023-07-05 12:26:00 +04:00
fa76819b2d Merge pull request #403 from ONLYOFFICE/feature/python-normalize-dependencies
python: pin and add new dependencies
2023-07-05 10:02:00 +03:00
69aa25880a python: 3rd party licenses 2023-07-05 10:00:21 +03:00
7cd79280ff python: add help, dev, lint, prod recipes to Makefile 2023-07-04 16:57:03 +04:00
4535bfe661 python: add development dependencies 2023-07-04 16:56:57 +04:00
01cabdf1e5 python: pin python version 2023-07-04 14:12:11 +04:00
8b15a0e417 python: pin dependency versions 2023-07-04 14:12:11 +04:00
451b3b7a38 ruby: standardize the format of the URIs in the configuration 2023-07-04 13:52:40 +04:00
952b495c4d ruby: support for configuration via environment variables 2023-07-04 13:52:37 +04:00
1cd3642de8 Merge pull request #407 from ONLYOFFICE/feature/reference-source
Feature/reference source
2023-07-04 12:49:58 +03:00
a4f49cb86b nodejs: change reference source to changelog 2023-07-04 12:45:15 +03:00
9ca722329f nodejs: 1.6.0 (50a4ddbd11) 2023-07-04 10:51:24 +03:00
496a150620 nodejs: onRequestReferenceSource method 2023-06-30 11:29:38 +03:00
983a92d9e0 nodejs: function for getting of file extension 2023-06-30 11:27:48 +03:00
ad94016a85 Merge remote-tracking branch 'remotes/origin/master' into develop
# Conflicts:
#	CHANGELOG.md
#	web/documentserver-example/php/functions.php
#	web/documentserver-example/php/views/DocEditorView.php
2023-06-29 11:13:23 +05:00
fcb807471f Merge pull request #406 from ONLYOFFICE/release/1.6.0
Release/1.6.0
2023-06-29 11:07:55 +05:00
50a4ddbd11 1.6.0 2023-06-29 11:00:42 +05:00
01d1dc4274 Merge pull request #405 from ONLYOFFICE/hotfix/csharp-reload-filelist-upload
Hotfix/csharp reload filelist upload
2023-06-28 11:20:58 +05:00
1447b304eb Merge pull request #404 from ONLYOFFICE/hotfix/delete-old-file-after-convert
Hotfix/delete old file after convert
2023-06-28 11:20:24 +05:00
8e79c6448f csharp: reload after click on edit or view in upload window 2023-06-27 12:08:59 +03:00
badf3c7d49 csharp-mvc: reload after click on edit or view in upload window 2023-06-27 12:08:35 +03:00
342b31f7d7 java-spring: delete original file after convert 2023-06-27 11:32:28 +03:00
0ae8f5d396 java: delete original file after convert 2023-06-27 11:09:43 +03:00
7a238c2b73 Merge branch 'release/v7.4.0' into hotfix/delete-old-file-after-convert 2023-06-27 10:55:39 +03:00
0b4c67e552 Merge branch 'hotfix/headers-charset-on-upload-convert' into release/v7.4.0 2023-06-27 12:10:42 +05:00
f5391051b1 ruby: delete original file after convert 2023-06-27 09:59:00 +03:00
01c8a940d4 csharp: fix error with convert response (6aa80c4a8c) 2023-06-26 17:33:42 +05:00
579992e40b Merge pull request #402 from ONLYOFFICE/hotfix/csharp
fixed: generating key
2023-06-26 15:42:14 +05:00
3a2218a466 Merge pull request #401 from ONLYOFFICE/hotfix/ruby-filelist-reload-fix
ruby: reload after click on edit or view in upload window
2023-06-26 15:40:55 +05:00
0ea28f525f Merge pull request #400 from ONLYOFFICE/hotfix/disable-cors-on-download
php: disable CORS on download
2023-06-26 15:40:27 +05:00
33363f6144 fixed: generating key 2023-06-26 13:01:03 +03:00
da8bdca022 ruby: reload after click on edit or view in upload window 2023-06-26 12:52:17 +03:00
c4eccc5ee8 Merge pull request #398 from ONLYOFFICE/hotfix/php-sample-key-fix
php: undefined "sample" key fix
2023-06-26 14:24:02 +05:00
ab13745cf6 Merge pull request #399 from ONLYOFFICE/hotfix/referenceData
Hotfix/reference data
2023-06-26 14:23:09 +05:00
97f07e4275 ruby: fixed directUrl property 2023-06-26 12:20:07 +03:00
7c3e250797 php: undefined "sample" key fix 2023-06-26 11:40:57 +03:00
32ab794f11 python: fixed directUrl property 2023-06-26 11:23:03 +03:00
800ef84f84 csharp: fixed directUrl property 2023-06-26 11:18:52 +03:00
a7e4036667 php: fixed directUrl property 2023-06-26 11:11:52 +03:00
4f589a7394 java: fixed directUrl property 2023-06-26 11:05:01 +03:00
a3abb58d72 java-spring: fixed directUrl property 2023-06-26 10:21:21 +03:00
17536df8e5 csharp-mvc: fixed directUrl property 2023-06-26 10:08:44 +03:00
2e8a483a0c csharp-mvc: fix error with convert response (d9a79e20d7) 2023-06-26 11:47:38 +05:00
a0aa7b4fd0 php: disable CORS on download 2023-06-23 13:38:06 +03:00
8b720beffa Merge pull request #397 from ONLYOFFICE/hotfix/java-spring
java-spring: fixed bug with update external links reference data
2023-06-23 11:36:50 +05:00
a1c286cbaa java-spring: fixed bug with update external links reference data 2023-06-23 09:05:26 +03:00
fc377b967d Merge pull request #395 from ONLYOFFICE/hotfix/disable-cors-for-download
python: disable CORS in download
2023-06-22 17:43:07 +05:00
b2de5eff4c Merge pull request #394 from ONLYOFFICE/hotfix/python-reload-file-list
python: reload file list after start of editing
2023-06-22 17:42:31 +05:00
02439f3699 Merge pull request #393 from ONLYOFFICE/hotfix/php-fixes-release-740
Hotfix/php fixes for release 7.4.0
2023-06-22 17:41:28 +05:00
2429f21a84 python: disable CORS in download 2023-06-22 12:13:36 +03:00
aa0a4b5400 php: encoded space used 2023-06-22 11:48:51 +03:00
a28300848b python: reload file list after start of editing 2023-06-22 11:22:56 +03:00
fec0e87218 php: fix warnings in editor 2023-06-22 10:46:36 +03:00
efbace1e8b php: correct name of file when downloading 2023-06-22 10:30:37 +03:00
35e479355a php: convert warning fix 2023-06-22 10:22:17 +03:00
32c91b9016 Merge pull request #392 from ONLYOFFICE/hotfix/users-permissions-fix
java: null instead of empty lists
2023-06-21 16:01:01 +05:00
183d165c00 java: null instead of empty lists 2023-06-21 12:40:35 +03:00
a996f2c3c3 Merge pull request #390 from ONLYOFFICE/hotfix/content-disposition-for-download-encode
python: filename encoding for content-disposition header
2023-06-21 13:19:06 +05:00
782243eb86 Merge pull request #391 from ONLYOFFICE/hotfix/java-spring
Hotfix/java spring
2023-06-21 13:18:15 +05:00
f058d68126 fix bug with switching from view to edit 2023-06-21 11:11:33 +03:00
a8f07fce4d fix bug with upload file size more 1MB 2023-06-21 11:11:28 +03:00
025bd1068d fix bug with file conversion 2023-06-21 11:11:17 +03:00
75b22614cf refresh licenses 2023-06-21 12:29:59 +05:00
6cb15697ab Merge pull request #388 from ONLYOFFICE/feature/ruby-normalize-dependencies
ruby: pin and add new dependencies
2023-06-21 12:12:22 +05:00
1da93ce071 python: filename encoding for content-disposition header 2023-06-21 09:37:26 +03:00
837e34de37 Merge pull request #389 from ONLYOFFICE/hotfix/convert-status-code-type
ruby: fix conversion service status type
2023-06-20 13:52:27 +05:00
20c4ec1b78 ruby: fix conversion service status type 2023-06-20 11:30:40 +03:00
39bab74422 Merge pull request #383 from ONLYOFFICE/feature/formats
Feature/formats
2023-06-19 11:47:19 +05:00
665ab6a77d formats to changelog 2023-06-19 11:47:03 +05:00
5663227c55 update formats repo 2023-06-19 11:45:26 +05:00
42ac89e5e5 Merge pull request #370 from ONLYOFFICE/hotfix/headers-charset-on-upload-convert
java: upload and convert fix
2023-06-19 11:33:09 +05:00
c95499536d ruby: add lint recipe to Makefile 2023-06-14 10:38:35 +04:00
5659756c07 ruby: add install recipe to Makefile 2023-06-14 10:38:35 +04:00
038b3b3049 ruby: add help recipe to Makefile 2023-06-14 10:38:35 +04:00
6b555c4d0d ruby: add sorbet as a type-checker dependency 2023-06-14 10:38:27 +04:00
44d49bed62 ruby: add rubocop as a lint dependency 2023-06-14 10:23:02 +04:00
517b130db6 ruby: pin ruby version 2023-06-09 12:13:40 +04:00
0ff435b9bd ruby: pin dependency versions and add support for the arm64 platform 2023-06-09 12:13:14 +04:00
56bc372140 Merge remote-tracking branch 'remotes/origin/release/v7.4.0' into develop
# Conflicts:
#	web/documentserver-example/nodejs/helpers/docManager.js
2023-06-07 18:57:00 +05:00
0068b6d87d Merge pull request #381 from ONLYOFFICE/feature/getServerHost
Fix get server host function
2023-06-07 18:44:17 +05:00
4679804774 Merge pull request #386 from ONLYOFFICE/hotfix/fix-php-readme
php: composer installation added to readme
2023-06-07 16:30:48 +05:00
d03f74087c php: composer installation added to readme 2023-06-07 16:29:57 +05:00
e3a088ccaf nodejs: fix undefined header 2023-06-07 13:29:45 +05:00
5865fedbe7 java: upload and convert fix 2023-06-05 10:19:58 +03:00
68390aa26c php: lossy-edit to getEditExtensions() 2023-06-02 12:31:41 +03:00
744e5203cb nodejs: lossy-edit to getEditExtensions() 2023-06-02 12:29:44 +03:00
7df7af3f47 nodejs, php: update submodule document-formats 2023-06-02 12:21:00 +03:00
bf40cd1249 Merge branch 'develop' into feature/formats 2023-06-02 11:01:19 +03:00
f3cb5adb22 nodejs: fix (668df46ec3) 2023-06-02 11:00:30 +03:00
c8d44199c2 php: fix lint 2023-06-01 16:21:36 +03:00
12bcc0009b nodejs: disable eslint for import onlyoffice-docs-formats.json 2023-06-01 16:14:12 +03:00
be1ea81f82 Merge branch 'develop' into feature/formats 2023-06-01 15:53:41 +03:00
668df46ec3 nodejs: fix(dd3255779f) 2023-06-01 15:53:07 +03:00
43905695e0 nodejs: fix lint 2023-06-01 14:50:06 +03:00
4a49becea1 php: revert composer.lock 2023-05-31 15:34:42 +03:00
c91d3a24b9 update submodule document-formats 2023-05-31 14:39:48 +03:00
d6a4984b84 Merge pull request #382 from ONLYOFFICE/feature/restore-version
Feature/restore version
2023-05-22 15:45:19 +05:00
f1dae06746 changelog: restore file 2023-05-22 15:44:45 +05:00
3cf3bcf2c8 Merge remote-tracking branch 'remotes/origin/develop' into feature/restore-version 2023-05-22 15:44:11 +05:00
aa6e19ebaa Merge pull request #372 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/nokogiri-1.14.3
build(deps): bump nokogiri from 1.13.9 to 1.14.3 in /web/documentserver-example/ruby
2023-05-22 14:01:04 +05:00
24a26fd530 Correct spelling mistake 2023-05-19 12:57:10 +00:00
a5f91bc14f Fix get server host function 2023-05-19 09:07:38 +00:00
d7034c72c9 Merge pull request #379 from ONLYOFFICE/feature/remove-row-without-reload
nodejs: remove row without reload
2023-05-18 18:12:46 +05:00
c0437b152f remove row to changelog 2023-05-18 18:10:44 +05:00
b72b2c6619 Merge branch 'develop' into feature/remove-row-without-reload
# Conflicts:
#	web/documentserver-example/nodejs/public/javascripts/jscript.js
2023-05-18 13:34:34 +03:00
c516631360 nodejs: fix remove for IE 2023-05-18 13:31:50 +03:00
5cc8d7c094 Merge pull request #380 from ONLYOFFICE/feature/get-history-by-request
nodejs: get history data by request
2023-05-18 11:23:10 +05:00
5f4764060c changelog: history request 2023-05-18 11:22:17 +05:00
44832008a8 nodejs: reload the page if deleted line is the last one 2023-05-17 13:24:28 +03:00
d86e737493 nodejs: fix properties for IE, historyObject used in requestRestore 2023-05-17 12:59:55 +03:00
07a1e3101b Merge branch 'feature/get-history-by-request' into feature/restore-version 2023-05-17 12:55:51 +03:00
1ebfe49916 nodejs: fix properties for IE 2023-05-17 12:54:15 +03:00
b1d6f8d652 Merge branch 'feature/get-history-by-request' into feature/restore-version 2023-05-17 12:46:15 +03:00
8f0edf90e6 nodejs: request in onRequestHistory only 2023-05-17 12:43:33 +03:00
7c77389550 build(deps): bump nokogiri in /web/documentserver-example/ruby
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.14.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.14.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-17 12:42:09 +05:00
637731a4d7 Merge pull request #373 from ONLYOFFICE/refactor/collect-params-for-url
Refactor/collect params for url
2023-05-17 12:34:35 +05:00
6fc98a025b Merge branch 'feature/get-history-by-request' into feature/restore-version
# Conflicts:
#	web/documentserver-example/nodejs/app.js
2023-05-12 13:03:31 +03:00
f123cbcce3 nodejs: handler for restore file version 2023-05-12 13:00:48 +03:00
11f166525e nodejs: onRequestRestore method on front 2023-05-12 12:56:24 +03:00
68db498dfd nodejs: get history data by request 2023-05-12 11:12:32 +03:00
f914afcc53 nodejs: remove row without reload 2023-05-11 15:14:07 +03:00
8dcf75f3fb nodejs: get history data by request 2023-05-11 14:06:48 +03:00
66faaab294 Merge branch 'develop' into refactor/collect-params-for-url
# Conflicts:
#	web/documentserver-example/nodejs/views/index.ejs
#	web/documentserver-example/nodejs/views/wopiIndex.ejs
2023-04-28 11:20:25 +03:00
f2a11a5894 nodejs: WOPI-page fix 2023-04-27 14:54:36 +03:00
c6043d4428 nodejs: fix tabulation 2023-04-27 11:36:04 +03:00
c37ba28ad3 php: added work with onlyoffice-docs-formats.json 2023-04-27 11:33:57 +03:00
53f810fc54 php: added module document-formats 2023-04-27 10:48:48 +03:00
a55875ae1e php: added module document-templates 2023-04-27 10:46:33 +03:00
707a634823 php: removed module document-templates 2023-04-27 10:42:31 +03:00
b511fa872a nodejs: added module document-formats 2023-04-27 10:36:56 +03:00
4a2e7d9a9e nodejs: added module document-templates 2023-04-27 10:32:49 +03:00
e4d5de2c0e removed module document-templates 2023-04-27 10:24:32 +03:00
50dca2e2c0 php: added work with onlyoffice-docs-formats.json 2023-04-26 14:58:00 +03:00
893303c27f nodejs: added work with onlyoffice-docs-formats.json 2023-04-26 11:48:38 +03:00
b543392c62 nodejs: server url to link in logo 2023-04-26 09:22:39 +03:00
adf52c756e nodejs: fix url-params + IE fix 2023-04-21 12:55:02 +03:00
c2b87959a2 nodejs: collectParams() instead of reload() + input text added 2023-04-19 11:14:45 +03:00
18ee7776ef nodejs: radio elements + "name" attribute instead of "data-param" 2023-04-19 10:06:29 +03:00
c99efda67a nodejs: open window in new tab 2023-04-19 09:25:49 +03:00
d65f970255 nodejs: collectParams() method added 2023-04-18 14:45:31 +03:00
f5442a8a89 nodejs: url params for collectable elements 2023-04-18 14:44:04 +03:00
e347ea36ce nodejs: "params" in links deleted, added class for actions 2023-04-18 11:50:54 +03:00
225 changed files with 10068 additions and 2685 deletions

View File

@ -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
View File

@ -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
View File

@ -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

View File

@ -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. Theres 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

View File

@ -1,5 +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

View File

@ -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

View File

@ -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;
}

View File

@ -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 () {

View File

@ -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 }

View File

@ -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

View File

@ -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=""/>

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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>{

View File

@ -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

View File

@ -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 () {

View File

@ -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=""/>

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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();

View File

@ -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));
}};

View File

@ -1,4 +1,4 @@
version=1.5.1
version=1.6.0
filesize-max=5242880
storage-folder=app_data

View File

@ -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

View File

@ -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;
@ -343,11 +333,11 @@ app.post('/convert', (req, res) => { // define a handler for converting files
const result = {};
// write file name, step and error values to the result object if they are defined
if (filename) result.filename = filename;
if (filename !== null) result.filename = filename;
if (step) result.step = step;
if (step !== null) result.step = step;
if (error) result.error = error;
if (error !== null) result.error = error;
response.setHeader('Content-Type', 'application/json');
response.write(JSON.stringify(result));
@ -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);
@ -548,6 +538,40 @@ app.post('/reference', (req, res) => { // define a handler for renaming file
result(data);
});
app.put('/restore', (req, res) => { // define a handler for restore file version
const { fileName } = req.body;
const result = {};
if (fileName) {
req.DocManager = new DocManager(req, res);
const userAddress = req.DocManager.curUserHostAddress();
const key = req.DocManager.getKey(fileName);
const { version } = req.body;
const filePath = req.DocManager.storagePath(fileName, userAddress);
const historyPath = req.DocManager.historyPath(fileName, userAddress);
const newVersion = req.DocManager.countVersion(historyPath) + 1;
const versionPath = `${historyPath}\\${version}\\prev${fileUtility.getFileExtension(fileName)}`;
const newVersionPath = `${historyPath}\\${newVersion}`;
if (fileSystem.existsSync(versionPath)) {
req.DocManager.createDirectory(newVersionPath);
req.DocManager.copyFile(filePath, `${newVersionPath}\\prev${fileUtility.getFileExtension(fileName)}`);
fileSystem.writeFileSync(`${newVersionPath}\\key.txt`, key);
req.DocManager.copyFile(versionPath, filePath);
result.success = true;
} else {
result.success = false;
result.error = 'Version path does not exists';
}
} else {
result.success = false;
result.error = 'Filename is empty';
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify(result));
res.end();
});
app.post('/track', async (req, res) => { // define a handler for tracking file changes
req.DocManager = new DocManager(req, res);
@ -848,8 +872,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
const fileName = fileUtility.getFileName(req.query.fileName);
let { fileExt } = req.query;
const history = [];
const historyData = [];
const lang = req.DocManager.getLang();
const user = users.getUser(req.query.userid);
const userDirectUrl = req.query.directUrl === 'true';
@ -916,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;
}
@ -927,76 +949,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
}
const submitForm = mode === 'fillForms' && userid === 'uid-1' && !1;
let countVersion = 1;
const historyPath = req.DocManager.historyPath(fileName, userAddress);
let changes = null;
let keyVersion = key;
if (historyPath !== '') {
countVersion = req.DocManager.countVersion(historyPath) + 1; // get the number of file versions
for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions
if (i < countVersion) {
const keyPath = req.DocManager.keyPath(fileName, userAddress, i);
if (!fileSystem.existsSync(keyPath)) continue;
keyVersion = `${fileSystem.readFileSync(keyPath)}`;
} else {
keyVersion = key;
}
// write all the file history information
history.push(req.DocManager.getHistory(fileName, changes, keyVersion, i));
const userUrl = i === countVersion ? directUrl : (`${req.DocManager.getServerUrl(false)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`);
const historyD = {
fileType: fileExt.slice(1),
version: i,
key: keyVersion,
url: i === countVersion ? url : (`${req.DocManager.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
directUrl: !userDirectUrl ? null : userUrl,
};
// check if the path to the file with document versions differences exists
if (i > 1 && req.DocManager.existsSync(req.DocManager.diffPath(fileName, userAddress, i - 1))) {
historyD.previous = { // write information about previous file version
fileType: historyData[i - 2].fileType,
key: historyData[i - 2].key,
url: historyData[i - 2].url,
directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl,
};
const changesUrl = `${req.DocManager.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`;
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
}
historyData.push(historyD);
if (i < countVersion) {
// get the path to the file with document changes
const changesFile = req.DocManager.changesPath(fileName, userAddress, i);
changes = req.DocManager.getChanges(changesFile); // get changes made in the file
}
}
} else { // if history path is empty
// write the history information about the last file version
history.push(req.DocManager.getHistory(fileName, changes, keyVersion, countVersion));
historyData.push({
fileType: fileExt.slice(1),
version: countVersion,
key,
url,
directUrl: !userDirectUrl ? null : directUrl,
});
}
if (cfgSignatureEnable) {
for (let i = 0; i < historyData.length; i++) {
// sign token with given data using signature secret
historyData[i].token = jwt.sign(historyData[i], cfgSignatureSecret, { expiresIn: cfgSignatureSecretExpiresIn });
}
}
// file config data
const argss = {
apiUrl: siteUrl + configServer.get('apiUrl'),
@ -1006,7 +958,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
uri: url,
directUrl: !userDirectUrl ? null : directUrl,
uriUser: directUrl,
version: countVersion,
created: new Date().toDateString(),
favorite: user.favorite != null ? user.favorite : 'null',
},
@ -1049,8 +1000,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
instanceId: userid !== 'uid-0' ? req.DocManager.getInstanceId() : null,
protect: !user.deniedPermissions.includes('protect'),
},
history,
historyData,
dataInsertImage: {
fileType: 'png',
url: `${req.DocManager.getServerUrl(true)}/images/logo.png`,
@ -1058,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',
@ -1129,6 +1080,27 @@ app.post('/rename', (req, res) => { // define a handler for renaming file
documentService.commandRequest('meta', dockey, result, meta);
});
app.post('/historyObj', (req, res) => {
req.DocManager = new DocManager(req, res);
const { fileName } = req.body;
const { directUrl } = req.body || null;
const historyObj = req.DocManager.getHistoryObject(fileName, null, directUrl);
if (cfgSignatureEnable) {
for (let i = 0; i < historyObj.historyData.length; i++) {
// sign token with given data using signature secret
historyObj.historyData[i].token = jwt.sign(
historyObj.historyData[i],
cfgSignatureSecret,
{ expiresIn: cfgSignatureSecretExpiresIn },
);
}
}
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify(historyObj));
res.end();
});
wopiApp.registerRoutes(app);
// "Not found" error with 404 status

View File

@ -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,

View File

@ -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,
};
@ -438,6 +439,78 @@ DocManager.prototype.countVersion = function countVersion(directory) {
return i;
};
DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = null) {
const userAddress = userAddr || this.curUserHostAddress();
const historyPath = this.historyPath(fileName, userAddress);
const key = this.getKey(fileName);
const directUrl = this.getDownloadUrl(fileName);
const fileExt = fileUtility.getFileExtension(fileName);
const url = this.getDownloadUrl(fileName, true);
const history = [];
const historyData = [];
let countVersion = 1;
let changes = null;
let keyVersion = key;
if (historyPath !== '') {
countVersion = this.countVersion(historyPath) + 1; // get the number of file versions
for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions
if (i < countVersion) {
const keyPath = this.keyPath(fileName, userAddress, i);
if (!fileSystem.existsSync(keyPath)) continue;
keyVersion = `${fileSystem.readFileSync(keyPath)}`;
} else {
keyVersion = key;
}
// write all the file history information
history.push(this.getHistory(fileName, changes, keyVersion, i));
const userUrl = i === countVersion ? directUrl : (`${this.getServerUrl(false)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`);
const historyD = {
fileType: fileExt.slice(1),
version: i,
key: keyVersion,
url: i === countVersion ? url : (`${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
directUrl: !userDirectUrl ? null : userUrl,
};
// check if the path to the file with document versions differences exists
if (i > 1 && this.existsSync(this.diffPath(fileName, userAddress, i - 1))) {
historyD.previous = { // write information about previous file version
fileType: historyData[i - 2].fileType,
key: historyData[i - 2].key,
url: historyData[i - 2].url,
directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl,
};
const changesUrl = `${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`;
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
}
historyData.push(historyD);
if (i < countVersion) {
// get the path to the file with document changes
const changesFile = this.changesPath(fileName, userAddress, i);
changes = this.getChanges(changesFile); // get changes made in the file
}
}
} else { // if history path is empty
// write the history information about the last file version
history.push(this.getHistory(fileName, changes, keyVersion, countVersion));
historyData.push({
fileType: fileExt.slice(1),
version: countVersion,
key,
url,
directUrl: !userDirectUrl ? null : directUrl,
});
}
return { history, historyData, countVersion };
};
// get file history information
DocManager.prototype.getHistory = function getHistory(fileName, content, keyVersion, version) {
let oldVersion = false;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
{
"name": "OnlineEditorsExampleNodeJS",
"version": "4.1.0",
"version": "1.6.0",
"private": false,
"scripts": {
"start": "node ./bin/www",

View File

@ -34,30 +34,17 @@ if (typeof jQuery != "undefined") {
else
language = jq("#language").val();
jq("#language").change(function() {
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&directUrl=" + directUrl;
});
if ("" != userid && undefined != userid)
jq("#user").val(userid);
else
userid = jq("#user").val();
jq("#user").change(function() {
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&directUrl=" + directUrl;
});
if (directUrl)
jq("#directUrl").prop("checked", directUrl);
else
directUrl = jq("#directUrl").prop("checked");
jq("#directUrl").change(function() {
window.location = "?lang=" + language + "&userid=" + userid + "&directUrl=" + jq(this).prop("checked");
});
jq(function () {
jq('#fileupload').fileupload({
@ -111,7 +98,7 @@ if (typeof jQuery != "undefined") {
}
});
});
var timer = null;
var checkConvert = function (filePass) {
filePass = filePass ? filePass : null;
@ -126,7 +113,7 @@ if (typeof jQuery != "undefined") {
jq("#filePass").val("");
var fileName = jq("#hiddenFileName").val();
var posExt = fileName.lastIndexOf('.');
var posExt = fileName.lastIndexOf('.') + 1;
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
if (ConverExtList.indexOf(posExt) == -1) {
@ -207,7 +194,7 @@ if (typeof jQuery != "undefined") {
jq("#beginView, #beginEmbedded").removeClass("disable");
var fileName = jq("#hiddenFileName").val();
var posExt = fileName.lastIndexOf('.');
var posExt = fileName.lastIndexOf('.') + 1;
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
var checkEdited = EditedExtList.split(",").filter(function(ext) { return ext == posExt;});
@ -230,6 +217,20 @@ if (typeof jQuery != "undefined") {
}
});
jq(document).on("click", ".action-link", function (e) {
e.preventDefault();
let url = this.href + collectParams(true);
let target = null;
if (e.target.hasAttribute("target")) {
target = e.target.getAttribute("target");
} else if (e.target.parentNode.hasAttribute("target")) {
target = e.target.parentNode.getAttribute("target");
}
target !== null ? window.open(url, target) : window.location = url;
});
jq(document).on("click", "#skipPass", function () {
jq("#blockPassword").hide();
loadScripts();
@ -238,32 +239,32 @@ if (typeof jQuery != "undefined") {
jq(document).on("click", "#beginEdit:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=edit";
var url = UrlEditor + "/" + fileId + "?action=edit" + collectParams(true);
}else{
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?fileName=" + fileId + collectParams(true);
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload(true);
window.location = collectParams();
});
jq(document).on("click", "#beginView:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=view";
var url = UrlEditor + "/" + fileId + "?action=view" + collectParams(true);
}else{
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?mode=view&fileName=" + fileId + collectParams(true);
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload(true);
window.location = collectParams();
});
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?type=embedded&fileName=" + fileId + collectParams(true);
jq("#mainProgress").addClass("embedded");
jq("#beginEmbedded").addClass("disable");
@ -272,13 +273,13 @@ if (typeof jQuery != "undefined") {
});
jq(document).on("click", ".reload-page", function () {
setTimeout(function () { document.location.reload(true); }, 1000);
setTimeout(function () { window.location = collectParams(); }, 1000);
return true;
});
jq(document).on("mouseup", ".reload-page", function (event) {
if (event.which == 2) {
setTimeout(function () { document.location.reload(true); }, 1000);
setTimeout(function () { window.location = collectParams(); }, 1000);
}
return true;
});
@ -288,12 +289,13 @@ if (typeof jQuery != "undefined") {
jq("#embeddedView").remove();
jq.unblockUI();
if (mustReload) {
document.location.reload(true);
window.location = collectParams();
}
});
jq(document).on("click", ".delete-file", function () {
var fileName = jq(this).attr("data");
const currentElement = jq(this);
var fileName = currentElement.attr("data");
var requestAddress = "file?filename=" + fileName;
@ -303,7 +305,16 @@ if (typeof jQuery != "undefined") {
type: "delete",
url: requestAddress,
complete: function (data) {
document.location.reload(true);
if (JSON.parse(data.responseText).success) {
const parentRow = currentElement.parents('tr')[0];
if (parentRow) {
jq(parentRow).remove();
}
const remainingRows = jq('tr.tableRow');
if (remainingRows.length === 0) {
window.location = collectParams();
}
}
}
});
});
@ -394,4 +405,32 @@ function getUrlVars() {
vars[hash[0]] = hash[1];
}
return vars;
};
};
function collectParams(startParams) {
let paramsObjects = Array.prototype.slice.call(document.getElementsByClassName('collectable'));
let params = [];
let startChar = startParams ? "&" : "?";
paramsObjects.forEach( function (element) {
if (element.name) {
switch (element.type) {
case "select-one":
case "text":
if (element.value) {
params.push(element.name + "=" + element.value);
}
break;
case "checkbox":
params.push(element.name + "=" + element.checked);
break;
case "radio":
if (element.checked) {
params.push(element.name + "=" + element.value);
}
break;
default:
}
}
});
return startChar + params.join("&");
}

View File

@ -39,6 +39,7 @@
var docEditor;
var config;
let historyObject;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -72,26 +73,72 @@
};
var onRequestHistory = function (event) { // the user is trying to show the document version history
var historyObj = <%- JSON.stringify(history) %> || null;
docEditor.refreshHistory( // show the document version history
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const data = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(data));
xhr.onload = function () {
historyObject = JSON.parse(xhr.responseText);
docEditor.refreshHistory( // show the document version history
{
currentVersion: "<%- file.version %>",
history: historyObj
currentVersion: historyObject.countVersion,
history: historyObject.history
});
}
};
var onRequestHistoryData = function (data) { // the user is trying to click the specific document version in the document version history
var version = data.data;
var historyData = <%- JSON.stringify(historyData) %> || null;
docEditor.setHistoryData(historyData[version-1]); // send the link to the document for viewing the version history
var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history
const version = event.data;
docEditor.setHistoryData(historyObject.historyData[version-1]); // send the link to the document for viewing the version history
};
var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
var onRequestRestore = function (event) { // the user is trying to restore file version
const version = event.data.version;
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const restoreData = {
version: version,
fileName: fileName,
};
let xhr = new XMLHttpRequest();
xhr.open("PUT", "restore");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(restoreData));
xhr.onload = function () {
const response = JSON.parse(xhr.responseText);
if (response.success && !response.error) {
const dataForHistory = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(dataForHistory));
xhr.onload = function () {
historyObject = JSON.parse(xhr.responseText);
docEditor.refreshHistory( // show the document version history
{
currentVersion: historyObject.countVersion,
history: historyObject.history
});
}
} else {
innerAlert(response.error);
}
}
}
var onError = function (event) { // an error or some other specific event occurs
if (event)
innerAlert(event.data);
@ -180,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;
@ -235,10 +329,12 @@
config.events.onRequestHistory = onRequestHistory;
config.events.onRequestHistoryData = onRequestHistoryData;
config.events.onRequestHistoryClose = onRequestHistoryClose;
config.events.onRequestRestore = onRequestRestore;
config.events.onRequestRename = onRequestRename;
config.events.onRequestUsers = onRequestUsers;
config.events.onRequestSendNotify = onRequestSendNotify;
config.events.onRequestReferenceData = onRequestReferenceData;
config.events.onRequestReferenceSource = onRequestReferenceSource;
}
if (config.editorConfig.createUrl) {
@ -278,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);

View File

@ -48,16 +48,16 @@
<div class="create-panel clearFix">
<ul class="try-editor-list clearFix">
<li>
<a class="try-editor word reload-page" target="_blank" href="editor?fileExt=docx<%= params %>" title="Create new document">Document</a>
<a class="try-editor word reload-page action-link" target="_blank" href="editor?fileExt=docx" title="Create new document">Document</a>
</li>
<li>
<a class="try-editor cell reload-page" target="_blank" href="editor?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
<a class="try-editor cell reload-page action-link" target="_blank" href="editor?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
</li>
<li>
<a class="try-editor slide reload-page" target="_blank" href="editor?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
<a class="try-editor slide reload-page action-link" target="_blank" href="editor?fileExt=pptx" title="Create new presentation">Presentation</a>
</li>
<li>
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
<a class="try-editor form reload-page action-link" target="_blank" href="editor?fileExt=docxf" title="Create new form template">Form template</a>
</li>
</ul>
<label class="side-option">
@ -67,7 +67,7 @@
<div class="upload-panel clearFix">
<a class="file-upload">Upload file
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
</a>
</div>
@ -77,7 +77,7 @@
<td valign="middle">
<span class="select-user">Username</span>
<img id="info" class="info" src="images/info.svg" />
<select class="select-user" id="user">
<select class="select-user collectable" name="userid" id="user">
<% users.forEach(user => { %>
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
<% }) %>
@ -88,7 +88,7 @@
<td valign="middle">
<span class="select-user">Language</span>
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
<select class="select-user" id="language">
<select class="select-user collectable" name="lang" id="language">
<% Object.keys(languages).forEach(key => { %>
<option value="<%= key %>"><%= languages[key] %></option>
<% }) %>
@ -98,7 +98,7 @@
<tr>
<td valign="middle">
<label class="side-option">
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
<input id="directUrl" type="checkbox" class="checkbox collectable" name="directUrl" />Try opening on client
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
</label>
</td>
@ -154,33 +154,33 @@
<% for (var i = 0; i < storedFiles.length; i++) { %>
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
<td class="contentCells">
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<span><%= storedFiles[i].name %></span>
</a>
</td>
<% if (storedFiles[i].canEdit) { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment" /></a>
</td>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/review.svg" alt="Open in editor for review" title="Open in editor for review" /></a>
</td>
<% } else if (storedFiles[i].documentType == "cell") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>
</td>
<% } %>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification" /></a>
</td>
<% } else { %>
@ -189,44 +189,44 @@
<% if (storedFiles[i].documentType !== "word" && storedFiles[i].documentType !== "cell") {%>
<td class="contentCells contentCells-icon "></td>
<% } %>
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<% } else {%>
<td class="contentCells contentCells-icon"></td>
<%}%>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>
</td>
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
<a href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" /></a>
</td>
<% } else { %>
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
<% } %>
<td class="contentCells contentCells-icon firstContentCellViewers">
<a href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>
</td>
<td class="contentCells contentCells-icon contentCells-shift">
<a href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode" /></a>
</td>
<td class="contentCells contentCells-icon contentCells-shift downloadContentCellShift">

View File

@ -51,16 +51,16 @@
<div class="create-panel clearFix">
<ul class="try-editor-list clearFix">
<li>
<a class="try-editor word reload-page" target="_blank" href="wopi-new?fileExt=docx<%= params %>" title="Create new document">Document</a>
<a class="try-editor word reload-page action-link" target="_blank" href="wopi-new?fileExt=docx" title="Create new document">Document</a>
</li>
<li>
<a class="try-editor cell reload-page" target="_blank" href="wopi-new?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
<a class="try-editor cell reload-page action-link" target="_blank" href="wopi-new?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
</li>
<li>
<a class="try-editor slide reload-page" target="_blank" href="wopi-new?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
<a class="try-editor slide reload-page action-link" target="_blank" href="wopi-new?fileExt=pptx" title="Create new presentation">Presentation</a>
</li>
<li>
<a class="try-editor form reload-page" target="_blank" href="wopi-new?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
<a class="try-editor form reload-page action-link" target="_blank" href="wopi-new?fileExt=docxf" title="Create new form template">Form template</a>
</li>
</ul>
</div>
@ -68,7 +68,7 @@
<div class="upload-panel clearFix">
<a class="file-upload">Upload file
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
</a>
</div>
@ -78,7 +78,7 @@
<td valign="middle">
<span class="select-user">Username</span>
<img id="info" class="info" data-id="user" src="images/info.svg" />
<select class="select-user" id="user">
<select class="select-user collectable" name="userid" id="user">
<% users.forEach(user => { %>
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
<% }) %>
@ -89,7 +89,7 @@
<td valign="middle">
<span class="select-user">Language</span>
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
<select class="select-user" id="language">
<select class="select-user collectable" name="lang" id="language">
<% Object.keys(languages).forEach(key => { %>
<option value="<%= key %>"><%= languages[key] %></option>
<% }) %>
@ -148,7 +148,7 @@
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
<td class="contentCells">
<% if (storedFiles[i].defaultAction) { %>
<a class="stored-edit <%= storedFiles[i].documentType %>" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %><%= params %>" target="_blank">
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %>" target="_blank">
<%} else { %>
<a class="stored-edit <%= storedFiles[i].documentType %>" href="#">
<% } %>
@ -158,7 +158,7 @@
<% if (storedFiles[i].actions && storedFiles[i].actions.length > 0) { %>
<td class="contentCells contentCells-wopi contentCells-shift">
<% for (var j = 0; j < storedFiles[i].actions.length; j++) { %>
<a href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %><%= params %>" target="_blank">
<a class="action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %>" target="_blank">
<img
src="images/wopi-<%= storedFiles[i].actions[j].name %>.svg"
alt="<%= storedFiles[i].actions[j].name %>" title="<%= storedFiles[i].actions[j].name %>" />

View File

@ -0,0 +1,2 @@
logs
vendor

View File

@ -0,0 +1 @@
8.1.21

View File

@ -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

View 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

View File

@ -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
![browse](screenshots/browse.png)
### 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:

View File

@ -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
];
}
}

View 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;
}

View 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);
}
}

View File

@ -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);
}
}

View 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');
}
}

View 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\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');
}
}

View 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');
}
}

View 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()
);
}
}

View File

@ -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());
}
}

View 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());
}
}

View 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
);
}
}

View File

@ -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/"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}

View File

@ -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'
];
}
}

View File

@ -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);
}
}

View File

@ -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()
);
}
}

View File

@ -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()
);
}
}

View File

@ -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()
);
}
}

View File

@ -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()
);
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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');
}
}

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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

View File

@ -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;
}
);
}
}

View File

@ -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 = "";

View File

@ -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();

View File

@ -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,

View File

@ -1,7 +0,0 @@
<?php
namespace Firebase\JWT;
class BeforeValidException extends \UnexpectedValueException
{
}

View File

@ -1,7 +0,0 @@
<?php
namespace Firebase\JWT;
class ExpiredException extends \UnexpectedValueException
{
}

View File

@ -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);
}
}

View File

@ -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.

View File

@ -1,7 +0,0 @@
<?php
namespace Firebase\JWT;
class SignatureInvalidException extends \UnexpectedValueException
{
}

View File

@ -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

View File

@ -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.

View 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

View 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>

View File

@ -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>

View File

@ -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}

View File

@ -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>

Some files were not shown because too many files have changed in this diff Show More