Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 45 lines (39 sloc) 1.253 kB
5677bc4 @vrana New plugin: Dump ZIP
authored
1 <?php
2
3 /** Dump to ZIP format
091a4d0 @vrana Link to documentation
authored
4 * @link http://www.adminer.org/plugins/#use
5677bc4 @vrana New plugin: Dump ZIP
authored
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 {
7578342 @vrana Comment
authored
11 /** @access protected */
f158d5e @vrana Zip dump only if requested
authored
12 var $filename, $data;
5677bc4 @vrana New plugin: Dump ZIP
authored
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) {
f158d5e @vrana Zip dump only if requested
authored
22 $this->data .= $string;
5677bc4 @vrana New plugin: Dump ZIP
authored
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
f158d5e @vrana Zip dump only if requested
authored
27 $zip->addFromString($this->filename, $this->data);
5677bc4 @vrana New plugin: Dump ZIP
authored
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) {
544b562 @vrana Simplify variables
authored
37 $this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]);
5677bc4 @vrana New plugin: Dump ZIP
authored
38 if ($_POST["output"] == "zip") {
39 header("Content-Type: application/zip");
f158d5e @vrana Zip dump only if requested
authored
40 ob_start(array($this, '_zip'));
5677bc4 @vrana New plugin: Dump ZIP
authored
41 }
42 }
43
44 }
Something went wrong with that request. Please try again.