Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
optimus
api
Commits
9c04d1e5
Commit
9c04d1e5
authored
Dec 01, 2020
by
Lionel VEST
Browse files
*
parent
c73f14ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
resources/files.php
resources/files.php
+9
-0
No files found.
resources/files.php
View file @
9c04d1e5
...
...
@@ -14,6 +14,15 @@ function read($connection,$input)
}
else
if
(
$input
->
body
->
action
==
'convert_to_zip'
)
{
if
(
!
isset
(
$input
->
body
->
path
)
return
array
(
"code"
=>
400
,
"message"
=>
"Aucun chemin n'a été spécifié"
);
if
(
!
isset
(
$input
->
body
->
items
)
return
array
(
"code"
=>
400
,
"message"
=>
"Aucun fichier ou dossier à compresser n'a été spécifié"
);
if
(
strpos
(
$input
->
body
->
path
,
'/..'
))
return
array
(
"code"
=>
400
,
"message"
=>
"Le chemin fourni est invalide"
);
foreach
(
$item
as
$input
->
body
->
items
)
if
(
strpos
(
$input
->
body
->
path
,
'/'
))
return
array
(
"code"
=>
400
,
"message"
=>
"Le fichier spécifié est invalide"
);
$path
=
'/srv/files/'
.
$input
->
db
.
str_replace
(
'/files/'
.
$input
->
db
,
''
,
$input
->
body
->
path
);
return
array
(
"code"
=>
200
,
"message"
=>
$path
);
exec
(
"LC_ALL=fr_FR.UTF-8 export HOME=/srv/api/tmp/"
.
$input
->
db
.
" && cd '/srv/files/demo@demoptimus.fr/==DOSSIERS==/'; zip -r 'test.zip' 'test' 'test2' 2>&1"
,
$output
);
if
(
is_file
(
'/srv/files/demo@demoptimus.fr/==DOSSIERS==/test.zip'
))
return
array
(
"code"
=>
200
,
"message"
=>
"Conversion effectuée avec succès"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment