PHP 8.5.0 Alpha 4 available for testing

Voting

: three plus five?
(Example: nine)

The Note You're Voting On

duke1 at drakkon dot net
17 years ago
if anyone is interested on how to get a directory listing:
$SSH_CONNECTION= ssh2_connect('shell.example.com', 22);
ssh2_auth_password($SSH_CONNECTION, 'username', 'password');
//-------------------------------------------------------------------
//this function finds all files within given directory and returns them
function scanFilesystem($dir) {
$tempArray = array();
$handle = opendir($dir);
// List all the files
while (false !== ($file = readdir($handle))) {
if (substr("$file", 0, 1) != "."){
if(is_dir($file)){
$tempArray[$file]=scanFilesystem("$dir/$file");
} else {
$tempArray[]=$file;
}
}
}
closedir($handle);
return $tempArray;
}

//-------------------------------------------------------------------
$sftp = ssh2_sftp($SSH_CONNECTION);

//code to get listing of all OUTGOING files
$dir = "ssh2.sftp://$sftp/outgoing";
$outgoing = scanFilesystem($dir);
sort($outgoing);
print_r($outgoing);

<< Back to user notes page

To Top