Commit 6646cb45 authored by Gerald Salin's avatar Gerald Salin
Browse files

#21

parent 23e4ef57
...@@ -102,8 +102,24 @@ class tx_nG6_utils { ...@@ -102,8 +102,24 @@ class tx_nG6_utils {
if ($directory != 'undefined' && $directory != '') { if ($directory != 'undefined' && $directory != '') {
// And process the directories structure // And process the directories structure
//TODO BUG NE RETOURNE PAS D'ERREUR si pas supprimer //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; return 1;
}else{
// Close the streams
fclose($errorStream);
fclose($stream);
return 0;
} }
} }
return 0; return 0;
...@@ -125,32 +141,32 @@ class tx_nG6_utils { ...@@ -125,32 +141,32 @@ class tx_nG6_utils {
$connection = ssh2_connect('127.0.0.1', 22); $connection = ssh2_connect('127.0.0.1', 22);
if (!$connection) { if (!$connection) {
return 3; return 3;
}else{ }
if (!ssh2_auth_password($connection, $user_login,$user_pwd )){
return 2; if (!ssh2_auth_password($connection, $user_login,$user_pwd )){
return 2;
}else{ }
$stream = ssh2_exec($connection, 'ls '.$directory.'/* | grep -v -e ".html$" -e ".png$" | xargs rm -f' );
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); $stream = ssh2_exec($connection, 'ls '.$directory.'/* | grep -v -e ".html$" -e ".png$" | xargs rm -f' );
// Enable blocking for both streams $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($errorStream, true); // Enable blocking for both streams
stream_set_blocking($stream, true); 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 // Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
if(stream_get_contents($errorStream)) { if(stream_get_contents($errorStream)) {
return 1; // Close the streams
}else{ fclose($errorStream);
return 0; fclose($stream);
} return 1;
}else{
// Close the streams // Close the streams
fclose($errorStream); fclose($errorStream);
fclose($stream); fclose($stream);
} return 0;
} }
} }
return 0;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment