Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 44 lines (39 sloc) 1.253 kb
5677bc4d »
2011-02-17 New plugin: Dump ZIP
1 <?php
2
3 /** Dump to ZIP format
091a4d04 »
2012-06-30 Link to documentation
4 * @link http://www.adminer.org/plugins/#use
5677bc4d »
2011-02-17 New plugin: Dump ZIP
5 * @uses ZipArchive, tempnam("")
6 * @author Jakub Vrana, http://www.vrana.cz/
7 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
9 */
10 class AdminerDumpZip {
75783421 »
2011-08-11 Comment
11 /** @access protected */
f158d5e3 »
2012-06-29 Zip dump only if requested
12 var $filename, $data;
5677bc4d »
2011-02-17 New plugin: Dump ZIP
13
14 function dumpOutput() {
15 if (!class_exists('ZipArchive')) {
16 return array();
17 }
18 return array('zip' => 'ZIP');
19 }
20
21 function _zip($string, $state) {
f158d5e3 »
2012-06-29 Zip dump only if requested
22 $this->data .= $string;
5677bc4d »
2011-02-17 New plugin: Dump ZIP
23 if ($state & PHP_OUTPUT_HANDLER_END) {
24 $zip = new ZipArchive;
25 $zipFile = tempnam("", "zip");
26 $zip->open($zipFile, ZipArchive::OVERWRITE); // php://output is not supported
f158d5e3 »
2012-06-29 Zip dump only if requested
27 $zip->addFromString($this->filename, $this->data);
5677bc4d »
2011-02-17 New plugin: Dump ZIP
28 $zip->close();
29 $return = file_get_contents($zipFile);
30 unlink($zipFile);
31 return $return;
32 }
33 return "";
34 }
35
36 function dumpHeaders($identifier, $multi_table = false) {
544b562c »
2011-02-18 Simplify variables
37 $this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]);
5677bc4d »
2011-02-17 New plugin: Dump ZIP
38 if ($_POST["output"] == "zip") {
39 header("Content-Type: application/zip");
f158d5e3 »
2012-06-29 Zip dump only if requested
40 ob_start(array($this, '_zip'));
5677bc4d »
2011-02-17 New plugin: Dump ZIP
41 }
42 }
43
44 }
Something went wrong with that request. Please try again.