コード例 #1
0
ファイル: upload.php プロジェクト: iwarsong/NCMI
 public function safetyUpload()
 {
     $ret = $this->upload();
     if ($ret == "success") {
         if (nt_check) {
             $f = new FTP(FTP_URL, FTP_USER, UPLOAD_PASSWORD, UPLOAD_DIR);
             if ($f->status == 1) {
                 $f->put($this->folder . $this->name, $this->name);
                 $i = 0;
                 $has = false;
                 while ($i < UPLOAD_TRY_TIME) {
                     sleep(UPLOAD_TRY_INTERVAL);
                     if ($f->isFile($this->name)) {
                         $has = true;
                         //echo $f->unlink($this->name);
                     }
                     $i++;
                 }
                 $f->bye();
                 if ($has) {
                     return "success";
                 } else {
                     return "not saft";
                 }
             } else {
                 unlink($this->folder . $this->name);
                 return "ftp_unconnect";
             }
         } else {
             return $ret;
         }
     } else {
         return $ret;
     }
 }
コード例 #2
0
ファイル: restore.php プロジェクト: ssrsfs/blg
mkdir(TYPEF_DIR . '/files/secure/backups/tmp');
/*
$archExtractor = new ArchiveExtractor();
$archExtractor->extractArchive($fullpath, TYPEF_SOURCE_DIR . '/backups/tmp');
*/
$tmpdir = tempnam(sys_get_temp_dir(), 'phrm_');
unlink($tmpdir);
mkdir($tmpdir);
exec("tar -zxvf {$fullpath} -C {$tmpdir}", $list, $retval);
if ($_POST['cmd'] == 'restore-all') {
    // Restore all files
    /*
    $list = $archExtractor->getTarGzipList($fullpath);
    */
    foreach ($list as $l) {
        $ftp->put(TYPEF_FTP_ROOT . '/' . substr($l['filename'], strlen(TYPEF_DIR)), $tmpdir . '/' . $l['filename']);
    }
    Typeframe::Redirect('All files restored from backup.', Typeframe::CurrentPage()->applicationUri(), -1);
} elseif ($_POST['cmd'] == 'restore-selected') {
    if (!isset($_REQUEST['files']) || !is_array($_REQUEST['files'])) {
        Typeframe::Redirect('No files selected from backup.', Typeframe::CurrentPage()->applicationUri(), -1);
        return;
    }
    // Restore selected
    foreach ($_REQUEST['files'] as $f) {
        $ftp->put(TYPEF_FTP_ROOT . '/' . substr($f, strlen(TYPEF_DIR)), $tmpdir . '/' . $f);
    }
    Typeframe::Redirect('Selected files have been restored.', Typeframe::CurrentPage()->applicationUri(), -1);
} else {
    Typeframe::Redirect('No action performed.', Typeframe::CurrentPage()->applicationUri(), -1);
}
コード例 #3
0
 /**
  * Writes a dummy file in the selected ftp directory.
  * Returns the file of the dummy file or null on failure.
  * 
  * @param 	FTP 		$ftp
  * @return	string		$filename
  */
 protected static function writeDummyFile(FTP $ftp)
 {
     $dummyUploadFile = FileUtil::getTemporaryFilename('ftpDummy_', '.dat');
     @touch($dummyUploadFile);
     $destFile = FileUtil::removeLeadingSlash(strrchr($dummyUploadFile, '/'));
     if (@(!$ftp->put($destFile, $dummyUploadFile, FTP_ASCII))) {
         @unlink($dummyUploadFile);
         return null;
     }
     @unlink($dummyUploadFile);
     return $destFile;
 }
コード例 #4
0
function moveFileToEVENTS_FTP($sourceFile = '')
{
    global $configArray;
    $fi = "classes/ftp_object.class.php";
    if (file_exists($fi)) {
        require_once $fi;
    } else {
        echo "Nu am putut include un fisier. (ftp)";
        exit;
    }
    //define ("LOG_NONE", 0) ;  // No log
    //define ("LOG_ECHO", 1) ;	// Echo to screen
    //define ("LOG_HIDE", 2) ;	// Echo to HTML comment <!-- -->
    //define ("LOG_FILE", 3) ;	// Echo to file
    $ftp = new FTP($configArray['EventsFtpHost'], $configArray['EventsFtpUser'], $configArray['EventsFtpPass'], 0, 21, 1);
    $ftp->lcd($configArray['uploadDir']);
    $ftp->cd('events/uploads/');
    if ($ftp->connected) {
        if (strlen($sourceFile) > 3) {
            $success = $ftp->put($sourceFile, 0);
        }
    }
    //endif ftp->conected
    return $success;
}