Exemplo n.º 1
0
                        $nnode = iconv("GBK", "UTF-8", $node);
                        echo $nnode . '<br>';
                        if (is_dir($node)) {
                            $this->addDir2($node);
                        } elseif (is_file($node)) {
                            $this->addFile($node);
                        }
                    }
                }
            }
            $zip = new Zipper();
            $time = date('D-d-M-g-h-s', $_SERVER['REQUEST_TIME']);
            $res = $zip->open($_SESSION['folder'] . 'Backup-' . $time . '.zip', ZipArchive::CREATE);
            if ($res === TRUE) {
                $f = substr($_SESSION['folder'], 0, -1);
                $zip->addDir($f);
                $zip->close();
                echo "压缩完成,文件保存为Backup-" . $time . ".zip<br>你可以 <a href=\"" . $meurl . "?op=home&folder=" . $_SESSION['folder'] . "\">查看文件夹</a> 或者 <a href=\"" . $meurl . "?op=home\">返回上次浏览的文件夹</a></div>\n";
            } else {
                echo '<span class="error">压缩失败!</span>' . "</div>\n";
            }
            mainbottom();
        } else {
            printerror('此服务器上的PHP不支持ZipArchive,无法压缩文件!');
        }
    } else {
        printerror("您没有选择文件");
    }
}
if ($os !== 'windows') {
    if (@$_POST['action'] == '权限') {
Exemplo n.º 2
0
$name = $_REQUEST["n"];
$dirPath = $_REQUEST["d"];
$date = new DateTime();
$archName = "backup/" . $name . "_" . $date->format("YmdHis") . ".zip";
class Zipper extends ZipArchive
{
    public function addDir($path)
    {
        $this->addEmptyDir($path);
        $nodes = glob($path . '/*');
        foreach ($nodes as $node) {
            if (is_dir($node)) {
                $this->addDir($node);
            } else {
                if (is_file($node)) {
                    $this->addFile($node);
                }
            }
        }
    }
}
$zip = new Zipper();
if ($zip->open($archName, ZipArchive::CREATE)) {
    //=== TRUE) {
    $zip->addDir($dirPath);
    $zip->close();
    echo "{\"archive\":\"{$archName}\"}";
} else {
    echo "{\"error\":\"Backup error. Can't open file '{$archName}'\"}";
}
Exemplo n.º 3
0
        foreach ($nodes as $node) {
            //print $node . '<br>';
            if (is_dir($node)) {
                if (!$onlystatus) {
                    $this->addDir($node);
                }
            } else {
                if (is_file($node)) {
                    $this->addFile($node);
                }
            }
        }
    }
}
/********************************************************************************/
include_once "../includes/main_back_inc.php";
$zip = new Zipper();
$ourFileName = "testFile.zip";
if ($zip->open($ourFileName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
    $zip->addDir('../upload/products');
    $zip->addDir('../upload', true);
    $zip->close();
} else {
    alert('匯出檔案資料失敗!!', '/');
    exit;
}
$filename = date("YmdHis");
header("Content-type: application/zip, application/octet-stream");
header("Content-Disposition: attachment; filename={$filename}.zip");
readfile($ourFileName);
unlink($ourFileName);
Exemplo n.º 4
0
 public function exportProject($exportsettings, $dontsavesettings = false)
 {
     $userid = $this->getUserId();
     $projectid = $this->getProjectId();
     $data = $this->loadProjectData();
     if (!$dontsavesettings) {
         $this->userdata->saveExportSettings($exportsettings);
     }
     //		$theme = (strlen($exportsettings['styleTemplate'])) ? $exportsettings['styleTemplate'] : 'default';
     $theme = "default";
     $zip = new Zipper();
     $filename = $this->projectpath . $data['path'] . "/" . $this->standardize($data['project']) . '.zip';
     if (@file_exists($filename)) {
         @unlink($filename);
     }
     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
         exit("cannot open <{$filename}>\n");
     }
     $zip->addEmptyDir('images');
     $zip->addEmptyDir('thumbs');
     $zip->addEmptyDir('audio');
     $zip->addEmptyDir('config');
     $zip->addDir('./css');
     $zip->addFile('./themes/' . $theme . '/css/styles.css', './css/styles.css');
     $zip->addEmptyDir('icons');
     $zip->addFilesFromDir('./themes/' . $theme . '/icons', './icons');
     $zip->addDir('./js');
     $zip->addFile('_index.html', '/index.html');
     $zip->addFile('integration.html', '/integration.html');
     $zip->addFile('_index_computer.html', '/_index_computer.html');
     $zip->addFile('./flash/mmslides.swf', '/mmslides.swf');
     $imageformat = strlen($exportsettings['width']) ? $exportsettings['width'] : "1024";
     foreach ($data['data']['slides'] as $idx => $filedata) {
         if (array_key_exists('file', $filedata) && strlen($filedata['file'])) {
             $filepaths = array('1280' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "1280" . DIRECTORY_SEPARATOR . $filedata['file'], '1024' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "1024" . DIRECTORY_SEPARATOR . $filedata['file'], '800' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "800" . DIRECTORY_SEPARATOR . $filedata['file'], '640' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "640" . DIRECTORY_SEPARATOR . $filedata['file'], '480' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "480" . DIRECTORY_SEPARATOR . $filedata['file'], '320' => $this->projectpath . $data['path'] . DIRECTORY_SEPARATOR . "320" . DIRECTORY_SEPARATOR . $filedata['file']);
             foreach ($filepaths as $filesize => $filepath) {
                 if (@file_exists($filepath)) {
                     $zip->addFile($filepath, '/images/' . $filesize . '/' . $filedata['file']);
                 }
                 $thumbpath = $this->projectpath . $data['path'] . "/thumbs/" . $filedata['file'];
                 if (@file_exists($thumbpath)) {
                     $zip->addFile($thumbpath, '/thumbs/' . $filedata['file'] . ".thumb.jpg");
                 }
             }
         }
     }
     $audiotrack = $data['data']['meta']['audio'];
     if (is_array($audiotrack) && strlen($audiotrack['file']) > 0) {
         $audiopath = $this->projectpath . $data['path'] . "/" . $audiotrack['file'];
         if (@file_exists($audiopath)) {
             $zip->addFile($audiopath, '/audio/' . $audiotrack['file']);
         }
     }
     $projectdata = $data;
     if (strlen($exportsettings['password'])) {
         $exportsettings['password'] = md5($exportsettings['password']);
     }
     $projectdata['slideshow'] = $exportsettings;
     $zip->addFromString('config/jsonconfig.js', json_encode($projectdata));
     $zip->close();
     return array('url' => $data['path'] . '/' . basename($filename));
 }