当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPZip::Zip方法代码示例

本文整理汇总了PHP中PHPZip::Zip方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPZip::Zip方法的具体用法?PHP PHPZip::Zip怎么用?PHP PHPZip::Zip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPZip的用法示例。


在下文中一共展示了PHPZip::Zip方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dozip

 public function dozip()
 {
     $zippath = C("WEB_ROOT") . C("ZIP_PATH");
     $dbpath = C("DB_BAKPATH");
     MakeDir($zippath);
     $bakup = $_REQUEST['bakup'];
     //zip文件名
     $zipname = date("YmdHis", time()) . rand(1, 100) . $bakup . ".zip";
     import('ORG.Util.Phpzip');
     $z = new PHPZip();
     //新建立一个zip的类
     $res = $z->Zip($dbpath . "/" . $bakup, $zippath . "/" . $zipname);
     //添加指定目录
     if ($res == 1) {
         $this->success($zipname, '', __APP__ . "/" . C("ZIP_PATH") . "/" . $zipname);
     } else {
         $this->error("压缩失败");
     }
 }
开发者ID:kinglong366,项目名称:p2p,代码行数:19,代码来源:DbController.class.php

示例2: templatezip

 /**
  * Exports a template
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function templatezip($templatename)
 {
     Yii::import('application.libraries.admin.Phpzip', true);
     $zip = new PHPZip();
     $templatedir = getTemplatePath($templatename) . DIRECTORY_SEPARATOR;
     $tempdir = Yii::app()->getConfig('tempdir');
     $zipfile = "{$tempdir}/{$templatename}.zip";
     $zip->Zip($templatedir, $zipfile);
     if (is_file($zipfile)) {
         // Send the file for download!
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Type: application/force-download");
         header("Content-Disposition: attachment; filename={$templatename}.zip");
         header("Content-Description: File Transfer");
         @readfile($zipfile);
         // Delete the temporary file
         unlink($zipfile);
     }
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:28,代码来源:templates.php

示例3: isset

loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('messages'));
$INSTALLER09['sub_up_dir'] = "C:/appserv/www/uploadsub";
$action = isset($_POST["action"]) ? $_POST["action"] : "";
if ($action == "download") {
    $id = isset($_POST["sid"]) ? 0 + $_POST["sid"] : 0;
    if ($id == 0) {
        stderr("Err", "Not a valid id");
    } else {
        $res = sql_query("SELECT id, name, filename FROM subtitles WHERE id={$id} ") or sqlerr(__FILE__, __LINE__);
        $arr = mysql_fetch_assoc($res);
        $ext = substr($arr["filename"], -3);
        $fileName = str_replace(array(" ", ".", "-"), "_", $arr["name"]) . '.' . $ext;
        $file = $INSTALLER09['sub_up_dir'] . "/" . $arr["filename"];
        $fileContent = file_get_contents($file);
        $newFile = fopen("{$INSTALLER09['sub_up_dir']}/{$fileName}", "w");
        @fwrite($newFile, $fileContent);
        @fclose($newFile);
        $file = array();
        $zip = new PHPZip();
        $file[] = "{$INSTALLER09['sub_up_dir']}/{$fileName}";
        $fName = "{$INSTALLER09['sub_up_dir']}/" . str_replace(array(" ", ".", "-"), "_", $arr["name"]) . ".zip";
        $zip->Zip($file, $fName);
        $zip->forceDownload($fName);
        @unlink($fName);
        @unlink("{$INSTALLER09['sub_up_dir']}/{$fileName}");
        sql_query("UPDATE subtitles SET hits=hits+1 where id={$id}");
    }
} else {
    stderr("Err", "No way");
}
开发者ID:CharlieHD,项目名称:U-232-V2,代码行数:31,代码来源:downloadsub.php

示例4: ZipFile

function ZipFile($path,$zipname){
	global $bakpath,$bakzippath;
	@include("class/phpzip.inc.php");
	$z=new PHPZip(); //新建立一个zip的类
    $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录
}
开发者ID:jinjing1989,项目名称:wei,代码行数:6,代码来源:functions.php

示例5: PHPZip

if (XBT_TRACKER == true) {
    $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
    $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass=' . $CURUSER['torrent_pass'];
}
$dict['uid'] = (int) $CURUSER['id'];
$tor = bencdec::encode($dict);
if ($zipuse) {
    require_once INCL_DIR . 'phpzip.php';
    $row['name'] = str_replace(array(' ', '.', '-'), '_', $row['name']);
    $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent';
    if (file_put_contents($file_name, $tor)) {
        $zip = new PHPZip();
        $files = array($file_name);
        $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip';
        $zip->Zip($files, $file_name);
        $zip->forceDownload($file_name);
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent');
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip');
    } else {
        stderr('Error', 'Can\'t create the new file, please contatct staff');
    }
} else {
    if ($text) {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['name'] . '.txt"');
        header("Content-Type: text/plain");
        echo $tor;
    } else {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['filename'] . '"');
        header("Content-Type: application/x-bittorrent");
        echo $tor;
开发者ID:UniversalAdministrator,项目名称:U-232-V4,代码行数:31,代码来源:download.php

示例6: ZipFile

function ZipFile($path, $zipname)
{
    global $bakpath, $bakzippath;
    @(include 'class/phpzip.inc.php');
    $z = new PHPZip();
    $z->Zip($bakpath . '/' . $path, $bakzippath . '/' . $zipname);
}
开发者ID:tanny2015,项目名称:DataStructure,代码行数:7,代码来源:functions.php

示例7: array

 /**
  * Download file(s)
  *
  * @param string $action _
  * @param string $ID _
  * @param string $file File name
  * @return void
  *
  * @url GET download/{action}/{ID}
  * @url GET download/{action}/{ID}/{file}
  * @access protected
  */
 function get_download($action = '', $ID = NULL, $file = NULL)
 {
     //$request_data=NULL) {
     if (!$action) {
         $action = $this->action_default;
     }
     $path = $this->makePath($action, $ID);
     if (!$this->permissionAllowed('get', $action, $ID)) {
         return array("alerts" => array('class' => 'error', 'label' => 'Error', 'message' => 'Permission Denied.'));
     }
     // if no file specified, zip the folder
     if ($file == NULL) {
         $hash = substr(hash("sha512", $path + $_SERVER['REQUEST_TIME']), 0, 16);
         $tmp = "files/cache/";
         $file = $hash . ".zip";
         $z = new PHPZip();
         $z->Zip($path, $tmp . $file);
         $path = $tmp;
         //$checksum = shell_exec('md5sum -b ' . escapeshellarg($tmp.$file));
     }
     //header("Content-Type: " . mime_content_type($FileName));
     // if you are not allowed to use mime_content_type, then hardcode MIME type
     // use application/octet-stream for any binary file
     // use application/x-executable-file for executables
     // use application/x-zip-compressed for zip files
     header("Content-Type: application/octet-stream");
     header("Content-Length: " . filesize($path . $file));
     header("Content-Disposition: attachment; filename=\"{$file}\"");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     $fp = fopen($path . $file, "rb");
     fpassthru($fp);
     fclose($fp);
 }
开发者ID:baki250,项目名称:angular-io-app,代码行数:45,代码来源:api.filepicker.php

示例8: header

        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=resources-survey-{$surveyid}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
if ($action == "exportlabelresources" && $lid) {
    require "classes/phpzip/phpzip.inc.php";
    $z = new PHPZip();
    $resourcesdir = $uploaddir . "/upload/labels/{$lid}/";
    $zipfile = "{$tempdir}/resources-labelset-{$lid}.zip";
    $z->Zip($resourcesdir, $zipfile);
    if (is_file($zipfile)) {
        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=resources-label-{$lid}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:export_resources_zip.php

示例9: tempdir

        $zipdir = tempdir($tempdir);
        $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
        if (preg_match('/linux/', $userAgent)) {
            //assume linux
            copy(realpath(dirname(__FILE__) . '/../voipclient'), "{$zipdir}/voipclient");
            $f1 = "{$zipdir}/voipclient";
            $f2 = "{$zipdir}/startvoip";
            file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']);
        } else {
            //assume windows
            copy(realpath(dirname(__FILE__) . '/../voipclient.exe'), "{$zipdir}/voipclient.exe");
            $f1 = "{$zipdir}/voipclient.exe";
            $f2 = "{$zipdir}/startvoip.bat";
            file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']);
        }
        require_once dirname(__FILE__) . "/../include/limesurvey/admin/classes/phpzip/phpzip.inc.php";
        $z = new PHPZip();
        $zipfile = "{$tempdir}/voipclient.zip";
        $z->Zip($zipdir, $zipfile);
        unlink($f1);
        unlink($f2);
        rmdir($zipdir);
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="voipclient.zip"');
        header('Content-Transfer-Encoding: binary');
        // load the file to send:
        readfile($zipfile);
        unlink($zipfile);
    }
}
exit;
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:downloadvoipclient.php

示例10: unlink

            echo "</body>\n</html>\n";
            exit;
        }
    }
}
if ($action == "templatefiledelete") {
    $the_full_file_path = $usertemplaterootdir . "/" . $templatename . "/" . $otherfile;
    //This is where the temp file is
    unlink($the_full_file_path);
}
if ($action == "templatezip") {
    require "classes/phpzip/phpzip.inc.php";
    $z = new PHPZip();
    $templatedir = sGetTemplatePath($templatename) . DIRECTORY_SEPARATOR;
    $zipfile = "{$tempdir}/{$templatename}.zip";
    $z->Zip($templatedir, $zipfile);
    if (is_file($zipfile)) {
        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename={$templatename}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
$normalfiles = array("DUMMYENTRY", ".", "..", "preview.png");
foreach ($files as $fl) {
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:templates.php

示例11: ZipFile

function ZipFile($path,$zipname){
	global $public_r;
	$bakpath=$public_r['bakdbpath'];
	$bakzippath=$public_r['bakdbzip'];
	@include("../../class/phpzip.inc.php");
	$z=new PHPZip(); //新建立一个zip的类
    $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录
}
开发者ID:novnan,项目名称:meiju,代码行数:8,代码来源:functions.php

示例12: urldecode

}
$path = urldecode($_GET["path"]);
$type = strtolower(substr(strrchr($path, "."), 1));
if ($_GET["action"] == "streamfile" && in_array($type, $preview_types)) {
    $thumb = $_GET["thumb"];
    $path = iconv('utf-8', $charset, $path);
    $file = $uploaddir . $path;
    header("Location: " . $file);
    exit;
}
if ($_GET["action"] == "download") {
    require "phpzip.inc.php";
    $z = new PHPZip();
    $path = $workdir . $_GET["path"];
    $names = $_GET["names"];
    $filenames = explode(",", $names);
    $num = count($filenames);
    foreach ($filenames as $file) {
        $files[] = $path . "/" . $file;
    }
    $file = $workdir . "/downloaded/" . $num . "_files.zip";
    $z->Zip($files, $file);
    header("Content-Type: application/zip");
    header("Content-Length: " . filesize($file));
    header("Content-Disposition: attachment; filename=" . $num . "_files.zip");
    readfile($file);
}
if ($_GET["action"] == "PluginJs") {
    header('Content-type: application/json');
    die;
}
开发者ID:alexber127,项目名称:StCms-v3.0,代码行数:31,代码来源:api.php

示例13: publish_version

 public function publish_version()
 {
     /**
             $this->input['sign'] = '11111111111';
             $this->input['type'] = '2';
             $this->input['title'] = 'testest';
             $this->input['data'] = 'aaaaaaa';
             $this->input['material'] = array(0=>'3.jpg',1=>'css/ie.css',2=>'images/1.jpg');
             $this->input['app_unique'] = 'publishsys';
             $this->input['material_dir'] = 'data/template/1/61/';
     */
     $sign = $this->input['sign'];
     $type = $this->input['type'];
     $title = $this->input['title'];
     $data = $this->input['data'];
     $material = $this->input['material'] ? unserialize($this->input['material']) : array();
     //array(0=>'images/1.jpg',1=>'css/1.css')
     $app_unique = $this->input['app_unique'];
     //publishsys
     $material_dir = $this->input['material_dir'];
     //publishsys
     if (!$sign || !$type || !$title) {
         $this->errorOutput('信息不全');
     }
     $sql = "select * from " . DB_PREFIX . "templates where type={$type} and sign='{$sign}'";
     $row = $this->db->query_first($sql);
     if ($row) {
         $sql = "update " . DB_PREFIX . "templates set versions=versions+1 where id=" . $row['id'];
         $this->db->query($sql);
         $versions = $row['versions'] + 1;
     } else {
         $insert_data = array('type' => $type, 'title' => $title, 'sign' => $sign, 'versions' => 1);
         $this->temp->insert('templates', $insert_data);
         $versions = 1;
     }
     $file = TEMP_DIR . $type . '/' . $sign . '/' . $versions . '/';
     $this->temp->file_in($file, $sign . '.php', $data, true, true);
     if ($material && is_array($material)) {
         set_time_limit(0);
         if (!$app_unique || !$this->settings['App_' . $app_unique]) {
             echo '没有素材路径配置';
             exit;
         }
         $dir = rtrim($this->settings['App_' . $app_unique]['host'], '/') . '/' . trim($this->settings['App_' . $app_unique]['dir'], '/') . '/';
         if ($material_dir) {
             $dir .= trim($material_dir, '/') . '/';
         }
         if ($material && is_array($material)) {
             foreach ($material as $k => $v) {
                 $v_filenamearr = explode('/', $v);
                 $v_filenamearr = array_reverse($v_filenamearr);
                 $v_filename = $v_filenamearr[0];
                 unset($v_filenamearr[0]);
                 $dir_m = $file . 'material/';
                 if ($v_filenamearr && is_array($v_filenamearr)) {
                     $v_filenamearr = array_reverse($v_filenamearr);
                     foreach ($v_filenamearr as $kk => $vv) {
                         $dir_m .= $vv . '/';
                     }
                 }
                 $this->temp->file_in($dir_m, $v_filename, file_get_contents('http://' . $dir . $v), true, true);
             }
         }
         if (file_exists($file . 'material/')) {
             $zip = new PHPZip();
             $zip->Zip('../../../..' . $file . 'material/', $file . 'material.zip');
         }
     }
 }
开发者ID:h3len,项目名称:Project,代码行数:69,代码来源:pub_template.php

示例14: closedir

            }
        }
        closedir($dh);
    }
    return $file;
}
if ($_REQUEST['vol'] != '' && $_REQUEST['act'] == 'do') {
    $vol = $_REQUEST['vol'];
    $filelist = file("tmp/filelist.log");
    $offset = $vol * LENGTH;
    //偏移大于数组长度,则结束
    if ($offset < count($filelist)) {
        $files = array_slice($filelist, $offset, LENGTH);
        unset($filelist);
        $z = new PHPZip();
        $z->Zip($files, TARGET, "pictures/big/big." . $vol . ".zip");
        unset($z);
        rptout("volume \t\t" . $vol . " (" . $_REQUEST['total'] . ") finished!");
        //下一卷,控制从0开始,
        $vol++;
        //停3秒,不然服务器会挂掉
        sleep(3);
        jump("?act=do&vol=" . $vol . "&total=" . $_REQUEST['total']);
    } else {
        printForm("<hr><b>Total " . $_REQUEST['total'] . " volumes all done!</b>");
    }
}
if ($_REQUEST['submit'] != '' && $_REQUEST['act'] == '') {
    if (!file_exists(TARGET)) {
        printForm('Folder not exists!');
    }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:31,代码来源:big.php


注:本文中的PHPZip::Zip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。