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


PHP zipfile::zipped_file方法代码示例

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


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

示例1: createZip

 /**
  * Create ZIP archive.
  *
  * @param   array    $files  An array of files to put in archive.
  * @param   boolean  $save   Whether to save zip data to file or not?
  * @param   string   $name   Name with path to store archive file.
  *
  * @return  mixed  Zip data if $save is FALSE, or boolean value if $save is TRUE
  */
 public static function createZip($files, $save = false, $name = '')
 {
     if (is_array($files) and count($files)) {
         // Initialize variables
         $zip = new zipfile();
         $root = str_replace('\\', '/', JPATH_ROOT);
         foreach ($files as $file) {
             // Add file to zip archive
             if (is_array($file)) {
                 foreach ($file as $k => $v) {
                     $zip->create_file($v, $k);
                 }
             } elseif (is_string($file) and is_readable($file)) {
                 // Initialize file path
                 $file = str_replace('\\', '/', $file);
                 $path = str_replace($root, '', $file);
                 $zip->create_file(JFile::read($file), $path);
             }
         }
         // Save zip archive to file system
         if ($save) {
             if (!JFolder::create($dest = dirname($name))) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_FOLDER_NOT_EXISTS', $dest));
             }
             if (!JFile::write($name, $zip->zipped_file())) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_CANNOT_WRITE_FILE', $name));
             }
             return true;
         } else {
             return $zip->zipped_file();
         }
     }
     return false;
 }
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:43,代码来源:archive.php

示例2: array

     @eval('$t = "ON";');
     $zip->create_file($t, 'evalTest.txt');
     #plugins info
     $zip->create_file(var_export($all_plg_hooks, true), 'hooks_info.txt');
     $zip->create_file(var_export($all_plg_plugins, true), 'plugins_info.txt');
     #ban info
     $zip->create_file(var_export($banss, true), 'ban_info.txt');
     #stats
     $stat_vars = array('stat_files', 'stat_imgs', 'stat_sizes', 'stat_users', 'stat_last_file', 'stat_last_f_del', 'stat_last_google', 'stat_last_bing', 'stat_google_num', 'stat_bing_num', 'stat_last_user');
     $zip->create_file(var_export(compact($stat_vars), true), 'stats.txt');
     unset($stat_vars);
     #push it
     header('Content-Type: application/zip');
     header('X-Download-Options: noopen');
     header('Content-Disposition: attachment; filename="KleejaDataForSupport' . date('dmY') . '.zip"');
     echo $zip->zipped_file();
     $SQL->close();
     exit;
     break;
     //
     //fix tables ..
     //
 //
 //fix tables ..
 //
 case 'tables':
     $query = "SHOW TABLE STATUS";
     $result = $SQL->query($query);
     $text = '';
     while ($row = $SQL->fetch_array($result)) {
         $queryf = "REPAIR TABLE `" . $row['Name'] . "`";
开发者ID:Saleh7,项目名称:Kleeja,代码行数:31,代码来源:r_repair.php

示例3: push

 function push($plg_name)
 {
     $z = new zipfile();
     foreach ($this->files as $filepath => $content) {
         $z->create_file($content, str_replace(PATH, '', $filepath));
     }
     $ff = md5($plg_name);
     //save file to cache and return the cached file name
     $c = $z->zipped_file();
     $fn = @fopen(PATH . 'cache/changes_of_' . $ff . '.zip', 'w');
     fwrite($fn, $c);
     fclose($fn);
     return $ff;
 }
开发者ID:Amine12boutouil,项目名称:Kleeja-2.0.0-alpha,代码行数:14,代码来源:plugins.php

示例4: 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


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