0

我有一个脚本,它连接我的源 FTP 和目标 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
4

0 回答 0