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


PHP Zip::setZipFile方法代码示例

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


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

示例1: create_zip_Zip

function create_zip_Zip($files = array(), $destination = '')
{
    if (count($files)) {
        //create the archive
        if (file_exists($destination)) {
            unlink($destination);
        }
        $zip = new Zip();
        $zip->setZipFile($destination);
        foreach ($files as $file) {
            $zip->addFile(file_get_contents($file), str_replace('/', '', strrchr($file, '/')));
        }
        $zip->finalize();
        $zip->setZipFile($destination);
        //check to make sure the file exists
        return (string) file_exists($destination);
    } else {
        return "No valid files found. Exiting<br/>";
    }
}
开发者ID:StudentLifeMarketingAndDesign,项目名称:krui-wp,代码行数:20,代码来源:downml_settings_page.php

示例2: isPOMExists

 /**
  * Megnézi, hogy a paraméterben kapott zip file-ban létezik e a pom.xml file.
  * @param string $pin_FileName          A vizsgált zip file
  * @return bool                         Létezik e a pom vagy sem
  */
 public static function isPOMExists(string $pin_FileName) : bool
 {
     $obj_Zip = new Zip();
     $obj_Zip->setZipFile($pin_FileName);
     (array) ($loc_Zip = $obj_Zip->getZipFileContent());
     (array) ($loc_Tmp = array());
     foreach ($loc_Zip as $loc_File) {
         $loc_Tmp = array_merge($loc_Tmp, explode('/', $loc_File));
     }
     if (in_array('pom.xml', $loc_Tmp)) {
         return true;
     }
     return false;
 }
开发者ID:szana8,项目名称:Szakdolgozat,代码行数:19,代码来源:addon.php

示例3: getArchive

 /**
  * Creates a new archive with the specified name and files
  * @param string $name Path to the archive with name and extension
  * @param array $files A numeric array of files
  * @param string $replace
  * @return int How many files has been successfully handled
  */
 public function getArchive($name, array $files, $replace = ABSPATH)
 {
     set_time_limit(300);
     if (!class_exists('Zip', false)) {
         /** @var backupBup $backup */
         $backup = $this->getModule();
         $backup->loadLibrary('zip');
     }
     $zip = new Zip();
     $zip->setZipFile($name);
     foreach ($files as $file) {
         $filename = str_replace($replace, '', $file);
         if (file_exists($file) && is_readable($file) && (substr(basename($file), 0, 3) != 'pcl' && substr($file, -2) != 'gz')) {
             $stream = @fopen($file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, $filename);
             }
         }
     }
     $zip->finalize();
     /* backward */
     return rand(100, 1000);
 }
开发者ID:VSVS,项目名称:vs_wp_4.0,代码行数:30,代码来源:filesystem.php

示例4: ZipArchive

     if (extension_loaded('zip')) {
         $save_to_zip = $export_dir . $export_name . '.zip';
         $zip = new ZipArchive();
         $res = $zip->open($save_to_zip, ZipArchive::CREATE);
         if ($res === TRUE) {
             $zip->addFile($save_to, "{$export_name}.xml");
             $zip->close();
         } else {
             die("{$hesklang['eZIP']} <{$save_to_zip}>\n");
         }
     } elseif (class_exists('ZipArchive')) {
         require HESK_PATH . 'inc/zip/Zip.php';
         $zip = new Zip();
         $zip->addLargeFile($save_to, "{$export_name}.xml");
         $zip->finalize();
         $zip->setZipFile($save_to_zip);
     } else {
         require HESK_PATH . 'inc/zip/pclzip.lib.php';
         $zip = new PclZip($save_to_zip);
         $zip->add($save_to, PCLZIP_OPT_REMOVE_ALL_PATH);
     }
     // Delete XML, just leave the Zip archive
     hesk_unlink($save_to);
     // Echo memory peak usage
     $flush_me .= hesk_date() . " | " . sprintf($hesklang['pmem'], @memory_get_peak_usage(true) / 1048576) . "<br />\r\n";
     // We're done!
     $flush_me .= hesk_date() . " | {$hesklang['fZIP']}<br /><br />";
     $flush_me .= '<a href="' . $save_to_zip . '">' . $hesklang['ch2d'] . "</a>\n";
 } else {
     hesk_unlink($save_to);
 }
开发者ID:riansopian,项目名称:hesk,代码行数:31,代码来源:export.php

示例5: backup_items

 public function backup_items($items)
 {
     $dir = SNS_BACKUPS_PATH . $this->filename;
     if (!class_exists('Zip', false)) {
         require_once SNS_LIB_PATH . 'Zip.php';
     }
     $warns = array('not_readable' => array());
     $zip = new Zip();
     $zip->setZipFile($dir . '.zip');
     self::$zipFile = $zip;
     foreach ($items as $name => $path) {
         if ($name == Sns_Option::DB) {
             $sql_file = SNS_BACKUPS_PATH . 'wp_dump.sql';
             Sns_Log::log_action('Exporting DB');
             Sns_Backup::export_db($sql_file);
             Sns_Log::log_action('Exporting DB', SNS_LOG_END);
             $stream = @fopen($sql_file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, 'wp_dump.sql');
             }
             @unlink($sql_file);
             continue;
         }
         Sns_Log::log_action('Backup item - ' . $name);
         $itemZip = new Zip();
         $itemZip->setZipFile(SNS_BACKUPS_PATH . $name . '.zip');
         $path = realpath($path);
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS));
         $exclude = array(realpath(SNS_BACKUP_ROOT), realpath(SNS_BACKUPS_PATH), realpath(WP_CONTENT_DIR . SNS_DS . 'debug.log'));
         for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
             $file = $iterator->current();
             $continue = false;
             foreach ($exclude as $excludeFile) {
                 if (strpos($file, $excludeFile) !== false) {
                     $continue = true;
                 }
             }
             if ($continue) {
                 continue;
             }
             if (file_exists($file) && is_readable($file)) {
                 $stream = @fopen($file, 'rb');
                 if ($stream) {
                     $file = substr($file, strlen($path));
                     $itemZip->addLargeFile($stream, $file);
                 }
             } else {
                 $warns['not_readable'][] = $file;
             }
         }
         $itemZip->finalize();
         $stream = @fopen(SNS_BACKUPS_PATH . $name . '.zip', 'rb');
         if ($stream) {
             $zip->addLargeFile($stream, $name . '.zip');
         }
         @unlink(SNS_BACKUPS_PATH . $name . '.zip');
         Sns_Log::log_action('Backup item - ' . $name, SNS_LOG_END);
     }
     Sns_Log::log_action('Summarize item backups');
     $zip->finalize();
     Sns_Log::log_action('Summarize item backups', SNS_LOG_END);
     $this->hash;
     $this->filename;
     $this->save();
     return $warns;
 }
开发者ID:eugenehiggins,项目名称:wordpress-intermediate,代码行数:66,代码来源:Sns_Backup.php

示例6: getArchive

 /**
  * Creates a new archive with the specified name and files
  * @param string $name Path to the archive with name and extension
  * @param array $files A numeric array of files
  * @param string $replace
  * @param string $fullPath
  * @return int How many files has been successfully handled
  */
 public function getArchive($name, array $files, $replace = ABSPATH, $fullPath = false)
 {
     set_time_limit(300);
     if (!class_exists('Zip', false)) {
         /** @var backupBup $backup */
         $backup = $this->getModule();
         $backup->loadLibrary('zip');
     }
     $zip = new Zip();
     $zip->setZipFile($name);
     if ($fullPath) {
         $absPath = null;
     } else {
         $absPath = str_replace('/', DS, ABSPATH);
     }
     foreach ($files as $filename) {
         $file = $absPath . $filename;
         if ($fullPath) {
             $file = str_replace('\\\\', DS, $filename);
         }
         if (file_exists($file) && is_readable($file) && (substr(basename($file), 0, 3) != 'pcl' && substr($file, -2) != 'gz')) {
             $stream = @fopen($file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, $filename);
             }
         }
     }
     $zip->finalize();
     if (false !== strpos($name, 'backup_')) {
         // if backup created - remove all temporary files from tmp directory
         $this->clearTmpDirectory();
     }
     /* backward */
     return rand(100, 1000);
 }
开发者ID:carlyns,项目名称:RESUSblog,代码行数:43,代码来源:filesystem.php

示例7: scanner


//.........这里部分代码省略.........
                 // close and save archive
                 $zip->close();
                 //$result['msg'][] = 'Archive created successfully';
             } else {
                 $error_msg = 'Error: Couldnt open ZIP archive.';
                 echo $error_msg;
                 self::UpdateProgressValue($current_task, $total_tasks, $error_msg);
                 if (self::$debug) {
                     self::DebugLog($error_msg);
                 }
                 exit;
             }
         } else {
             $error_msg = 'Error: ZipArchive class is not exist.';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
         }
         $error_msg = 'ZipArchive method - finished';
         if (self::$debug) {
             self::DebugLog($error_msg);
         }
         // Check if zip file exists
         if (!file_exists($file_zip)) {
             $error_msg = 'Error: zip file is not exists. Use OwnZipClass';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $error_msg = 'OwnZipClass method - started';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $zip = new Zip();
             $zip->setZipFile($file_zip);
             foreach ($files_list as $file_name_short) {
                 $file_name = trim($this->scan_path . $file_name_short);
                 $handle = fopen($file_name, "r");
                 if (filesize($file_name) > 0) {
                     $zip->addFile(fread($handle, filesize($file_name)), $file_name_short, filectime($file_name), NULL, TRUE, Zip::getFileExtAttr($file_name));
                 }
                 fclose($handle);
             }
             $zip->finalize();
             $error_msg = 'OwnZipClass method - finished';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $ssh_flag = false;
         }
     }
     // Update progress
     $current_task += 1;
     self::UpdateProgressValue($current_task, $total_tasks, 'Collecting information about the files.');
     /**
      * Send files to SG server
      */
     if ($ssh_flag) {
         $archive_filename = $this->tmp_dir . "pack.tar";
         $archive_format = 'tar';
     } else {
         $archive_filename = $this->tmp_dir . "pack.zip";
         $archive_format = 'zip';
     }
     $error_msg = 'Pack file: ' . $archive_filename;
     if (self::$debug) {
         self::DebugLog($error_msg);
开发者ID:nhathong1204,项目名称:bdshungthinh,代码行数:67,代码来源:scanner.class.php

示例8: date

<?php

// Example. Zip all .html files in the current directory and save to current directory.
// Make a copy, also to the current dir, for good measure.
$fileDir = './';
include_once "Zip.php";
$fileTime = date("D, d M Y H:i:s T");
$zip = new Zip();
$zip->setZipFile("ZipExample.zip");
$zip->setComment("Example Zip file.\nCreated on " . date('l jS \\of F Y h:i:s A'));
$zip->addFile("Hello World!", "hello.txt");
@($handle = opendir($fileDir));
if ($handle) {
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        if (strpos($file, ".html") !== false) {
            $pathData = pathinfo($fileDir . $file);
            $fileName = $pathData['filename'];
            $zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file));
        }
    }
}
$zip->finalize();
// as we are not using getZipData or getZipFile, we need to call finalize ourselves.
$zip->setZipFile("ZipExample2.zip");
?>
<html>
<head>
<title>Zip Test</title>
</head>
<body>
开发者ID:vrtulka23,项目名称:daiquiri,代码行数:31,代码来源:Zip.Example2.php

示例9: Zip

 function download_archive()
 {
     global $wpdb, $current_user;
     if (!is_user_logged_in()) {
         exit;
     }
     $user_ID = $_GET['id'];
     $dir = '' . SP_CDM_UPLOADS_DIR . '' . $user_ID . '/';
     $path = '' . SP_CDM_UPLOADS_DIR_URL . '' . $user_ID . '/';
     $return_file = "Account.zip";
     $zip = new Zip();
     $r = $wpdb->get_results($wpdb->prepare("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where uid = %d  order by date desc", $user_ID), ARRAY_A);
     //@unlink($dir.$return_file);
     for ($i = 0; $i < count($r); $i++) {
         $zip->addFile(file_get_contents($dir . $r[$i]['file']), $r[$i]['file'], filectime($dir . $r[$i]['file']));
     }
     $zip->finalize();
     // as we are not using getZipData or getZipFile, we need to call finalize ourselves.
     $zip->setZipFile($dir . $return_file);
     header("Location: " . $path . $return_file . "");
 }
开发者ID:beafus,项目名称:Living-Meki-Platform,代码行数:21,代码来源:ajax.php

示例10: sp_Admin_uploadFile

function sp_Admin_uploadFile($files, $user_ID)
{
    global $wpdb;
    $dir = '' . SP_CDM_UPLOADS_DIR . '' . $user_ID . '/';
    $count = sp_array_remove_empty($files['dlg-upload-file']['name']);
    if ($history == 1) {
        $dir = '' . SP_CDM_UPLOADS_DIR . '' . $user_ID . '/';
        $filename = '' . sp_client_upload_filename($user_ID) . '' . $files['dlg-upload-file']['name'][0] . '';
        $filename = strtolower($filename);
        $filename = sanitize_file_name($filename);
        $filename = remove_accents($filename);
        $target_path = $dir . $filename;
        move_uploaded_file($files['dlg-upload-file']['tmp_name'][0], $target_path);
        $ext = preg_replace('/^.*\\./', '', $filename);
        if (get_option('sp_cu_user_projects_thumbs_pdf') == 1 && class_exists('imagick')) {
            $info = new Imagick();
            $formats = $info->queryFormats();
            if (in_array(strtoupper($ext), $formats)) {
                cdm_thumbPdf($target_path);
            }
        }
        return $filename;
    } else {
        if (count($count) > 1) {
            //echo $count;
            //	echo '<pre>';
            //print_r($files);exit;
            //echo '</pre>';
            $fileTime = date("D, d M Y H:i:s T");
            $zip = new Zip();
            for ($i = 0; $i < count($files['dlg-upload-file']['name']); $i++) {
                if ($files['dlg-upload-file']['error'][$i] == 0) {
                    $filename = '' . sp_client_upload_filename($user_ID) . '' . $files['dlg-upload-file']['name'][$i] . '';
                    $filename = strtolower($filename);
                    $filename = sanitize_file_name($filename);
                    $filename = remove_accents($filename);
                    $target_path = $dir . $filename;
                    move_uploaded_file($files['dlg-upload-file']['tmp_name'][$i], $target_path);
                    $zip->addFile(file_get_contents($target_path), $filename, filectime($target_path));
                }
            }
            $zip->finalize();
            // as we are not using getZipData or getZipFile, we need to call finalize ourselves.
            $return_file = "" . rand(100000, 100000000000) . "_Archive.zip";
            $zip->setZipFile($dir . $return_file);
            return $return_file;
        } else {
            $dir = '' . SP_CDM_UPLOADS_DIR . '' . $user_ID . '/';
            $filename = '' . sp_client_upload_filename($user_ID) . '' . $files['dlg-upload-file']['name'][1] . '';
            $filename = strtolower($filename);
            $filename = sanitize_file_name($filename);
            $filename = remove_accents($filename);
            $target_path = $dir . $filename;
            move_uploaded_file($files['dlg-upload-file']['tmp_name'][1], $target_path);
            $ext = preg_replace('/^.*\\./', '', $filename);
            if (get_option('sp_cu_user_projects_thumbs_pdf') == 1 && class_exists('imagick')) {
                $info = new Imagick();
                $formats = $info->queryFormats();
                if (in_array(strtoupper($ext), $formats)) {
                    cdm_thumbPdf($target_path);
                }
            }
            return $filename;
        }
    }
}
开发者ID:beafus,项目名称:Living-Meki-Platform,代码行数:66,代码来源:common.php

示例11: header

        header("Location: " . $path . $return_file . "");
        break;
    case "download-archive":
        $user_ID = $_GET['id'];
        $dir = '' . SP_CDM_UPLOADS_DIR . '' . $user_ID . '/';
        $path = '' . SP_CDM_UPLOADS_DIR_URL . '' . $user_ID . '/';
        $return_file = "Account.zip";
        $zip = new Zip();
        $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu   where uid = {$user_ID}  order by date desc", ARRAY_A);
        //@unlink($dir.$return_file);
        for ($i = 0; $i < count($r); $i++) {
            $zip->addFile(file_get_contents($dir . $r[$i]['file']), $r[$i]['file'], filectime($dir . $r[$i]['file']));
        }
        $zip->finalize();
        // as we are not using getZipData or getZipFile, we need to call finalize ourselves.
        $zip->setZipFile($dir . $return_file);
        header("Location: " . $path . $return_file . "");
        break;
    case "email-vendor":
        if (count($_POST['vendor_email']) == 0) {
            echo '<p style="color:red;font-weight:bold">' . __("Please select at least one file!", "sp-cdm") . '</p>';
        } else {
            $files = implode(",", $_POST['vendor_email']);
            $r = $wpdb->get_results("SELECT *  FROM " . $wpdb->prefix . "sp_cu  WHERE id IN (" . $files . ")", ARRAY_A);
            $message .= '

	' . $_POST['vendor-message'] . '<br><br>';
            for ($i = 0; $i < count($r); $i++) {
                if ($r[$i]['name'] == "") {
                    $name = $r[$i]['file'];
                } else {
开发者ID:beafus,项目名称:Living-Meki-Platform,代码行数:31,代码来源:ajax.php


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