mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
35 Commits
feature/ja
...
feature/cs
| Author | SHA1 | Date | |
|---|---|---|---|
| cf1212aae0 | |||
| 81c0e25c9e | |||
| c9dc7314d5 | |||
| 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
|
||||
@ -32,6 +36,10 @@ Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastru
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
MinIO - MinIO Client SDK provides higher level APIs for MinIO and Amazon S3 compatible cloud storage services. (https://github.com/minio/minio-dotnet)
|
||||
License: Apache-2.0 license
|
||||
License File: MinIO.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -26,6 +26,8 @@ using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
using OnlineEditorsExampleMVC.Models;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
@ -80,21 +82,28 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get the storage path of the file
|
||||
public static string StoragePath(string fileName, string userAddress = null)
|
||||
{
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
return fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
return directory + (fileName.Contains("\\") ? fileName : Path.GetFileName(fileName));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
return directory + (fileName.Contains("\\") ? fileName : Path.GetFileName(fileName));
|
||||
}
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
@ -110,7 +119,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
return "";
|
||||
@ -146,13 +155,27 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get the history directory
|
||||
public static string HistoryDir(string storagePath)
|
||||
{
|
||||
return storagePath += "-hist";
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
return storagePath + "-hist/";
|
||||
}
|
||||
else
|
||||
{
|
||||
return storagePath + "-hist";
|
||||
}
|
||||
}
|
||||
|
||||
// get the path to the file version by the history path and file version
|
||||
public static string VersionDir(string histPath, int version)
|
||||
{
|
||||
return Path.Combine(histPath, version.ToString());
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
return histPath + version + "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(histPath, version.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// get the path to the file version by the file name, user address and file version
|
||||
@ -177,38 +200,62 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get a file name with an index if the file with such a name already exists
|
||||
public static string GetCorrectName(string fileName, string userAddress = null)
|
||||
{
|
||||
var baseName = Path.GetFileNameWithoutExtension(fileName);
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
var name = baseName + ext;
|
||||
|
||||
for (var i = 1; File.Exists(StoragePath(name, userAddress)); i++) // run through all the files with such a name in the storage directory
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
name = baseName + " (" + i + ")" + ext; // and add an index to the base name
|
||||
}
|
||||
return name;
|
||||
}
|
||||
var files = S3Helper.Instance.ListAllItemsSync().Select(file => file.Key);
|
||||
var baseName = Path.GetFileNameWithoutExtension(fileName);
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
var name = baseName + ext;
|
||||
|
||||
// get all the stored files from the user host address
|
||||
public static List<FileInfo> GetStoredFiles()
|
||||
{
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
for (var i = 1; files.Contains(name); i++) // run through all the files with such a name in the storage directory
|
||||
{
|
||||
name = baseName + " (" + i + ")" + ext; // and add an index to the base name
|
||||
}
|
||||
return name;
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
var baseName = Path.GetFileNameWithoutExtension(fileName);
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
var name = baseName + ext;
|
||||
|
||||
for (var i = 1; File.Exists(StoragePath(name, userAddress)); i++) // run through all the files with such a name in the storage directory
|
||||
{
|
||||
name = baseName + " (" + i + ")" + ext; // and add an index to the base name
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory)) return new List<FileInfo>();
|
||||
}
|
||||
|
||||
var directoryInfo = new DirectoryInfo(directory);
|
||||
// get all the stored files from the user host address
|
||||
public static IEnumerable<FileInfoModel> GetStoredFiles()
|
||||
{
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var files = S3Helper.Instance.ListAllItemsSync();
|
||||
return files.Where(file => !file.IsDir).Select(file => FileInfoModel.FromS3(file));
|
||||
}
|
||||
else
|
||||
{
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
}
|
||||
|
||||
// take files from the root directory
|
||||
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
if (!Directory.Exists(directory)) return new List<FileInfoModel>();
|
||||
|
||||
return storedFiles;
|
||||
var directoryInfo = new DirectoryInfo(directory);
|
||||
|
||||
// take files from the root directory
|
||||
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
|
||||
return storedFiles.Select(file => FileInfoModel.FromFileInfo(file));
|
||||
}
|
||||
}
|
||||
|
||||
// create demo document
|
||||
@ -219,7 +266,14 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
var fileName = GetCorrectName(demoName); // get a file name with an index if the file with such a name already exists
|
||||
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName)); // copy file to the storage directory
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
S3Helper.Instance.UploadFileSync(StoragePath(fileName), HttpRuntime.AppDomainAppPath + demoPath + demoName);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName)); // copy file to the storage directory
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
@ -228,26 +282,34 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
public static void CreateMeta(string fileName, string uid, string uname, string userAddress = null)
|
||||
{
|
||||
var histDir = HistoryDir(StoragePath(fileName, userAddress)); // create history directory
|
||||
Directory.CreateDirectory(histDir);
|
||||
// create createdInfo.json file with meta information in the history directory (creation time, user id and name)
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", uid },
|
||||
{ "name", uname }
|
||||
}));
|
||||
var content = new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", uid },
|
||||
{ "name", uname }
|
||||
});
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
S3Helper.Instance.UploadFileSync(histDir + "createdInfo.json", S3Helper.StringToStream(content));
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(histDir);
|
||||
// create createdInfo.json file with meta information in the history directory (creation time, user id and name)
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), content);
|
||||
}
|
||||
}
|
||||
|
||||
// get file url
|
||||
public static string GetFileUri(string fileName, Boolean forDocumentServer)
|
||||
{
|
||||
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ CurUserHostAddress() + "/"
|
||||
+ fileName,
|
||||
Query = ""
|
||||
};
|
||||
Query = ""
|
||||
};
|
||||
|
||||
return uri.ToString();
|
||||
}
|
||||
@ -326,7 +388,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ userAddress
|
||||
+ "&ver=" + version
|
||||
+ "&file="+ file
|
||||
+ "&file=" + file
|
||||
};
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
@ -397,14 +459,14 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// write all the parameters to the map
|
||||
var dictionary = new Dictionary<string, object>();
|
||||
dictionary.Add("version", GetFileVersion(file.Name, null));
|
||||
dictionary.Add("id", ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress() + "/" + file.Name + "/" + File.GetLastWriteTime(DocManagerHelper.StoragePath(file.Name, null)).GetHashCode()));
|
||||
dictionary.Add("id", ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress() + "/" + file + "/" + file.LastModified.GetHashCode()));
|
||||
dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB");
|
||||
dictionary.Add("pureContentLength", file.Length);
|
||||
dictionary.Add("title", file.Name);
|
||||
dictionary.Add("updated", file.LastWriteTime.ToString());
|
||||
dictionary.Add("title", file);
|
||||
dictionary.Add("updated", file.LastModified.ToString());
|
||||
|
||||
// get file information by its id
|
||||
if (fileId != null)
|
||||
if (fileId != null)
|
||||
{
|
||||
if (fileId.Equals(dictionary["id"]))
|
||||
{
|
||||
@ -425,7 +487,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
public static void VerifySSL()
|
||||
{
|
||||
// hack. http://ubuntuforums.org/showthread.php?t=1841740
|
||||
if(WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("true")) {
|
||||
if (WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("true"))
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
}
|
||||
@ -436,9 +499,9 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var languages = new Dictionary<string, string>();
|
||||
String[] couples = (WebConfigurationManager.AppSettings["files.docservice.languages"] ?? "").Split('|');
|
||||
foreach (string couple in couples)
|
||||
{
|
||||
{
|
||||
String[] tmp = couple.Split(':');
|
||||
languages.Add(tmp[0],tmp[1]);
|
||||
languages.Add(tmp[0], tmp[1]);
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
159
web/documentserver-example/csharp-mvc/Helpers/S3Helper.cs
Normal file
159
web/documentserver-example/csharp-mvc/Helpers/S3Helper.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using Minio;
|
||||
using Minio.DataModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
public class S3Helper
|
||||
{
|
||||
private S3Helper()
|
||||
{
|
||||
bool.TryParse(WebConfigurationManager.AppSettings["s3-enabled"], out var enable);
|
||||
if (enable)
|
||||
{
|
||||
MinioClient = new MinioClient()
|
||||
.WithEndpoint(WebConfigurationManager.AppSettings["s3-endpoint"])
|
||||
.WithCredentials(WebConfigurationManager.AppSettings["s3-access-key"], WebConfigurationManager.AppSettings["s3-secret-key"])
|
||||
.WithRegion(WebConfigurationManager.AppSettings["s3-region"]);
|
||||
|
||||
if (bool.Parse(WebConfigurationManager.AppSettings["s3-secure"]))
|
||||
{
|
||||
MinioClient.WithSSL();
|
||||
}
|
||||
|
||||
MinioClient.Build();
|
||||
}
|
||||
}
|
||||
|
||||
private static S3Helper instance;
|
||||
public static S3Helper Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new S3Helper();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private string Bucket { get { return WebConfigurationManager.AppSettings["s3-bucket"]; } }
|
||||
private MinioClient MinioClient { get; set; }
|
||||
|
||||
public bool Enabled { get { return MinioClient != null; } }
|
||||
|
||||
public List<Item> ListAllItemsSync(string prefix = null)
|
||||
{
|
||||
return AwaitTaskSync(() => ListAllItems(prefix));
|
||||
}
|
||||
|
||||
public void UploadFileSync(string name, string path)
|
||||
{
|
||||
AwaitTaskSync(() => UploadFile(name, path));
|
||||
}
|
||||
|
||||
public void UploadFileSync(string name, Stream stream)
|
||||
{
|
||||
AwaitTaskSync(() => UploadFile(name, stream));
|
||||
}
|
||||
|
||||
public void RemoveFilesSync(IEnumerable<string> names)
|
||||
{
|
||||
AwaitTaskSync(() => RemoveFiles(names));
|
||||
}
|
||||
|
||||
public Stream DownloadFileSync(string name)
|
||||
{
|
||||
return AwaitTaskSync(() => DownloadFile(name));
|
||||
}
|
||||
|
||||
public void CopyFileSync(string oldname, string newname)
|
||||
{
|
||||
AwaitTaskSync(() => CopyFile(oldname, newname));
|
||||
}
|
||||
|
||||
private async Task<List<Item>> ListAllItems(string prefix = null)
|
||||
{
|
||||
var list = new List<Item>();
|
||||
var shouldWait = true;
|
||||
var args = new ListObjectsArgs().WithBucket(Bucket).WithRecursive(false);
|
||||
if (!string.IsNullOrWhiteSpace(prefix))
|
||||
{
|
||||
args.WithPrefix(prefix).WithRecursive(true);
|
||||
}
|
||||
var observable = MinioClient.ListObjectsAsync(args);
|
||||
var subscription = observable.Subscribe(item => list.Add(item), () => shouldWait = false);
|
||||
while (shouldWait)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private async Task UploadFile(string name, string path)
|
||||
{
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
await UploadFile(name, stream);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UploadFile(string name, Stream stream)
|
||||
{
|
||||
await MinioClient.PutObjectAsync(new PutObjectArgs().WithBucket(Bucket).WithObject(name).WithObjectSize(stream.Length).WithStreamData(stream));
|
||||
}
|
||||
|
||||
private async Task RemoveFiles(IEnumerable<string> names)
|
||||
{
|
||||
await MinioClient.RemoveObjectsAsync(new RemoveObjectsArgs().WithBucket(Bucket).WithObjects(names.ToList()));
|
||||
}
|
||||
|
||||
private async Task CopyFile(string oldname, string newname)
|
||||
{
|
||||
await MinioClient.CopyObjectAsync(new CopyObjectArgs().WithBucket(Bucket).WithObject(newname)
|
||||
.WithCopyObjectSource(new CopySourceObjectArgs().WithBucket(Bucket).WithObject(oldname)));
|
||||
}
|
||||
|
||||
private async Task<Stream> DownloadFile(string name)
|
||||
{
|
||||
Stream stream = null;
|
||||
var shouldWait = true;
|
||||
await MinioClient.GetObjectAsync(new GetObjectArgs().WithBucket(Bucket).WithObject(name).WithCallbackStream((s) =>
|
||||
{
|
||||
stream = s;
|
||||
shouldWait = false;
|
||||
}));
|
||||
while (shouldWait)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private void AwaitTaskSync(Func<Task> f)
|
||||
{
|
||||
Task.Run(() => f()).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private T AwaitTaskSync<T>(Func<Task<T>> f)
|
||||
{
|
||||
return Task.Run(() => f()).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static Stream StringToStream(string content)
|
||||
{
|
||||
return new MemoryStream(Encoding.UTF8.GetBytes(content ?? ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file saving process
|
||||
public static int processSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if (string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
if (string.IsNullOrEmpty((string)fileData["url"]))
|
||||
{
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
var downloadUri = (string)fileData["url"];
|
||||
@ -115,11 +116,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get the correct file name if it already exists
|
||||
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
downloadUri = newFileUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
@ -128,48 +129,57 @@ 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 (!S3Helper.Instance.Enabled)
|
||||
{
|
||||
var bytesFile = DownloadFile(downloadUri); // download document file
|
||||
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
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
|
||||
if (!S3Helper.Instance.Enabled)
|
||||
{
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
|
||||
}
|
||||
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
S3Helper.Instance.CopyFileSync(fileName, versionDir + "prev" + curExt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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
|
||||
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
|
||||
DownloadToFile((string)fileData["changesurl"], S3Helper.Instance.Enabled ? versionDir + "diff.zip" : Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
|
||||
|
||||
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"]);
|
||||
}
|
||||
|
||||
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
|
||||
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
{
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
hist = jss.Serialize(fileData["history"]);
|
||||
S3Helper.Instance.UploadFileSync(versionDir + "changes.json", S3Helper.StringToStream(hist));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
else
|
||||
{
|
||||
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
|
||||
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)
|
||||
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
{
|
||||
return 1;
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -178,7 +188,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file force saving process
|
||||
public static int processForceSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if ( string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
if (string.IsNullOrEmpty((string)fileData["url"]))
|
||||
{
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
var downloadUri = (string)fileData["url"];
|
||||
@ -201,11 +212,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
newFileName = true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
downloadUri = newFileUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
newFileName = true;
|
||||
@ -214,50 +225,43 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
DocManagerHelper.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 = 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);
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
}
|
||||
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;
|
||||
@ -279,7 +283,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{ "key", key }
|
||||
};
|
||||
|
||||
if (meta != null)
|
||||
if (meta != null)
|
||||
{
|
||||
body.Add("meta", meta);
|
||||
}
|
||||
@ -329,30 +333,34 @@ 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");
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
S3Helper.Instance.UploadFileSync(path, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (var fs = File.Open(path, FileMode.Create))
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
using Minio.DataModel;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
public class FileInfoModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public long Length { get; set; }
|
||||
|
||||
public static FileInfoModel FromFileInfo(FileInfo info)
|
||||
{
|
||||
return new FileInfoModel()
|
||||
{
|
||||
Name = info.Name,
|
||||
LastModified = info.LastWriteTime,
|
||||
Length = info.Length
|
||||
};
|
||||
}
|
||||
|
||||
public static FileInfoModel FromS3(Item info)
|
||||
{
|
||||
return new FileInfoModel()
|
||||
{
|
||||
Name = info.Key,
|
||||
LastModified = info.LastModifiedDateTime.Value,
|
||||
Length = (long)info.Size
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,7 @@ using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Models
|
||||
@ -75,8 +76,6 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
// get the document config
|
||||
public string GetDocConfig(HttpRequest request, UrlHelper url)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
var ext = Path.GetExtension(FileName).ToLower(); // get file extension
|
||||
var editorsMode = Mode ?? "edit"; // get editor mode
|
||||
|
||||
@ -96,7 +95,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
bool? favorite = user.favorite;
|
||||
|
||||
var actionLink = request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : JsonConvert.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = DocManagerHelper.GetDownloadUrl(FileName, false);
|
||||
var createUrl = DocManagerHelper.GetCreateUrl(FileUtility.GetFileType(FileName));
|
||||
@ -221,7 +220,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
config.Add("token", token);
|
||||
}
|
||||
|
||||
return jss.Serialize(config);
|
||||
return JsonConvert.SerializeObject(config, Formatting.Indented);
|
||||
}
|
||||
|
||||
// get the document history
|
||||
|
||||
@ -43,15 +43,92 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Crc32.NET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dc0b95cf99bf4e99, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="JWT, Version=9.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
|
||||
<HintPath>packages\JWT.9.0.3\lib\net46\JWT.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Minio, Version=4.0.0.0, Culture=neutral, PublicKeyToken=348239ebd7debb4c, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Minio.4.0.0\lib\net46\Minio.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Reactive.5.0.0\lib\net472\System.Reactive.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reactive.Linq, Version=3.0.6000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Reactive.Linq.5.0.0\lib\net472\System.Reactive.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.9\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
@ -59,45 +136,27 @@
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
@ -108,12 +167,14 @@
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\S3Helper.cs" />
|
||||
<Compile Include="Helpers\TrackManager.cs" />
|
||||
<Compile Include="Helpers\DocManagerHelper.cs" />
|
||||
<Compile Include="Helpers\DocumentConverter.cs" />
|
||||
<Compile Include="Helpers\JwtManager.cs" />
|
||||
<Compile Include="Helpers\Users.cs" />
|
||||
<Compile Include="Helpers\Utils.cs" />
|
||||
<Compile Include="Models\FileInfoModel.cs" />
|
||||
<Compile Include="Models\FileModel.cs" />
|
||||
<Compile Include="Models\FileUtility.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
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
@ -53,6 +53,10 @@
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
@ -63,11 +67,27 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.9.0" newVersion="5.2.9.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.9.0" newVersion="5.2.9.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reactive" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@ -82,7 +82,7 @@ namespace OnlineEditorsExampleMVC
|
||||
context.Response.ContentType = "text/plain";
|
||||
try
|
||||
{
|
||||
string fileData;
|
||||
string fileData;
|
||||
try
|
||||
{
|
||||
using (var receiveStream = context.Request.InputStream)
|
||||
@ -96,53 +96,60 @@ namespace OnlineEditorsExampleMVC
|
||||
{
|
||||
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
|
||||
}
|
||||
|
||||
|
||||
var jss = new JavaScriptSerializer();
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var fileUrl = (string) body["url"];
|
||||
var title = (string) body["title"];
|
||||
var fileUrl = (string)body["url"];
|
||||
var title = (string)body["title"];
|
||||
var fileName = DocManagerHelper.GetCorrectName(title);
|
||||
var extension = "." + (Path.GetExtension(fileName).ToLower() ?? "").Trim('.');
|
||||
|
||||
|
||||
var allExt = DocManagerHelper.ConvertExts
|
||||
.Concat(DocManagerHelper.EditedExts)
|
||||
.Concat(DocManagerHelper.ViewedExts)
|
||||
.Concat(DocManagerHelper.FillFormExts)
|
||||
.ToArray();
|
||||
|
||||
|
||||
if (!allExt.Contains(extension))
|
||||
{
|
||||
{
|
||||
context.Response.Write("{\"error\":\"File type is not supported\"}");
|
||||
}
|
||||
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(fileUrl);
|
||||
|
||||
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
using (var stream = req.GetResponse().GetResponseStream())
|
||||
{
|
||||
|
||||
if (stream == null || req.GetResponse().ContentLength <= 0 || req.GetResponse().ContentLength > DocManagerHelper.MaxFileSize)
|
||||
{
|
||||
context.Response.Write("{\"error\": \"File size is incorrect\"}");
|
||||
}
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (var fs = File.Open(DocManagerHelper.StoragePath(fileName, null), FileMode.Create))
|
||||
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
|
||||
S3Helper.Instance.UploadFileSync(fileName, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (var fs = File.Open(DocManagerHelper.StoragePath(fileName, null), FileMode.Create))
|
||||
{
|
||||
fs.Write(buffer, 0, readed); // write bytes to the output stream
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var id = context.Request.Cookies.GetOrDefault("uid", null);
|
||||
var user = Users.getUser(id); // get the user
|
||||
DocManagerHelper.CreateMeta(fileName, user.id, user.name, null);
|
||||
|
||||
|
||||
context.Response.Write("{ \"file\": \"" + fileName + "\"}");
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -158,7 +165,7 @@ namespace OnlineEditorsExampleMVC
|
||||
try
|
||||
{
|
||||
DocManagerHelper.VerifySSL();
|
||||
|
||||
|
||||
var httpPostedFile = context.Request.Files[0];
|
||||
string fileName;
|
||||
|
||||
@ -188,8 +195,15 @@ namespace OnlineEditorsExampleMVC
|
||||
fileName = DocManagerHelper.GetCorrectName(fileName); // get the correct file name if such a name already exists
|
||||
var documentType = FileUtility.GetFileType(fileName).ToString().ToLower();
|
||||
|
||||
var savedFileName = DocManagerHelper.StoragePath(fileName); // get the storage path to the uploading file
|
||||
httpPostedFile.SaveAs(savedFileName); // and save it
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
S3Helper.Instance.UploadFileSync(fileName, httpPostedFile.InputStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
var savedFileName = DocManagerHelper.StoragePath(fileName); // get the storage path to the uploading file
|
||||
httpPostedFile.SaveAs(savedFileName); // and save it
|
||||
}
|
||||
// get file meta information or create the default one
|
||||
var id = context.Request.Cookies.GetOrDefault("uid", null);
|
||||
var user = Users.getUser(id);
|
||||
@ -263,15 +277,29 @@ namespace OnlineEditorsExampleMVC
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the converting file
|
||||
{
|
||||
if (stream == null) throw new Exception("Stream is null");
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (var fs = File.Open(DocManagerHelper.StoragePath(correctName), FileMode.Create))
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var buffer = new byte[bufferSize];
|
||||
int readed;
|
||||
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
|
||||
var path = Path.Combine(Path.GetTempPath(), $"temp-conv-upload-{DateTime.Now.Ticks}");
|
||||
using (var file = File.Open(path, FileMode.Create))
|
||||
{
|
||||
fs.Write(buffer, 0, readed); // write bytes to the output stream
|
||||
stream.CopyTo(file);
|
||||
}
|
||||
S3Helper.Instance.UploadFileSync(correctName, path);
|
||||
File.Delete(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int bufferSize = 4096;
|
||||
|
||||
using (var fs = File.Open(DocManagerHelper.StoragePath(correctName), FileMode.Create))
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,7 +340,7 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
var userAddress = context.Request["userAddress"];
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var status = (TrackerStatus) (int) fileData["status"]; // get status from the request body
|
||||
var status = (TrackerStatus)(int)fileData["status"]; // get status from the request body
|
||||
var saved = 0;
|
||||
switch (status)
|
||||
{
|
||||
@ -320,8 +348,8 @@ namespace OnlineEditorsExampleMVC
|
||||
try
|
||||
{
|
||||
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 actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
|
||||
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
|
||||
if (action != null && action["type"].ToString().Equals("0")) // finished edit
|
||||
{
|
||||
var user = action["userid"].ToString(); // the user who finished editing
|
||||
@ -396,8 +424,17 @@ namespace OnlineEditorsExampleMVC
|
||||
var path = DocManagerHelper.StoragePath(fileName, null); // delete file
|
||||
var histDir = DocManagerHelper.HistoryDir(path); // delete file history
|
||||
|
||||
if (File.Exists(path)) File.Delete(path);
|
||||
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var filesToRemove = S3Helper.Instance.ListAllItemsSync(histDir).Select(file => file.Key).ToList();
|
||||
filesToRemove.Add(path);
|
||||
S3Helper.Instance.RemoveFilesSync(filesToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists(path)) File.Delete(path);
|
||||
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
// get files information
|
||||
@ -456,26 +493,25 @@ namespace OnlineEditorsExampleMVC
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileName = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? context.Request["fileName"]
|
||||
var fileName = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? context.Request["fileName"]
|
||||
: Path.GetFileName(context.Request["fileName"]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +522,7 @@ namespace OnlineEditorsExampleMVC
|
||||
}
|
||||
download(filePath, context);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
context.Response.Write("{ \"error\": \"File not found!\"}");
|
||||
}
|
||||
@ -495,13 +531,22 @@ namespace OnlineEditorsExampleMVC
|
||||
// download data from the url to the file
|
||||
private static void download(string filePath, HttpContext context)
|
||||
{
|
||||
var fileinf = new FileInfo(filePath);
|
||||
context.Response.AddHeader("Content-Length", fileinf.Length.ToString()); // set headers to the response
|
||||
context.Response.AddHeader("Content-Type", MimeMapping.GetMimeMapping(filePath));
|
||||
var tmp = HttpUtility.UrlEncode(Path.GetFileName(filePath));
|
||||
tmp = tmp.Replace("+", "%20");
|
||||
context.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + tmp);
|
||||
context.Response.TransmitFile(filePath);
|
||||
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
var stream = S3Helper.Instance.DownloadFileSync(filePath);
|
||||
stream.CopyTo(context.Response.OutputStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileinf = new FileInfo(filePath);
|
||||
context.Response.AddHeader("Content-Length", fileinf.Length.ToString()); // set headers to the response
|
||||
context.Response.TransmitFile(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
@ -543,7 +588,15 @@ namespace OnlineEditorsExampleMVC
|
||||
}
|
||||
}
|
||||
var histPath = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(fileName, userAddress));
|
||||
var filePath = Path.Combine(DocManagerHelper.VersionDir(histPath, version), file); // get the path to document version
|
||||
string filePath;
|
||||
if (S3Helper.Instance.Enabled)
|
||||
{
|
||||
filePath = DocManagerHelper.VersionDir(histPath, version) + file;
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = Path.Combine(DocManagerHelper.VersionDir(histPath, version), file); // get the path to document version
|
||||
}
|
||||
|
||||
download(filePath, context);
|
||||
}
|
||||
@ -575,17 +628,17 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
var jss = new JavaScriptSerializer();
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var newFileName = (string) body["newfilename"];
|
||||
var docKey = (string) body["dockey"];
|
||||
var newFileName = (string)body["newfilename"];
|
||||
var docKey = (string)body["dockey"];
|
||||
|
||||
var origExt = '.' + (string) body["ext"];
|
||||
var origExt = '.' + (string)body["ext"];
|
||||
var curExt = Path.GetExtension(newFileName).ToLower();
|
||||
|
||||
if (string.Compare(origExt, curExt, true) != 0)
|
||||
{
|
||||
newFileName += origExt;
|
||||
}
|
||||
var meta = new Dictionary<string, object>() {
|
||||
var meta = new Dictionary<string, object>() {
|
||||
{ "title", newFileName }
|
||||
};
|
||||
TrackManager.commandRequest("meta", docKey, meta);
|
||||
|
||||
@ -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
|
||||
|
||||
201
web/documentserver-example/csharp-mvc/licenses/MinIO.license
Normal file
201
web/documentserver-example/csharp-mvc/licenses/MinIO.license
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
||||
@ -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,17 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net48" />
|
||||
<package id="Crc32.NET" version="1.2.0" targetFramework="net48" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
|
||||
<package id="JWT" version="9.0.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net48" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net48" />
|
||||
<package id="Minio" version="4.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Net.Http" version="4.3.4" targetFramework="net48" />
|
||||
<package id="System.Net.Primitives" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Reactive" version="5.0.0" targetFramework="net48" />
|
||||
<package id="System.Reactive.Linq" version="5.0.0" targetFramework="net48" />
|
||||
<package id="System.Runtime" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
|
||||
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@ -1,10 +1,18 @@
|
||||
<?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=""/>
|
||||
|
||||
<add key="s3-enabled" value="true"/>
|
||||
<add key="s3-endpoint" value="s3.region.example"/>
|
||||
<add key="s3-region" value="region"/>
|
||||
<add key="s3-access-key" value="key"/>
|
||||
<add key="s3-secret-key" value="secret"/>
|
||||
<add key="s3-secure" value="false"/>
|
||||
<add key="s3-bucket" value="bucket-name"/>
|
||||
|
||||
<add key="files.docservice.fillform-docs" value=".oform|.docx"/>
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps|.oxps"/>
|
||||
|
||||
@ -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
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user