function extract_file_from_tarball($pkg, $filename, $dest_dir) { global $packages; $name = $pkg . '-' . $packages[$pkg]; $tarball = $dest_dir . "/" . $name . '.tgz'; $filename = $name . '/' . $filename; $destfilename = $dest_dir . "/" . basename($filename); $fp = gzopen($tarball, 'rb'); $done = false; do { /* read the header */ $hdr_data = gzread($fp, 512); if (strlen($hdr_data) == 0) { break; } $checksum = 0; for ($i = 0; $i < 148; $i++) { $checksum += ord($hdr_data[$i]); } for ($i = 148; $i < 156; $i++) { $checksum += 32; } for ($i = 156; $i < 512; $i++) { $checksum += ord($hdr_data[$i]); } $hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data); $hdr['checksum'] = octdec(trim($hdr['checksum'])); if ($hdr['checksum'] != $checksum) { echo "Checksum for {$tarball} {$hdr['filename']} is invalid\n"; print_r($hdr); return; } $hdr['size'] = octdec(trim($hdr['size'])); echo "File: {$hdr['filename']} {$hdr['size']}\n"; if ($filename == $hdr['filename']) { echo "Found the file we want\n"; $dest = fopen($destfilename, 'wb'); $x = stream_copy_to_stream($fp, $dest, $hdr['size']); fclose($dest); echo "Wrote {$x} bytes into {$destfilename}\n"; break; } /* skip body of the file */ $size = 512 * ceil((int) $hdr['size'] / 512); echo "Skipping {$size} bytes\n"; gzseek($fp, gztell($fp) + $size); } while (!$done); }
function _getOffset($p_len = null) { $ofset = null; if (is_resource($this->_file)) { if ($p_len === null) { $p_len = 512; } if ($this->_compress_type == 'gz') { $ofset = @gztell($this->_file) / $p_len; } else { if ($this->_compress_type == 'bz2') { // ----- Replace missing bztell() and bzseek() $ofset = 0; } else { if ($this->_compress_type == 'none') { $ofset = @ftell($this->_file) / $p_len; } else { $this->_error('Unknown or missing compression type (' . $this->_compress_type . ')'); } } } } return floor($ofset); }
SQLError($sqlCommand, $sqlError); $restore['restore_in_progress'] = 0; die; // TODO clean end of process - last message is not // logged on restore screen and // not sent back to client. Flag missing here that // should be handled via JSON } } } } } $timeElapsed = time() - $restore['page_start_time']; } if ($restore['compressed']) { $restore['offset'] = gztell($restore['filehandle']); gzclose($restore['filehandle']); } else { $restore['offset'] = ftell($restore['filehandle']); fclose($restore['filehandle']); } $restore['page_refreshs']++; // progress of actual file if ($restore['compressed']) { // compressed backup - there is no way to get the exact file offset, // because gztell delivers uncompressed bytes // so we assume the average packing factor is 11 and will divide the file // offset by it $restore['progress_file_percent'] = $restore['offset'] / 11 * 100 / $filesize; if ($restore['progress_file_percent'] > 100) { $restore['progress_file_percent'] = 100;
<?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 _jumpBlock($p_len = null) { if (is_resource($this->_file)) { if ($p_len === null) { $p_len = 1; } if ($this->_compress_type == 'gz') { @gzseek($this->_file, @gztell($this->_file) + $p_len * 512); } else { if ($this->_compress_type == 'bz2') { // ----- Replace missing bztell() and bzseek() for ($i = 0; $i < $p_len; $i++) { $this->_readBlock(); } } else { if ($this->_compress_type == 'none') { @fseek($this->_file, @ftell($this->_file) + $p_len * 512); } else { $this->_error('Unknown or missing compression type (' . $this->_compress_type . ')'); } } } } return true; }
function PclTarHandleUpdate($p_tarname, $p_file_list, &$p_list_detail, $p_tar_mode, $p_add_dir, $p_remove_dir) { TrFctStart(__FILE__, __LINE__, "PclTarHandleUpdate", "archive='{$p_tarname}', list, tar_mode={$p_tar_mode}"); $v_result = 1; $v_nb = 0; $v_found_list = array(); // ----- Look for regular tar file if ($p_tar_mode == "tar") { // ----- Open file TrFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_tar = @fopen($p_tarname, "rb")) == 0) { // ----- Error log PclErrorLog(-2, "Unable to open file '{$p_tarname}' in binary read mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Open a temporary file in write mode $v_temp_tarname = uniqid("pcltar-") . ".tmp"; TrFctMessage(__FILE__, __LINE__, 2, "Creating temporary archive file {$v_temp_tarname}"); if (($v_temp_tar = @fopen($v_temp_tarname, "wb")) == 0) { // ----- Close tar file fclose($v_tar); // ----- Error log PclErrorLog(-1, "Unable to open file '{$v_temp_tarname}' in binary write mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } } else { // ----- Open the file in read mode TrFctMessage(__FILE__, __LINE__, 3, "Open file in gzip binary read mode"); if (($v_tar = @gzopen($p_tarname, "rb")) == 0) { // ----- Error log PclErrorLog(-2, "Unable to open file '{$p_tarname}' in binary read mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Open a temporary file in write mode $v_temp_tarname = uniqid("pcltar-") . ".tmp"; TrFctMessage(__FILE__, __LINE__, 2, "Creating temporary archive file {$v_temp_tarname}"); if (($v_temp_tar = @gzopen($v_temp_tarname, "wb")) == 0) { // ----- Close tar file gzclose($v_tar); // ----- Error log PclErrorLog(-1, "Unable to open file '{$v_temp_tarname}' in binary write mode"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } } // ----- Prepare the list of files for ($i = 0; $i < sizeof($p_file_list); $i++) { // ----- Reset the found list $v_found_list[$i] = 0; // ----- Calculate the stored filename $v_stored_list[$i] = $p_file_list[$i]; if ($p_remove_dir != "") { if (substr($p_file_list[$i], -1) != '/') { $p_remove_dir .= "/"; } if (substr($p_file_list[$i], 0, strlen($p_remove_dir)) == $p_remove_dir) { $v_stored_list[$i] = substr($p_file_list[$i], strlen($p_remove_dir)); TrFctMessage(__FILE__, __LINE__, 3, "Remove path '{$p_remove_dir}' in file '{$p_file_list[$i]}' = '{$v_stored_list[$i]}'"); } } if ($p_add_dir != "") { if (substr($p_add_dir, -1) == "/") { $v_stored_list[$i] = $p_add_dir . $v_stored_list[$i]; } else { $v_stored_list[$i] = $p_add_dir . "/" . $v_stored_list[$i]; } TrFctMessage(__FILE__, __LINE__, 3, "Add path '{$p_add_dir}' in file '{$p_file_list[$i]}' = '{$v_stored_list[$i]}'"); } $v_stored_list[$i] = PclTarHandlePathReduction($v_stored_list[$i]); TrFctMessage(__FILE__, __LINE__, 3, "After reduction '{$v_stored_list[$i]}'"); } // ----- Update file cache clearstatcache(); // ----- Read the blocks while (!($v_end_of_file = $p_tar_mode == "tar" ? feof($v_tar) : gzeof($v_tar))) { TrFctMessage(__FILE__, __LINE__, 3, "Looking for next header ..."); // ----- Clear cache of file infos clearstatcache(); // ----- Reset current found filename $v_current_filename = ""; // ----- Reset delete tag $v_delete_file = FALSE; // ----- Read the first 512 block header if ($p_tar_mode == "tar") { $v_binary_data = fread($v_tar, 512); } else { $v_binary_data = gzread($v_tar, 512); } // ----- Read the header properties if (($v_result = PclTarHandleReadHeader($v_binary_data, $v_header)) != 1) { // ----- Close the archive file if ($p_tar_mode == "tar") { fclose($v_tar); fclose($v_temp_tar); } else { gzclose($v_tar); gzclose($v_temp_tar); } @unlink($v_temp_tarname); // ----- Return TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look for empty blocks to skip if ($v_header[filename] == "") { TrFctMessage(__FILE__, __LINE__, 2, "Empty block found. End of archive ?"); continue; } TrFctMessage(__FILE__, __LINE__, 2, "Found file '{$v_header['filename']}', size '{$v_header['size']}'"); // ----- Look for filenames to update for ($i = 0, $v_update_file = FALSE, $v_found_file = FALSE; $i < sizeof($v_stored_list) && !$v_update_file; $i++) { TrFctMessage(__FILE__, __LINE__, 4, "Compare with file '{$v_stored_list[$i]}'"); // ----- Compare the file names if ($v_stored_list[$i] == $v_header[filename]) { TrFctMessage(__FILE__, __LINE__, 3, "File '{$v_stored_list[$i]}' is present in archive"); TrFctMessage(__FILE__, __LINE__, 3, "File '{$v_stored_list[$i]}' mtime=" . filemtime($p_file_list[$i]) . " " . date("l dS of F Y h:i:s A", filemtime($p_file_list[$i]))); TrFctMessage(__FILE__, __LINE__, 3, "Archived mtime=" . $v_header[mtime] . " " . date("l dS of F Y h:i:s A", $v_header[mtime])); // ----- Store found informations $v_found_file = TRUE; $v_current_filename = $p_file_list[$i]; // ----- Look if the file need to be updated if (filemtime($p_file_list[$i]) > $v_header[mtime]) { TrFctMessage(__FILE__, __LINE__, 3, "File '{$p_file_list[$i]}' need to be updated"); $v_update_file = TRUE; } else { TrFctMessage(__FILE__, __LINE__, 3, "File '{$p_file_list[$i]}' does not need to be updated"); $v_update_file = FALSE; } // ----- Flag the name in order not to add the file at the end $v_found_list[$i] = 1; } else { TrFctMessage(__FILE__, __LINE__, 4, "File '{$p_file_list[$i]}' is not '{$v_header['filename']}'"); } } // ----- Copy files that do not need to be updated if (!$v_update_file) { TrFctMessage(__FILE__, __LINE__, 2, "Keep file '{$v_header['filename']}'"); // ----- Write the file header if ($p_tar_mode == "tar") { fputs($v_temp_tar, $v_binary_data, 512); } else { gzputs($v_temp_tar, $v_binary_data, 512); } // ----- Write the file data $n = ceil($v_header[size] / 512); for ($j = 0; $j < $n; $j++) { TrFctMessage(__FILE__, __LINE__, 3, "Read complete 512 bytes block number " . ($j + 1)); if ($p_tar_mode == "tar") { $v_content = fread($v_tar, 512); fwrite($v_temp_tar, $v_content, 512); } else { $v_content = gzread($v_tar, 512); gzwrite($v_temp_tar, $v_content, 512); } } // ----- File name and properties are logged if listing mode or file is extracted TrFctMessage(__FILE__, __LINE__, 2, "Memorize info about file '{$v_header['filename']}'"); // ----- Add the array describing the file into the list $p_list_detail[$v_nb] = $v_header; $p_list_detail[$v_nb][status] = $v_found_file ? "not_updated" : "ok"; // ----- Increment $v_nb++; } else { // ----- Trace TrFctMessage(__FILE__, __LINE__, 2, "Start update of file '{$v_current_filename}'"); // ----- Store the old file size $v_old_size = $v_header[size]; // ----- Add the file if (($v_result = PclTarHandleAddFile($v_temp_tar, $v_current_filename, $p_tar_mode, $v_header, $p_add_dir, $p_remove_dir)) != 1) { // ----- Close the tarfile if ($p_tar_mode == "tar") { fclose($v_tar); fclose($v_temp_tar); } else { gzclose($v_tar); gzclose($v_temp_tar); } @unlink($p_temp_tarname); // ----- Return status TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Trace TrFctMessage(__FILE__, __LINE__, 2, "Skip old file '{$v_header['filename']}'"); // ----- Jump to next file if ($p_tar_mode == "tar") { fseek($v_tar, ftell($v_tar) + ceil($v_old_size / 512) * 512); } else { gzseek($v_tar, gztell($v_tar) + ceil($v_old_size / 512) * 512); } // ----- Add the array describing the file into the list $p_list_detail[$v_nb] = $v_header; $p_list_detail[$v_nb][status] = "updated"; // ----- Increment $v_nb++; } // ----- Look for end of file if ($p_tar_mode == "tar") { $v_end_of_file = feof($v_tar); } else { $v_end_of_file = gzeof($v_tar); } } // ----- Look for files that does not exists in the archive and need to be added for ($i = 0; $i < sizeof($p_file_list); $i++) { // ----- Look if file not found in the archive if (!$v_found_list[$i]) { TrFctMessage(__FILE__, __LINE__, 3, "File '{$p_file_list[$i]}' need to be added"); // ----- Add the file if (($v_result = PclTarHandleAddFile($v_temp_tar, $p_file_list[$i], $p_tar_mode, $v_header, $p_add_dir, $p_remove_dir)) != 1) { // ----- Close the tarfile if ($p_tar_mode == "tar") { fclose($v_tar); fclose($v_temp_tar); } else { gzclose($v_tar); gzclose($v_temp_tar); } @unlink($p_temp_tarname); // ----- Return status TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Add the array describing the file into the list $p_list_detail[$v_nb] = $v_header; $p_list_detail[$v_nb][status] = "added"; // ----- Increment $v_nb++; } else { TrFctMessage(__FILE__, __LINE__, 3, "File '{$p_file_list[$i]}' was already updated if needed"); } } // ----- Write the last empty buffer PclTarHandleFooter($v_temp_tar, $p_tar_mode); // ----- Close the tarfile if ($p_tar_mode == "tar") { fclose($v_tar); fclose($v_temp_tar); } else { gzclose($v_tar); gzclose($v_temp_tar); } // ----- Unlink tar file if (!@unlink($p_tarname)) { // ----- Error log PclErrorLog(-11, "Error while deleting archive name {$p_tarname}"); } // ----- Rename tar file if (!@rename($v_temp_tarname, $p_tarname)) { // ----- Error log PclErrorLog(-12, "Error while renaming temporary file {$v_temp_tarname} to archive name {$p_tarname}"); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Return TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; }
function _seek($p_flen, $tell = 0) { if ($this->_nomf === TarLib::ARCHIVE_DYNAMIC) { $this->_memdat = substr($this->_memdat, 0, ($tell ? strlen($this->_memdat) : 0) + $p_flen); } elseif ($this->_comptype == TarLib::COMPRESS_GZIP) { @gzseek($this->_fp, ($tell ? @gztell($this->_fp) : 0) + $p_flen); } elseif ($this->_comptype == TarLib::COMPRESS_BZIP) { @fseek($this->_fp, ($tell ? @ftell($this->_fp) : 0) + $p_flen); } else { @fseek($this->_fp, ($tell ? @ftell($this->_fp) : 0) + $p_flen); } }
/** Restore a mysql dump * * @param $DB DB object * @param $dumpFile dump file * @param $duree max delay before refresh **/ function restoreMySqlDump($DB, $dumpFile, $duree) { global $DB, $TPSCOUR, $offset, $cpt; // $dumpFile, fichier source // $duree=timeout pour changement de page (-1 = aucun) // Desactivation pour empecher les addslashes au niveau de la creation des tables // En plus, au niveau du dump on considere qu'on est bon // set_magic_quotes_runtime(0); if (!file_exists($dumpFile)) { echo sprintf(__('File %s not found.'), $dumpFile) . "<br>"; return false; } if (substr($dumpFile, -2) == "gz") { $fileHandle = gzopen($dumpFile, "rb"); } else { $fileHandle = fopen($dumpFile, "rb"); } if (!$fileHandle) { //TRASN: %s is the name of the file echo sprintf(__('Unauthorized access to the file %s'), $dumpFile) . "<br>"; return false; } if ($offset != 0) { if (substr($dumpFile, -2) == "gz") { if (gzseek($fileHandle, $offset, SEEK_SET) != 0) { //erreur //TRANS: %s is the number of the byte printf(__("Unable to find the byte %s"), Html::formatNumber($offset, false, 0)); echo "<br>"; return false; } } else { if (fseek($fileHandle, $offset, SEEK_SET) != 0) { //erreur //TRANS: %s is the number of the byte printf(__("Unable to find the byte %s"), Html::formatNumber($offset, false, 0)); echo "<br>"; return false; } } Html::glpi_flush(); } $formattedQuery = ""; if (substr($dumpFile, -2) == "gz") { while (!gzeof($fileHandle)) { current_time(); if ($duree > 0 && $TPSCOUR >= $duree) { //on atteint la fin du temps imparti return true; } // specify read length to be able to read long lines $buffer = gzgets($fileHandle, 102400); // do not strip comments due to problems when # in begin of a data line $formattedQuery .= $buffer; if (substr(rtrim($formattedQuery), -1) == ";") { // Do not use the $DB->query if ($DB->query($formattedQuery)) { //if no success continue to concatenate $offset = gztell($fileHandle); $formattedQuery = ""; $cpt++; } } } } else { while (!feof($fileHandle)) { current_time(); if ($duree > 0 && $TPSCOUR >= $duree) { //on atteint la fin du temps imparti return true; } // specify read length to be able to read long lines $buffer = fgets($fileHandle, 102400); // do not strip comments due to problems when # in begin of a data line $formattedQuery .= $buffer; if (substr(rtrim($formattedQuery), -1) == ";") { // Do not use the $DB->query if ($DB->query($formattedQuery)) { //if no success continue to concatenate $offset = ftell($fileHandle); $formattedQuery = ""; $cpt++; } } } } if ($DB->error) { echo "<hr>"; //TRANS: %s is the SQL query which generates the error printf(__("SQL error starting from %s"), "[{$formattedQuery}]"); echo "<br>" . $DB->error() . "<hr>"; } if (substr($dumpFile, -2) == "gz") { gzclose($fileHandle); } else { fclose($fileHandle); } $offset = -1; return true; }
function Skip($Block = 0) { if (!$Block) return false; $pos = $this->gzip ? gztell($this->res) : ftell($this->res); if (file_exists($this->getNextName())) { while(($BlockLeft = ($this->getArchiveSize($this->file) - $pos)/512) < $Block) { if ($BlockLeft != floor($BlockLeft)) return false; // invalid file size $this->Block += $BlockLeft; $Block -= $BlockLeft; if (!$this->openNext()) return false; $pos = 0; } } $this->Block += $Block; return 0 === ($this->gzip ? gzseek($this->res,$pos + $Block*512) : fseek($this->res,$pos + $Block*512)); }
public function tell() { if (is_null($this->handle)) { return false; } return gztell($this->handle); }
$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); VS($u, $s); $compressable = str_repeat('\\0', 1024); $bs = $compressable; $bt = nzcompress($bs);
/** * Returns the current position of the file read/write pointer. * * @return mixed * * @since 1.0 * @throws \RuntimeException */ public function tell() { if (!$this->fh) { throw new \RuntimeException('File not open'); } // Capture PHP errors $php_errormsg = ''; $track_errors = ini_get('track_errors'); ini_set('track_errors', true); switch ($this->processingmethod) { case 'gz': $res = gztell($this->fh); break; case 'bz': case 'f': default: $res = ftell($this->fh); break; } // May return 0 so check if it's really false if ($res === false) { throw new \RuntimeException($php_errormsg); } // Restore error tracking to what it was before ini_set('track_errors', $track_errors); // Return the result return $res; }
function restoreMySqlDump_old($dumpFile, $duree) { // $dumpFile, fichier source // $duree=timeout pour changement de page (-1 = aucun) global $TPSCOUR, $offset, $cpt, $erreur_mysql; if (!file_exists($dumpFile)) { echo "{$dumpFile} non trouvé<br />\n"; return FALSE; } $fileHandle = gzopen($dumpFile, "rb"); if (!$fileHandle) { echo "Ouverture de {$dumpFile} impossible.<br />\n"; return FALSE; } if ($offset != 0) { if (gzseek($fileHandle, $offset, SEEK_SET) != 0) { //erreur echo "Impossible de trouver l'octet " . number_format($offset, 0, "", " ") . "<br />\n"; return FALSE; } flush(); } $formattedQuery = ""; $old_offset = $offset; while (!gzeof($fileHandle)) { current_time(); if ($duree > 0 and $TPSCOUR >= $duree) { //on atteint la fin du temps imparti if ($old_offset == $offset) { echo "<p class=\"rouge center\"><strong>La procédure de restauration ne peut pas continuer.\n <br />Un problème est survenu lors du traitement d'une requête près de :.\n <br />" . $debut_req . "</strong></p><hr />\n"; return FALSE; } $old_offset = $offset; return TRUE; } //echo $TPSCOUR."<br />"; $buffer = gzgets($fileHandle); if (mb_substr($buffer, mb_strlen($buffer), 1) == 0) { $buffer = mb_substr($buffer, 0, mb_strlen($buffer) - 1); } //echo $buffer."<br />"; if (mb_substr($buffer, 0, 1) != "#" and mb_substr($buffer, 0, 1) != "/") { if (!isset($debut_req)) { $debut_req = $buffer; } $formattedQuery .= $buffer; //echo $formattedQuery."<hr />"; if (trim($formattedQuery) != "") { $sql = $formattedQuery; if (mysqli_query($GLOBALS["mysqli"], $sql)) { //réussie sinon continue à concaténer $offset = gztell($fileHandle); //echo $offset; $formattedQuery = ""; unset($debut_req); $cpt++; //echo "$cpt requêtes exécutées avec succès jusque là .<br />"; } } } } if (mysqli_error($GLOBALS["mysqli"])) { echo "<hr />\nERREUR à partir de " . nl2br($formattedQuery) . "<br />" . mysqli_error($GLOBALS["mysqli"]) . "<hr />\n"; $erreur_mysql = TRUE; } gzclose($fileHandle); $offset = -1; return TRUE; }
<?php $f = dirname(__FILE__) . "/004.txt.gz"; $h = gzopen($f, 'r'); $extra_arg = 'nothing'; var_dump(gztell($h, $extra_arg)); var_dump(gztell()); gzclose($h); ?> ===DONE===
function skipFile($zh, $size) { gzseek($zh, gztell($zh) + ceil($size / 512) * 512); }
function _jumpBlock($p_len = false) { if (is_resource($this->_dFile)) { if ($p_len === false) { $p_len = 1; } if ($this->_bCompress) { gzseek($this->_dFile, gztell($this->_dFile) + $p_len * 512); } else { fseek($this->_dFile, ftell($this->_dFile) + $p_len * 512); } } return true; }
break; } $totalQueries++; $queries++; $query = ""; $queryLines = 0; } $lineNumber++; } } // Get the current file position if (!$error) { if (!$gzipMode) { $fOffset = ftell($file); } else { $fOffset = gztell($file); } if (!$fOffset) { echo $installer->getAlertMsg($LANG_BIGDUMP[20]); $error = true; } } // Print statistics if (!$error) { $lines_this = $lineNumber - $_REQUEST["start"]; $lines_done = $lineNumber - 1; $lines_togo = ' ? '; $lines_tota = ' ? '; $queries_this = $queries; $queries_done = $totalQueries; $queries_togo = ' ? ';
/** * Retrieve file pointer position * * @throws io.IOException in case of an error * @return int position */ public function tell($position = 0, $mode = SEEK_SET) { $result = gztell($this->_fd); if (FALSE === $result && xp::errorAt(__FILE__, __LINE__ - 1)) { throw new IOException('retrieve file pointer\'s position ' . $this->uri); } return $result; }
<?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=" . gztell($h) . "\n"; //seek forwards 20 bytes. gzseek($h, 20, SEEK_CUR); echo "tell=" . gztell($h) . "\n"; gzwrite($h, $str2); echo "tell=" . gztell($h) . "\n"; gzclose($h); echo "\nreading the output file\n"; $h = gzopen($f, 'r'); echo gzread($h, strlen($str1)) . "\n"; var_dump(bin2hex(gzread($h, 20))); echo gzread($h, strlen($str2)) . "\n"; gzclose($h); unlink($f); ?> ===DONE===
$table_type = $row['Engine']; if (substr($row['Comment'], 0, 4) == 'VIEW') { $table_type = 'View'; $table_size = '-'; } $tpl->assign_block_vars('ROW', array('CLASS' => 'dbrow' . $klasse, 'ID' => $i, 'NR' => $i + 1, 'TABLENAME' => $row['Name'], 'TABLETYPE' => $table_type, 'RECORDS' => $table_type == 'View' ? '<i>' . $row['Rows'] . '</i>' : '<strong>' . $row['Rows'] . '</strong>', 'SIZE' => is_int($table_size) ? byte_output($table_size) : $table_size, 'LAST_UPDATE' => $row['Update_time'])); } } else { $tpl->set_filenames(array('show' => './tpl/restore_select_tables.tpl')); //Restore - Header aus Backupfile lesen $button_name = 'restore_tbl'; $gz = substr($filename, -3) == '.gz' ? 1 : 0; if ($gz) { $fp = gzopen($fpath . $filename, "r"); $statusline = gzgets($fp, 40960); $offset = gztell($fp); } else { $fp = fopen($fpath . $filename, "r"); $statusline = fgets($fp, 5000); $offset = ftell($fp); } //Header auslesen $sline = ReadStatusline($statusline); $anzahl_tabellen = $sline['tables']; $anzahl_eintraege = $sline['records']; $tbl_zeile = ''; $part = $sline['part'] == '' ? 0 : substr($sline['part'], 3); if ($anzahl_eintraege == -1) { // not a backup of MySQLDumper $tpl->assign_block_vars('NO_MSD_BACKUP', array()); } else {
function _extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path) { $v_result = true; $v_nb = 0; $v_extract_all = true; $v_listing = false; $p_path = $this->_translateWinPath($p_path, false); if ($p_path == '' || substr($p_path, 0, 1) != '/' && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':')) { $p_path = "./" . $p_path; } $p_remove_path = $this->_translateWinPath($p_remove_path); // ----- Look for path to remove format (should end by /) if ($p_remove_path != '' && substr($p_remove_path, -1) != '/') { $p_remove_path .= '/'; } $p_remove_path_size = strlen($p_remove_path); switch ($p_mode) { case "complete": $v_extract_all = TRUE; $v_listing = FALSE; break; case "partial": $v_extract_all = FALSE; $v_listing = FALSE; break; case "list": $v_extract_all = FALSE; $v_listing = TRUE; break; default: $this->_error('Invalid extract mode (' . $p_mode . ')'); return false; } clearstatcache(); while (!($v_end_of_file = $this->_compress ? @gzeof($this->_file) : @feof($this->_file))) { $v_extract_file = FALSE; $v_extraction_stopped = 0; if ($this->_compress) { $v_binary_data = @gzread($this->_file, 512); } else { $v_binary_data = @fread($this->_file, 512); } if (!$this->_readHeader($v_binary_data, $v_header)) { return false; } if ($v_header['filename'] == '') { continue; } // ----- Look for long filename if ($v_header['typeflag'] == 'L') { if (!$this->_readLongHeader($v_header)) { return false; } } if (!$v_extract_all && is_array($p_file_list)) { // ----- By default no unzip if the file is not found $v_extract_file = false; for ($i = 0; $i < sizeof($p_file_list); $i++) { // ----- Look if it is a directory if (substr($p_file_list[$i], -1) == '/') { // ----- Look if the directory is in the filename path if (strlen($v_header['filename']) > strlen($p_file_list[$i]) && substr($v_header['filename'], 0, strlen($p_file_list[$i])) == $p_file_list[$i]) { $v_extract_file = TRUE; break; } } elseif ($p_file_list[$i] == $v_header['filename']) { $v_extract_file = TRUE; break; } } } else { $v_extract_file = TRUE; } // ----- Look if this file need to be extracted if ($v_extract_file && !$v_listing) { if ($p_remove_path != '' && substr($v_header['filename'], 0, $p_remove_path_size) == $p_remove_path) { $v_header['filename'] = substr($v_header['filename'], $p_remove_path_size); } if ($p_path != './' && $p_path != '/') { while (substr($p_path, -1) == '/') { $p_path = substr($p_path, 0, strlen($p_path) - 1); } if (substr($v_header['filename'], 0, 1) == '/') { $v_header['filename'] = $p_path . $v_header['filename']; } else { $v_header['filename'] = $p_path . '/' . $v_header['filename']; } } if (file_exists($v_header['filename'])) { if (@is_dir($v_header['filename']) && $v_header['typeflag'] == '') { $this->_error('File ' . $v_header['filename'] . ' already exists as a directory'); return false; } if (is_file($v_header['filename']) && $v_header['typeflag'] == "5") { $this->_error('Directory ' . $v_header['filename'] . ' already exists as a file'); return false; } if (!is_writeable($v_header['filename'])) { $this->_error('File ' . $v_header['filename'] . ' already exists and is write protected'); return false; } if (filemtime($v_header['filename']) > $v_header['mtime']) { // To be completed : An error or silent no replace ? } } elseif (($v_result = $this->_dirCheck($v_header['typeflag'] == "5" ? $v_header['filename'] : dirname($v_header['filename']))) != 1) { $this->_error('Unable to create path for ' . $v_header['filename']); return false; } if ($v_extract_file) { if ($v_header['typeflag'] == "5") { if (!@file_exists($v_header['filename'])) { if (!@mkdir($v_header['filename'], 0777)) { $this->_error('Unable to create directory {' . $v_header['filename'] . '}'); return false; } } } else { if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { $this->_error('Error while opening {' . $v_header['filename'] . '} in write binary mode'); return false; } else { $n = floor($v_header['size'] / 512); for ($i = 0; $i < $n; $i++) { if ($this->_compress) { $v_content = @gzread($this->_file, 512); } else { $v_content = @fread($this->_file, 512); } fwrite($v_dest_file, $v_content, 512); } if ($v_header['size'] % 512 != 0) { if ($this->_compress) { $v_content = @gzread($this->_file, 512); } else { $v_content = @fread($this->_file, 512); } fwrite($v_dest_file, $v_content, $v_header['size'] % 512); } @fclose($v_dest_file); // ----- Change the file mode, mtime @touch($v_header['filename'], $v_header['mtime']); // To be completed //chmod($v_header[filename], DecOct($v_header[mode])); } // ----- Check the file size clearstatcache(); if (filesize($v_header['filename']) != $v_header['size']) { $this->_error('Extracted file ' . $v_header['filename'] . ' does not have the correct file size \'' . filesize($v_filename) . '\' (' . $v_header['size'] . ' expected). Archive may be corrupted.'); return false; } } } else { // ----- Jump to next file if ($this->_compress) { @gzseek($this->_file, @gztell($this->_file) + ceil($v_header['size'] / 512) * 512); } else { @fseek($this->_file, @ftell($this->_file) + ceil($v_header['size'] / 512) * 512); } } } else { // ----- Jump to next file if ($this->_compress) { @gzseek($this->_file, @gztell($this->_file) + ceil($v_header['size'] / 512) * 512); } else { @fseek($this->_file, @ftell($this->_file) + ceil($v_header['size'] / 512) * 512); } } if ($this->_compress) { $v_end_of_file = @gzeof($this->_file); } else { $v_end_of_file = @feof($this->_file); } if ($v_listing || $v_extract_file || $v_extraction_stopped) { // ----- Log extracted files if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename']) { $v_file_dir = ''; } if (substr($v_header['filename'], 0, 1) == '/' && $v_file_dir == '') { $v_file_dir = '/'; } $p_list_detail[$v_nb++] = $v_header; } } return true; }
function PclTarHandleExtractFile($p_tar, &$v_header, $p_path, $p_remove_path, $p_tar_mode) { TrFctStart(__FILE__, __LINE__, "PclTarHandleExtractFile", "archive_descr='{$p_tar}', path={$p_path}, remove_path='{$p_remove_path}', tar_mode={$p_tar_mode}"); $v_result = 1; // TBC : I should replace all $v_tar by $p_tar in this function .... $v_tar = $p_tar; $v_extract_file = 1; $p_remove_path_size = strlen($p_remove_path); // ----- Look for path to remove if ($p_remove_path != "" && substr($v_header[filename], 0, $p_remove_path_size) == $p_remove_path) { TrFctMessage(__FILE__, __LINE__, 3, "Found path '{$p_remove_path}' to remove in file '{$v_header['filename']}'"); // ----- Remove the path $v_header[filename] = substr($v_header[filename], $p_remove_path_size); TrFctMessage(__FILE__, __LINE__, 3, "Resulting file is '{$v_header['filename']}'"); } // ----- Add the path to the file if ($p_path != "./" && $p_path != "/") { // ----- Look for the path end '/' while (substr($p_path, -1) == "/") { TrFctMessage(__FILE__, __LINE__, 3, "Destination path [{$p_path}] ends by '/'"); $p_path = substr($p_path, 0, strlen($p_path) - 1); TrFctMessage(__FILE__, __LINE__, 3, "Modified to [{$p_path}]"); } // ----- Add the path if (substr($v_header[filename], 0, 1) == "/") { $v_header[filename] = $p_path . $v_header[filename]; } else { $v_header[filename] = $p_path . "/" . $v_header[filename]; } } // ----- Trace TrFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '{$v_header['filename']}', size '{$v_header['size']}'"); // ----- Check that the file does not exists if (file_exists($v_header[filename])) { TrFctMessage(__FILE__, __LINE__, 2, "File '{$v_header['filename']}' already exists"); // ----- Look if file is a directory if (is_dir($v_header[filename])) { TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is a directory"); // ----- Change the file status $v_header[status] = "already_a_directory"; // ----- Skip the extract $v_extraction_stopped = 1; $v_extract_file = 0; } else { if (!is_writeable($v_header[filename])) { if (!is_writeable($v_header[filename])) { TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is write protected"); // ----- Change the file status $v_header[status] = "write_protected"; // ----- Skip the extract $v_extraction_stopped = 1; $v_extract_file = 0; } else { if (filemtime($v_header[filename]) > $v_header[mtime]) { TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is newer (" . date("l dS of F Y h:i:s A", filemtime($v_header[filename])) . ") than the extracted file (" . date("l dS of F Y h:i:s A", $v_header[mtime]) . ")"); // ----- Change the file status $v_header[status] = "newer_exist"; // ----- Skip the extract $v_extraction_stopped = 1; $v_extract_file = 0; } } } } } else { if ($v_header[typeflag] == "5") { $v_dir_to_check = $v_header[filename]; } else { if (!strstr($v_header[filename], "/")) { $v_dir_to_check = ""; } else { $v_dir_to_check = dirname($v_header[filename]); } } if (($v_result = PclTarHandlerDirCheck($v_dir_to_check)) != 1) { TrFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '{$v_header['filename']}'"); // ----- Change the file status $v_header[status] = "path_creation_fail"; // ----- Skip the extract $v_extraction_stopped = 1; $v_extract_file = 0; } } // ----- Do the real bytes extraction (if not a directory) if ($v_extract_file && $v_header[typeflag] != "5") { // ----- Open the destination file in write mode if (($v_dest_file = @fopen($v_header[filename], "wb")) == 0) { TrFctMessage(__FILE__, __LINE__, 2, "Error while opening '{$v_header['filename']}' in write binary mode"); // ----- Change the file status $v_header[status] = "write_error"; // ----- Jump to next file TrFctMessage(__FILE__, __LINE__, 2, "Jump to next file"); if ($p_tar_mode == "tar") { fseek($v_tar, ftell($v_tar) + ceil($v_header[size] / 512) * 512); } else { gzseek($v_tar, gztell($v_tar) + ceil($v_header[size] / 512) * 512); } } else { TrFctMessage(__FILE__, __LINE__, 2, "Start extraction of '{$v_header['filename']}'"); // ----- Read data $n = floor($v_header[size] / 512); for ($i = 0; $i < $n; $i++) { TrFctMessage(__FILE__, __LINE__, 3, "Read complete 512 bytes block number " . ($i + 1)); if ($p_tar_mode == "tar") { $v_content = fread($v_tar, 512); } else { $v_content = gzread($v_tar, 512); } fwrite($v_dest_file, $v_content, 512); } if ($v_header[size] % 512 != 0) { TrFctMessage(__FILE__, __LINE__, 3, "Read last " . $v_header[size] % 512 . " bytes in a 512 block"); if ($p_tar_mode == "tar") { $v_content = fread($v_tar, 512); } else { $v_content = gzread($v_tar, 512); } fwrite($v_dest_file, $v_content, $v_header[size] % 512); } // ----- Close the destination file fclose($v_dest_file); // ----- Change the file mode, mtime touch($v_header[filename], $v_header[mtime]); //chmod($v_header[filename], DecOct($v_header[mode])); } // ----- Check the file size clearstatcache(); if (filesize($v_header[filename]) != $v_header[size]) { // ----- Error log PclErrorLog(-7, "Extracted file '{$v_header['filename']}' does not have the correct file size '" . filesize($v_filename) . "' ('{$v_header['size']}' expected). Archive may be corrupted."); // ----- Return TrFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString()); return PclErrorCode(); } // ----- Trace TrFctMessage(__FILE__, __LINE__, 2, "Extraction done"); } else { TrFctMessage(__FILE__, __LINE__, 2, "Extraction of file '{$v_header['filename']}' skipped."); // ----- Jump to next file TrFctMessage(__FILE__, __LINE__, 2, "Jump to next file"); if ($p_tar_mode == "tar") { fseek($v_tar, ftell($v_tar) + ceil($v_header[size] / 512) * 512); } else { gzseek($v_tar, gztell($v_tar) + ceil($v_header[size] / 512) * 512); } } // ----- Return TrFctEnd(__FILE__, __LINE__, $v_result); return $v_result; }
/** * Returns the current position of the file read/write pointer. * * @return mixed * * @since 11.1 */ public function tell() { if (!$this->_fh) { $this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN')); return false; } $res = false; // Capture PHP errors $php_errormsg = ''; $track_errors = ini_get('track_errors'); ini_set('track_errors', true); switch ($this->processingmethod) { case 'gz': $res = gztell($this->_fh); break; case 'bz': case 'f': default: $res = ftell($this->_fh); break; } // May return 0 so check if it's really false if ($res === false) { $this->setError($php_errormsg); } // Restore error tracking to what it was before ini_set('track_errors', $track_errors); // Return the result return $res; }
public function entryTell() { if (!$this->entryFile) { return false; } return $this->writeMode ? gztell($this->entryFile) : ftell($this->entryFile); }
function doTell() { return @gztell($this->File); }
protected function extractList($p_path, &$plistDetail, $p_mode, $p_file_list, $p_remove_path) { $v_result=true; $v_nb = 0; $v_extract_all = true; $v_listing = false; $p_path = $this->translateWinPath($p_path, false); if ($p_path == '' || (substr($p_path, 0, 1) != '/' && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { $p_path = "./".$p_path; } $p_remove_path = $this->translateWinPath($p_remove_path); // ----- Look for path to remove format (should end by /) if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) $p_remove_path .= '/'; $p_remove_path_size = strlen($p_remove_path); switch ($p_mode) { case "complete" : $v_extract_all = TRUE; $v_listing = FALSE; break; case "partial" : $v_extract_all = FALSE; $v_listing = FALSE; break; case "list" : $v_extract_all = FALSE; $v_listing = TRUE; break; default : $this->error('Invalid extract mode ('.$p_mode.')'); return false; } clearstatcache(); while (strlen($v_binary_data = $this->readBlock()) != 0) { $v_extract_file = FALSE; $v_extraction_stopped = 0; if (!$this->readHeader($v_binary_data, $v_header)) return false; if ($v_header['filename'] == '') { continue; } // ----- Look for long filename if ($v_header['typeflag'] == 'L') { if (!$this->readLongHeader($v_header)) return false; } if ((!$v_extract_all) && (is_array($p_file_list))) { // ----- By default no unzip if the file is not found $v_extract_file = false; for ($i=0; $i<sizeof($p_file_list); $i++) { // ----- Look if it is a directory if (substr($p_file_list[$i], -1) == '/') { // ----- Look if the directory is in the filename path if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) == $p_file_list[$i])) { $v_extract_file = TRUE; break; } } // ----- It is a file, so compare the file names elseif ($p_file_list[$i] == $v_header['filename']) { $v_extract_file = TRUE; break; } } } else { $v_extract_file = TRUE; } if ($v_listing&&$v_header['typeflag']==0) { if ($this->compressType == 'gz') $v_header['position'] = @gztell($this->file); else if ($this->compressType == 'none') $v_header['position'] = @ftell($this->file); } // ----- Look if this file need to be extracted if (($v_extract_file) && (!$v_listing)) { if (($p_remove_path != '') && (substr($v_header['filename'], 0, $p_remove_path_size) == $p_remove_path)) $v_header['filename'] = substr($v_header['filename'], $p_remove_path_size); if (($p_path != './') && ($p_path != '/')) { while (substr($p_path, -1) == '/') $p_path = substr($p_path, 0, strlen($p_path)-1); if (substr($v_header['filename'], 0, 1) == '/') $v_header['filename'] = $p_path.$v_header['filename']; else $v_header['filename'] = $p_path.'/'.$v_header['filename']; } if (file_exists($v_header['filename'])) { if ( (@is_dir($v_header['filename'])) && ($v_header['typeflag'] == '')) { $this->error('File '.$v_header['filename'] .' already exists as a directory'); return false; } if ( ($this->isArchive($v_header['filename'])) && ($v_header['typeflag'] == "5")) { $this->error('Directory '.$v_header['filename'] .' already exists as a file'); return false; } if (!is_writeable($v_header['filename'])) { $this->error('File '.$v_header['filename'] .' already exists and is write protected'); return false; } if (filemtime($v_header['filename']) > $v_header['mtime']) { // To be completed : An error or silent no replace ? } } // ----- Check the directory availability and create it if necessary elseif (($v_result = $this->dirCheck(($v_header['typeflag'] == "5" ?$v_header['filename'] :dirname($v_header['filename'])))) != 1) { $this->error('Unable to create path for '.$v_header['filename']); return false; } if ($v_extract_file) { if ($v_header['typeflag'] == "5") { if (!@file_exists($v_header['filename'])) { if (!@mkdir($v_header['filename'], 0777)) { $this->error('Unable to create directory {' .$v_header['filename'].'}'); return false; } } } elseif ($v_header['typeflag'] == "2") { if (@file_exists($v_header['filename'])) { @unlink($v_header['filename']); } if (!@symlink($v_header['link'], $v_header['filename'])) { $this->error('Unable to extract symbolic link {' .$v_header['filename'].'}'); return false; } } else { if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { $this->error('Error while opening {'.$v_header['filename'] .'} in write binary mode'); return false; } else { $n = floor($v_header['size']/512); for ($i=0; $i<$n; $i++) { $v_content = $this->readBlock(); fwrite($v_dest_file, $v_content, 512); } if (($v_header['size'] % 512) != 0) { $v_content = $this->readBlock(); fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); } @fclose($v_dest_file); // ----- Change the file mode, mtime @touch($v_header['filename'], $v_header['mtime']); if ($v_header['mode'] & 0111) { // make file executable, obey umask $mode = fileperms($v_header['filename']) | (~umask() & 0111); @chmod($v_header['filename'], $mode); } } // ----- Check the file size clearstatcache(); if (filesize($v_header['filename']) != $v_header['size']) { $this->error('Extracted file '.$v_header['filename'] .' does not have the correct file size \'' .filesize($v_header['filename']) .'\' ('.$v_header['size'] .' expected). Archive may be corrupted.'); return false; } } } else { $this->jumpBlock(ceil(($v_header['size']/512))); } } else { $this->jumpBlock(ceil(($v_header['size']/512))); } /* TBC : Seems to be unused ... if ($this->compress) $v_end_of_file = @gzeof($this->file); else $v_end_of_file = @feof($this->file); */ if ($v_listing || $v_extract_file || $v_extraction_stopped) { // ----- Log extracted files if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename']) $v_file_dir = ''; if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) $v_file_dir = '/'; $plistDetail[$v_nb++] = $v_header; if (is_array($p_file_list) && (count($plistDetail) == count($p_file_list))) { return true; } } } return true; }
public function stream_tell() { return gztell($this->_resource); }
Errorlog("RESTORE", $databases['db_actual'], $sql_command, $meldung); $restore['errors']++; } else { Errorlog("RESTORE", $databases['db_actual'], $sql_command, 'Restore failed: ' . $meldung, 0); SQLError($sql_command, $meldung); die; } } } } $a++; $dauer = time() - $restore['startzeit']; } $eingetragen = $a - 1; } $restore['offset'] = $restore['compressed'] ? gztell($restore['filehandle']) : ftell($restore['filehandle']); if ($restore['compressed']) { gzclose($restore['filehandle']); } else { fclose($restore['filehandle']); } $aus_header[] = PicCache($relativ_path); $aus_header[] = headline($lang['restore']); $aus_header[] = 'Browser : <img src="images/' . $BrowserIcon . '"> '; $restore['aufruf']++; if (!$restore['compressed']) { $prozent = $filegroesse > 0 ? $restore['offset'] * 100 / $filegroesse : 0; } else { if ($restore['anzahl_eintraege'] > 0) { $prozent = $restore['eintraege_ready'] * 100 / $restore['anzahl_eintraege']; } else {
break; } $totalqueries++; $queries++; $query = ""; $querylines = 0; } $linenumber++; } } // Get the current file position if (!$error) { if (!$gzipmode) { $foffset = ftell($file); } else { $foffset = gztell($file); } if (!$foffset) { echo "<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"; $error = true; } } // Print statistics skin_open(); // echo ("<p class=\"centr\"><b>Statistics</b></p>\n"); if (!$error) { $lines_this = $linenumber - $_REQUEST["start"]; $lines_done = $linenumber - 1; $lines_togo = ' ? '; $lines_tota = ' ? '; $queries_this = $queries;
function position() { return gztell($this->pointer); }