well... you didn't say that in the first place.... you said from one server to the next, so I thought you were FXPing, not FTPing....
Anyway, you could always adapt it to get the permissions, and then use that to chmod the other directories.... like:
// Get the local stuff....
$ftp['host'] = 'ftp.domain.com';
$ftp['user'] = 'username';
$ftp['pass'] = 'password';
$ftp['dir'] = '/';
$ftp['conn'] = ftp_connect($ftp['host']);
ftp_login($ftp['conn'], $ftp['user'], $ftp['pass']);
$list = ftp_rawlist($ftp['conn'], $ftp['dir']);
ftp_close($ftp['conn']);
$i = 0;
foreach($list as $file)
{
$split = preg_split("[ ]", $file, 9, PREG_SPLIT_NO_EMPTY);
if($split[0] != "total")
{
$param[$split[8]]['perms'] = $split[0];
}
$i++;
}
function get_level($str, $opt)
{
// This function will take the string drwxrw-r-- and convert it to an octal
switch($str)
{
case 'rwx':
$lvl = 700;
break;
case 'rw-':
$lvl = 600;
break;
case 'r-x':
$lvl = 500;
break;
case 'r--':
$lvl = 400;
break;
case '-wx':
$lvl = 300;
break;
case '-w-':
$lvl = 200;
break;
case '--x':
$lvl = 100;
break;
case '---':
$lvl = 0;
break;
}
if($opt == 'owner'){ return '0'.$lvl; }
if($opt == 'group'){ $lvl = $lvl/10; return '0'.$lvl; }
if($opt == 'global'){ $lvl = $lvl/100; return '0'.$lvl; }
}
function check_perms($file)
{
// This function takes the parameters we got from our local file, and grabs them from the
// array based upon the $file name. Then, we dynamically generate the chmod octal using
// our above function
$perm = $param[$file]['perms'];
$perm = substr($perm, 1);
$chmod = str_split($perm, 3);
$i=0;
foreach($chmod as $lvl)
{
if($i==0)
{
$chmod['owner'] = get_level($lvl[0], 'owner');
}
elseif($i==1)
{
$chmod['group'] = get_level($lvl[1], 'group');
}
else
{
$chmod['global'] = get_level($lvl[2], 'global');
}
$i++;
}
$perm = $chmod['owner']+$chmod['group']+$chmod['global'];
return $perm;
}
// Here is where you'd connect to the other server and start your
// modification/uploads...
// So when you call the chmod() function, you would use it like...:
chmod($file, check_perms($file));
I hope that helps you....
~Brett