mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-12 10:55:15 +08:00
Compare commits
32 Commits
feature/ja
...
v7.4.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a6e5e44bf | |||
| 16e39b5535 | |||
| 5c3d64df54 | |||
| a1fd64af8f | |||
| 2724f007db | |||
| 8744e79b62 | |||
| a0abfb39a7 | |||
| ccd5584b0c | |||
| a871b29d7c | |||
| 4f5c38be87 | |||
| cc1b3cdbe8 | |||
| 0387b80843 | |||
| 2c1a160215 | |||
| 5c773cb5e6 | |||
| 5b666247cc | |||
| 7c0b67215e | |||
| 18650f7da2 | |||
| b62214a416 | |||
| d4ed01196e | |||
| 9ec9cd4912 | |||
| 547da16760 | |||
| 51be4d06d8 | |||
| 456b27e4c3 | |||
| 3f9f0d01f6 | |||
| 60222f3068 | |||
| 1683a08660 | |||
| 3427554bf0 | |||
| ec2845af5e | |||
| 3283e14c01 | |||
| 17f336a156 | |||
| 33c093f7a6 | |||
| de9f27465f |
33
.github/workflows/artifact-csharp-mvc.yml
vendored
Normal file
33
.github/workflows/artifact-csharp-mvc.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Csharp MVC
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/csharp-mvc/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/csharp-mvc/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/csharp-mvc
|
||||
mkdir -p ./deploy/'DotNet (Csharp MVN) Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'DotNet (Csharp MVC) Example'
|
||||
cd ./deploy/'DotNet (Csharp MVC) Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DotNet.Csharp.MVC.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/csharp-mvc/deploy
|
||||
33
.github/workflows/artifact-csharp.yml
vendored
Normal file
33
.github/workflows/artifact-csharp.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Csharp
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/csharp/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/csharp/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/csharp
|
||||
mkdir -p ./deploy/'DotNet (Csharp) Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'DotNet (Csharp) Example'
|
||||
cd ./deploy/'DotNet (Csharp) Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DotNet.Csharp.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/csharp/deploy
|
||||
33
.github/workflows/artifact-java.yml
vendored
Normal file
33
.github/workflows/artifact-java.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Java
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/java
|
||||
mkdir -p ./deploy/'Java Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'Java Example'
|
||||
cd ./deploy/'Java Example'/src/main/resources/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Java.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/java/deploy
|
||||
33
.github/workflows/artifact-node.yml
vendored
Normal file
33
.github/workflows/artifact-node.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Nodejs
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/nodejs
|
||||
mkdir -p ./deploy/'Node.js Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'Node.js Example'
|
||||
cd ./deploy/'Node.js Example'/public/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Node.js.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/nodejs/deploy
|
||||
33
.github/workflows/artifact-php.yml
vendored
Normal file
33
.github/workflows/artifact-php.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact PHP
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/php
|
||||
mkdir -p ./deploy/'PHP Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'PHP Example'
|
||||
cd ./deploy/'PHP Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: PHP.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/php/deploy
|
||||
33
.github/workflows/artifact-python.yml
vendored
Normal file
33
.github/workflows/artifact-python.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Python
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/python
|
||||
mkdir -p ./deploy/'Python Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'Python Example'
|
||||
cd ./deploy/'Python Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Python.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/python/deploy
|
||||
33
.github/workflows/artifact-ruby.yml
vendored
Normal file
33
.github/workflows/artifact-ruby.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Ruby
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/ruby
|
||||
mkdir -p ./deploy/'Ruby Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'Ruby Example'
|
||||
cd ./deploy/'Ruby Example'/public/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Ruby.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/ruby/deploy
|
||||
33
.github/workflows/artifact-spring.yml
vendored
Normal file
33
.github/workflows/artifact-spring.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Artifact Java Spring
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
|
||||
jobs:
|
||||
artifact:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/java-spring
|
||||
mkdir -p ./deploy/'Java Spring Example'
|
||||
rsync -av --exclude='deploy' ./ ./deploy/'Java Spring Example'
|
||||
cd ./deploy/'Java Spring Example'/src/main/resources/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Java.Spring.Example
|
||||
path: ${{ github.workspace }}/web/documentserver-example/java-spring/deploy
|
||||
2
.github/workflows/lint-java.yml
vendored
2
.github/workflows/lint-java.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
|
||||
jobs:
|
||||
|
||||
2
.github/workflows/lint-nodejs.yml
vendored
2
.github/workflows/lint-nodejs.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
|
||||
env:
|
||||
|
||||
8
.github/workflows/lint-php.yml
vendored
8
.github/workflows/lint-php.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
|
||||
jobs:
|
||||
@ -22,10 +22,8 @@ jobs:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.2'
|
||||
php-version: '8.1'
|
||||
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 ./
|
||||
run: phpcs -q --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor ./
|
||||
2
.github/workflows/lint-python.yml
vendored
2
.github/workflows/lint-python.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
|
||||
jobs:
|
||||
|
||||
2
.github/workflows/lint-ruby.yml
vendored
2
.github/workflows/lint-ruby.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
|
||||
jobs:
|
||||
|
||||
2
.github/workflows/lint-spring.yml
vendored
2
.github/workflows/lint-spring.yml
vendored
@ -6,7 +6,7 @@ on:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
|
||||
jobs:
|
||||
|
||||
146
.github/workflows/release.yml
vendored
Normal file
146
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master,main]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Zip
|
||||
run: sudo apt-get install zip
|
||||
- name: Get Info
|
||||
run: |
|
||||
echo "version=$(grep -Eo '[0-9]+(\.[0-9]+)+' CHANGELOG.md | head -n 1)" >> $GITHUB_OUTPUT
|
||||
id: info
|
||||
- name: Generate Changelog
|
||||
run: |
|
||||
awk '/## [0-9]/{p++} p; /## [0-9]/{if (p > 1) exit}' CHANGELOG.md | awk 'NR>2 {print last} {last=$0}' > RELEASE.md
|
||||
- name: Build Csharp MVC Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/csharp-mvc
|
||||
mkdir -p ./'DotNet (Csharp MVC) Example'
|
||||
rsync -av --exclude='DotNet (Csharp MVC) Example' ./ ./'DotNet (Csharp MVC) Example'
|
||||
cd ./'DotNet (Csharp MVC) Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Csharp Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/csharp
|
||||
mkdir -p ./'DotNet (Csharp) Example'
|
||||
rsync -av --exclude='DotNet (Csharp) Example' ./ ./'DotNet (Csharp) Example'
|
||||
cd ./'DotNet (Csharp) Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Java Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/java
|
||||
mkdir -p ./'Java Example'
|
||||
rsync -av --exclude='Java Example' ./ ./'Java Example'
|
||||
cd ./'Java Example'/src/main/resources/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Nodejs Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/nodejs
|
||||
mkdir -p ./'Node.js Example'
|
||||
rsync -av --exclude='Node.js Example' ./ ./'Node.js Example'
|
||||
cd ./'Node.js Example'/public/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build PHP Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/php
|
||||
mkdir -p ./'PHP Example'
|
||||
rsync -av --exclude='PHP Example' ./ ./'PHP Example'
|
||||
cd ./'PHP Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Python Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/python
|
||||
mkdir -p ./'Python Example'
|
||||
rsync -av --exclude='Python Example' ./ ./'Python Example'
|
||||
cd ./'Python Example'/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Ruby Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/ruby
|
||||
mkdir -p ./'Ruby Example'
|
||||
rsync -av --exclude='Ruby Example' ./ ./'Ruby Example'
|
||||
cd ./'Ruby Example'/public/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Build Spring Artifact
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
cwd=$(pwd)
|
||||
git submodule update --init --recursive
|
||||
cd ./web/documentserver-example/java-spring
|
||||
mkdir -p ./'Java Spring Example'
|
||||
rsync -av --exclude='Java Spring Example' ./ ./'Java Spring Example'
|
||||
cd ./'Java Spring Example'/src/main/resources/assets
|
||||
rm -rf ./.git/
|
||||
rm .git
|
||||
- name: Pack Artifacts
|
||||
run: |
|
||||
cd ${{ github.workspace }}/web/documentserver-example/csharp-mvc
|
||||
zip -r DotNet.Csharp.MVC.Example.zip ./'DotNet (Csharp MVC) Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/csharp
|
||||
zip -r DotNet.Csharp.Example.zip ./'DotNet (Csharp) Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/java
|
||||
zip -r Java.Example.zip ./'Java Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/nodejs
|
||||
zip -r Node.js.Example.zip ./'Node.js Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/php
|
||||
zip -r PHP.Example.zip ./'PHP Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/python
|
||||
zip -r Python.Example.zip ./'Python Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/ruby
|
||||
zip -r Ruby.Example.zip ./'Ruby Example'
|
||||
cd ${{ github.workspace }}/web/documentserver-example/java-spring
|
||||
zip -r Java.Spring.Example.zip ./'Java Spring Example'
|
||||
- name: Create Release
|
||||
uses: ncipollo/release-action@v1
|
||||
id: create_release
|
||||
with:
|
||||
bodyFile: RELEASE.md
|
||||
artifacts: "
|
||||
${{ github.workspace }}/web/documentserver-example/csharp-mvc/DotNet.Csharp.MVC.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/csharp/DotNet.Csharp.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/java/Java.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/nodejs/Node.js.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/php/PHP.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/python/Python.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/ruby/Ruby.Example.zip,
|
||||
${{ github.workspace }}/web/documentserver-example/java-spring/Java.Spring.Example.zip
|
||||
"
|
||||
tag: v${{ steps.info.outputs.version }}
|
||||
13
.gitignore
vendored
13
.gitignore
vendored
@ -11,6 +11,19 @@
|
||||
**/.vscode/
|
||||
**/.vs/
|
||||
**/.idea
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
*.iml
|
||||
*.iws
|
||||
.DS_Store
|
||||
/web/documentserver-example/java/target/
|
||||
/web/documentserver-example/java-spring/target/
|
||||
/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
|
||||
|
||||
@ -19,6 +19,10 @@ 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
|
||||
@ -46,6 +50,10 @@ 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
|
||||
@ -81,6 +89,10 @@ 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
|
||||
@ -108,6 +120,10 @@ 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
|
||||
@ -199,6 +215,10 @@ 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
|
||||
@ -246,17 +266,56 @@ 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
|
||||
|
||||
JWT - JSON Web Token implementation (https://github.com/firebase/php-jwt/blob/master/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
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)
|
||||
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: PHP_CodeSniffer.license
|
||||
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
|
||||
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: PyJWT.license
|
||||
|
||||
python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: python-magic.license
|
||||
|
||||
requests - Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE)
|
||||
License: Apache 2.0
|
||||
License File: requests.license
|
||||
|
||||
|
||||
web/documentserver-example/ruby
|
||||
@ -289,6 +348,10 @@ 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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Change Log
|
||||
|
||||
- php: linter refactoring
|
||||
## 1.5.1
|
||||
- update jquery
|
||||
|
||||
## 1.5.0
|
||||
- nodejs: added wopi putRelativeFile action
|
||||
|
||||
@ -26,13 +26,13 @@
|
||||
<RemoveDir Directories="$(To)" ContinueOnError="true" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp).vs\**;$(DirCSharp)bin\*.pdb;$(DirCSharp)bin\*.xml;$(DirCSharp)obj\**;$(DirCSharp)packages\**;$(DirCSharp)**\.git" />
|
||||
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)obj\**;$(DirCSharp)**\.git" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesCSharp)" DestinationFiles="@(ZipFilesCSharp->'$(NameCSharp)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameCSharp)" WorkingDirectory="$(To)" ZipFileName="$(NameCSharp).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc).vs\**;$(DirMvc)bin\*.pdb;$(DirMvc)bin\*.xml;$(DirMvc)obj\**;$(DirMvc)packages\**;$(DirMvc)**\.git" />
|
||||
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc)obj\**;$(DirMvc)**\.git" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesMVC)" DestinationFiles="@(ZipFilesMVC->'$(NameMvc)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameMvc)" WorkingDirectory="$(To)" ZipFileName="$(NameMvc).zip" />
|
||||
|
||||
@ -20,6 +20,10 @@ 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
|
||||
|
||||
@ -28,6 +28,7 @@ namespace OnlineEditorsExampleMVC
|
||||
// create a jquery script bundle
|
||||
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
|
||||
"~/Scripts/jquery-{version}.js",
|
||||
"~/Scripts/jquery-migrate-{version}.js",
|
||||
"~/Scripts/jquery-ui.js",
|
||||
"~/Scripts/jquery.blockUI.js",
|
||||
"~/Scripts/jquery.iframe-transport.js",
|
||||
|
||||
@ -128,48 +128,37 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
try
|
||||
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
|
||||
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and move it to the storage directory
|
||||
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
|
||||
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
|
||||
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and move it to the storage directory
|
||||
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
SaveFile(bytesFile, storagePath);// save document file
|
||||
|
||||
byte[] bytesChanges = DownloadFile((string)fileData["changesurl"]); // download changes file
|
||||
SaveFile(bytesChanges, Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
} catch (Exception)
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
return 1;
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -213,51 +202,43 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
try
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
if (newFileName)
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
} else
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
|
||||
SaveFile(bytesFile, forcesavePath);// save document file
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
}
|
||||
} catch (Exception)
|
||||
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
}
|
||||
|
||||
DownloadToFile(downloadUri, forcesavePath);
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -329,30 +310,27 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
// save file
|
||||
private static void SaveFile(byte[] data, string path)
|
||||
{
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
fs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// save file information from the url to the file specified
|
||||
private static byte[] DownloadFile(string url)
|
||||
private static void DownloadToFile(string url, string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url"); // url isn't specified
|
||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Timeout = 5000;
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
|
||||
{
|
||||
if (stream == null) throw new Exception("stream is null");
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
|
||||
{
|
||||
fs.Write(buffer, 0, readed); // write bytes to the output stream
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
web/documentserver-example/csharp-mvc/Scripts/jquery-3.6.4.js
vendored
Normal file
2
web/documentserver-example/csharp-mvc/Scripts/jquery-3.6.4.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -461,21 +461,20 @@ namespace OnlineEditorsExampleMVC
|
||||
var userAddress = context.Request["userAddress"];
|
||||
var isEmbedded = context.Request["dmode"];
|
||||
|
||||
if (JwtManager.Enabled && isEmbedded == null && userAddress != null)
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = "";
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
token = JwtManager.Decode(headerToken);
|
||||
}
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
return;
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,10 @@ 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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.0"/>
|
||||
<add key="version" value="1.5.1"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -356,7 +356,8 @@
|
||||
</footer>
|
||||
</form>
|
||||
|
||||
<script language="javascript" type="text/javascript" src="script/jquery-1.9.0.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="script/jquery-3.6.4.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="script/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="script/jquery-ui.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="script/jquery.blockUI.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="script/jquery.iframe-transport.js"></script>
|
||||
|
||||
@ -130,48 +130,37 @@ namespace OnlineEditorsExample
|
||||
|
||||
_Default.VerifySSL();
|
||||
|
||||
try
|
||||
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
|
||||
var histDir = _Default.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and rename the storage path with it
|
||||
File.Copy(_Default.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
|
||||
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
|
||||
|
||||
var histDir = _Default.HistoryDir(storagePath); // get the path to the history directory
|
||||
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
|
||||
|
||||
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and rename the storage path with it
|
||||
File.Copy(_Default.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
|
||||
|
||||
SaveFile(bytesFile, storagePath);// save document file
|
||||
|
||||
var bytesChanges = DownloadFile((string)fileData["changesurl"]); // download changes file
|
||||
SaveFile(bytesChanges, Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!string.IsNullOrEmpty(forcesavePath)) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
return 1;
|
||||
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!string.IsNullOrEmpty(forcesavePath)) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -216,51 +205,43 @@ namespace OnlineEditorsExample
|
||||
|
||||
_Default.VerifySSL();
|
||||
|
||||
try
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
string forcesavePath = "";
|
||||
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
|
||||
|
||||
if (isSubmitForm) // if the form is submitted
|
||||
if (newFileName)
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
} else
|
||||
{
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
forcesavePath = _Default.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
|
||||
}
|
||||
forcesavePath = _Default.StoragePath(fileName, userAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newFileName)
|
||||
{
|
||||
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
}
|
||||
|
||||
SaveFile(bytesFile, forcesavePath);// save document file
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocEditor.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
DownloadToFile(downloadUri, forcesavePath);
|
||||
|
||||
if (isSubmitForm)
|
||||
{
|
||||
return 1;
|
||||
var jss = new JavaScriptSerializer();
|
||||
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
var user = action["userid"].ToString(); // get the user id
|
||||
DocEditor.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -332,29 +313,27 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveFile(byte[] data, string path)
|
||||
{
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
fs.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// save file information from the url to the file specified
|
||||
private static byte[] DownloadFile(string url)
|
||||
private static void DownloadToFile(string url, string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url"); // url isn't specified
|
||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Timeout = 5000;
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
|
||||
{
|
||||
if (stream == null) throw new Exception("stream is null");
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
|
||||
{
|
||||
fs.Write(buffer, 0, readed); // write bytes to the output stream
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,21 +281,21 @@ namespace OnlineEditorsExample
|
||||
var userAddress = Path.GetFileName(context.Request["userAddress"]);
|
||||
var isEmbedded = context.Request["dmode"];
|
||||
|
||||
if (JwtManager.Enabled && isEmbedded == null && userAddress != null)
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = "";
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
token = JwtManager.Decode(headerToken);
|
||||
}
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
return;
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
web/documentserver-example/csharp/script/jquery-3.6.4.min.js
vendored
Normal file
2
web/documentserver-example/csharp/script/jquery-3.6.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
web/documentserver-example/csharp/script/jquery-migrate-3.4.1.min.js
vendored
Normal file
2
web/documentserver-example/csharp/script/jquery-migrate-3.4.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.0"/>
|
||||
<add key="version" value="1.5.1"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
# Eclipse
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# Intellij
|
||||
.idea/
|
||||
*.iml
|
||||
*.iws
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
||||
# Maven
|
||||
log/
|
||||
target/
|
||||
|
||||
#project
|
||||
documents
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@ -35,14 +35,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* (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.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.onlyoffice.integration.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
|
||||
return http
|
||||
.requiresChannel(channel -> channel.anyRequest().requiresSecure())
|
||||
.authorizeRequests(authorize -> authorize.anyRequest().permitAll())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -285,19 +285,16 @@ public class FileController {
|
||||
|
||||
@GetMapping(path = "${url.download}")
|
||||
public ResponseEntity<Resource> download(final HttpServletRequest request, // download a file
|
||||
@RequestParam("fileName") final String fileName,
|
||||
@RequestParam(value = "userAddress", required = false) final String userAddress){
|
||||
@RequestParam("fileName") final String fileName) {
|
||||
try {
|
||||
// check if a token is enabled or not
|
||||
if (jwtManager.tokenEnabled() && userAddress != null) {
|
||||
String header = request.getHeader(documentJwtHeader == null // get the document JWT header
|
||||
if (jwtManager.tokenEnabled()) {
|
||||
String header = request.getHeader(documentJwtHeader == null // get the document JWT header
|
||||
|| documentJwtHeader.isEmpty() ? "Authorization" : documentJwtHeader);
|
||||
if (header != null && !header.isEmpty()) {
|
||||
String token = header
|
||||
.replace("Bearer ", ""); // token is the header without the Bearer prefix
|
||||
jwtManager.readToken(token); // read the token
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return downloadFile(fileName); // download data from the specified file
|
||||
|
||||
@ -35,7 +35,6 @@ import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -76,12 +75,14 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
@Autowired
|
||||
private ServiceConverter serviceConverter;
|
||||
|
||||
// download file from url
|
||||
@SneakyThrows
|
||||
private byte[] getDownloadFile(final String url) {
|
||||
// save file information from the URL to the file specified
|
||||
private void downloadToFile(final String url, final Path path) throws Exception {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new RuntimeException("Url argument is not specified"); // URL isn't specified
|
||||
}
|
||||
if (path == null) {
|
||||
throw new RuntimeException("Path argument is not specified"); // file isn't specified
|
||||
}
|
||||
|
||||
URL uri = new URL(url);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
|
||||
@ -99,17 +100,7 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
throw new RuntimeException("Input stream is null");
|
||||
}
|
||||
|
||||
return stream.readAllBytes();
|
||||
}
|
||||
|
||||
// file saving
|
||||
@SneakyThrows
|
||||
private void saveFile(final byte[] byteArray, final Path path) {
|
||||
if (path == null) {
|
||||
throw new RuntimeException("Path argument is not specified"); // file isn't specified
|
||||
}
|
||||
// update a file or create a new one
|
||||
storageMutator.createOrUpdateFile(path, new ByteArrayInputStream(byteArray));
|
||||
storageMutator.createOrUpdateFile(path, stream); // update a file or create a new one
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@ -143,8 +134,6 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
|
||||
|
||||
String storagePath = storagePathBuilder.getFileLocation(newFileName); // get the path to a new file
|
||||
Path lastVersion = Paths.get(storagePathBuilder
|
||||
.getFileLocation(fileName)); // get the path to the last file version
|
||||
@ -163,11 +152,12 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
|
||||
storageMutator.createDirectory(ver); // create the file version directory
|
||||
|
||||
saveFile(byteArrayFile, toSave); // save document file
|
||||
// move the last file version to the file version directory with the "prev" postfix
|
||||
storageMutator.moveFile(lastVersion, Paths.get(versionDir + File.separator + "prev" + curExt));
|
||||
|
||||
byte[] byteArrayChanges = getDownloadFile(changesUri); // download file changes
|
||||
saveFile(byteArrayChanges, Path
|
||||
.of(versionDir + File.separator + "diff.zip")); // save file changes to the diff.zip archive
|
||||
downloadToFile(downloadUri, toSave); // save file to the storage path
|
||||
downloadToFile(changesUri, Path
|
||||
.of(versionDir + File.separator + "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
JSONObject jsonChanges = new JSONObject(); // create a json object for document changes
|
||||
jsonChanges.put("changes", body.getHistory().getChanges()); // put the changes to the json object
|
||||
@ -256,8 +246,8 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException(response.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void processForceSave(final Track body, final String fileNameParam) { // file force saving process
|
||||
@ -288,7 +278,6 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
|
||||
String forcesavePath = "";
|
||||
|
||||
// todo: Use ENUMS
|
||||
@ -324,6 +313,6 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
}
|
||||
}
|
||||
|
||||
saveFile(byteArrayFile, Path.of(forcesavePath));
|
||||
downloadToFile(downloadUri, Path.of(forcesavePath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ package com.onlyoffice.integration.documentserver.storage;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
@ -38,5 +37,5 @@ public interface FileStorageMutator {
|
||||
Resource loadFileAsResourceHistory(String fileName, String version, String file); // load file as a resource
|
||||
File[] getStoredFiles(); // get a collection of all the stored files
|
||||
void createMeta(String fileName, String uid, String uname); // create the file meta information
|
||||
boolean createOrUpdateFile(Path path, ByteArrayInputStream stream); // create or update a file
|
||||
boolean createOrUpdateFile(Path path, InputStream stream); // create or update a file
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
@ -333,7 +332,7 @@ public class LocalFileStorage implements FileStorageMutator, FileStoragePathBuil
|
||||
}
|
||||
|
||||
// create or update a file
|
||||
public boolean createOrUpdateFile(final Path path, final ByteArrayInputStream stream) {
|
||||
public boolean createOrUpdateFile(final Path path, final InputStream stream) {
|
||||
if (!Files.exists(path)) { // if the specified file does not exist
|
||||
return createFile(path, stream); // create it in the specified directory
|
||||
} else {
|
||||
@ -373,7 +372,7 @@ public class LocalFileStorage implements FileStorageMutator, FileStoragePathBuil
|
||||
path = Paths.get(historyPath); // otherwise, get the path to the history directory
|
||||
if (!Files.exists(path)) {
|
||||
return 1; // if the history directory does not exist, then the file version is 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// run through all the files in the history directory
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
server.version=1.5.0
|
||||
server.version=1.5.1
|
||||
|
||||
server.address=
|
||||
server.port=8443
|
||||
server.ssl.key-store=classpath:springboot.p12
|
||||
server.ssl.key-store-password=111111
|
||||
server.ssl.key-alias=springboot
|
||||
server.ssl.key-password=111111
|
||||
server.port=4000
|
||||
|
||||
filesize-max=5242880
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
2
web/documentserver-example/java-spring/src/main/resources/static/scripts/jquery-3.6.4.min.js
vendored
Normal file
2
web/documentserver-example/java-spring/src/main/resources/static/scripts/jquery-3.6.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -211,14 +211,10 @@ if (typeof jQuery !== "undefined") {
|
||||
setCookie("ulang", langSel.val());
|
||||
});
|
||||
if(!userId){
|
||||
jq(document).on("ready",function(){
|
||||
setCookie("uid",1)
|
||||
})
|
||||
setCookie("uid",1);
|
||||
}
|
||||
if(!langId){
|
||||
jq(document).on("ready",function () {
|
||||
setCookie("ulang","en")
|
||||
})
|
||||
setCookie("ulang","en");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -333,7 +333,8 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="scripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery.iframe-transport.js"></script>
|
||||
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -16,6 +16,10 @@ 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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@ -517,23 +517,22 @@ public class IndexServlet extends HttpServlet {
|
||||
String userAddress = request.getParameter("userAddress");
|
||||
String isEmbedded = request.getParameter("dmode");
|
||||
|
||||
if (DocumentManager.tokenEnabled() && isEmbedded == null && userAddress != null) {
|
||||
if (DocumentManager.tokenEnabled() && isEmbedded == null) {
|
||||
|
||||
String documentJwtHeader = ConfigManager.getProperty("files.docservice.header");
|
||||
|
||||
String header = (String) request.getHeader(documentJwtHeader == null || documentJwtHeader.isEmpty()
|
||||
? "Authorization" : documentJwtHeader);
|
||||
String token = "";
|
||||
if (header != null && !header.isEmpty()) {
|
||||
String bearerPrefix = "Bearer ";
|
||||
token = header.startsWith(bearerPrefix) ? header.substring(bearerPrefix.length()) : header;
|
||||
}
|
||||
try {
|
||||
Verifier verifier = HMACVerifier.newVerifier(DocumentManager.getTokenSecret());
|
||||
JWT jwt = JWT.getDecoder().decode(token, verifier);
|
||||
} catch (Exception e) {
|
||||
response.sendError(HttpServletResponse.SC_FORBIDDEN, "JWT validation failed");
|
||||
return;
|
||||
String token = header.startsWith(bearerPrefix) ? header.substring(bearerPrefix.length()) : header;
|
||||
try {
|
||||
Verifier verifier = HMACVerifier.newVerifier(DocumentManager.getTokenSecret());
|
||||
JWT jwt = JWT.getDecoder().decode(token, verifier);
|
||||
} catch (Exception e) {
|
||||
response.sendError(HttpServletResponse.SC_FORBIDDEN, "JWT validation failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,26 +26,19 @@ import org.primeframework.jwt.domain.JWT;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static utils.Constants.BUFFER_SIZE;
|
||||
import static utils.Constants.FILE_SAVE_TIMEOUT;
|
||||
import static utils.Constants.KILOBYTE_SIZE;
|
||||
|
||||
@ -174,8 +167,6 @@ public final class TrackManager {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
|
||||
|
||||
String storagePath = DocumentManager.storagePath(newFileName, userAddress); // get the file path
|
||||
File histDir = new File(DocumentManager.historyDir(storagePath)); // get the path to the history direction
|
||||
if (!histDir.exists()) {
|
||||
@ -186,7 +177,7 @@ public final class TrackManager {
|
||||
.getFileVersion(histDir.getAbsolutePath())); // get the path to the file version
|
||||
File ver = new File(versionDir);
|
||||
File lastVersion = new File(DocumentManager.storagePath(fileName, userAddress));
|
||||
Path toSave = Paths.get(storagePath);
|
||||
File toSave = new File(storagePath);
|
||||
|
||||
if (!ver.exists()) {
|
||||
ver.mkdirs();
|
||||
@ -195,10 +186,10 @@ public final class TrackManager {
|
||||
// get the path to the previous file version and rename the last file version with it
|
||||
lastVersion.renameTo(new File(versionDir + File.separator + "prev" + curExt));
|
||||
|
||||
saveFile(byteArrayFile, toSave); // save document file
|
||||
downloadToFile(downloadUri, toSave); // save file to the storage path
|
||||
|
||||
byte[] byteArrayChanges = getDownloadFile(changesUri);
|
||||
saveFile(byteArrayChanges, Paths.get(versionDir + File.separator + "diff.zip"));
|
||||
// save file changes to the diff.zip archive
|
||||
downloadToFile(changesUri, new File(versionDir + File.separator + "diff.zip"));
|
||||
|
||||
String history = (String) body.get("changeshistory");
|
||||
if (history == null && body.containsKey("history")) {
|
||||
@ -257,7 +248,6 @@ public final class TrackManager {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
|
||||
String forcesavePath = "";
|
||||
boolean isSubmitForm = body.get("forcesavetype").toString().equals("3"); // SubmitForm
|
||||
|
||||
@ -284,7 +274,8 @@ public final class TrackManager {
|
||||
}
|
||||
}
|
||||
|
||||
saveFile(byteArrayFile, Paths.get(forcesavePath));
|
||||
File toSave = new File(forcesavePath);
|
||||
downloadToFile(downloadUri, toSave);
|
||||
|
||||
if (isSubmitForm) {
|
||||
JSONArray actions = (JSONArray) body.get("actions");
|
||||
@ -296,79 +287,43 @@ public final class TrackManager {
|
||||
}
|
||||
}
|
||||
|
||||
// create a new file if it does not exist
|
||||
private static boolean createFile(final byte[] byteArray, final Path path) {
|
||||
if (Files.exists(path)) {
|
||||
return true;
|
||||
}
|
||||
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray)) {
|
||||
File file = Files.createFile(path).toFile(); // create a new file in the specified path
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
int read;
|
||||
final byte[] bytes = new byte[KILOBYTE_SIZE];
|
||||
while ((read = byteArrayInputStream.read(bytes)) != -1) {
|
||||
out.write(bytes, 0, read); // write bytes to the output stream
|
||||
}
|
||||
out.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// get byte array from stream
|
||||
private static byte[] getAllBytes(final InputStream is) throws IOException {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
for (int len = is.read(buffer); len != -1; len = is.read(buffer)) {
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
return os.toByteArray();
|
||||
}
|
||||
|
||||
// save file
|
||||
private static boolean saveFile(final byte[] byteArray, final Path path) {
|
||||
if (path == null) {
|
||||
throw new RuntimeException("Path argument is not specified"); // file isn't specified
|
||||
}
|
||||
if (!Files.exists(path)) { // if the specified file does not exist
|
||||
return createFile(byteArray, path); // create it in the specified directory
|
||||
} else {
|
||||
try {
|
||||
Files.write(path, byteArray); // otherwise, write new information in the bytes format to the file
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// download file from url
|
||||
private static byte[] getDownloadFile(final String url) throws Exception {
|
||||
// save file information from the url to the file specified
|
||||
private static void downloadToFile(final String url, final File file) throws Exception {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new RuntimeException("Url argument is not specified"); // URL isn't specified
|
||||
throw new Exception("argument url"); // url isn't specified
|
||||
}
|
||||
if (file == null) {
|
||||
throw new Exception("argument path"); // file isn't specified
|
||||
}
|
||||
|
||||
URL uri = new URL(url);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
|
||||
connection.setConnectTimeout(FILE_SAVE_TIMEOUT);
|
||||
InputStream stream = connection.getInputStream(); // get input stream of the file information from the URL
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
|
||||
if (statusCode != HttpServletResponse.SC_OK) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Document editing service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream(); // get input stream of the file information from the url
|
||||
|
||||
if (stream == null) {
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Input stream is null");
|
||||
throw new Exception("Stream is null");
|
||||
}
|
||||
|
||||
return getAllBytes(stream);
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
int read;
|
||||
final byte[] bytes = new byte[KILOBYTE_SIZE];
|
||||
while ((read = stream.read(bytes)) != -1) {
|
||||
out.write(bytes, 0, read); // write bytes to the output stream
|
||||
}
|
||||
|
||||
// force write data to the output stream that can be cached in the current thread
|
||||
out.flush();
|
||||
}
|
||||
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
// create a command request
|
||||
|
||||
@ -26,7 +26,6 @@ public final class Constants {
|
||||
public static final Integer FILE_SAVE_TIMEOUT = 5000;
|
||||
public static final Integer MAX_KEY_LENGTH = 20;
|
||||
public static final Integer KILOBYTE_SIZE = 1024;
|
||||
public static final Integer BUFFER_SIZE = 0xFFFF;
|
||||
|
||||
private Constants() { }
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
version=1.5.0
|
||||
version=1.5.1
|
||||
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
|
||||
@ -357,7 +357,8 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="scripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="scripts/jquery.iframe-transport.js"></script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
web/documentserver-example/java/src/main/webapp/scripts/jquery-3.6.4.min.js
vendored
Normal file
2
web/documentserver-example/java/src/main/webapp/scripts/jquery-3.6.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
web/documentserver-example/java/src/main/webapp/scripts/jquery-migrate-3.4.1.min.js
vendored
Normal file
2
web/documentserver-example/java/src/main/webapp/scripts/jquery-migrate-3.4.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -48,6 +48,10 @@ 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"log": {
|
||||
"appenders": [
|
||||
{
|
||||
|
||||
@ -40,6 +40,10 @@ 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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
web/documentserver-example/nodejs/public/javascripts/jquery-3.6.4.min.js
vendored
Normal file
2
web/documentserver-example/nodejs/public/javascripts/jquery-3.6.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
web/documentserver-example/nodejs/public/javascripts/jquery-migrate-3.4.1.min.js
vendored
Normal file
2
web/documentserver-example/nodejs/public/javascripts/jquery-migrate-3.4.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -315,7 +315,8 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.iframe-transport.js"></script>
|
||||
|
||||
@ -16,14 +16,14 @@ 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
|
||||
|
||||
JWT - JSON Web Token implementation (https://github.com/firebase/php-jwt/blob/master/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
License: BSD
|
||||
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
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,66 +14,52 @@
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require dirname(__FILE__) . '/config.php';
|
||||
|
||||
/**
|
||||
* Check if the request is an AJAX request
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isAjax()
|
||||
{
|
||||
return isset($_SERVER['HTTP_X_REQUESTED_WITH'])
|
||||
&& mb_strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
|
||||
|
||||
require( dirname(__FILE__) . '/config.php' );
|
||||
|
||||
// check if the request is an AJAX request
|
||||
function is_ajax() {
|
||||
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the http origin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getHttpOrigin()
|
||||
{
|
||||
$origin = '';
|
||||
if (!empty($_SERVER['HTTP_ORIGIN'])) {
|
||||
$origin = $_SERVER['HTTP_ORIGIN'];
|
||||
}
|
||||
return $origin;
|
||||
// get the http origin
|
||||
function get_http_origin() {
|
||||
$origin = '';
|
||||
if ( ! empty ( $_SERVER[ 'HTTP_ORIGIN' ] ) )
|
||||
$origin = $_SERVER[ 'HTTP_ORIGIN' ];
|
||||
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;
|
||||
// set headers that prevent caching in all the browsers
|
||||
function nocache_headers() {
|
||||
$headers = array(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset( $headers['Last-Modified'] );
|
||||
|
||||
foreach ($headers as $name => $field_value) {
|
||||
@header("{$name}: {$field_value}");
|
||||
}
|
||||
// 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 === stripos( $header, 'Last-Modified' ) ) {
|
||||
$headers['Last-Modified'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $headers as $name => $field_value )
|
||||
@header("{$name}: {$field_value}");
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,62 +14,44 @@
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
require_once dirname(__FILE__) . '/functions.php';
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
|
||||
/**
|
||||
* Put log files into the log folder
|
||||
*
|
||||
* @param string $msg
|
||||
* @param integer $logFileName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function sendlog($msg, $logFileName)
|
||||
{
|
||||
// put log files into the log folder
|
||||
function sendlog($msg, $logFileName) {
|
||||
$logsFolder = "logs/";
|
||||
if (!file_exists($logsFolder)) { // if log folder doesn't exist, make it
|
||||
if (!file_exists($logsFolder)) { // if log folder does't exist, make it
|
||||
mkdir($logsFolder);
|
||||
}
|
||||
file_put_contents($logsFolder . $logFileName, $msg . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new uuid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function guid()
|
||||
{
|
||||
// create new uuid
|
||||
function guid() {
|
||||
if (function_exists('com_create_guid')) {
|
||||
return com_create_guid();
|
||||
} else {
|
||||
mt_srand((double)microtime()*10000); // optional for php 4.2.0 and up
|
||||
$charid = strtoupper(md5(uniqid(rand(), true)));
|
||||
$hyphen = chr(45); // "-"
|
||||
$uuid = chr(123) // "{"
|
||||
.substr($charid, 0, 8).$hyphen
|
||||
.substr($charid, 8, 4).$hyphen
|
||||
.substr($charid,12, 4).$hyphen
|
||||
.substr($charid,16, 4).$hyphen
|
||||
.substr($charid,20,12)
|
||||
.chr(125); // "}"
|
||||
return $uuid;
|
||||
}
|
||||
mt_srand((float) microtime() * 10000); // optional for php 4.2.0 and up
|
||||
$charid = mb_strtoupper(md5(uniqid(rand(), true)));
|
||||
$hyphen = chr(45); // "-"
|
||||
$uuid = chr(123) // "{"
|
||||
.mb_substr($charid, 0, 8).$hyphen
|
||||
.mb_substr($charid, 8, 4).$hyphen
|
||||
.mb_substr($charid, 12, 4).$hyphen
|
||||
.mb_substr($charid, 16, 4).$hyphen
|
||||
.mb_substr($charid, 20, 12)
|
||||
.chr(125); // "}"
|
||||
return $uuid;
|
||||
}
|
||||
|
||||
if (!function_exists('mime_content_type')) {
|
||||
/**
|
||||
* Create new uuid
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function mime_content_type($filename)
|
||||
{
|
||||
$mime_types = [
|
||||
if(!function_exists('mime_content_type')) {
|
||||
function mime_content_type($filename) {
|
||||
|
||||
$mime_types = array(
|
||||
|
||||
'txt' => 'text/plain',
|
||||
'htm' => 'text/html',
|
||||
@ -122,36 +105,35 @@ if (!function_exists('mime_content_type')) {
|
||||
// open office
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
];
|
||||
);
|
||||
|
||||
// check if the file extension is in the mime type array
|
||||
$ext = mb_strtolower(array_pop(explode('.', $filename)));
|
||||
$ext = strtolower(array_pop(explode('.',$filename)));
|
||||
if (array_key_exists($ext, $mime_types)) {
|
||||
return $mime_types[$ext]; // get the mime type of this extension
|
||||
} elseif (function_exists('finfo_open')) { // or get the mime type from the file information
|
||||
}
|
||||
// or get the mime type from the file information
|
||||
elseif (function_exists('finfo_open')) {
|
||||
$finfo = finfo_open(FILEINFO_MIME);
|
||||
$mimetype = finfo_file($finfo, $filename);
|
||||
finfo_close($finfo);
|
||||
return $mimetype;
|
||||
}
|
||||
|
||||
return 'application/octet-stream';
|
||||
else {
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ip address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getClientIp()
|
||||
{
|
||||
$ipaddress = getenv('HTTP_CLIENT_IP') ?:
|
||||
getenv('HTTP_X_FORWARDED_FOR') ?:
|
||||
getenv('HTTP_X_FORWARDED') ?:
|
||||
getenv('HTTP_FORWARDED_FOR') ?:
|
||||
getenv('HTTP_FORWARDED') ?:
|
||||
getenv('REMOTE_ADDR') ?:
|
||||
// get ip address
|
||||
function getClientIp() {
|
||||
$ipaddress =
|
||||
getenv('HTTP_CLIENT_IP')?:
|
||||
getenv('HTTP_X_FORWARDED_FOR')?:
|
||||
getenv('HTTP_X_FORWARDED')?:
|
||||
getenv('HTTP_FORWARDED_FOR')?:
|
||||
getenv('HTTP_FORWARDED')?:
|
||||
getenv('REMOTE_ADDR')?:
|
||||
'Storage';
|
||||
|
||||
$ipaddress = preg_replace("/[^0-9a-zA-Z.=]/", "_", $ipaddress);
|
||||
@ -159,132 +141,65 @@ function getClientIp()
|
||||
return $ipaddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server url
|
||||
*
|
||||
* @param string $forDocumentServer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function serverPath($forDocumentServer = null)
|
||||
{
|
||||
// get server url
|
||||
function serverPath($forDocumentServer = NULL) {
|
||||
return $forDocumentServer && isset($GLOBALS['EXAMPLE_URL']) && $GLOBALS['EXAMPLE_URL'] != ""
|
||||
? $GLOBALS['EXAMPLE_URL']
|
||||
: (getScheme() . '://' . $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user host address
|
||||
*
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getCurUserHostAddress($userAddress = null)
|
||||
{
|
||||
// get current user host address
|
||||
function getCurUserHostAddress($userAddress = NULL) {
|
||||
if ($GLOBALS['ALONE']) {
|
||||
if (empty($GLOBALS['STORAGE_PATH'])) {
|
||||
return "Storage";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (is_null($userAddress)) {
|
||||
$userAddress = getClientIp();
|
||||
}
|
||||
if (is_null($userAddress)) {$userAddress = getClientIp();}
|
||||
return preg_replace("[^0-9a-zA-Z.=]", '_', $userAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an internal file extension
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getInternalExtension($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
// get an internal file extension
|
||||
function getInternalExtension($filename) {
|
||||
$ext = strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) {
|
||||
return ".docx";
|
||||
} // .docx for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) {
|
||||
return ".xlsx";
|
||||
} // .xlsx for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) {
|
||||
return ".pptx";
|
||||
} // .pptx for presentation extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) return ".docx"; // .docx for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) return ".xlsx"; // .xlsx for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) return ".pptx"; // .pptx for presentation extensions
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image url for templates
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getTemplateImageUrl($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
// get image url for templates
|
||||
function getTemplateImageUrl($filename) {
|
||||
$ext = strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$path = serverPath(true) . "/css/images/";
|
||||
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) {
|
||||
return $path . "file_docx.svg";
|
||||
} // for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) {
|
||||
return $path . "file_xlsx.svg";
|
||||
} // for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) {
|
||||
return $path . "file_pptx.svg";
|
||||
} // for presentation extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) return $path . "file_docx.svg"; // for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) return $path . "file_xlsx.svg"; // for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) return $path . "file_pptx.svg"; // for presentation extensions
|
||||
return $path . "file_docx.svg";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document type
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDocumentType($filename)
|
||||
{
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
// get the document type
|
||||
function getDocumentType($filename) {
|
||||
$ext = strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) {
|
||||
return "word";
|
||||
} // word for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) {
|
||||
return "cell";
|
||||
} // cell for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) {
|
||||
return "slide";
|
||||
} // slide for presentation extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsDocument'])) return "word"; // word for text document extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsSpreadsheet'])) return "cell"; // cell for spreadsheet extensions
|
||||
if (in_array($ext, $GLOBALS['ExtsPresentation'])) return "slide"; // slide for presentation extensions
|
||||
return "word";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getScheme()
|
||||
{
|
||||
// get the protocol
|
||||
function getScheme() {
|
||||
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the storage path of the given file
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getStoragePath($fileName, $userAddress = null)
|
||||
{
|
||||
$storagePath = trim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
// get the storage path of the given file
|
||||
function getStoragePath($fileName, $userAddress = NULL) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
}
|
||||
@ -295,8 +210,9 @@ function getStoragePath($fileName, $userAddress = null)
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
}
|
||||
|
||||
if ($storagePath != "") {
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
if ($storagePath != "")
|
||||
{
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
// if the file directory doesn't exist, make it
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
@ -310,62 +226,39 @@ function getStoragePath($fileName, $userAddress = null)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the forcesaved file version
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $userAddress
|
||||
* @param bool $create
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getForcesavePath($fileName, $userAddress, $create)
|
||||
{
|
||||
$storagePath = trim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
// get the path to the forcesaved file version
|
||||
function getForcesavePath($fileName, $userAddress, $create) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
|
||||
// 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;
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
return "";
|
||||
}
|
||||
if (!is_dir($directory)) return "";
|
||||
|
||||
// create the directory to the history of this file version
|
||||
$directory = $directory . $fileName . "-hist" . DIRECTORY_SEPARATOR;
|
||||
if (!$create && !is_dir($directory)) {
|
||||
return "";
|
||||
}
|
||||
if (!$create && !is_dir($directory)) return "";
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
$directory = $directory . $fileName;
|
||||
if (!$create && !file_exists($directory)) {
|
||||
return "";
|
||||
}
|
||||
if (!$create && !file_exists($directory)) return "";
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the file history
|
||||
*
|
||||
* @param string $storagePath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getHistoryDir($storagePath)
|
||||
{
|
||||
// get the path to the file history
|
||||
function getHistoryDir($storagePath) {
|
||||
$directory = $storagePath . "-hist";
|
||||
// if the history directory doesn't exist, make it
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
@ -374,36 +267,19 @@ function getHistoryDir($storagePath)
|
||||
return $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the specified file version
|
||||
*
|
||||
* @param string $histDir
|
||||
* @param string $version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getVersionDir($histDir, $version)
|
||||
{
|
||||
// get the path to the specified file version
|
||||
function getVersionDir($histDir, $version) {
|
||||
return $histDir . DIRECTORY_SEPARATOR . $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a number of the last file version from the history directory
|
||||
*
|
||||
* @param string $histDir
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getFileVersion($histDir)
|
||||
{
|
||||
if (!file_exists($histDir) || !is_dir($histDir)) {
|
||||
return 1;
|
||||
} // check if the history directory exists
|
||||
// get a number of the last file version from the history directory
|
||||
function getFileVersion($histDir) {
|
||||
if (!file_exists($histDir) || !is_dir($histDir)) return 1; // check if the history directory exists
|
||||
|
||||
$cdir = scandir($histDir);
|
||||
$ver = 1;
|
||||
foreach ($cdir as $key => $fileName) {
|
||||
if (!in_array($fileName, [".", ".."])) {
|
||||
foreach($cdir as $key => $fileName) {
|
||||
if (!in_array($fileName,array(".", ".."))) {
|
||||
if (is_dir($histDir . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
$ver++;
|
||||
}
|
||||
@ -412,14 +288,9 @@ function getFileVersion($histDir)
|
||||
return $ver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the stored files from the folder
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getStoredFiles()
|
||||
{
|
||||
$storagePath = trim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
// get all the stored files from the folder
|
||||
function getStoredFiles() {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
}
|
||||
@ -431,9 +302,10 @@ function getStoredFiles()
|
||||
}
|
||||
|
||||
// get the storage path and check if it exists
|
||||
$result = [];
|
||||
if ($storagePath != "") {
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
$result = array();
|
||||
if ($storagePath != "")
|
||||
{
|
||||
$directory = $directory . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
@ -449,18 +321,18 @@ function getStoredFiles()
|
||||
}
|
||||
|
||||
$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, [".", ".."])) {
|
||||
$result = array();
|
||||
foreach($cdir as $key => $fileName) { // run through all the file and folder names
|
||||
if (!in_array($fileName,array(".", ".."))) {
|
||||
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) { // if an element isn't a directory
|
||||
$ext = mb_strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$ext = 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, $GLOBALS['DOC_SERV_EDITED']),
|
||||
"isFillFormDoc" => in_array($ext, $GLOBALS['DOC_SERV_FILLFORMS']),
|
||||
];
|
||||
$result[$dat] = (object) array( // and write the file to the result
|
||||
"name" => $fileName,
|
||||
"documentType" => getDocumentType($fileName),
|
||||
"canEdit" => in_array($ext, $GLOBALS['DOC_SERV_EDITED']),
|
||||
"isFillFormDoc" => in_array($ext, $GLOBALS['DOC_SERV_FILLFORMS'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -468,18 +340,12 @@ function getStoredFiles()
|
||||
return array_reverse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the virtual path
|
||||
*
|
||||
* @param string $forDocumentServer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getVirtualPath($forDocumentServer)
|
||||
{
|
||||
$storagePath = trim(str_replace(['/', '\\'], '/', $GLOBALS['STORAGE_PATH']), '/');
|
||||
// get the virtual path
|
||||
function getVirtualPath($forDocumentServer) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), '/', $GLOBALS['STORAGE_PATH']), '/');
|
||||
$storagePath = $storagePath != "" ? $storagePath . '/' : "";
|
||||
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . '/';
|
||||
} else {
|
||||
@ -489,18 +355,8 @@ function getVirtualPath($forDocumentServer)
|
||||
return $virtPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file with meta information
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $uid
|
||||
* @param string $uname
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function createMeta($fileName, $uid, $uname, $userAddress = null)
|
||||
{
|
||||
// get a file with meta information
|
||||
function createMeta($fileName, $uid, $uname, $userAddress = NULL) {
|
||||
$histDir = getHistoryDir(getStoragePath($fileName, $userAddress)); // get the history directory
|
||||
|
||||
// turn the file information into the json format
|
||||
@ -514,113 +370,72 @@ function createMeta($fileName, $uid, $uname, $userAddress = null)
|
||||
file_put_contents($histDir . DIRECTORY_SEPARATOR . "createdInfo.json", json_encode($json, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file url
|
||||
*
|
||||
* @param string $file_name
|
||||
* @param string $forDocumentServer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function fileUri($file_name, $forDocumentServer = null)
|
||||
{
|
||||
// get the file url
|
||||
function FileUri($file_name, $forDocumentServer = NULL) {
|
||||
$uri = getVirtualPath($forDocumentServer) . rawurlencode($file_name); // add encoded file name to the virtual path
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file information
|
||||
*
|
||||
* @param string $fileId
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
function getFileInfo($fileId)
|
||||
{
|
||||
// get file information
|
||||
function getFileInfo($fileId){
|
||||
$storedFiles = getStoredFiles();
|
||||
$result = [];
|
||||
$resultID = [];
|
||||
$result = array();
|
||||
$resultID = array();
|
||||
|
||||
// run through all the stored files
|
||||
foreach ($storedFiles as $key => $value) {
|
||||
$result[$key] = (object) [ // write all the parameters to the map
|
||||
foreach ($storedFiles as $key => $value){
|
||||
$result[$key] = (object) array( // write all the parameters to the map
|
||||
"version" => getFileVersion(getHistoryDir(getStoragePath($value->name))),
|
||||
"id" => getDocEditorKey($value->name),
|
||||
"contentLength" => number_format(filesize(getStoragePath($value->name)) / 1024, 2)." KB",
|
||||
"contentLength" => number_format( filesize(getStoragePath($value->name)) / 1024, 2 )." KB",
|
||||
"pureContentLength" => filesize(getStoragePath($value->name)),
|
||||
"title" => $value->name,
|
||||
"updated" => date(DATE_ATOM, filemtime(getStoragePath($value->name))),
|
||||
];
|
||||
"updated" => date( DATE_ATOM, filemtime(getStoragePath($value->name))),
|
||||
);
|
||||
// get file information by its id
|
||||
if ($fileId != null) {
|
||||
if ($fileId == getDocEditorKey($value->name)) {
|
||||
if ($fileId != null){
|
||||
if ($fileId == getDocEditorKey($value->name)){
|
||||
$resultID[count($resultID)] = $result[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileId != null) {
|
||||
if (count($resultID) != 0) {
|
||||
return $resultID;
|
||||
}
|
||||
return "File not found";
|
||||
if ($fileId != null){
|
||||
if (count($resultID) != 0) return $resultID;
|
||||
else return "File not found";
|
||||
}
|
||||
else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the supported file extensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getFileExts()
|
||||
{
|
||||
return array_merge(
|
||||
$GLOBALS['DOC_SERV_VIEWD'],
|
||||
$GLOBALS['DOC_SERV_EDITED'],
|
||||
$GLOBALS['DOC_SERV_CONVERT'],
|
||||
$GLOBALS['DOC_SERV_FILLFORMS']
|
||||
);
|
||||
// get all the supported file extensions
|
||||
function getFileExts() {
|
||||
return array_merge($GLOBALS['DOC_SERV_VIEWD'], $GLOBALS['DOC_SERV_EDITED'], $GLOBALS['DOC_SERV_CONVERT'], $GLOBALS['DOC_SERV_FILLFORMS']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct file name if such a name already exists
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function GetCorrectName($fileName, $userAddress = null)
|
||||
{
|
||||
// get the correct file name if such a name already exists
|
||||
function GetCorrectName($fileName, $userAddress = NULL) {
|
||||
$path_parts = pathinfo($fileName);
|
||||
|
||||
$ext = mb_strtolower($path_parts['extension']);
|
||||
$ext = strtolower($path_parts['extension']);
|
||||
$name = $path_parts['basename'];
|
||||
// get file name from the basename without extension
|
||||
$baseNameWithoutExt = mb_substr($name, 0, mb_strlen($name) - mb_strlen($ext) - 1);
|
||||
$baseNameWithoutExt = substr($name, 0, strlen($name) - strlen($ext) - 1); // get file name from the basename without extension
|
||||
$name = $baseNameWithoutExt . "." . $ext;
|
||||
|
||||
// if a file with such a name already exists in this directory
|
||||
for ($i = 1; file_exists(getStoragePath($name, $userAddress)); $i++) {
|
||||
for ($i = 1; file_exists(getStoragePath($name, $userAddress)); $i++) // if a file with such a name already exists in this directory
|
||||
{
|
||||
$name = $baseNameWithoutExt . " (" . $i . ")." . $ext; // add an index after its base name
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get document key
|
||||
*
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDocEditorKey($fileName)
|
||||
{
|
||||
// get document key by adding local file url to the current user host address
|
||||
$key = getCurUserHostAddress() . fileUri($fileName);
|
||||
// get document key
|
||||
function getDocEditorKey($fileName) {
|
||||
$key = getCurUserHostAddress() . FileUri($fileName); // get document key by adding local file url to the current user host address
|
||||
$stat = filemtime(getStoragePath($fileName)); // get creation time
|
||||
$key = $key . $stat; // and add it to the document key
|
||||
return generateRevisionId($key); // generate the document key value
|
||||
return GenerateRevisionId($key); // generate the document key value
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,17 +0,0 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "*"
|
||||
},
|
||||
"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"
|
||||
]
|
||||
}
|
||||
}
|
||||
75
web/documentserver-example/php/composer.lock
generated
75
web/documentserver-example/php/composer.lock
generated
@ -1,75 +0,0 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "0ae1576e556ebadd2933ecd2483a4b26",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
|
||||
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpcs",
|
||||
"bin/phpcbf"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Sherwood",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
||||
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"keywords": [
|
||||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
|
||||
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"time": "2022-06-18T07:21:10+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.2.0"
|
||||
}
|
||||
@ -1,36 +1,19 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
$GLOBALS['version'] = "1.5.0";
|
||||
$GLOBALS['version'] = "1.5.1";
|
||||
|
||||
$GLOBALS['FILE_SIZE_MAX'] = 5242880;
|
||||
$GLOBALS['STORAGE_PATH'] = "";
|
||||
$GLOBALS['ALONE'] = false;
|
||||
$GLOBALS['ALONE'] = FALSE;
|
||||
|
||||
$GLOBALS['DOC_SERV_FILLFORMS'] = [".oform", ".docx"];
|
||||
$GLOBALS['DOC_SERV_VIEWD'] = [".pdf", ".djvu", ".xps", ".oxps"];
|
||||
$GLOBALS['DOC_SERV_EDITED'] = [".docx", ".xlsx", ".csv", ".pptx", ".txt", ".docxf"];
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = [".docm", ".doc", ".dotx", ".dotm", ".dot",
|
||||
".odt", ".fodt", ".ott", ".xlsm", ".xlsb", ".xls", ".xltx", ".xltm",
|
||||
".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps",
|
||||
".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2"];
|
||||
$GLOBALS['DOC_SERV_FILLFORMS'] = array(".oform", ".docx");
|
||||
$GLOBALS['DOC_SERV_VIEWD'] = array(".pdf", ".djvu", ".xps", ".oxps");
|
||||
$GLOBALS['DOC_SERV_EDITED'] = array(".docx", ".xlsx", ".csv", ".pptx", ".txt", ".docxf");
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = array(".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xlsb", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2");
|
||||
|
||||
$GLOBALS['DOC_SERV_TIMEOUT'] = "120000";
|
||||
|
||||
|
||||
$GLOBALS['DOC_SERV_SITE_URL'] = "http://documentserver/";
|
||||
|
||||
$GLOBALS['DOC_SERV_CONVERTER_URL'] = "ConvertService.ashx";
|
||||
@ -41,31 +24,29 @@ $GLOBALS['DOC_SERV_COMMAND_URL'] = "coauthoring/CommandService.ashx";
|
||||
$GLOBALS['DOC_SERV_JWT_SECRET'] = "";
|
||||
$GLOBALS['DOC_SERV_JWT_HEADER'] = "Authorization";
|
||||
|
||||
$GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] = true;
|
||||
$GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] = TRUE;
|
||||
|
||||
$GLOBALS['EXAMPLE_URL'] = "";
|
||||
|
||||
$GLOBALS['MOBILE_REGEX'] = "android|avantgo|playbook|blackberry|blazer|
|
||||
compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |
|
||||
maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|
|
||||
pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
|
||||
$GLOBALS['MOBILE_REGEX'] = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
|
||||
|
||||
$GLOBALS['ExtsSpreadsheet'] = [".xls", ".xlsx", ".xlsm", ".xlsb",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"];
|
||||
|
||||
$GLOBALS['ExtsPresentation'] = [".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"];
|
||||
$GLOBALS['ExtsSpreadsheet'] = array(".xls", ".xlsx", ".xlsm", ".xlsb",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv");
|
||||
|
||||
$GLOBALS['ExtsDocument'] = [".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".xml",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"];
|
||||
$GLOBALS['ExtsPresentation'] = array(".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp");
|
||||
|
||||
$GLOBALS['LANGUAGES'] = [
|
||||
$GLOBALS['ExtsDocument'] = array(".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".xml",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform");
|
||||
|
||||
$GLOBALS['LANGUAGES'] = array(
|
||||
'en' => 'English',
|
||||
'hy' => 'Armenian',
|
||||
'az' => 'Azerbaijani',
|
||||
@ -104,5 +85,6 @@ $GLOBALS['LANGUAGES'] = [
|
||||
'tr' => 'Turkish',
|
||||
'uk' => 'Ukrainian',
|
||||
'vi' => 'Vietnamese',
|
||||
'aa-AA' => 'Test Language',
|
||||
];
|
||||
'aa-AA' => 'Test Language'
|
||||
);
|
||||
?>
|
||||
@ -1,434 +1,360 @@
|
||||
<?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 PhpExample;
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/common.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
require_once( dirname(__FILE__) . '/jwtmanager.php' );
|
||||
require_once( dirname(__FILE__) . '/users.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.
|
||||
*/
|
||||
$filename;
|
||||
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
require_once dirname(__FILE__) . '/common.php';
|
||||
require_once dirname(__FILE__) . '/functions.php';
|
||||
require_once dirname(__FILE__) . '/jwtmanager.php';
|
||||
require_once dirname(__FILE__) . '/users.php';
|
||||
$user = getUser($_GET["user"]);
|
||||
$isEnableDirectUrl = $_GET["directUrl"] != null ? filter_var($_GET["directUrl"], FILTER_VALIDATE_BOOLEAN) : false;
|
||||
|
||||
$user = getUser($_GET["user"]);
|
||||
$isEnableDirectUrl = isset($_GET["directUrl"]) ? filter_var($_GET["directUrl"], FILTER_VALIDATE_BOOLEAN) : false;
|
||||
// get the file url and upload it
|
||||
$externalUrl = $_GET["fileUrl"];
|
||||
if (!empty($externalUrl))
|
||||
{
|
||||
$filename = DoUpload($externalUrl);
|
||||
}
|
||||
// if the file url doesn't exist, get file name and file extension
|
||||
else
|
||||
{
|
||||
$filename = basename($_GET["fileID"]);
|
||||
}
|
||||
$createExt = $_GET["fileExt"];
|
||||
|
||||
// get the file url and upload it
|
||||
$externalUrl = $_GET["fileUrl"] ?? "";
|
||||
if (!empty($externalUrl)) {
|
||||
$filename = doUpload($externalUrl);
|
||||
} else { // if the file url doesn't exist, get file name and file extension
|
||||
$filename = basename($_GET["fileID"]);
|
||||
}
|
||||
$createExt = $_GET["fileExt"] ?? "";
|
||||
if (!empty($createExt))
|
||||
{
|
||||
// and get demo file name by the extension
|
||||
$filename = tryGetDefaultByType($createExt, $user);
|
||||
|
||||
if (!empty($createExt)) {
|
||||
// and get demo file name by the extension
|
||||
$filename = tryGetDefaultByType($createExt, $user);
|
||||
|
||||
// create the demo file url
|
||||
$new_url = "doceditor.php?fileID=" . $filename . "&user=" . $_GET["user"];
|
||||
header('Location: ' . $new_url, true);
|
||||
exit;
|
||||
}
|
||||
|
||||
$fileuri = fileUri($filename, true);
|
||||
$fileuriUser = realpath($GLOBALS['STORAGE_PATH']) === $GLOBALS['STORAGE_PATH'] ?
|
||||
getDownloadUrl($filename) . "&dmode=emb" : fileUri($filename);
|
||||
$directUrl = getDownloadUrl($filename, false);
|
||||
$docKey = getDocEditorKey($filename);
|
||||
$filetype = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
$ext = mb_strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$editorsMode = empty($_GET["action"]) ? "edit" : $_GET["action"]; // get the editors mode
|
||||
$canEdit = in_array($ext, $GLOBALS['DOC_SERV_EDITED']); // check if the file can be edited
|
||||
if ((!$canEdit && $editorsMode == "edit"
|
||||
|| $editorsMode == "fillForms")
|
||||
&& in_array($ext, $GLOBALS['DOC_SERV_FILLFORMS'])
|
||||
) {
|
||||
$editorsMode = "fillForms";
|
||||
$canEdit = true;
|
||||
}
|
||||
|
||||
// check if the Submit form button is displayed or not
|
||||
$submitForm = $editorsMode == "fillForms" && $user->id == "uid-1" && !1;
|
||||
$mode = $canEdit && $editorsMode != "view" ? "edit" : "view"; // define if the editing mode is edit or view
|
||||
$type = empty($_GET["type"]) ? "desktop" : $_GET["type"];
|
||||
|
||||
$templatesImageUrl = getTemplateImageUrl($filename); // templates image url in the "From Template" section
|
||||
$createUrl = getCreateUrl($filename, $user->id, $type);
|
||||
$templates = [
|
||||
[
|
||||
"image" => "",
|
||||
"title" => "Blank",
|
||||
"url" => $createUrl,
|
||||
],
|
||||
[
|
||||
"image" => $templatesImageUrl,
|
||||
"title" => "With sample content",
|
||||
"url" => $createUrl . "&sample=true",
|
||||
],
|
||||
];
|
||||
|
||||
// specify the document config
|
||||
$config = [
|
||||
"type" => $type,
|
||||
"documentType" => getDocumentType($filename),
|
||||
"document" => [
|
||||
"title" => $filename,
|
||||
"url" => getDownloadUrl($filename),
|
||||
"directUrl" => $isEnableDirectUrl ? $directUrl : "",
|
||||
"fileType" => $filetype,
|
||||
"key" => $docKey,
|
||||
"info" => [
|
||||
"owner" => "Me",
|
||||
"uploaded" => date('d.m.y'),
|
||||
"favorite" => $user->favorite,
|
||||
],
|
||||
"permissions" => [ // the permission for the document to be edited and downloaded or not
|
||||
"comment" => $editorsMode != "view" && $editorsMode
|
||||
!= "fillForms" && $editorsMode != "embedded" && $editorsMode != "blockcontent",
|
||||
"copy" => !in_array("copy", $user->deniedPermissions),
|
||||
"download" => !in_array("download", $user->deniedPermissions),
|
||||
"edit" => $canEdit && ($editorsMode == "edit" ||
|
||||
$editorsMode == "view" || $editorsMode == "filter" || $editorsMode == "blockcontent"),
|
||||
"print" => !in_array("print", $user->deniedPermissions),
|
||||
"fillForms" => $editorsMode != "view" && $editorsMode != "comment"
|
||||
&& $editorsMode != "embedded" && $editorsMode != "blockcontent",
|
||||
"modifyFilter" => $editorsMode != "filter",
|
||||
"modifyContentControl" => $editorsMode != "blockcontent",
|
||||
"review" => $canEdit && ($editorsMode == "edit" || $editorsMode == "review"),
|
||||
"chat" => $user->id != "uid-0",
|
||||
"reviewGroups" => $user->reviewGroups,
|
||||
"commentGroups" => $user->commentGroups,
|
||||
"userInfoGroups" => $user->userInfoGroups,
|
||||
],
|
||||
],
|
||||
"editorConfig" => [
|
||||
"actionLink" => empty($_GET["actionLink"]) ? null : json_decode($_GET["actionLink"]),
|
||||
"mode" => $mode,
|
||||
"lang" => empty($_COOKIE["ulang"]) ? "en" : $_COOKIE["ulang"],
|
||||
"callbackUrl" => getCallbackUrl($filename), // absolute URL to the document storage service
|
||||
"coEditing" => $editorsMode == "view" && $user->id == "uid-0" ? [
|
||||
"mode" => "strict",
|
||||
"change" => false,
|
||||
] : null,
|
||||
"createUrl" => $user->id != "uid-0" ? $createUrl : null,
|
||||
"templates" => $user->templates ? $templates : null,
|
||||
"user" => [ // the user currently viewing or editing the document
|
||||
"id" => $user->id != "uid-0" ? $user->id : null,
|
||||
"name" => $user->name,
|
||||
"group" => $user->group,
|
||||
],
|
||||
"embedded" => [ // the parameters for the embedded document type
|
||||
// the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
"saveUrl" => $directUrl,
|
||||
// the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
"embedUrl" => $directUrl,
|
||||
// the absolute URL that will allow other users to share this document
|
||||
"shareUrl" => $directUrl,
|
||||
"toolbarDocked" => "top", // the place for the embedded viewer toolbar (top or bottom)
|
||||
],
|
||||
"customization" => [ // the parameters for the editor interface
|
||||
"about" => true, // the About section display
|
||||
"comments" => true,
|
||||
"feedback" => true, // the Feedback & Support menu button display
|
||||
// adds the request for the forced file saving to the callback handler when saving the document
|
||||
"forcesave" => false,
|
||||
"submitForm" => $submitForm, // if the Submit form button is displayed or not
|
||||
"goback" => [ // settings for the Open file location menu button and upper right corner button
|
||||
// the absolute URL to the website address which will be opened
|
||||
// when clicking the Open file location menu button
|
||||
"url" => serverPath(),
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// an image for inserting
|
||||
$dataInsertImage = $isEnableDirectUrl ? [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png",
|
||||
"directUrl" => serverPath(false) . "/css/images/logo.png",
|
||||
] : [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png",
|
||||
];
|
||||
|
||||
// a document for comparing
|
||||
$dataCompareFile = $isEnableDirectUrl ? [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=assets&name=sample.docx",
|
||||
] : [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx",
|
||||
];
|
||||
|
||||
// recipients data for mail merging
|
||||
$dataMailMergeRecipients = $isEnableDirectUrl ? [
|
||||
"fileType" => "csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=csv",
|
||||
] : [
|
||||
"fileType" => "csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv",
|
||||
];
|
||||
|
||||
// users data for mentions
|
||||
$usersForMentions = $user->id != "uid-0" ? getUsersForMentions($user->id) : null;
|
||||
|
||||
// check if the secret key to generate token exists
|
||||
if (isJwtEnabled()) {
|
||||
$config["token"] = jwtEncode($config); // encode config into the token
|
||||
$dataInsertImage["token"] = jwtEncode($dataInsertImage); // encode the dataInsertImage object into the token
|
||||
$dataCompareFile["token"] = jwtEncode($dataCompareFile); // encode the dataCompareFile object into the token
|
||||
// encode the dataMailMergeRecipients object into the token
|
||||
$dataMailMergeRecipients["token"] = jwtEncode($dataMailMergeRecipients);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get demo file name by the extension
|
||||
*
|
||||
* @param string $createExt
|
||||
* @param string $user
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function tryGetDefaultByType($createExt, $user)
|
||||
{
|
||||
$demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . $demoPath . $demoName, getStoragePath($demoFilename))) {
|
||||
sendlog("Copy file error to ". getStoragePath($demoFilename), "common.log");
|
||||
// Copy error!!!
|
||||
// create the demo file url
|
||||
$new_url = "doceditor.php?fileID=" . $filename . "&user=" . $_GET["user"];
|
||||
header('Location: ' . $new_url, true);
|
||||
exit;
|
||||
}
|
||||
|
||||
// create demo file meta information
|
||||
createMeta($demoFilename, $user->id, $user->name);
|
||||
$fileuri = FileUri($filename, true);
|
||||
$fileuriUser = realpath($GLOBALS['STORAGE_PATH']) === $GLOBALS['STORAGE_PATH'] ? getDownloadUrl($filename) . "&dmode=emb" : FileUri($filename);
|
||||
$directUrl = getDownloadUrl($filename, FALSE);
|
||||
$docKey = getDocEditorKey($filename);
|
||||
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
return $demoFilename;
|
||||
}
|
||||
$ext = strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$editorsMode = empty($_GET["action"]) ? "edit" : $_GET["action"]; // get the editors mode
|
||||
$canEdit = in_array($ext, $GLOBALS['DOC_SERV_EDITED']); // check if the file can be edited
|
||||
if ((!$canEdit && $editorsMode == "edit" || $editorsMode == "fillForms") && in_array($ext, $GLOBALS['DOC_SERV_FILLFORMS'])) {
|
||||
$editorsMode = "fillForms";
|
||||
$canEdit = true;
|
||||
}
|
||||
$submitForm = $editorsMode == "fillForms" && $user->id == "uid-1" && !1; // check if the Submit form button is displayed or not
|
||||
$mode = $canEdit && $editorsMode != "view" ? "edit" : "view"; // define if the editing mode is edit or view
|
||||
$type = empty($_GET["type"]) ? "desktop" : $_GET["type"];
|
||||
|
||||
/**
|
||||
* Get the callback url
|
||||
*
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getCallbackUrl($fileName)
|
||||
{
|
||||
return serverPath(true) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=track"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
$templatesImageUrl = getTemplateImageUrl($filename); // templates image url in the "From Template" section
|
||||
$createUrl = getCreateUrl($filename, $user->id, $type);
|
||||
$templates = array(
|
||||
array (
|
||||
"image" => "",
|
||||
"title" => "Blank",
|
||||
"url" => $createUrl
|
||||
),
|
||||
array (
|
||||
"image" => $templatesImageUrl,
|
||||
"title" => "With sample content",
|
||||
"url" => $createUrl . "&sample=true"
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Get url to the created file
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $uid
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getCreateUrl($fileName, $uid, $type)
|
||||
{
|
||||
$ext = trim(getInternalExtension($fileName), '.');
|
||||
return serverPath(false) . '/'
|
||||
. "doceditor.php"
|
||||
. "?fileExt=" . $ext
|
||||
. "&user=" . $uid
|
||||
. "&type=" . $type;
|
||||
}
|
||||
// specify the document config
|
||||
$config = [
|
||||
"type" => $type,
|
||||
"documentType" => getDocumentType($filename),
|
||||
"document" => [
|
||||
"title" => $filename,
|
||||
"url" => getDownloadUrl($filename),
|
||||
"directUrl" => $isEnableDirectUrl ? $directUrl : "",
|
||||
"fileType" => $filetype,
|
||||
"key" => $docKey,
|
||||
"info" => [
|
||||
"owner" => "Me",
|
||||
"uploaded" => date('d.m.y'),
|
||||
"favorite" => $user->favorite
|
||||
],
|
||||
"permissions" => [ // the permission for the document to be edited and downloaded or not
|
||||
"comment" => $editorsMode != "view" && $editorsMode != "fillForms" && $editorsMode != "embedded" && $editorsMode != "blockcontent",
|
||||
"copy" => !in_array("copy", $user->deniedPermissions),
|
||||
"download" => !in_array("download", $user->deniedPermissions),
|
||||
"edit" => $canEdit && ($editorsMode == "edit" || $editorsMode == "view" || $editorsMode == "filter" || $editorsMode == "blockcontent"),
|
||||
"print" => !in_array("print", $user->deniedPermissions),
|
||||
"fillForms" => $editorsMode != "view" && $editorsMode != "comment" && $editorsMode != "embedded" && $editorsMode != "blockcontent",
|
||||
"modifyFilter" => $editorsMode != "filter",
|
||||
"modifyContentControl" => $editorsMode != "blockcontent",
|
||||
"review" => $canEdit && ($editorsMode == "edit" || $editorsMode == "review"),
|
||||
"chat" => $user->id != "uid-0",
|
||||
"reviewGroups" => $user->reviewGroups,
|
||||
"commentGroups" => $user->commentGroups,
|
||||
"userInfoGroups" => $user->userInfoGroups
|
||||
]
|
||||
],
|
||||
"editorConfig" => [
|
||||
"actionLink" => empty($_GET["actionLink"]) ? null : json_decode($_GET["actionLink"]),
|
||||
"mode" => $mode,
|
||||
"lang" => empty($_COOKIE["ulang"]) ? "en" : $_COOKIE["ulang"],
|
||||
"callbackUrl" => getCallbackUrl($filename), // absolute URL to the document storage service
|
||||
"coEditing" => $editorsMode == "view" && $user->id == "uid-0" ? [
|
||||
"mode" => "strict",
|
||||
"change" => false
|
||||
] : null,
|
||||
"createUrl" => $user->id != "uid-0" ? $createUrl : null,
|
||||
"templates" => $user->templates ? $templates : null,
|
||||
"user" => [ // the user currently viewing or editing the document
|
||||
"id" => $user->id != "uid-0" ? $user->id : null,
|
||||
"name" => $user->name,
|
||||
"group" => $user->group
|
||||
],
|
||||
"embedded" => [ // the parameters for the embedded document type
|
||||
"saveUrl" => $directUrl, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
"embedUrl" => $directUrl, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
"shareUrl" => $directUrl, // the absolute URL that will allow other users to share this document
|
||||
"toolbarDocked" => "top", // the place for the embedded viewer toolbar (top or bottom)
|
||||
],
|
||||
"customization" => [ // the parameters for the editor interface
|
||||
"about" => true, // the About section display
|
||||
"comments" => true,
|
||||
"feedback" => true, // the Feedback & Support menu button display
|
||||
"forcesave" => false, // adds the request for the forced file saving to the callback handler when saving the document
|
||||
"submitForm" => $submitForm, // if the Submit form button is displayed or not
|
||||
"goback" => [ // settings for the Open file location menu button and upper right corner button
|
||||
"url" => serverPath(), // the absolute URL to the website address which will be opened when clicking the Open file location menu button
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Get url for history download
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $version
|
||||
* @param string $file
|
||||
* @param bool $isServer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getHistoryDownloadUrl($fileName, $version, $file, $isServer = true)
|
||||
{
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=history"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&ver=" . $version
|
||||
. "&file=" . urlencode($file)
|
||||
. $userAddress;
|
||||
}
|
||||
// an image for inserting
|
||||
$dataInsertImage = $isEnableDirectUrl ? [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png",
|
||||
"directUrl" => serverPath(false) . "/css/images/logo.png"
|
||||
] : [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png"
|
||||
];
|
||||
|
||||
/**
|
||||
* Get url to download a file
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param bool $isServer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDownloadUrl($fileName, $isServer = true)
|
||||
{
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=download"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. $userAddress;
|
||||
}
|
||||
// a document for comparing
|
||||
$dataCompareFile = $isEnableDirectUrl ? [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=assets&name=sample.docx"
|
||||
] : [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx"
|
||||
];
|
||||
|
||||
/**
|
||||
* Get document history
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $filetype
|
||||
* @param string $docKey
|
||||
* @param string $fileuri
|
||||
* @param bool $isEnableDirectUrl
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
{
|
||||
$storagePath = $GLOBALS['STORAGE_PATH'];
|
||||
$histDir = getHistoryDir(getStoragePath($filename)); // get the path to the file history
|
||||
// recipients data for mail merging
|
||||
$dataMailMergeRecipients = $isEnableDirectUrl ? [
|
||||
"fileType" =>"csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=csv"
|
||||
] : [
|
||||
"fileType" =>"csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv"
|
||||
];
|
||||
|
||||
// users data for mentions
|
||||
$usersForMentions = $user->id != "uid-0" ? getUsersForMentions($user->id) : null;
|
||||
|
||||
if (getFileVersion($histDir) > 0) { // check if the file was modified (the file version is greater than 0)
|
||||
$curVer = getFileVersion($histDir);
|
||||
// check if the secret key to generate token exists
|
||||
if (isJwtEnabled()) {
|
||||
$config["token"] = jwtEncode($config); // encode config into the token
|
||||
$dataInsertImage["token"] = jwtEncode($dataInsertImage); // encode the dataInsertImage object into the token
|
||||
$dataCompareFile["token"] = jwtEncode($dataCompareFile); // encode the dataCompareFile object into the token
|
||||
$dataMailMergeRecipients["token"] = jwtEncode($dataMailMergeRecipients); // encode the dataMailMergeRecipients object into the token
|
||||
}
|
||||
|
||||
$hist = [];
|
||||
$histData = [];
|
||||
// get demo file name by the extension
|
||||
function tryGetDefaultByType($createExt, $user) {
|
||||
$demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
for ($i = 1; $i <= $curVer; $i++) { // run through all the file versions
|
||||
$obj = [];
|
||||
$dataObj = [];
|
||||
$verDir = getVersionDir($histDir, $i); // get the path to the file version
|
||||
|
||||
// get document key
|
||||
$key = $i == $curVer ? $docKey : file_get_contents($verDir . DIRECTORY_SEPARATOR . "key.txt");
|
||||
$obj["key"] = $key;
|
||||
$obj["version"] = $i;
|
||||
|
||||
if ($i == 1) { // check if the version number is equal to 1
|
||||
// get meta data of this file
|
||||
$createdInfo = file_get_contents($histDir . DIRECTORY_SEPARATOR . "createdInfo.json");
|
||||
$json = json_decode($createdInfo, true); // decode the meta data from the createdInfo.json file
|
||||
|
||||
$obj["created"] = $json["created"];
|
||||
$obj["user"] = [
|
||||
"id" => $json["uid"],
|
||||
"name" => $json["name"],
|
||||
];
|
||||
}
|
||||
|
||||
$fileExe = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
$prevFileName = $verDir . DIRECTORY_SEPARATOR . "prev." . $filetype;
|
||||
$prevFileName = mb_substr($prevFileName, mb_strlen(getStoragePath("")));
|
||||
$dataObj["fileType"] = $fileExe;
|
||||
$dataObj["key"] = $key;
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$dataObj["url"] = $prevFileUrl; // write file url to the data object
|
||||
if ($isEnableDirectUrl) {
|
||||
$dataObj["directUrl"] = $directUrl; // write direct url to the data object
|
||||
}
|
||||
$dataObj["version"] = $i;
|
||||
|
||||
if ($i > 1) { // check if the version number is greater than 1 (the document was modified)
|
||||
$changes = json_decode(file_get_contents(getVersionDir($histDir, $i - 1) .
|
||||
DIRECTORY_SEPARATOR . "changes.json"), true); // get the path to the changes.json file
|
||||
$change = $changes["changes"][0];
|
||||
|
||||
// write information about changes to the object
|
||||
$obj["changes"] = $changes ? $changes["changes"] : null;
|
||||
$obj["serverVersion"] = $changes["serverVersion"];
|
||||
$obj["created"] = $change ? $change["created"] : null;
|
||||
$obj["user"] = $change ? $change["user"] : null;
|
||||
|
||||
$prev = $histData[$i - 2]; // get the history data from the previous file version
|
||||
// write information about previous file version to the data object
|
||||
$dataObj["previous"] = $isEnableDirectUrl ? [
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"],
|
||||
"directUrl" => $prev["directUrl"],
|
||||
] : [
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"],
|
||||
];
|
||||
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
$dataObj["changesUrl"] = getHistoryDownloadUrl($filename, $i - 1, "diff.zip");
|
||||
}
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$dataObj["token"] = jwtEncode($dataObj);
|
||||
}
|
||||
|
||||
$hist[] = $obj; // add object dictionary to the hist list
|
||||
$histData[$i - 1] = $dataObj; // write data object information to the history data
|
||||
if(!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . $demoPath . $demoName, getStoragePath($demoFilename)))
|
||||
{
|
||||
sendlog("Copy file error to ". getStoragePath($demoFilename), "common.log");
|
||||
// Copy error!!!
|
||||
}
|
||||
|
||||
// write history information about the current file version
|
||||
$out = [];
|
||||
array_push(
|
||||
$out,
|
||||
[
|
||||
"currentVersion" => $curVer,
|
||||
"history" => $hist,
|
||||
],
|
||||
$histData
|
||||
);
|
||||
return $out;
|
||||
// create demo file meta information
|
||||
createMeta($demoFilename, $user->id, $user->name);
|
||||
|
||||
return $demoFilename;
|
||||
}
|
||||
|
||||
// get the callback url
|
||||
function getCallbackUrl($fileName) {
|
||||
return serverPath(TRUE) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=track"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
}
|
||||
|
||||
// get url to the created file
|
||||
function getCreateUrl($fileName, $uid, $type) {
|
||||
$ext = trim(getInternalExtension($fileName),'.');
|
||||
return serverPath(false) . '/'
|
||||
. "doceditor.php"
|
||||
. "?fileExt=" . $ext
|
||||
. "&user=" . $uid
|
||||
. "&type=" . $type;
|
||||
}
|
||||
|
||||
function getHistoryDownloadUrl($fileName, $version, $file, $isServer = TRUE) {
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=history"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&ver=" . $version
|
||||
. "&file=" . urlencode($file)
|
||||
. $userAddress;
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
function getDownloadUrl($fileName, $isServer = TRUE) {
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=download"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. $userAddress;
|
||||
}
|
||||
|
||||
// get document history
|
||||
function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl) {
|
||||
$storagePath = $GLOBALS['STORAGE_PATH'];
|
||||
$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)
|
||||
$curVer = getFileVersion($histDir);
|
||||
|
||||
$hist = [];
|
||||
$histData = [];
|
||||
|
||||
for ($i = 1; $i <= $curVer; $i++) { // run through all the file versions
|
||||
$obj = [];
|
||||
$dataObj = [];
|
||||
$verDir = getVersionDir($histDir, $i); // get the path to the file version
|
||||
|
||||
$key = $i == $curVer ? $docKey : file_get_contents($verDir . DIRECTORY_SEPARATOR . "key.txt"); // get document key
|
||||
$obj["key"] = $key;
|
||||
$obj["version"] = $i;
|
||||
|
||||
if ($i == 1) { // check if the version number is equal to 1
|
||||
$createdInfo = file_get_contents($histDir . DIRECTORY_SEPARATOR . "createdInfo.json"); // get meta data of this file
|
||||
$json = json_decode($createdInfo, true); // decode the meta data from the createdInfo.json file
|
||||
|
||||
$obj["created"] = $json["created"];
|
||||
$obj["user"] = [
|
||||
"id" => $json["uid"],
|
||||
"name" => $json["name"]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$fileExe = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
$prevFileName = $verDir . DIRECTORY_SEPARATOR . "prev." . $filetype;
|
||||
$prevFileName = substr($prevFileName, strlen(getStoragePath("")));
|
||||
$dataObj["fileType"] = $fileExe;
|
||||
$dataObj["key"] = $key;
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$dataObj["url"] = $prevFileUrl; // write file url to the data object
|
||||
if ($isEnableDirectUrl) {
|
||||
$dataObj["directUrl"] = $directUrl; // write direct url to the data object
|
||||
}
|
||||
$dataObj["version"] = $i;
|
||||
|
||||
if ($i > 1) { // check if the version number is greater than 1 (the document was modified)
|
||||
$changes = json_decode(file_get_contents(getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "changes.json"), true); // get the path to the changes.json file
|
||||
$change = $changes["changes"][0];
|
||||
|
||||
$obj["changes"] = $changes ? $changes["changes"] : null; // write information about changes to the object
|
||||
$obj["serverVersion"] = $changes["serverVersion"];
|
||||
$obj["created"] = $change ? $change["created"] : null;
|
||||
$obj["user"] = $change ? $change["user"] : null;
|
||||
|
||||
$prev = $histData[$i - 2]; // get the history data from the previous file version
|
||||
$dataObj["previous"] = $isEnableDirectUrl ? [ // write information about previous file version to the data object
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"],
|
||||
"directUrl" => $prev["directUrl"]
|
||||
] : [
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"]
|
||||
];
|
||||
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
$dataObj["changesUrl"] = getHistoryDownloadUrl($filename, $i - 1, "diff.zip");
|
||||
|
||||
}
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$dataObj["token"] = jwtEncode($dataObj);
|
||||
}
|
||||
|
||||
array_push($hist, $obj); // add object dictionary to the hist list
|
||||
$histData[$i - 1] = $dataObj; // write data object information to the history data
|
||||
}
|
||||
|
||||
// write history information about the current file version
|
||||
$out = [];
|
||||
array_push($out, [
|
||||
"currentVersion" => $curVer,
|
||||
"history" => $hist
|
||||
],
|
||||
$histData);
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1,
|
||||
maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<link rel="icon" href="css/images/<?php echo getDocumentType($filename) ?>.ico" type="image/x-icon" />
|
||||
@ -463,9 +389,7 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="
|
||||
<?php echo $GLOBALS["DOC_SERV_SITE_URL"].$GLOBALS["DOC_SERV_API_URL"] ?>">
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo $GLOBALS["DOC_SERV_SITE_URL"].$GLOBALS["DOC_SERV_API_URL"] ?>"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -513,8 +437,7 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&actionLink=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) +
|
||||
"&actionLink=" + encodeURIComponent(linkParam);
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
@ -524,13 +447,11 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
return link;
|
||||
}
|
||||
|
||||
// the user is trying to get link for opening the document which contains a bookmark,
|
||||
// scrolling to the bookmark position
|
||||
// the user is trying to get link for opening the document which contains a bookmark, scrolling to the bookmark position
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
// set the link to the document which contains a bookmark
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam)); // set the link to the document which contains a bookmark
|
||||
};
|
||||
|
||||
// the meta information of the document is changed via the meta command
|
||||
@ -549,11 +470,7 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
var onRequestInsertImage = function(event) {
|
||||
docEditor.insertImage({ // insert an image into the file
|
||||
"c": event.data.c,
|
||||
<?php echo mb_strimwidth(
|
||||
json_encode($dataInsertImage),
|
||||
1,
|
||||
mb_strlen(json_encode($dataInsertImage)) - 2
|
||||
)?>
|
||||
<?php echo mb_strimwidth(json_encode($dataInsertImage), 1, strlen(json_encode($dataInsertImage)) - 2)?>
|
||||
})
|
||||
};
|
||||
|
||||
@ -564,8 +481,7 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
|
||||
// the user is trying to select recipients data by clicking the Mail merge button
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
// insert recipient data for mail merge into the file
|
||||
docEditor.setMailMergeRecipients(<?php echo json_encode($dataMailMergeRecipients) ?>);
|
||||
docEditor.setMailMergeRecipients(<?php echo json_encode($dataMailMergeRecipients) ?>); // insert recipient data for mail merge into the file
|
||||
};
|
||||
|
||||
var onRequestSaveAs = function (event) { // the user is trying to save file by clicking Save Copy as... button
|
||||
@ -606,11 +522,11 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
<?php
|
||||
if (!file_exists(getStoragePath($filename))) {
|
||||
echo "alert('File not found'); return;";
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if (!file_exists(getStoragePath($filename))) {
|
||||
echo "alert('File not found'); return;";
|
||||
}
|
||||
?>
|
||||
|
||||
config = <?php echo json_encode($config) ?>;
|
||||
|
||||
@ -631,30 +547,28 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
};
|
||||
|
||||
<?php
|
||||
$out = getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl);
|
||||
$history = $out[0];
|
||||
$historyData = $out[1];
|
||||
$out = getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl);
|
||||
$history = $out[0];
|
||||
$historyData = $out[1];
|
||||
?>
|
||||
|
||||
<?php if ($user->id != "uid-0") { ?>
|
||||
<?php if ($history != null && $historyData != null) { ?>
|
||||
<?php if ($user->id != "uid-0"): ?>
|
||||
<?php if ($history != null && $historyData != null): ?>
|
||||
// the user is trying to show the document version history
|
||||
config.events['onRequestHistory'] = function () {
|
||||
// show the document version history
|
||||
docEditor.refreshHistory(<?php echo json_encode($history) ?>);
|
||||
docEditor.refreshHistory(<?php echo json_encode($history) ?>); // show the document version history
|
||||
};
|
||||
// the user is trying to click the specific document version in the document version history
|
||||
config.events['onRequestHistoryData'] = function (event) {
|
||||
var ver = event.data;
|
||||
var histData = <?php echo json_encode($historyData) ?>;
|
||||
// send the link to the document for viewing the version history
|
||||
docEditor.setHistoryData(histData[ver - 1]);
|
||||
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
|
||||
};
|
||||
// the user is trying to go back to the document from viewing the document version history
|
||||
config.events['onRequestHistoryClose'] = function () {
|
||||
document.location.reload();
|
||||
};
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
// add mentions for not anonymous users
|
||||
config.events['onRequestUsers'] = function () {
|
||||
docEditor.setUsers({ // set a list of users to mention in the comments
|
||||
@ -669,7 +583,7 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl)
|
||||
};
|
||||
// prevent file renaming for anonymous users
|
||||
config.events['onRequestRename'] = onRequestRename;
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
|
||||
if (config.editorConfig.createUrl) {
|
||||
config.events.onRequestSaveAs = onRequestSaveAs;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,33 +14,28 @@
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
require_once dirname(__FILE__) . '/jwtmanager.php';
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/jwtmanager.php' );
|
||||
|
||||
/**
|
||||
* File uploading
|
||||
*
|
||||
* @param string $fileUri
|
||||
*
|
||||
* @throws Exception If file type is not supported or copy operation is unsuccessful
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function doUpload($fileUri)
|
||||
{
|
||||
|
||||
// file uploading
|
||||
function DoUpload($fileUri) {
|
||||
$_fileName = GetCorrectName($fileUri);
|
||||
|
||||
// check if file extension is supported by the editor
|
||||
$ext = mb_strtolower('.' . pathinfo($_fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, getFileExts())) {
|
||||
$ext = strtolower('.' . pathinfo($_fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, getFileExts()))
|
||||
{
|
||||
throw new Exception("File type is not supported");
|
||||
}
|
||||
|
||||
// check if the file copy operation is successful
|
||||
if (!@copy($fileUri, getStoragePath($_fileName))) {
|
||||
$errors = error_get_last();
|
||||
if(!@copy($fileUri, getStoragePath($_fileName)))
|
||||
{
|
||||
$errors= error_get_last();
|
||||
$err = "Copy file error: " . $errors['type'] . "<br />\n" . $errors['message'];
|
||||
throw new Exception($err);
|
||||
}
|
||||
@ -47,22 +43,21 @@ function doUpload($fileUri)
|
||||
return $_fileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate an error code table
|
||||
*
|
||||
* @param string $errorCode Error code
|
||||
*
|
||||
* @throws Exception If error code is unknown
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function processConvServResponceError($errorCode)
|
||||
{
|
||||
* Generate an error code table
|
||||
*
|
||||
* @param string $errorCode Error code
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function ProcessConvServResponceError($errorCode) {
|
||||
$errorMessageTemplate = "Error occurred in the document service: ";
|
||||
$errorMessage = '';
|
||||
|
||||
// add the error message to the error message template depending on the error code
|
||||
switch ($errorCode) {
|
||||
switch ($errorCode)
|
||||
{
|
||||
case -8:
|
||||
$errorMessage = $errorMessageTemplate . "Error document VKey";
|
||||
break;
|
||||
@ -97,48 +92,38 @@ function processConvServResponceError($errorCode)
|
||||
throw new Exception($errorMessage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translation key to a supported form.
|
||||
*
|
||||
* @param string $expected_key Expected key
|
||||
*
|
||||
* @return string key
|
||||
*/
|
||||
function generateRevisionId($expected_key)
|
||||
{
|
||||
if (mb_strlen($expected_key) > 20) {
|
||||
$expected_key = crc32($expected_key);
|
||||
} // if the expected key length is greater than 20, calculate the crc32 for it
|
||||
* Translation key to a supported form.
|
||||
*
|
||||
* @param string $expected_key Expected key
|
||||
*
|
||||
* @return Supported key
|
||||
*/
|
||||
function GenerateRevisionId($expected_key) {
|
||||
if (strlen($expected_key) > 20) $expected_key = crc32( $expected_key); // if the expected key length is greater than 20, calculate the crc32 for it
|
||||
$key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expected_key);
|
||||
$key = mb_substr($key, 0, min([mb_strlen($key), 20])); // the resulting key length is 20 or less
|
||||
$key = substr($key, 0, min(array(strlen($key), 20))); // the resulting key length is 20 or less
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request for conversion to a service.
|
||||
*
|
||||
* @param string $document_uri Uri for the document to convert
|
||||
* @param string $from_extension Document extension
|
||||
* @param string $to_extension Extension to which to convert
|
||||
* @param string $document_revision_id Key for caching on service
|
||||
* @param bool $is_async Perform conversions asynchronously
|
||||
* @param string $filePass
|
||||
* @param string $lang
|
||||
*
|
||||
* @return string request result of conversion
|
||||
*/
|
||||
function sendRequestToConvertService(
|
||||
$document_uri,
|
||||
$from_extension,
|
||||
$to_extension,
|
||||
$document_revision_id,
|
||||
$is_async,
|
||||
$filePass,
|
||||
$lang
|
||||
) {
|
||||
if (empty($from_extension)) {
|
||||
* Request for conversion to a service.
|
||||
*
|
||||
* @param string $document_uri Uri for the document to convert
|
||||
* @param string $from_extension Document extension
|
||||
* @param string $to_extension Extension to which to convert
|
||||
* @param string $document_revision_id Key for caching on service
|
||||
* @param bool $is_async Perform conversions asynchronously
|
||||
*
|
||||
* @return Document request result of conversion
|
||||
*/
|
||||
function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $filePass, $lang) {
|
||||
if (empty($from_extension))
|
||||
{
|
||||
$path_parts = pathinfo($document_uri);
|
||||
$from_extension = mb_strtolower($path_parts['extension']);
|
||||
$from_extension = strtolower($path_parts['extension']);
|
||||
}
|
||||
|
||||
// if title is undefined, then replace it with a random guid
|
||||
@ -152,19 +137,19 @@ function sendRequestToConvertService(
|
||||
}
|
||||
|
||||
// generate document token
|
||||
$document_revision_id = generateRevisionId($document_revision_id);
|
||||
$document_revision_id = GenerateRevisionId($document_revision_id);
|
||||
|
||||
$urlToConverter = $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_CONVERTER_URL'];
|
||||
|
||||
$arr = [
|
||||
"async" => $is_async,
|
||||
"url" => $document_uri,
|
||||
"outputtype" => trim($to_extension, '.'),
|
||||
"outputtype" => trim($to_extension,'.'),
|
||||
"filetype" => trim($from_extension, '.'),
|
||||
"title" => $title,
|
||||
"key" => $document_revision_id,
|
||||
"password" => $filePass,
|
||||
"region" => $lang,
|
||||
"region" => $lang
|
||||
];
|
||||
|
||||
// add header token
|
||||
@ -172,111 +157,88 @@ function sendRequestToConvertService(
|
||||
$jwtHeader = $GLOBALS['DOC_SERV_JWT_HEADER'] == "" ? "Authorization" : $GLOBALS['DOC_SERV_JWT_HEADER'];
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$headerToken = jwtEncode(["payload" => $arr]);
|
||||
$headerToken = jwtEncode([ "payload" => $arr ]);
|
||||
$arr["token"] = jwtEncode($arr);
|
||||
}
|
||||
|
||||
$data = json_encode($arr);
|
||||
|
||||
// request parameters
|
||||
$opts = ['http' => [
|
||||
'method' => 'POST',
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
|
||||
'header' => "Content-type: application/json\r\n" .
|
||||
"Accept: application/json\r\n" .
|
||||
(empty($headerToken) ? "" : $jwtHeader.": Bearer $headerToken\r\n"),
|
||||
'content' => $data,
|
||||
],
|
||||
];
|
||||
$opts = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
|
||||
'header'=> "Content-type: application/json\r\n" .
|
||||
"Accept: application/json\r\n" .
|
||||
(empty($headerToken) ? "" : $jwtHeader.": Bearer $headerToken\r\n"),
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
if (mb_substr($urlToConverter, 0, mb_strlen("https")) === "https") {
|
||||
if ($GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] === true) {
|
||||
$opts['ssl'] = ['verify_peer' => false, 'verify_peer_name' => false];
|
||||
if (substr($urlToConverter, 0, strlen("https")) === "https") {
|
||||
if($GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] === TRUE) {
|
||||
$opts['ssl'] = array( 'verify_peer' => FALSE, 'verify_peer_name' => FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$response_data = file_get_contents($urlToConverter, false, $context);
|
||||
$response_data = file_get_contents($urlToConverter, FALSE, $context);
|
||||
|
||||
return $response_data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The method is to convert the file to the required format.
|
||||
*
|
||||
* Example:
|
||||
* string convertedDocumentUri;
|
||||
* getConvertedUri("http://helpcenter.onlyoffice.com/content/GettingStarted.pdf",
|
||||
* ".pdf", ".docx", "http://helpcenter.onlyoffice.com/content/GettingStarted.pdf", false, out convertedDocumentUri);
|
||||
*
|
||||
* @param string $document_uri Uri for the document to convert
|
||||
* @param string $from_extension Document extension
|
||||
* @param string $to_extension Extension to which to convert
|
||||
* @param string $document_revision_id Key for caching on service
|
||||
* @param bool $is_async Perform conversions asynchronously
|
||||
* @param string $converted_document_uri Uri to the converted document
|
||||
* @param string $filePass File pass
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @throws Exception if an error occurs
|
||||
*
|
||||
* @return int percentage of completion of conversion
|
||||
*/
|
||||
function getConvertedUri(
|
||||
$document_uri,
|
||||
$from_extension,
|
||||
$to_extension,
|
||||
$document_revision_id,
|
||||
$is_async,
|
||||
&$converted_document_uri,
|
||||
$filePass,
|
||||
$lang
|
||||
) {
|
||||
* The method is to convert the file to the required format.
|
||||
*
|
||||
* Example:
|
||||
* string convertedDocumentUri;
|
||||
* GetConvertedUri("http://helpcenter.onlyoffice.com/content/GettingStarted.pdf", ".pdf", ".docx", "http://helpcenter.onlyoffice.com/content/GettingStarted.pdf", false, out convertedDocumentUri);
|
||||
*
|
||||
* @param string $document_uri Uri for the document to convert
|
||||
* @param string $from_extension Document extension
|
||||
* @param string $to_extension Extension to which to convert
|
||||
* @param string $document_revision_id Key for caching on service
|
||||
* @param bool $is_async Perform conversions asynchronously
|
||||
* @param string $converted_document_uri Uri to the converted document
|
||||
*
|
||||
* @return The percentage of completion of conversion
|
||||
*/
|
||||
function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, &$converted_document_uri, $filePass, $lang) {
|
||||
$converted_document_uri = "";
|
||||
$responceFromConvertService = sendRequestToConvertService(
|
||||
$document_uri,
|
||||
$from_extension,
|
||||
$to_extension,
|
||||
$document_revision_id,
|
||||
$is_async,
|
||||
$filePass,
|
||||
$lang
|
||||
);
|
||||
$responceFromConvertService = SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $filePass, $lang);
|
||||
$json = json_decode($responceFromConvertService, true);
|
||||
|
||||
// if an error occurs, then display an error message
|
||||
$errorElement = $json["error"];
|
||||
if ($errorElement != null && $errorElement != "") {
|
||||
processConvServResponceError($errorElement);
|
||||
}
|
||||
if ($errorElement != NULL && $errorElement != "") ProcessConvServResponceError($errorElement);
|
||||
|
||||
$isEndConvert = $json["endConvert"];
|
||||
$percent = $json["percent"];
|
||||
|
||||
// if the conversion is completed successfully
|
||||
if ($isEndConvert != null && $isEndConvert == true) {
|
||||
if ($isEndConvert != NULL && $isEndConvert == true)
|
||||
{
|
||||
// then get the file url
|
||||
$converted_document_uri = $json["fileUrl"];
|
||||
$percent = 100;
|
||||
} elseif ($percent >= 100) { // otherwise, get the percentage of conversion completion
|
||||
$percent = 99;
|
||||
}
|
||||
// otherwise, get the percentage of conversion completion
|
||||
else if ($percent >= 100)
|
||||
$percent = 99;
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processing document received from the editing service.
|
||||
*
|
||||
* @param Response $document_response The result from editing service
|
||||
* @param string $response_uri Uri to the converted document
|
||||
*
|
||||
* @throws Exception if an error occurs
|
||||
*
|
||||
* @return int percentage of completion of conversion
|
||||
*/
|
||||
function getResponseUri($document_response, &$response_uri)
|
||||
{
|
||||
* Processing document received from the editing service.
|
||||
*
|
||||
* @param string $document_response The result from editing service
|
||||
* @param string $response_uri Uri to the converted document
|
||||
*
|
||||
* @return The percentage of completion of conversion
|
||||
*/
|
||||
function GetResponseUri($document_response, &$response_uri) {
|
||||
$response_uri = "";
|
||||
$resultPercent = 0;
|
||||
|
||||
@ -286,35 +248,33 @@ function getResponseUri($document_response, &$response_uri)
|
||||
|
||||
// if an error occurs, then display an error message
|
||||
$errorElement = $document_response->Error;
|
||||
if ($errorElement != null && $errorElement != "") {
|
||||
processConvServResponceError($document_response->Error);
|
||||
}
|
||||
if ($errorElement != NULL && $errorElement != "") ProcessConvServResponceError($document_response->Error);
|
||||
|
||||
$endConvert = $document_response->EndConvert;
|
||||
if ($endConvert != null && $endConvert == "") {
|
||||
throw new Exception("Invalid answer format");
|
||||
}
|
||||
if ($endConvert != NULL && $endConvert == "") throw new Exception("Invalid answer format");
|
||||
|
||||
// if the conversion is completed successfully
|
||||
if ($endConvert != null && mb_strtolower($endConvert) == true) {
|
||||
if ($endConvert != NULL && strtolower($endConvert) == true)
|
||||
{
|
||||
$fileUrl = $document_response->FileUrl;
|
||||
if ($fileUrl == null || $fileUrl == "") {
|
||||
throw new Exception("Invalid answer format");
|
||||
}
|
||||
if ($fileUrl == NULL || $fileUrl == "") throw new Exception("Invalid answer format");
|
||||
|
||||
// get the response file url
|
||||
$response_uri = $fileUrl;
|
||||
$resultPercent = 100;
|
||||
} else { // otherwise, get the percentage of conversion completion
|
||||
}
|
||||
// otherwise, get the percentage of conversion completion
|
||||
else
|
||||
{
|
||||
$percent = $document_response->Percent;
|
||||
|
||||
if ($percent != null && $percent != "") {
|
||||
if ($percent != NULL && $percent != "")
|
||||
$resultPercent = $percent;
|
||||
}
|
||||
if ($resultPercent >= 100) {
|
||||
if ($resultPercent >= 100)
|
||||
$resultPercent = 99;
|
||||
}
|
||||
}
|
||||
|
||||
return $resultPercent;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,34 +1,32 @@
|
||||
<?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 PhpExample;
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
require_once( dirname(__FILE__) . '/common.php' );
|
||||
require_once( dirname(__FILE__) . '/functions.php' );
|
||||
require_once( dirname(__FILE__) . '/users.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.
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
require_once dirname(__FILE__) . '/common.php';
|
||||
require_once dirname(__FILE__) . '/functions.php';
|
||||
require_once dirname(__FILE__) . '/users.php';
|
||||
|
||||
$user = $_GET["user"] ?? "";
|
||||
$directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] : "";
|
||||
$user = $_GET["user"];
|
||||
$directUrlArg = $_GET["directUrl"] != null ? "&directUrl=" . $_GET["directUrl"] : "";
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
@ -38,8 +36,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
|
||||
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,
|
||||
800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/media.css">
|
||||
@ -65,36 +62,25 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<div class="create-panel clearFix">
|
||||
<ul class="try-editor-list clearFix">
|
||||
<li>
|
||||
<a class="try-editor word reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=docx&user=
|
||||
<?php echo htmlentities($user); ?>">Document</a>
|
||||
<a class="try-editor word reload-page" target="_blank" href="doceditor.php?fileExt=docx&user=<?php echo htmlentities($user); ?>">Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor cell reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=xlsx&user=
|
||||
<?php echo htmlentities($user); ?>">Spreadsheet</a>
|
||||
<a class="try-editor cell reload-page" target="_blank" href="doceditor.php?fileExt=xlsx&user=<?php echo htmlentities($user); ?>">Spreadsheet</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor slide reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=pptx&user=
|
||||
<?php echo htmlentities($user); ?>">Presentation</a>
|
||||
<a class="try-editor slide reload-page" target="_blank" href="doceditor.php?fileExt=pptx&user=<?php echo htmlentities($user); ?>">Presentation</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="try-editor form reload-page" target="_blank"
|
||||
href="doceditor.php?fileExt=docxf&user=
|
||||
<?php echo htmlentities($user); ?>">Form template</a>
|
||||
<a class="try-editor form reload-page" target="_blank" href="doceditor.php?fileExt=docxf&user=<?php echo htmlentities($user); ?>">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="side-option">
|
||||
<input type="checkbox" id="createSample" class="checkbox" />
|
||||
With sample content
|
||||
<input type="checkbox" id="createSample" class="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
<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=
|
||||
<?php echo htmlentities($user); ?>" />
|
||||
<input type="file" id="fileupload" name="files" data-url="webeditor-ajax.php?type=upload&user=<?php echo htmlentities($user); ?>" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -104,8 +90,8 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<span class="select-user">Username</span>
|
||||
<img id="info" class="info" src="css/images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<?php foreach (getAllUsers() as $user_l) {
|
||||
$name = $user_l->name ?: "Anonymous";
|
||||
<?php foreach(getAllUsers() as $user_l) {
|
||||
$name = $user_l->name ? $user_l->name : "Anonymous";
|
||||
echo '<option value="'.$user_l->id.'">'.$name.'</option>';
|
||||
} ?>
|
||||
</select>
|
||||
@ -127,13 +113,8 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />
|
||||
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="css/images/info.svg" />
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />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="css/images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
@ -145,32 +126,20 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<div class="main-panel">
|
||||
<?php
|
||||
$storedFiles = getStoredFiles();
|
||||
if (!empty($storedFiles)) { ?>
|
||||
if (!empty($storedFiles)): ?>
|
||||
<div id="portal-info" style="display: none">
|
||||
<?php } else { ?>
|
||||
<?php else: ?>
|
||||
<div id="portal-info" style="display: table-cell">
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors,
|
||||
the first html5-based editors.
|
||||
<br /> You may upload your own documents for testing using the
|
||||
"<b>Upload file</b>" button and <b>selecting</b>
|
||||
the necessary files on your PC.
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
<br /> You may upload your own documents for testing using the "<b>Upload file</b>" button and <b>selecting</b> the necessary files on your PC.
|
||||
</span>
|
||||
<span class="portal-descr">
|
||||
Please do NOT use this integration example on your own server without
|
||||
proper code modifications, it is intended for testing purposes only.
|
||||
In case you enabled this test example, disable it before going for
|
||||
production.
|
||||
</span>
|
||||
<span class="portal-descr">
|
||||
You can open the same document using different
|
||||
users in different Web browser sessions, so you can check out multi-user
|
||||
editing functions.
|
||||
</span>
|
||||
<?php foreach (getAllUsers() as $user_l) {
|
||||
$name = $user_l->name ?: "Anonymous";
|
||||
<span class="portal-descr">Please do NOT use this integration example on your own server without proper code modifications, it is intended for testing purposes only. In case you enabled this test example, disable it before going for production.</span>
|
||||
<span class="portal-descr">You can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.</span>
|
||||
<?php foreach(getAllUsers() as $user_l) {
|
||||
$name = $user_l->name ? $user_l->name : "Anonymous";
|
||||
echo '<div class="user-descr">';
|
||||
echo '<b>'.$name.'</b>';
|
||||
echo '<ul>';
|
||||
@ -182,28 +151,17 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
} ?>
|
||||
</div>
|
||||
<?php
|
||||
if (!empty($storedFiles)) { ?>
|
||||
if (!empty($storedFiles)) { ?>
|
||||
<div class="stored-list">
|
||||
<span class="header-list">Your documents</span>
|
||||
<table class="tableHeader" cellspacing="0" cellpadding="0" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">
|
||||
Filename
|
||||
</td>
|
||||
<td class="tableHeaderCell tableHeaderCellEditors
|
||||
contentCells-shift">
|
||||
Editors
|
||||
</td>
|
||||
<td class="tableHeaderCell tableHeaderCellViewers">
|
||||
Viewers
|
||||
</td>
|
||||
<td class="tableHeaderCell tableHeaderCellDownload">
|
||||
Download
|
||||
</td>
|
||||
<td class="tableHeaderCell tableHeaderCellRemove">
|
||||
Remove
|
||||
</td>
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
|
||||
<td class="tableHeaderCell tableHeaderCellEditors contentCells-shift">Editors</td>
|
||||
<td class="tableHeaderCell tableHeaderCellViewers">Viewers</td>
|
||||
<td class="tableHeaderCell tableHeaderCellDownload">Download</td>
|
||||
<td class="tableHeaderCell tableHeaderCellRemove">Remove</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
@ -211,234 +169,90 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<table cellspacing="0" cellpadding="0" width="100%">
|
||||
<tbody>
|
||||
<?php foreach ($storedFiles as &$storeFile) {
|
||||
echo '<tr class="tableRow" title="'.
|
||||
$storeFile->name.' ['.
|
||||
getFileVersion(
|
||||
getHistoryDir(
|
||||
getStoragePath($storeFile->name)
|
||||
)
|
||||
).
|
||||
']">';
|
||||
echo '<tr class="tableRow" title="'.$storeFile->name.' ['.getFileVersion(getHistoryDir(getStoragePath($storeFile->name))).']">';
|
||||
echo ' <td class="contentCells">';
|
||||
echo ' <a class="stored-edit '.
|
||||
$storeFile->documentType.
|
||||
'" href="doceditor.php?fileID='.
|
||||
urlencode($storeFile->name) .
|
||||
'&user='.htmlentities($user) .
|
||||
$directUrlArg .'" target="_blank">';
|
||||
echo ' <a class="stored-edit '.$storeFile->documentType.'" href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.htmlentities($user) . $directUrlArg .'" target="_blank">';
|
||||
echo ' <span>'.$storeFile->name.'</span>';
|
||||
echo ' </a>';
|
||||
echo ' </td>';
|
||||
if ($storeFile->canEdit) {
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' . htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=edit&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/desktop.svg"
|
||||
alt="Open in editor for full size screens"
|
||||
title="Open in editor for full size screens"
|
||||
/></a>';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=edit&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' . htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=edit&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile.svg"
|
||||
alt="Open in editor for mobile devices"
|
||||
title="Open in editor for mobile devices"
|
||||
/></a>';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=edit&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=comment&type=desktop" target="_blank">'
|
||||
;
|
||||
echo ' <img src="css/images/comment.svg"
|
||||
alt="Open in editor for comment"
|
||||
title="Open in editor for comment" />
|
||||
</a>';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=comment&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment" /></a>';
|
||||
echo ' </td>';
|
||||
if ($storeFile->documentType == "word") {
|
||||
echo ' <td
|
||||
class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=review&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/images/review.svg"
|
||||
alt="Open in editor for review"
|
||||
title="Open in editor for review" />
|
||||
</a>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=review&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/review.svg" alt="Open in editor for review" title="Open in editor for review" /></a>';
|
||||
echo ' </td>';
|
||||
} elseif ($storeFile->documentType == "cell") {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=filter&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/images/filter.svg"
|
||||
alt="Open in editor without
|
||||
access to change the filter"
|
||||
title="Open in editor without
|
||||
access to change the filter" /></a>';
|
||||
} else if ($storeFile->documentType == "cell") {
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=filter&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>';
|
||||
echo ' </td>';
|
||||
}
|
||||
if ($storeFile->documentType == "word") {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon ">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=blockcontent&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/images/block-content.svg"
|
||||
alt="Open in editor without
|
||||
content control modification"
|
||||
title="Open in editor without
|
||||
content control modification" /></a>';
|
||||
echo ' <td class="contentCells contentCells-icon ">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=blockcontent&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification" /></a>';
|
||||
echo ' </td>';
|
||||
} else {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td> ';
|
||||
} else{
|
||||
echo ' <td class="contentCells contentCells-icon"></td> ';
|
||||
}
|
||||
if ($storeFile->documentType != "word"
|
||||
&& $storeFile->documentType != "cell"
|
||||
) {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td>';
|
||||
if($storeFile->documentType!="word" && $storeFile->documentType!="cell"){
|
||||
echo ' <td class="contentCells contentCells-icon"></td>';
|
||||
}
|
||||
if ($storeFile->isFillFormDoc) {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-shift contentCells-icon
|
||||
firstContentCellShift">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=fillForms&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/images/fill-forms.svg"
|
||||
alt="Open in editor for filling in forms"
|
||||
title="Open in editor for filling in forms"
|
||||
/></a>';
|
||||
echo ' <td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=fillForms&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>';
|
||||
echo ' </td>';
|
||||
} else {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-shift contentCells-icon
|
||||
firstContentCellShift"></td> ';
|
||||
echo ' <td class="contentCells contentCells-shift contentCells-icon firstContentCellShift"></td> ';
|
||||
}
|
||||
} elseif ($storeFile->isFillFormDoc) {
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=fillForms&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/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>';
|
||||
} else if ($storeFile->isFillFormDoc) {
|
||||
echo ' <td class="contentCells contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=fillForms&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/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>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-shift contentCells-icon
|
||||
firstContentCellShift">';
|
||||
echo ' <a href="doceditor.php?fileID=' .
|
||||
urlencode($storeFile->name) .
|
||||
'&user=' .
|
||||
htmlentities($user) .
|
||||
$directUrlArg .
|
||||
'&action=fillForms&type=desktop"
|
||||
target="_blank">';
|
||||
echo ' <img src="css/images/fill-forms.svg"
|
||||
alt="Open in editor for filling in forms"
|
||||
title="Open in editor for filling in forms"
|
||||
/></a>';
|
||||
echo ' <td class="contentCells contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells contentCells-icon"></td>';
|
||||
echo ' <td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . $directUrlArg . '&action=fillForms&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>';
|
||||
echo ' </td>';
|
||||
} else {
|
||||
echo '<td class="contentCells
|
||||
contentCells-shift contentCells-icon
|
||||
contentCellsEmpty" colspan="6"></td>';
|
||||
echo '<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>';
|
||||
}
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon firstContentCellViewers">';
|
||||
echo ' <a href="doceditor.php?fileID='.
|
||||
urlencode($storeFile->name).
|
||||
'&user='.htmlentities($user).
|
||||
$directUrlArg.
|
||||
'&action=view&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/desktop.svg"
|
||||
alt="Open in viewer for full size screens"
|
||||
title="Open in viewer for full size screens"
|
||||
/></a>';
|
||||
echo ' <td class="contentCells contentCells-icon firstContentCellViewers">';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.htmlentities($user) . $directUrlArg . '&action=view&type=desktop" target="_blank">';
|
||||
echo ' <img src="css/images/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells contentCells-icon">';
|
||||
echo ' <a href="doceditor.php?fileID='.
|
||||
urlencode($storeFile->name).
|
||||
'&user='.htmlentities($user).
|
||||
$directUrlArg.
|
||||
'&action=view&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile.svg"
|
||||
alt="Open in viewer for mobile devices"
|
||||
title="Open in viewer for mobile devices" /></a>';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.htmlentities($user) . $directUrlArg . '&action=view&type=mobile" target="_blank">';
|
||||
echo ' <img src="css/images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon contentCells-shift">';
|
||||
echo ' <a href="doceditor.php?fileID='.
|
||||
urlencode($storeFile->name).
|
||||
'&user='.
|
||||
htmlentities($user).
|
||||
$directUrlArg.
|
||||
'&action=embedded&type=embedded" target="_blank">';
|
||||
echo ' <img src="css/images/embeded.svg"
|
||||
alt="Open in embedded mode"
|
||||
title="Open in embedded mode" /></a>';
|
||||
echo ' <td class="contentCells contentCells-icon contentCells-shift">';
|
||||
echo ' <a href="doceditor.php?fileID='.urlencode($storeFile->name).'&user='.htmlentities($user) . $directUrlArg . '&action=embedded&type=embedded" target="_blank">';
|
||||
echo ' <img src="css/images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon contentCells-shift
|
||||
downloadContentCellShift">';
|
||||
echo ' <a href="
|
||||
webeditor-ajax.php?type=download&fileName='.
|
||||
urlencode($storeFile->name).'">';
|
||||
echo ' <img class="icon-download"
|
||||
src="css/images/download.svg"
|
||||
alt="Download" title="Download" /></a>';
|
||||
echo ' <td class="contentCells contentCells-icon contentCells-shift downloadContentCellShift">';
|
||||
echo ' <a href="webeditor-ajax.php?type=download&fileName='.urlencode($storeFile->name).'">';
|
||||
echo ' <img class="icon-download" src="css/images/download.svg" alt="Download" title="Download" /></a>';
|
||||
echo ' </td>';
|
||||
echo ' <td class="contentCells
|
||||
contentCells-icon contentCells-shift">';
|
||||
echo ' <a class="delete-file" data="'.
|
||||
$storeFile->name.'">';
|
||||
echo ' <img class="icon-delete"
|
||||
src="css/images/delete.svg"
|
||||
alt="Delete" title="Delete" /></a>';
|
||||
echo ' <td class="contentCells contentCells-icon contentCells-shift">';
|
||||
echo ' <a class="delete-file" data="'.$storeFile->name.'">';
|
||||
echo ' <img class="icon-delete" src="css/images/delete.svg" alt="Delete" title="Delete" /></a>';
|
||||
echo ' </td>';
|
||||
echo '</tr>';
|
||||
} ?>
|
||||
@ -446,8 +260,8 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -460,8 +274,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<span id="uploadFileName" class="uploadFileName"></span>
|
||||
<div class="describeUpload">After these steps are completed, you can work with your document.</div>
|
||||
<span id="step1" class="step">1. Loading the file.</span>
|
||||
<span class="step-descr">The loading speed depends on file size
|
||||
and additional elements it contains.</span>
|
||||
<span class="step-descr">The loading speed depends on file size and additional elements it contains.</span>
|
||||
<br />
|
||||
<span id="step2" class="step">2. Conversion.</span>
|
||||
<span class="step-descr">The file is converted to OOXML so that you can edit it.</span>
|
||||
@ -481,8 +294,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<span class="step-descr">They are loaded only once, they will be cached on your computer.</span>
|
||||
<input type="hidden" name="hiddenFileName" id="hiddenFileName" />
|
||||
<br />
|
||||
<span class="progress-descr">Note the speed of all operations depends
|
||||
on your connection quality and server location.</span>
|
||||
<span class="progress-descr">Note the speed of all operations depends on your connection quality and server location.</span>
|
||||
<br />
|
||||
<div class="error-message">
|
||||
<b>Upload error: </b><span></span>
|
||||
@ -490,8 +302,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
Please select another file and try again.
|
||||
</div>
|
||||
</div>
|
||||
<iframe id="embeddedView" src="" height="345px" width="432px"
|
||||
frameborder="0" scrolling="no" allowtransparency></iframe>
|
||||
<iframe id="embeddedView" src="" height="345px" width="432px" frameborder="0" scrolling="no" allowtransparency></iframe>
|
||||
<br />
|
||||
<div class="buttonsMobile">
|
||||
<?php if (($GLOBALS['MODE']) != "view") { ?>
|
||||
@ -503,9 +314,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="
|
||||
<?php echo $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_PRELOADER_URL'] ?>
|
||||
"></span>
|
||||
<span id="loadScripts" data-docs="<?php echo $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_PRELOADER_URL'] ?>"></span>
|
||||
|
||||
<footer>
|
||||
<div class="center">
|
||||
@ -513,9 +322,7 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">
|
||||
API Documentation
|
||||
</a>
|
||||
<a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="mailto:sales@onlyoffice.com">Submit your request</a>
|
||||
@ -530,7 +337,8 @@ $directUrlArg = isset($_GET["directUrl"]) ? "&directUrl=" . $_GET["directUrl"] :
|
||||
</footer>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="js/jquery.iframe-transport.js"></script>
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
web/documentserver-example/php/js/jquery-3.6.4.min.js
vendored
Normal file
2
web/documentserver-example/php/js/jquery-3.6.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
web/documentserver-example/php/js/jquery-migrate-3.4.1.min.js
vendored
Normal file
2
web/documentserver-example/php/js/jquery-migrate-3.4.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,50 +14,33 @@
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/lib/jwt/BeforeValidException.php';
|
||||
require_once dirname(__FILE__) . '/lib/jwt/ExpiredException.php';
|
||||
require_once dirname(__FILE__) . '/lib/jwt/SignatureInvalidException.php';
|
||||
require_once dirname(__FILE__) . '/lib/jwt/JWT.php';
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
|
||||
/**
|
||||
* Check if a secret key to generate token exists or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isJwtEnabled()
|
||||
{
|
||||
|
||||
require_once( dirname(__FILE__) . '/lib/jwt/BeforeValidException.php' );
|
||||
require_once( dirname(__FILE__) . '/lib/jwt/ExpiredException.php' );
|
||||
require_once( dirname(__FILE__) . '/lib/jwt/SignatureInvalidException.php' );
|
||||
require_once( dirname(__FILE__) . '/lib/jwt/JWT.php' );
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
|
||||
// check if a secret key to generate token exists or not
|
||||
function isJwtEnabled() {
|
||||
return !empty($GLOBALS['DOC_SERV_JWT_SECRET']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a payload object into a token using a secret key
|
||||
*
|
||||
* @param array $payload
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function jwtEncode($payload)
|
||||
{
|
||||
// encode a payload object into a token using a secret key
|
||||
function jwtEncode($payload) {
|
||||
return \Firebase\JWT\JWT::encode($payload, $GLOBALS["DOC_SERV_JWT_SECRET"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a token into a payload object using a secret key
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function jwtDecode($token)
|
||||
{
|
||||
// decode a token into a payload object using a secret key
|
||||
function jwtDecode($token) {
|
||||
try {
|
||||
$payload = \Firebase\JWT\JWT::decode($token, $GLOBALS["DOC_SERV_JWT_SECRET"], ["HS256"]);
|
||||
$payload = \Firebase\JWT\JWT::decode($token, $GLOBALS["DOC_SERV_JWT_SECRET"], array("HS256"));
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$payload = "";
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
?>
|
||||
@ -16,14 +16,14 @@ 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
|
||||
|
||||
JWT - JSON Web Token implementation (https://github.com/firebase/php-jwt/blob/master/LICENSE)
|
||||
License: BSD-3-Clause
|
||||
License: BSD
|
||||
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
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
Copyright (c) 2012, Squiz Pty Ltd (ABN 77 084 670 600)
|
||||
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 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 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.
|
||||
@ -0,0 +1,36 @@
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/jquery/jquery-migrate
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
All files located in the node_modules and external directories are
|
||||
externally maintained libraries used by this software which have their
|
||||
own licenses; we recommend you read them, as their terms may differ from
|
||||
the terms above.
|
||||
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="CustomRuleset">
|
||||
<description>This standard changes the line length</description>
|
||||
|
||||
|
||||
<rule ref="PSR1">
|
||||
<exclude name="PSR1.Files.SideEffects" />
|
||||
</rule>
|
||||
<!-- 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>
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,23 +14,20 @@
|
||||
* 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.
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/jwtmanager.php';
|
||||
require_once dirname(__FILE__) . '/common.php';
|
||||
require_once dirname(__FILE__) . '/config.php';
|
||||
|
||||
/**
|
||||
* Read request body
|
||||
*
|
||||
* @return int|array
|
||||
*/
|
||||
function readBody()
|
||||
{
|
||||
|
||||
require_once( dirname(__FILE__) . '/jwtmanager.php' );
|
||||
require_once( dirname(__FILE__) . '/common.php' );
|
||||
require_once( dirname(__FILE__) . '/config.php' );
|
||||
|
||||
|
||||
// read request body
|
||||
function readBody() {
|
||||
$result["error"] = 0;
|
||||
|
||||
// get the body of the post request and check if it is correct
|
||||
if (($body_stream = file_get_contents('php://input')) === false) {
|
||||
if (($body_stream = file_get_contents('php://input')) === FALSE) {
|
||||
$result["error"] = "Bad Request";
|
||||
return $result;
|
||||
}
|
||||
@ -37,7 +35,7 @@ function readBody()
|
||||
$data = json_decode($body_stream, false);
|
||||
|
||||
// check if the response is correct
|
||||
if ($data === null) {
|
||||
if ($data === NULL) {
|
||||
$result["error"] = "Bad Response";
|
||||
return $result;
|
||||
}
|
||||
@ -56,12 +54,7 @@ function readBody()
|
||||
$data = jwtDecode($data["token"]); // decode it
|
||||
sendlog(" jwt in body", "webedior-ajax.log");
|
||||
} elseif (!empty(apache_request_headers()[$jwtHeader])) { // if the Authorization header exists
|
||||
$data = jwtDecode(
|
||||
mb_substr(
|
||||
apache_request_headers()[$jwtHeader],
|
||||
mb_strlen("Bearer ")
|
||||
)
|
||||
); // decode its part after Authorization prefix
|
||||
$data = jwtDecode(substr(apache_request_headers()[$jwtHeader], strlen("Bearer "))); // decode its part after Authorization prefix
|
||||
$inHeader = true;
|
||||
sendlog(" jwt in header", "webedior-ajax.log");
|
||||
} else { // otherwise, an error occurs
|
||||
@ -76,88 +69,63 @@ function readBody()
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($inHeader) {
|
||||
$data = $data->payload;
|
||||
}
|
||||
if ($inHeader) $data = $data->payload;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* File saving process
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $fileName
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function processSave($data, $fileName, $userAddress)
|
||||
{
|
||||
// file saving process
|
||||
function processSave($data, $fileName, $userAddress) {
|
||||
$downloadUri = $data->url;
|
||||
if ($downloadUri === null) {
|
||||
$result["error"] = 1;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$curExt = mb_strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION)); // get current file extension
|
||||
$downloadExt = mb_strtolower('.' . $data->filetype); // get the extension of the downloaded file
|
||||
$curExt = strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION)); // get current file extension
|
||||
$downloadExt = strtolower('.' . $data->filetype); // get the extension of the downloaded file
|
||||
|
||||
$newFileName = $fileName;
|
||||
|
||||
// convert downloaded file to the file with the current extension if these extensions aren't equal
|
||||
if ($downloadExt != $curExt) {
|
||||
$key = generateRevisionId($downloadUri);
|
||||
$key = GenerateRevisionId($downloadUri);
|
||||
|
||||
try {
|
||||
sendlog(" Convert " . $downloadUri . " from " . $downloadExt . " to " . $curExt, "webedior-ajax.log");
|
||||
$convertedUri; // convert file and give url to a new file
|
||||
$percent = getConvertedUri($downloadUri, $downloadExt, $curExt, $key, false, $convertedUri);
|
||||
$percent = GetConvertedUri($downloadUri, $downloadExt, $curExt, $key, FALSE, $convertedUri);
|
||||
if (!empty($convertedUri)) {
|
||||
$downloadUri = $convertedUri;
|
||||
} else {
|
||||
sendlog(" Convert after save convertedUri is empty", "webedior-ajax.log");
|
||||
$baseNameWithoutExt = mb_substr($fileName, 0, mb_strlen($fileName) - mb_strlen($curExt));
|
||||
|
||||
// get the correct file name if it already exists
|
||||
$newFileName = GetCorrectName($baseNameWithoutExt . $downloadExt, $userAddress);
|
||||
$baseNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($curExt));
|
||||
$newFileName = GetCorrectName($baseNameWithoutExt . $downloadExt, $userAddress); // get the correct file name if it already exists
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
sendlog(" Convert after save ".$e->getMessage(), "webedior-ajax.log");
|
||||
$baseNameWithoutExt = mb_substr($fileName, 0, mb_strlen($fileName) - mb_strlen($curExt));
|
||||
$baseNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($curExt));
|
||||
$newFileName = GetCorrectName($baseNameWithoutExt . $downloadExt, $userAddress);
|
||||
}
|
||||
}
|
||||
|
||||
$saved = 1;
|
||||
|
||||
if (!(($new_data = file_get_contents(
|
||||
$downloadUri,
|
||||
false,
|
||||
stream_context_create(["http" => ["timeout" => 5]])
|
||||
)) === false)
|
||||
) {
|
||||
if (!(($new_data = file_get_contents($downloadUri, false,
|
||||
stream_context_create(["http"=>["timeout"=>5]]))) === FALSE)) {
|
||||
$storagePath = getStoragePath($newFileName, $userAddress); // get the file path
|
||||
$histDir = getHistoryDir($storagePath); // get the path to the history direction
|
||||
$verDir = getVersionDir($histDir, getFileVersion($histDir)); // get the path to the file version
|
||||
|
||||
mkdir($verDir); // if the path doesn't exist, create it
|
||||
|
||||
// get the path to the previous file version and rename the storage path with it
|
||||
rename(getStoragePath($fileName, $userAddress), $verDir .
|
||||
DIRECTORY_SEPARATOR . "prev" . $curExt);
|
||||
rename(getStoragePath($fileName, $userAddress), $verDir . DIRECTORY_SEPARATOR . "prev" . $curExt); // get the path to the previous file version and rename the storage path with it
|
||||
file_put_contents($storagePath, $new_data, LOCK_EX); // save file to the storage directory
|
||||
|
||||
if ($changesData = file_get_contents(
|
||||
$data->changesurl,
|
||||
false,
|
||||
stream_context_create(["http" => ["timeout" => 5]])
|
||||
)
|
||||
) {
|
||||
// save file changes to the diff.zip archive
|
||||
file_put_contents($verDir . DIRECTORY_SEPARATOR .
|
||||
"diff.zip", $changesData, LOCK_EX);
|
||||
if ($changesData = file_get_contents($data->changesurl, false,
|
||||
stream_context_create(["http"=>["timeout"=>5]]))) {
|
||||
file_put_contents($verDir . DIRECTORY_SEPARATOR . "diff.zip", $changesData, LOCK_EX); // save file changes to the diff.zip archive
|
||||
}
|
||||
|
||||
$histData = empty($data->changeshistory) ? null : $data->changeshistory;
|
||||
@ -165,16 +133,11 @@ function processSave($data, $fileName, $userAddress)
|
||||
$histData = json_encode($data->history, JSON_PRETTY_PRINT);
|
||||
}
|
||||
if (!empty($histData)) {
|
||||
// write the history changes to the changes.json file
|
||||
file_put_contents($verDir .
|
||||
DIRECTORY_SEPARATOR . "changes.json", $histData, LOCK_EX);
|
||||
file_put_contents($verDir . DIRECTORY_SEPARATOR . "changes.json", $histData, LOCK_EX); // write the history changes to the changes.json file
|
||||
}
|
||||
// write the key value to the key.txt file
|
||||
file_put_contents($verDir .
|
||||
DIRECTORY_SEPARATOR . "key.txt", $data->key, LOCK_EX);
|
||||
file_put_contents($verDir . DIRECTORY_SEPARATOR . "key.txt", $data->key, LOCK_EX); // write the key value to the key.txt file
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
$forcesavePath = getForcesavePath($newFileName, $userAddress, false);
|
||||
$forcesavePath = getForcesavePath($newFileName, $userAddress, false); // get the path to the forcesaved file version
|
||||
if ($forcesavePath != "") { // if the forcesaved file version exists
|
||||
unlink($forcesavePath); // remove it
|
||||
}
|
||||
@ -187,41 +150,32 @@ function processSave($data, $fileName, $userAddress)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* File force saving process
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $fileName
|
||||
* @param string $userAddress
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function processForceSave($data, $fileName, $userAddress)
|
||||
{
|
||||
// file force saving process
|
||||
function processForceSave($data, $fileName, $userAddress) {
|
||||
$downloadUri = $data->url;
|
||||
if ($downloadUri === null) {
|
||||
$result["error"] = 1;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$curExt = mb_strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION)); // get current file extension
|
||||
$downloadExt = mb_strtolower('.' . $data->filetype); // get the extension of the downloaded file
|
||||
$curExt = strtolower('.' . pathinfo($fileName, PATHINFO_EXTENSION)); // get current file extension
|
||||
$downloadExt = strtolower('.' . $data->filetype); // get the extension of the downloaded file
|
||||
|
||||
$newFileName = false;
|
||||
|
||||
// convert downloaded file to the file with the current extension if these extensions aren't equal
|
||||
if ($downloadExt != $curExt) {
|
||||
$key = generateRevisionId($downloadUri);
|
||||
$key = GenerateRevisionId($downloadUri);
|
||||
|
||||
try {
|
||||
sendlog(" Convert " . $downloadUri . " from " . $downloadExt . " to " . $curExt, "webedior-ajax.log");
|
||||
$convertedUri; // convert file and give url to a new file
|
||||
$percent = getConvertedUri($downloadUri, $downloadExt, $curExt, $key, false, $convertedUri);
|
||||
$percent = GetConvertedUri($downloadUri, $downloadExt, $curExt, $key, FALSE, $convertedUri);
|
||||
if (!empty($convertedUri)) {
|
||||
$downloadUri = $convertedUri;
|
||||
} else {
|
||||
sendlog(" Convert after save convertedUri is empty", "webedior-ajax.log");
|
||||
$baseNameWithoutExt = mb_substr($fileName, 0, mb_strlen($fileName) - mb_strlen($curExt));
|
||||
$baseNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($curExt));
|
||||
$newFileName = true;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@ -232,25 +186,20 @@ function processForceSave($data, $fileName, $userAddress)
|
||||
|
||||
$saved = 1;
|
||||
|
||||
if (!(($new_data = file_get_contents(
|
||||
$downloadUri,
|
||||
false,
|
||||
stream_context_create(["http" => ["timeout" => 5]])
|
||||
)) === false)
|
||||
) {
|
||||
$baseNameWithoutExt = mb_substr($fileName, 0, mb_strlen($fileName) - mb_strlen($curExt));
|
||||
if (!(($new_data = file_get_contents($downloadUri, false,
|
||||
stream_context_create(["http"=>["timeout"=>5]]))) === FALSE)) {
|
||||
$baseNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($curExt));
|
||||
$isSubmitForm = $data->forcesavetype == 3; // SubmitForm
|
||||
|
||||
if ($isSubmitForm) {
|
||||
if ($newFileName) {
|
||||
$fileName = GetCorrectName($baseNameWithoutExt .
|
||||
"-form" . $downloadExt, $userAddress); // get the correct file name if it already exists
|
||||
if ($newFileName){
|
||||
$fileName = GetCorrectName($baseNameWithoutExt . "-form" . $downloadExt, $userAddress); // get the correct file name if it already exists
|
||||
} else {
|
||||
$fileName = GetCorrectName($baseNameWithoutExt . "-form" . $curExt, $userAddress);
|
||||
}
|
||||
$forcesavePath = getStoragePath($fileName, $userAddress);
|
||||
} else {
|
||||
if ($newFileName) {
|
||||
if ($newFileName){
|
||||
$fileName = GetCorrectName($baseNameWithoutExt . $downloadExt, $userAddress);
|
||||
}
|
||||
// create forcesave path if it doesn't exist
|
||||
@ -275,55 +224,45 @@ function processForceSave($data, $fileName, $userAddress)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a command request
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $key
|
||||
* @param string $meta
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
function commandRequest($method, $key, $meta = null)
|
||||
{
|
||||
// create a command request
|
||||
function commandRequest($method, $key, $meta = null){
|
||||
$documentCommandUrl = $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_COMMAND_URL'];
|
||||
|
||||
$arr = [
|
||||
"c" => $method,
|
||||
"key" => $key,
|
||||
"key" => $key
|
||||
];
|
||||
|
||||
if ($meta) {
|
||||
if($meta)
|
||||
$arr["meta"] = $meta;
|
||||
}
|
||||
|
||||
$headerToken = "";
|
||||
$jwtHeader = $GLOBALS['DOC_SERV_JWT_HEADER'] == "" ? "Authorization" : $GLOBALS['DOC_SERV_JWT_HEADER'];
|
||||
|
||||
if (isJwtEnabled()) { // check if a secret key to generate token exists or not
|
||||
$headerToken = jwtEncode(["payload" => $arr]); // encode a payload object into a header token
|
||||
$headerToken = jwtEncode([ "payload" => $arr ]); // encode a payload object into a header token
|
||||
$arr["token"] = jwtEncode($arr); // encode a payload object into a body token
|
||||
}
|
||||
|
||||
$data = json_encode($arr);
|
||||
|
||||
$opts = ['http' => [
|
||||
'method' => 'POST',
|
||||
'header' => "Content-type: application/json\r\n" .
|
||||
// add a header Authorization with a header token and Authorization prefix in it
|
||||
(empty($headerToken) ? "" : $jwtHeader.
|
||||
": Bearer $headerToken\r\n"),
|
||||
'content' => $data,
|
||||
]];
|
||||
$opts = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'header'=> "Content-type: application/json\r\n" .
|
||||
(empty($headerToken) ? "" : $jwtHeader.": Bearer $headerToken\r\n"), // add a header Authorization with a header token and Authorization prefix in it
|
||||
'content' => $data
|
||||
));
|
||||
|
||||
if (mb_substr($documentCommandUrl, 0, mb_strlen("https")) === "https") {
|
||||
if ($GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] === true) {
|
||||
$opts['ssl'] = ['verify_peer' => false, 'verify_peer_name' => false];
|
||||
if (substr($documentCommandUrl, 0, strlen("https")) === "https") {
|
||||
if($GLOBALS['DOC_SERV_VERIFY_PEER_OFF'] === TRUE) {
|
||||
$opts['ssl'] = array( 'verify_peer' => FALSE, 'verify_peer_name' => FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$response_data = file_get_contents($documentCommandUrl, false, $context);
|
||||
$response_data = file_get_contents($documentCommandUrl, FALSE, $context);
|
||||
|
||||
return $response_data;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace PhpExample;
|
||||
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -16,40 +14,12 @@ namespace PhpExample;
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
final class User
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $group
|
||||
* @param array|null $reviewGroups
|
||||
* @param array $commentGroups
|
||||
* @param array|null $userInfoGroups
|
||||
* @param bool|null $favorite
|
||||
* @param array $deniedPermissions
|
||||
* @param array $descriptions
|
||||
* @param bool $templates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$id,
|
||||
$name,
|
||||
$email,
|
||||
$group,
|
||||
$reviewGroups,
|
||||
$commentGroups,
|
||||
$userInfoGroups,
|
||||
$favorite,
|
||||
$deniedPermissions,
|
||||
$descriptions,
|
||||
$templates
|
||||
) {
|
||||
class User {
|
||||
function __construct($id, $name, $email, $group, $reviewGroups, $commentGroups, $userInfoGroups, $favorite, $deniedPermissions, $descriptions, $templates)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->email = $email;
|
||||
@ -71,17 +41,16 @@ $descr_user_1 = [
|
||||
"Can perform all actions with comments",
|
||||
"The file favorite state is undefined",
|
||||
"Can create files from templates using data from the editor",
|
||||
"Can see the information about all users",
|
||||
"Can see the information about all users"
|
||||
];
|
||||
|
||||
$descr_user_2 = [
|
||||
"Belongs to Group2",
|
||||
"Can review only his own changes or changes made by users with no group",
|
||||
"Can view comments, edit his own comments and comments left by users with no group.
|
||||
Can remove his own comments only",
|
||||
"Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only",
|
||||
"This file is marked as favorite",
|
||||
"Can create new files from the editor",
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group",
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group"
|
||||
];
|
||||
|
||||
$descr_user_3 = [
|
||||
@ -93,7 +62,7 @@ $descr_user_3 = [
|
||||
"Can’t download the file",
|
||||
"Can’t print the file",
|
||||
"Can create new files from the editor",
|
||||
"Can see the information about Group2 users",
|
||||
"Can see the information about Group2 users"
|
||||
];
|
||||
|
||||
$descr_user_0 = [
|
||||
@ -111,90 +80,40 @@ $descr_user_0 = [
|
||||
];
|
||||
|
||||
$users = [
|
||||
new User(
|
||||
"uid-1",
|
||||
"John Smith",
|
||||
"smith@example.com",
|
||||
"",
|
||||
null,
|
||||
[],
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
$descr_user_1,
|
||||
true
|
||||
),
|
||||
new User(
|
||||
"uid-2",
|
||||
"Mark Pottato",
|
||||
"pottato@example.com",
|
||||
"group-2",
|
||||
["group-2", ""],
|
||||
[
|
||||
"view" => "",
|
||||
"edit" => ["group-2", ""],
|
||||
"remove" => ["group-2"],
|
||||
],
|
||||
["group-2", ""],
|
||||
true,
|
||||
[],
|
||||
$descr_user_2,
|
||||
false
|
||||
),
|
||||
new User(
|
||||
"uid-3",
|
||||
"Hamish Mitchell",
|
||||
"mitchell@example.com",
|
||||
"group-3",
|
||||
["group-2"],
|
||||
[
|
||||
"view" => ["group-3", "group-2"],
|
||||
"edit" => ["group-2"],
|
||||
"remove" => [],
|
||||
],
|
||||
["group-2"],
|
||||
false,
|
||||
["copy", "download", "print"],
|
||||
$descr_user_3,
|
||||
false
|
||||
),
|
||||
new User(
|
||||
"uid-0",
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
[],
|
||||
[],
|
||||
null,
|
||||
[],
|
||||
$descr_user_0,
|
||||
false
|
||||
),
|
||||
new User("uid-1", "John Smith", "smith@example.com",
|
||||
"", null, [], null,
|
||||
null, [], $descr_user_1, true),
|
||||
new User("uid-2", "Mark Pottato", "pottato@example.com",
|
||||
"group-2", ["group-2", ""], [
|
||||
"view" => "",
|
||||
"edit" => ["group-2", ""],
|
||||
"remove" => ["group-2"]
|
||||
],
|
||||
["group-2", ""],
|
||||
true, [], $descr_user_2, false),
|
||||
new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
|
||||
"group-3", ["group-2"], [
|
||||
"view" => ["group-3", "group-2"],
|
||||
"edit" => ["group-2"],
|
||||
"remove" => []
|
||||
],
|
||||
["group-2"],
|
||||
false, ["copy", "download", "print"], $descr_user_3, false),
|
||||
new User("uid-0", null, null,
|
||||
"", null, [], [],
|
||||
null, [], $descr_user_0, false)
|
||||
];
|
||||
|
||||
/**
|
||||
* Get a list of all the users
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getAllUsers()
|
||||
{
|
||||
// get a list of all the users
|
||||
function getAllUsers() {
|
||||
global $users;
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user by id specified
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getUser($id)
|
||||
{
|
||||
// get a user by id specified
|
||||
function getUser($id) {
|
||||
global $users;
|
||||
foreach ($users as $user) {
|
||||
foreach ($users as $user){
|
||||
if ($user->id == $id) {
|
||||
sendlog("User ". $user->id, "common.log");
|
||||
return $user;
|
||||
@ -203,24 +122,18 @@ function getUser($id)
|
||||
return $users[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users with their names and emails for mentions
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getUsersForMentions($id)
|
||||
{
|
||||
// get a list of users with their names and emails for mentions
|
||||
function getUsersForMentions($id) {
|
||||
global $users;
|
||||
$usersData = [];
|
||||
foreach ($users as $user) {
|
||||
if ($user->id != $id && $user->name != null && $user->email != null) {
|
||||
$usersData[] = [
|
||||
array_push($usersData,[
|
||||
"name" => $user->name,
|
||||
"email" => $user->email,
|
||||
];
|
||||
"email" => $user->email
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $usersData;
|
||||
}
|
||||
?>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user