Completed
Pull Request — master (#2)
by Michael
07:48
created

include/plugins/dump-bz2.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/** Dump to Bzip2 format
4
* @link https://www.adminer.org/plugins/#use
5
* @uses bzopen(), 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 AdminerDumpBz2 {
11
	/** @access protected */
12
	var $filename, $fp;
13
	
14
	function dumpOutput() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
		if (!function_exists('bzopen')) {
16
			return array();
17
		}
18
		return array('bz2' => 'bzip2');
19
	}
20
	
21
	function _bz2($string, $state) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
		bzwrite($this->fp, $string);
23
		if ($state & PHP_OUTPUT_HANDLER_END) {
24
			bzclose($this->fp);
25
			$return = file_get_contents($this->filename);
26
			unlink($this->filename);
27
			return $return;
28
		}
29
		return '';
30
	}
31
	
32
	function dumpHeaders($identifier, $multi_table = false) {
0 ignored issues
show
The parameter $identifier is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $multi_table is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
		if ($_POST['output'] == 'bz2') {
34
			$this->filename = tempnam('', 'bz2');
35
			$this->fp = bzopen($this->filename, 'w');
36
			header('Content-Type: application/x-bzip');
37
			ob_start(array($this, '_bz2'), 1e6);
38
		}
39
	}
40
41
}
42