ソース FTP と宛先 FTP を接続し、すべてのファイルをソースから宛先にコピーするスクリプトがあり、サーバーを変更したところ、これらのエラーが返されました。私のコードは以下に書かれています。
$ftp1 = new ClsFTP("$user1","$pass1", "$site1");
if(!$ftp1)
{
echo "could not connect";
exit;
}
$ftp2 = new ClsFTP("$user2","$pass2", "$site2");
$mod = "0755";
$dir_list[] = "httpdocs";
for($i=0;$i<count($dir_list); $i++)
{
echo "<br>Copying Directory: " . $dir_list[$i];
if(!$ftp1->cd($dir_list[$i]))
{
echo "1::$site1 could not open directory: $dir_list[$i]. skipping<br>\n";
continue;
}
if(!$ftp2->cd($dir_list[$i]))
{
echo "2::$site2 could not open directory: $dir_list[$i]. Trying to create it<br>\n";
if(!$ftp2->mkdir($dir_list[$i]))
{
echo "2::$site2 could not create directory: $dir_list[$i]. skipping<br>\n";
continue;
}
if(!$ftp2->cd($dir_list[$i]))
{
echo "2::$site2 could not open directory: $dir_list[$i]. skipping<br>\n";
continue;
}
}
if($dir_list[$i]=="httpdocs/tmpupload"){
}else{
$dir_rawlist = $ftp1->rawlist();
$dir_nlist = $ftp1->nlist();
$ftp1->p($dir_rawlist);
#$ftp1->p($dir_nlist);
for($k = 0; $k<count($dir_nlist); $k++)
{
if($dir_list[$i]=="httpdocs/includes" && $dir_nlist[$k]=="cert_key_pem.txt"){
continue;
}
if($dir_list[$i]=="httpdocs" && $dir_nlist[$k]=="PayPal.class.php"){
continue;
}
$size = $ftp1->check_file($dir_nlist[$k]);
if($size >0)//substr($dir_rawlist[$k], 0, 1)=='-')//its a file
{
$ftp1->get("tmp/".$dir_nlist[$k], $dir_nlist[$k]);
$handle = fopen("tmp/".$dir_nlist[$k], 'r');
$contents = fread($handle, filesize("tmp/".$dir_nlist[$k]));
fclose($handle);
$contents = str_replace($search_for, $replace_with, $contents);
$handle = fopen("tmp/".$dir_nlist[$k], 'w');
fwrite($handle, $contents);
fclose($handle);
$ftp2->put($dir_nlist[$k], "tmp/".$dir_nlist[$k]);
$ftp2->chmod($dir_nlist[$k], $mod);
}
}
}
$ftp1->cd("/");
$ftp2->cd("/");
}
これらの警告はスクリプトによってスローされます。
Warning: ftp_get(): Error opening tmp/InviteFriend2.php in /var/www/vhosts/virtualphoneline.com/httpdocs/includes/ftp.class.php on line 120
Warning: fopen(tmp/InviteFriend2.php): failed to open stream: Permission denied in /var/www/vhosts/virtualphoneline.com/httpdocs/includes/clone.php on line 228
Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/vhosts/virtualphoneline.com/httpdocs/includes/clone.php on line 229
Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/vhosts/virtualphoneline.com/httpdocs/includes/clone.php on line 230