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


PHP zipfile::get方法代码示例

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


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

示例1: fwrite

             $zipfile->store('yacs/' . $file, Safe::filemtime($file_path . $file), $content);
         }
         // to be included in tar file as well
         $all_files[] = $file_path . $file;
     } else {
         $context['text'] .= BR . 'cannot read ' . $file_path . $file;
     }
     // avoid timeouts
     if (!($index++ % 50)) {
         Safe::set_time_limit(30);
         SQL::ping();
     }
 }
 // save the zipfile
 if ($handle = Safe::fopen($context['path_to_root'] . $file_name . '.zip', 'wb')) {
     fwrite($handle, $zipfile->get());
     fclose($handle);
     $context['text'] .= BR . Skin::build_link($file_name . '.zip', $file_name . '.zip', 'basic');
 }
 // start the tar file
 include_once '../included/tar.php';
 $tarfile = new Archive_Tar($context['path_to_root'] . $file_name . '.tgz');
 // extend the tar file as well
 if ($tarfile->createModify($all_files, '', $file_path)) {
     $context['text'] .= BR . Skin::build_link($file_name . '.tgz', $file_name . '.tgz', 'basic');
 }
 $context['text'] .= "</p>\n";
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
 $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
 // forward to the index page
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:build.php

示例2: foreach

     $items = Files::list_by_date_for_anchor($type . ':' . $id, 0, 20, 'raw');
 }
 // archive each file
 $file_path = $context['path_to_root'] . Files::get_path($type . ':' . $id);
 foreach ($items as $id => $attributes) {
     // read file content
     if ($content = Safe::file_get_contents($file_path . '/' . $attributes['file_name'], 'rb')) {
         // add the binary data
         $zipfile->deflate($attributes['file_name'], Safe::filemtime($file_path . '/' . $attributes['file_name']), $content);
     }
 }
 //
 // transfer to the user agent
 //
 // send the archive content
 if ($archive = $zipfile->get()) {
     // suggest a download
     Safe::header('Content-Type: application/octet-stream');
     // suggest a name for the saved file
     $file_name = utf8::to_ascii($item['title']) . '.zip';
     Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
     // file size
     Safe::header('Content-Length: ' . strlen($archive));
     // already encoded
     Safe::header('Content-Transfer-Encoding: binary');
     // enable 30-minute caching (30*60 = 1800), even through https, to help IE on download
     http::expire(1800);
     // strong validator
     $etag = '"' . md5($archive) . '"';
     // manage web cache
     if (http::validate(NULL, $etag)) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch_all.php

示例3:

            // read file content
            if (($content = Safe::file_get_contents($file_prefix . $file)) !== FALSE) {
                // store binary data
                $zipfile->store($file, Safe::filemtime($file_prefix . $file), $content);
                // avoid timeouts
                if (!($index++ % 50)) {
                    Safe::set_time_limit(30);
                    SQL::ping();
                }
            }
        }
        // suggest a download
        Safe::header('Content-Type: application/zip');
        Safe::header('Content-Disposition: attachment; filename="backup_' . $context['skin'] . '.zip"');
        // send the archive content
        echo $zipfile->get();
        // do not allow for regular rendering
        return;
        // no file
    } else {
        $context['text'] .= BR . i18n::s('No item has been found.') . '</p>' . "\n";
    }
    // select the operation to perform
} else {
    // the splash label
    $context['text'] .= '<p>' . i18n::s('Please select the action to perform.') . "</p>\n";
    // backup
    $context['text'] .= Skin::build_block(i18n::s('Backup database content'), 'title');
    // introductory text
    $context['text'] .= '<p>' . i18n::s('This script will generate SQL statements necessary to rebuild your database from scratch. Please file it at your computer for backup purpose.') . "</p>\n";
    // backup optimization
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:backup.php


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