function test_gzopen($mode) { 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); echo "\n** testing with mode={$mode} **\n"; // should read dir2 file $h = gzopen($filename, $mode, true); gzpassthru($h); gzclose($h); 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 $h = gzopen($filename, $mode, true); gzpassthru($h); gzclose($h); 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 $h = gzopen($filename, $mode, true); gzpassthru($h); gzclose($h); echo "\n"; unlink($firstFile); unlink($secondFile); //should read the file in working dir $h = gzopen($filename, $mode, true); gzpassthru($h); gzclose($h); 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 $h = gzopen($filename, $mode, true); gzpassthru($h); gzclose($h); echo "\n"; //cleanup unlink($filename); unlink($scriptFile); }
<?php $f = "temp3.txt.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; gzwrite($h, $str1); echo "tell="; var_dump(gztell($h)); //seek to the end which is not sensible of course. echo "move to the end of the file\n"; var_dump(gzseek($h, 0, SEEK_END)); echo "tell="; var_dump(gztell($h)); gzwrite($h, $str2); echo "tell="; var_dump(gztell($h)); gzclose($h); echo "\nreading the output file\n"; $h = gzopen($f, 'r'); gzpassthru($h); gzclose($h); echo "\n"; unlink($f); ?> ===DONE===
function doPasstrough($closeFile = true) { return @gzpassthru($this->File); }
function doPasstrough($closeFile = true) { $result = @gzpassthru($this->File); if (!$closeFile) { // The file must be reopened because gzpasstru will close the file. $this->File = @gzopen($this->filename(), $this->mode(), $this->isBinaryMode()); } else { $this->File = false; } return $result; }
function readgzfile($fn) { if ($fp = gzopen($fn, "rb")) { gzpassthru($fp); } }
<?php $f = dirname(__FILE__) . "/004.txt.gz"; $h = gzopen($f, 'r'); $extra_arg = 'nothing'; var_dump(gzpassthru($h, $extra_arg)); var_dump(gzpassthru()); gzclose($h); ?> ===DONE===
$json = json_encode($result); echo $json; die(); }*/ if ($atpagina == -1) { if (file_exists('../../../preconsultas/consultas/' . $nome . ".txt.gz")) { // $SQL = "UPDATE cache_tabela SET // acessos = acessos+1, // ultimo_acesso = now() WHERE nome LIKE '$nome' // "; // $bd = new bd(); // $bd->insert($SQL); $myFile = '../../../preconsultas/consultas/' . $nome . ".txt.gz"; //metricas(); $fh = gzopen($myFile, 'r'); $theData = gzpassthru($fh); die; } } if (isset($_POST['json_search_names'])) { $searchName = true; } else { $searchName = false; } $varReturn = false; if (isset($_POST['dataBring']) && $_POST['dataBring'] == "var_only") { $varReturn = true; } //die(var_dump($arrayConsulta)); $ObjConsulta = Consulta::tableParse($arrayConsulta); //die(var_dump($ObjConsulta));
<?php error_reporting(E_ALL); $f = gzopen("ftp://83.247.110.3/traveltime.gz", "r"); ob_start(); gzpassthru($f); $data = ob_get_clean(); $xml = simplexml_load_string(str_replace("soap:", "", $data)); $traveltimes = array(); $timestamp = null; foreach ($xml->Body->d2LogicalModel->payloadPublication->siteMeasurements as $m) { $traveltimes[(string) $m->measurementSiteReference["id"]] = $m->measuredValue->measuredValue->basicData; if ($m->measurementTimeDefault) { $timestamp = (string) $m->measurementTimeDefault; } } $json = json_decode(file_get_contents("ndw-shapefiles-amsterdam.geojson")); foreach ($json->features as $i => $f) { $properties = new stdClass(); $properties->Id = $json->features[$i]->properties->dgl_loc; $properties->Name = $json->features[$i]->properties->naam; $properties->Type = $json->features[$i]->properties->wegtype; $properties->Timestamp = $timestamp; $properties->Length = $json->features[$i]->properties->lengte; if (array_key_exists($f->properties->dgl_loc, $traveltimes)) { $properties->Traveltime = (int) $traveltimes[$f->properties->dgl_loc]->travelTime->duration; if ($properties->Traveltime > 0 && $properties->Length) { $properties->Velocity = round($properties->Length / $properties->Traveltime * 3.6); } } else { //unset($json->features[$i]);
<?php // note that gzpassthru is an alias to fpassthru. parameter checking tests will be // the same as fpassthru $f = dirname(__FILE__) . "/004.txt.gz"; $h = gzopen($f, 'r'); var_dump(gzpassthru($h)); var_dump(gzpassthru($h)); gzclose($h); ?> ===DONE===
/** * Output all remaining data on a gz-file pointer * * @param resource $zp The gz-file pointer. It must be valid, and must point to a file * successfully opened by gzopen. * * @return int */ public function gzpassthru($zp) : int { return gzpassthru($zp); }
function _internalCacheFunc($start, $func = false, $params = false, $moreargs = false, $age = false) { global $cache_age_days, $gzip_page_cache, $enable_page_caching; static $signature_stack = array(); if ($enable_page_caching == "false") { return false; } if ($start) { // START THE CACHE $cacheFile = $this->createCachedPageName($func, $params, $moreargs); // Did they specify an age? if ($age && is_numeric($age)) { $cache_age_days = $age; } if (is_file($cacheFile) and time() - filemtime($cacheFile) < $cache_age_days * 86400) { if ($gzip_page_cache == "true") { $fp = gzopen($cacheFile, 'r'); gzpassthru($fp); } else { include_once $cacheFile; } return true; } else { if (is_object($params)) { writeLogData("messages", "Cache: Building cache for: " . $params->getName() . " type: " . $func); } ob_start(); array_push($signature_stack, $cacheFile); } } else { // END THE CACHE $cacheFile = array_pop($signature_stack); if ($gzip_page_cache == "true") { $fp = gzopen($cacheFile, 'w'); gzwrite($fp, ob_get_contents()); gzclose($fp); } else { $fp = fopen($cacheFile, 'w'); fwrite($fp, ob_get_contents()); fclose($fp); } ob_end_flush(); } }
public function passThru($zp = '') { if (!is_resource($zp)) { return Error::set(lang('Error', 'resourceParameter', '1.(zp)')); } return gzpassthru($zp); }
break; case "gz": $ctype = "application/x-gzip"; break; case "jpeg": case "jpg": $ctype = "image/jpg"; break; default: $ctype = "application/ocet-stream"; } 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: {$ctype}"); // change, added quotes to allow spaces in filenames, by Rajkumar Singh header("Content-Disposition: attachment; filename=\"" . basename($_GET['file']) . "\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($_GET['file'])); ob_clean(); flush(); if (strcmp($info['extension'], 'gz') == 0) { $file = gzopen($_GET['file'], 'r'); gzpassthru($file); gzclose($file); } else { readfile($_GET['file']); }