本文整理汇总了PHP中readgzfile函数的典型用法代码示例。如果您正苦于以下问题:PHP readgzfile函数的具体用法?PHP readgzfile怎么用?PHP readgzfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readgzfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uncompress
function uncompress($path = null)
{
ob_start();
readgzfile($path);
$result = ob_get_clean();
return $result;
}
示例2: dcrec
public function dcrec($gameid, $filename = false)
{
$game = Game::getgame($gameid);
$file = $game->get_dcrec();
if ($filename && $filename !== basename($file)) {
app()->show_404();
}
$gz = false;
if (!is_readable($file)) {
$file = $file . ".gz";
if (!is_readable($file)) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403');
die("access denied");
}
$gz = true;
}
$patt = '/\\.gz$/';
$base = basename($file);
//$gz = preg_match($patt, $file);
$name = $gz ? preg_replace($patt, '', $base) : $base;
header('Content-Description: Dedcon Recording');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $name . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
if (!$gz) {
header('Content-Length: ' . filesize($file));
}
ob_clean();
flush();
readgzfile($file);
exit;
}
示例3: gzdecode
public static function gzdecode($data)
{
$g = tempnam('/tmp', 'ff');
@file_put_contents($g, $data);
ob_start();
readgzfile($g);
$d = ob_get_clean();
return $d;
}
示例4: gzdecode
function gzdecode($data)
{
$g = tempnam(APPLICATION_PATH . '/../../data/temp', 'gzip');
@file_put_contents($g, $data);
ob_start();
readgzfile($g);
$d = ob_get_clean();
unlink($g);
return $d;
}
示例5: uncompress
/**
* Uncompress data from package
* @param string $path
*/
public function uncompress($path = null, $callback = null)
{
ob_start();
readgzfile($path);
$result = ob_get_clean();
if ($callback instanceof \Closure) {
return call_user_func_array($callback, array($result));
}
return $result;
}
示例6: my_gzdecode
function my_gzdecode($data)
{
$g = tempnam('', 'gztmp');
@file_put_contents($g, $data);
ob_start();
readgzfile($g);
$d = ob_get_clean();
unlink($g);
return $d;
}
示例7: gzdecode
function gzdecode($data)
{
$file = tempnam("/tmp", "gzip");
@file_put_contents($file, $data);
ob_start();
readgzfile($file);
$data = ob_get_clean();
unlink($file);
return $data;
}
示例8: downloadFile
function downloadFile($fullPath, $filename)
{
// Must be fresh start
if (headers_sent()) {
die('Headers Sent');
}
// Required for some browsers
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// echo `ls -la /`;
// echo `ls -la /home/`;
// echo `ls -la /home/data2/`;
// echo `ls -la /home/data2/secure-upload/`;
// echo `ls -la /home/data2/secure-upload/isolates/`;
// echo `ls -la /home/data2/secure-upload/isolates/*`;
// echo `ls -la /home/data2/secure-upload/isolates/*/0/`;
// echo `ls -la $fullPath`;
// echo $fullPath;
// File Exists?
if (file_exists($fullPath)) {
// $pos = strrpos($filename, '.gz');
// if($pos !== false){
// $filename = substr($filename, 0, $pos);
// };
//header("Pragma: public"); // required
//header("Expires: 0");
//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//header("Cache-Control: private",false); // required for certain browsers
//header("Content-Type: application/force-download");
//header("Content-Disposition: attachment; filename=".$filename.";" );
//header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".filesize($fullPath));
//ob_clean();
//flush();
//readfile( $fullPath );
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename={$filename};");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
// required for certain browsers
header("Expires: 0");
header("Pragma: public");
// required
#header("Content-Length: ".filesize($fullPath));
header("X-Sendfile: {$fullPath}");
ob_clean();
flush();
readgzfile($fullPath);
} else {
die('File Not Found');
}
}
示例9: gzdecode
private static function gzdecode($file)
{
if (!is_file($file)) {
return '';
}
if (function_exists('gzdecode')) {
return gzdecode($file);
}
ob_start();
readgzfile($file);
$content = ob_get_clean();
return $content;
}
示例10: testDumper
public function testDumper()
{
$dumper = new GzFileDumper($this->file);
$dumper->dump('joe');
$dumper->dump('-hell yeah!');
$this->assertTrue(file_exists($this->file));
unset($dumper);
// force the dumper to close the file
// readgzfile reads the content of the file and also prints it...
ob_start();
readgzfile($this->file);
$content = ob_get_contents();
ob_clean();
$this->assertEquals('joe-hell yeah!', $content);
$this->assertNotEquals('joe-hell yeah!', file_get_contents($this->file), 'The file\'s content is compressed');
}
示例11: test_readgzfile
function test_readgzfile()
{
global $scriptFile, $secondFile, $firstFile, $filename;
// create a file in the middle directory
$h = gzopen($secondFile, "w");
gzwrite($h, "This is a file in dir2");
gzclose($h);
// should read dir2 file
echo "file content:";
readgzfile($filename, true);
echo "\n";
//create a file in dir1
$h = gzopen($firstFile, "w");
gzwrite($h, "This is a file in dir1");
gzclose($h);
//should now read dir1 file
echo "file content:";
readgzfile($filename, true);
echo "\n";
// create a file in working directory
$h = gzopen($filename, "w");
gzwrite($h, "This is a file in working dir");
gzclose($h);
//should still read dir1 file
echo "file content:";
readgzfile($filename, true);
echo "\n";
unlink($firstFile);
unlink($secondFile);
//should read the file in working dir
echo "file content:";
readgzfile($filename, true);
echo "\n";
// create a file in the script directory
$h = gzopen($scriptFile, "w");
gzwrite($h, "This is a file in script dir");
gzclose($h);
//should read the file in script dir
echo "file content:";
readgzfile($filename, true);
echo "\n";
//cleanup
unlink($filename);
unlink($scriptFile);
}
示例12: gzdecode
/**
* gzdecode function.
*
* @param mixed $data
* @return mixed
*/
protected function gzdecode($data)
{
do {
$tempName = uniqid('temp ');
} while (file_exists($tempName));
if (file_put_contents($tempName, $data)) {
try {
ob_start();
@readgzfile($tempName);
$uncompressed = ob_get_clean();
} catch (Exception $e) {
$ex = $e;
}
unlink($tempName);
if (isset($ex)) {
throw $ex;
}
return $uncompressed;
}
}
示例13: get_text
/**
* Récupération du texte à indexer dans l'archive
*/
function get_text($filename)
{
$this->zip = zip_open($filename);
if ($this->zip) {
while ($zip_entry = zip_read($this->zip)) {
$t = array();
$tab = explode("/", dirname(zip_entry_name($zip_entry)));
$type_images_doc_num = $tab[count($tab) - 1];
if ($type_images_doc_num == "X") {
if (zip_entry_open($this->zip, $zip_entry, "r")) {
$xmlGz = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$tmpfile = tempnam("/tmp", "ocr");
@file_put_contents($tmpfile, $xmlGz);
ob_start();
readgzfile($tmpfile);
$xml = ob_get_clean();
$xml_dom = new xml_dom($xml, "iso-8859-1");
$textBlocs = @$xml_dom->get_nodes("alto/Layout/Page/PrintSpace/TextBlock");
if ($textBlocs) {
foreach ($textBlocs as $textBloc) {
$textlines = $xml_dom->get_nodes("TextLine", $textBloc);
foreach ($textlines as $textline) {
$strings = $xml_dom->get_nodes("String", $textline);
foreach ($strings as $string) {
$attrs = $xml_dom->get_attributes($string);
foreach ($attrs as $attr => $value) {
if ($attr == 'CONTENT') {
$texte_final .= " " . $value;
}
}
}
}
}
}
}
}
}
}
return $texte_final;
}
示例14: _extract_gz
/**
* Extract gz file
*/
private function _extract_gz($source)
{
$cache_path = $this->_cache_path();
ob_start();
readgzfile($cache_path . $source);
$file_contents = ob_get_contents();
ob_end_clean();
$outname = str_replace('.gz', '', $source);
file_put_contents($cache_path . $outname, $file_contents);
@chmod($cache_path . $outname, FILE_WRITE_MODE);
}
示例15: readgzfile
<?php
readgzfile("mmog.sql.gz");