function restore($filename) { $zp = gzopen($filename, "r"); // output until end of the file and close it. $buffer = ""; while (!gzeof($zp)) { $buffer .= gzgetss($zp, 4096); } gzclose($zp); $explodesql = explode(";\n", $buffer); //what are we going to do if the file gets really big ??? foreach ($explodesql as $id => $sql) { if (trim($sql) != "") { if ($this->debug) { echo $this->debugmsg("Executing {$sql} ..."); } $this->exec($sql); } } $this->commit(); if ($this->debug) { echo $this->debugmsg("{$filename} successfully restored ...", "blue"); } }
$f = fopen($tmpfile, "w"); fwrite($f, $zipped); fclose($f); var_dump(readgzfile($tmpfile)); $zipped = gzencode("testing gzencode"); VS(gzdecode($zipped), "testing gzencode"); $f = gzopen($tmpfile, "w"); VERIFY($f !== false); gzputs($f, "testing gzputs\n"); gzwrite($f, "<html>testing gzwrite</html>\n"); gzclose($f); $f = gzopen($tmpfile, "r"); VS(gzread($f, 7), "testing"); VS(gzgetc($f), " "); VS(gzgets($f), "gzputs\n"); VS(gzgetss($f), "testing gzwrite\n"); VS(gztell($f), 44); VERIFY(gzeof($f)); VERIFY(gzrewind($f)); VS(gztell($f), 0); VERIFY(!gzeof($f)); gzseek($f, -7, SEEK_END); VS(gzgets($f), "testing gzputs\n"); gzclose($f); $f = gzopen(__DIR__ . "/test_ext_zlib.gz", "r"); gzpassthru($f); $compressable = str_repeat('A', 1024); $s = $compressable; $t = nzcompress($s); VERIFY(strlen($t) < strlen($s)); $u = nzuncompress($t);
public function getCleanLine($zp = '') { if (!is_resource($zp)) { return Error::set(lang('Error', 'resourceParameter', '1.(zp)')); } return gzgetss($zp); }