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

#21

parent 23e4ef57
......@@ -102,8 +102,24 @@ 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;
......@@ -125,32 +141,32 @@ class tx_nG6_utils {
$connection = ssh2_connect('127.0.0.1', 22);
if (!$connection) {
return 3;
}else{
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);
// Enable blocking for both streams
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
}
if (!ssh2_auth_password($connection, $user_login,$user_pwd )){
return 2;
}
$stream = ssh2_exec($connection, 'ls '.$directory.'/* | grep -v -e ".html$" -e ".png$" | xargs rm -f' );
$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
// Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
if(stream_get_contents($errorStream)) {
return 1;
}else{
return 0;
}
// Close the streams
fclose($errorStream);
fclose($stream);
}
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;
}
......
Markdown is supported
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