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


PHP zipfile::read_zip方法代码示例

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


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

示例1: cwget

 }
 $dn = cwget('https://github.com/CuteNews/cute-news-repo/archive/master.zip');
 if ($dn) {
     $w = fopen($update_file_source, 'w');
     if (!$w) {
         create_html_template('Cannot upload the update file ' . $update_file_source);
     }
     if (!fwrite($w, $dn)) {
         create_html_template('Cannot write the update file ' . $update_file_source);
     }
     fclose($w);
 } else {
     create_html_template('Cannot download the update file: https://github.com/CuteNews/cute-news-repo/archive/master.zip');
 }
 $zipfile = new zipfile();
 $zipfile->read_zip($update_file_source);
 foreach ($zipfile->files as $filea) {
     $path = SERVDIR;
     $temp = substr($filea['dir'], 31);
     $pathtofile = !empty($temp) ? $temp . '/' . $filea['name'] : $filea['name'];
     if (array_key_exists($pathtofile, $hashes)) {
         if (file_exists($path . '/' . $pathtofile)) {
             $hash_my = md5_file($path . '/' . $pathtofile);
         } else {
             $hash_my = false;
         }
         if ($hash_my != $hashes[$pathtofile]) {
             foreach (explode('/', $pathtofile) as $dc) {
                 $path .= '/' . $dc;
                 if (strpos($dc, '.') === false) {
                     if (!is_dir($path) && !mkdir($path, 0777)) {
开发者ID:jasmith152,项目名称:Jackie_Davis,代码行数:31,代码来源:update_cutenews.php

示例2: dirname

 function extract_zip($archive, $path = '')
 {
     $basename = false;
     if (substr($archive, -4) == '.zip') {
         if (is_file($archive)) {
             require_once dirname(__FILE__) . '/zip.class.php';
             $basename = substr(basename($archive), 0, -4);
             $zipfile = new zipfile();
             $zipfile->read_zip($archive);
             if (empty($path)) {
                 $path = dirname($archive);
             }
             $path .= '/' . $basename;
             if (!is_dir($path)) {
                 $this->mkdir($path);
             }
             for ($i = 0; isset($zipfile->dirs[$i]); ++$i) {
                 $temp = explode('/', $zipfile->dirs[$i]);
                 $sub_path = $path;
                 for ($j = 0; isset($temp[$j]); ++$j) {
                     if ($temp[$j] != '') {
                         $sub_path .= '/' . $temp[$j];
                         if (!is_dir($sub_path)) {
                             $this->mkdir($sub_path);
                         }
                     }
                 }
             }
             for ($i = 0; isset($zipfile->files[$i]); ++$i) {
                 $this->file_put_contents($path . $zipfile->files[$i]['dir'] . '/' . $zipfile->files[$i]['name'], $zipfile->files[$i]['data']);
             }
         }
     }
     return $basename;
 }
开发者ID:babae,项目名称:etano,代码行数:35,代码来源:fileop.class.php

示例3: dashboard_backup

function dashboard_backup()
{
    $name = '';
    require_once SERVDIR . '/core/zip.class.php';
    if (request_type('POST')) {
        cn_dsi_check();
        $name = trim(preg_replace('/[^a-z0_9_]/i', '', REQ('backup_name')));
        $backup_sysonly = REQ('backup_sysonly');
        if (!$name) {
            cn_throw_message('Enter correct backup name', 'e');
        } else {
            // Do compress files
            $zip = new zipfile();
            if (!$backup_sysonly) {
                $zip->create_dir('news/');
                $zip->create_dir('users/');
                // Compress news
                $news = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'news'));
                foreach ($news as $file) {
                    $data = join('', file(cn_path_construct(SERVDIR, 'cdata', 'news') . $file));
                    $zip->create_file($data, 'news' . DIRECTORY_SEPARATOR . $file);
                }
                // Compress users
                $news = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'users'));
                foreach ($news as $file) {
                    $data = join('', file(cn_path_construct(SERVDIR, 'cdata', 'users') . $file));
                    $zip->create_file($data, 'news' . DIRECTORY_SEPARATOR . $file);
                }
                $files = array('conf.php', 'users.txt');
            } else {
                $files = array('conf.php');
            }
            // Append files
            foreach ($files as $file) {
                $data = join('', file(cn_path_construct(SERVDIR, 'cdata') . $file));
                $zip->create_file($data, $file);
            }
            // write compressed data
            $wb = fopen(cn_path_construct(SERVDIR, 'cdata', 'backup') . $name . '.zip', 'w+');
            fwrite($wb, $zip->zipped_file());
            fclose($wb);
            // backup created
            cn_throw_message('Backup sucessfull created');
            unset($zip);
            $name = '';
        }
    } elseif ($unpack_file = REQ('unpack', 'GET')) {
        cn_dsi_check();
        if (file_exists($cf = cn_path_construct(SERVDIR, 'cdata', 'backup') . $unpack_file . 'zip')) {
            $zip = new zipfile();
            $files = $zip->read_zip(cn_path_construct(SERVDIR, 'cdata', 'backup') . $unpack_file . 'zip');
            unset($zip);
            // replace files from zip-archive
            foreach ($files as $fdata) {
                $file = $fdata['dir'] . DIRECTORY_SEPARATOR . $fdata['name'];
                $w = fopen(cn_path_construct(SERVDIR, 'cdata') . $file, 'w+');
                fwrite($w, $fdata['data']);
                fclose($w);
            }
            unlink($cf);
            cn_throw_message('File decompressed, backup removed');
        } else {
            cn_throw_message('File [' . cn_htmlspecialchars($unpack_file) . '] not exists', 'e');
        }
    }
    $archives = array();
    $list = scan_dir(cn_path_construct(SERVDIR, 'cdata', 'backup'), '\\.zip');
    foreach ($list as $d) {
        $file = cn_path_construct(SERVDIR, 'cdata', 'backup') . $d;
        $archives[] = array('name' => str_replace('.zip', '', $d), 'size' => filesize($file), 'date' => date('Y-m-d H:i:s', filemtime($file)));
    }
    cn_assign('archives, name', $archives, $name);
    echoheader('-@dashboard/style.css', 'Backups');
    echo exec_tpl('dashboard/backups');
    echofooter();
}
开发者ID:JulioCF,项目名称:cutenews-2.0,代码行数:76,代码来源:dashboard.php

示例4: array

    $mcodes[$rsrow['module_code']] = $rsrow['version'];
}
// read the manifests of existing packages into $packages
$packages = array();
$d = dir(_BASEPATH_ . '/tmp/packages');
$i = 0;
$filenames = array();
while (false !== ($entry = $d->read())) {
    if (substr($entry, -4) == '.zip') {
        $filename = substr($entry, 0, -4);
        if (is_file(_BASEPATH_ . '/tmp/packages/' . $filename . '.info')) {
            $filenames[$i] = $entry;
            $packages[$i++] = _BASEPATH_ . '/tmp/packages/' . $filename . '.info';
        } else {
            // read the manifest from the zip file
            $zipfile->read_zip(_BASEPATH_ . '/tmp/packages/' . $entry);
            $found = false;
            $manifest_content = '';
            foreach ($zipfile->files as $zfile) {
                if ($zfile['name'] == 'manifest.xml' && $zfile['dir'] == '/') {
                    $found = true;
                    $filenames[$i] = $entry;
                    $manifest_content = $zfile['data'];
                    break;
                }
            }
            if ($found) {
                // now save it as a separate file to speed things up next time
                $fileop->file_put_contents(_BASEPATH_ . '/tmp/packages/' . $filename . '.info', $manifest_content);
                $packages[$i++] = _BASEPATH_ . '/tmp/packages/' . $filename . '.info';
            }
开发者ID:babae,项目名称:etano,代码行数:31,代码来源:packages.php


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