Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
0a0fcc3f
Commit
0a0fcc3f
authored
Aug 09, 2018
by
Gerald Salin
Browse files
#21
: enhance ssh2_connect management
parent
eaf80301
Changes
1
Hide whitespace changes
Inline
Side-by-side
ui/nG6/lib/class.tx_nG6_utils.php
View file @
0a0fcc3f
...
...
@@ -101,9 +101,23 @@ class tx_nG6_utils {
if
(
$directory
!=
'undefined'
&&
$directory
!=
''
)
{
// And process the directories structure
//TODO BUG NE RETOURNE PAS D'ERREUR si pas supprimer
if
(
!
ssh2_exec
(
$connection
,
'rm -rf '
.
$directory
.
"/"
))
{
$stream
=
ssh2_exec
(
$connection
,
'rm -rf '
.
$directory
.
"/"
);
$errorStream
=
ssh2_fetch_stream
(
$stream
,
SSH2_STREAM_STDERR
);
// Enable blocking for both streams
stream_set_blocking
(
$errorStream
,
true
);
stream_set_blocking
(
$stream
,
true
);
// Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
if
(
stream_get_contents
(
$errorStream
))
{
// Close the streams
fclose
(
$errorStream
);
fclose
(
$stream
);
return
1
;
}
else
{
// Close the streams
fclose
(
$errorStream
);
fclose
(
$stream
);
return
0
;
}
}
return
0
;
...
...
@@ -120,8 +134,7 @@ class tx_nG6_utils {
static
function
purge_directory
(
$user_login
,
$user_pwd
,
$directory
)
{
if
(
$directory
!=
'undefined'
&&
$directory
!=
''
)
{
// And process the directories structure, remove all files except .html ans .png
// And process the directories structure, remove all files except .html and .png
$connection
=
ssh2_connect
(
'127.0.0.1'
,
22
);
if
(
!
$connection
)
{
return
3
;
...
...
@@ -135,18 +148,19 @@ class tx_nG6_utils {
// Enable blocking for both streams
stream_set_blocking
(
$errorStream
,
true
);
stream_set_blocking
(
$stream
,
true
);
// Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
if
(
stream_get_contents
(
$errorStream
))
{
// Close the streams
fclose
(
$errorStream
);
fclose
(
$stream
);
return
1
;
}
else
{
// Close the streams
fclose
(
$errorStream
);
fclose
(
$stream
);
return
0
;
}
// Close the streams
fclose
(
$errorStream
);
fclose
(
$stream
);
}
}
}
...
...
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