Commit 0a0fcc3f authored by Gerald Salin's avatar Gerald Salin
Browse files

#21 : enhance ssh2_connect management

parent eaf80301
......@@ -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);
}
}
}
......
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