Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (39 sloc) 1.21 kb
5677bc4 Jakub Vrána New plugin: Dump ZIP
authored
1 <?php
2
3 /** Dump to ZIP format
4 * @uses ZipArchive, tempnam("")
5 * @author Jakub Vrana, http://www.vrana.cz/
6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
8 */
9 class AdminerDumpZip {
7578342 Jakub Vrána Comment
authored
10 /** @access protected */
544b562 Jakub Vrána Simplify variables
authored
11 var $filename;
5677bc4 Jakub Vrána New plugin: Dump ZIP
authored
12
13 function dumpOutput() {
14 if (!class_exists('ZipArchive')) {
15 return array();
16 }
17 return array('zip' => 'ZIP');
18 }
19
20 function _zip($string, $state) {
544b562 Jakub Vrána Simplify variables
authored
21 static $data = "";
22 $data .= $string;
5677bc4 Jakub Vrána 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
544b562 Jakub Vrána Simplify variables
authored
27 $zip->addFromString($this->filename, $data);
5677bc4 Jakub Vrána 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 Jakub Vrána Simplify variables
authored
37 $this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]);
5677bc4 Jakub Vrána New plugin: Dump ZIP
authored
38 if ($_POST["output"] == "zip") {
39 header("Content-Type: application/zip");
40 }
41 ob_start(array($this, '_zip'));
42 }
43
44 }
Something went wrong with that request. Please try again.