Exemplo n.º 1
0
 /**
  * ftpCopyFiles
  * 
  * @param string $from
  * @param string $to
  * @param int    $chmodf
  * @param int    $chmodd
  * @param bool   $overwrite
  */
 public function ftpCopyFiles($from = '', $to = '', $chmodf = 0644, $chmodd = 0755, $overwrite = false)
 {
     foreach (self::$_instance->iterator($from) as $f) {
         if (self::$_instance->is_dir($from . '/' . $f)) {
             self::$_instance->mkdir($to . '/' . $f, $chmodd);
             $this->ftpCopyFiles($from . '/' . $f, $to . '/' . $f, $chmodf, $chmodd, $overwrite);
         } else {
             if ($overwrite || !self::$_instance->file_exists($to . '/' . $f)) {
                 self::$_instance->file_put_contents($to . '/' . $f, self::$_instance->file_get_contents($from . '/' . $f));
                 $this->rechmod($to . '/' . $f, $chmodf);
             }
         }
     }
 }
Exemplo n.º 2
0
Arquivo: edit.php Projeto: ssrsfs/blg
        Typeframe::Redirect('Unable to connect to FTP server.', Typeframe::CurrentPage()->applicationUri(), -1);
        return;
    }
    if (!$ftp->login($_SESSION['typef_ftp_user'], $_SESSION['typef_ftp_pass'])) {
        Typeframe::Redirect('Unable to log into FTP server.', Typeframe::CurrentPage()->applicationUri(), -1);
        return;
    }
    $h = tmpfile();
    fwrite($h, $_REQUEST['source']);
    if (!fflush($h)) {
        die("Failed to flush");
    }
    rewind($h);
    // Make sure that all required directories exist
    $dirs = dirname("{$_REQUEST['skin']}{$_REQUEST['stylesheet']}");
    $dirnames = split("/", $dirs);
    $localpath = TYPEF_DIR . '/skins';
    $curdir = '';
    for ($i = 0; $i < count($dirnames); $i++) {
        $curdir .= '/' . $dirnames[$i];
        if (!file_exists("{$localpath}{$curdir}")) {
            echo "Making /skins{$curdir}<br/>";
            $ftp->mkdir(TYPEF_FTP_ROOT . "/skins{$curdir}");
        }
    }
    $ftp->fput(TYPEF_FTP_ROOT . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}", $h, FTP_ASCII);
    $ftp->close();
    fclose($h);
    Typeframe::Redirect("Stylesheet updated.", Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
Exemplo n.º 3
0
 echo $ftp->error();
 echo "<br>";
 echo nl2br($ftp->features());
 $ftp->setType('FTP_BINARY');
 echo "<br>Connect Ok<br>";
 $fp_list = fopen('migtask.txt', 'r');
 for ($i = 1; $i < $startline; $i++) {
     fgetline($fp_list);
 }
 //跳至起始行
 $session_count = 0;
 while ($buffer = fgetline($fp_list)) {
     $startline++;
     $session_count++;
     if (substr($buffer, 0, 4) == 'DIR:') {
         @$ftp->mkdir($_POST['remotepath'] . substr($buffer, 5));
         rptout("<font color=green>" . $_POST['remotepath'] . substr($buffer, 5) . "目录已建立</font>");
         $dirs_num++;
     }
     if (substr($buffer, 0, 4) == 'FIL:') {
         if (filesize(substr($buffer, 4)) < 5000000) {
             if (@$ftp->write($_POST['remotepath'] . substr($buffer, 5), substr($buffer, 4))) {
                 rptout($_POST['remotepath'] . substr($buffer, 5) . " 成功上传");
                 usleep(10000);
                 $files_num++;
             } else {
                 $theline = $startline - 1;
                 rptout("<font color=red>" . $_POST['remotepath'] . substr($buffer, 5) . " 上传失败 line:{$theline}</font>");
                 echo "<br><a href=\"mig.php?step=3&startline={$theline}\">点击重试</a>";
                 exit;
                 $filefail_num++;