当前位置: 首页>>代码示例>>PHP>>正文


PHP gzeof函数代码示例

本文整理汇总了PHP中gzeof函数的典型用法代码示例。如果您正苦于以下问题:PHP gzeof函数的具体用法?PHP gzeof怎么用?PHP gzeof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gzeof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAll

 public function getAll()
 {
     $buffer = "";
     $counter = 0;
     $sum = 0;
     $total = 0;
     $last = microtime(true);
     $bwlimit = $this->getBwlimit();
     while (!gzeof($this->datasource)) {
         $tmp = $this->read();
         $bytes = strlen($tmp);
         $buffer .= $tmp;
         $sum += $bytes;
         $total += $bytes;
         $counter++;
         if ($bwlimit > 0 && $sum > $bwlimit) {
             $current = microtime(true);
             $wait = $current - $last;
             if ($wait < 1) {
                 $wait = 1 - $wait;
                 usleep($wait * 1000000);
             }
             $sum = 0;
             $last = microtime(true);
         }
     }
     return $buffer;
 }
开发者ID:chobie,项目名称:treasuredata-api-client,代码行数:28,代码来源:GzipInputStream.php

示例2: extractTar

 public function extractTar($src, $dest)
 {
     if ($this->is_tar($src)) {
         file_put_contents($tmp = '~tmp(' . microtime() . ').tar', $src);
         $src = $tmp;
     }
     $ptr = gzopen($src, 'r');
     while (!gzeof($ptr)) {
         $infos = $this->readTarHeader($ptr);
         if ($infos['type'] == '5') {
             if (!file_exists($dest . $infos['name'])) {
                 mkdir($dest . $infos['name'], 0777, true);
             }
             $result[] = $dest . $infos['name'];
         } elseif ($infos['type'] == '0' || $infos['type'] == chr(0)) {
             $dirPath = substr($infos['name'], 0, strrpos($infos['name'], '/'));
             if (!file_exists($dest . $dirPath)) {
                 mkdir($dest . $dirPath, 0777, true);
             }
             if (file_put_contents($dest . $infos['name'], $infos['data'])) {
                 $result[] = $dest . $infos['name'];
             }
         }
         if ($infos) {
             chmod($dest . $infos['name'], 0777);
         }
     }
     if (is_file($tmp)) {
         unlink($tmp);
     }
     return $result;
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:32,代码来源:targz.php

示例3: import

 public function import()
 {
     // It might not look like it, but it is actually compatible to
     // uncompressed files.
     $gzFileHandler = gzopen($this->file, 'r');
     Model\DownloadIntent::delete_all();
     Model\DownloadIntentClean::delete_all();
     $batchSize = 1000;
     $batch = array();
     while (!gzeof($gzFileHandler)) {
         $line = gzgets($gzFileHandler);
         list($id, $user_agent_id, $media_file_id, $request_id, $accessed_at, $source, $context, $geo_area_id, $lat, $lng) = explode(",", $line);
         $batch[] = array($user_agent_id, $media_file_id, $request_id, $accessed_at, $source, $context, $geo_area_id, $lat, $lng);
         if (count($batch) >= $batchSize) {
             self::save_batch_to_db($batch);
             $batch = [];
         }
     }
     gzclose($gzFileHandler);
     // save last batch to db
     self::save_batch_to_db($batch);
     \Podlove\Analytics\DownloadIntentCleanup::cleanup_download_intents();
     \Podlove\Cache\TemplateCache::get_instance()->setup_purge();
     wp_redirect(admin_url('admin.php?page=podlove_imexport_migration_handle&status=success'));
     exit;
 }
开发者ID:johannes-mueller,项目名称:podlove-publisher,代码行数:26,代码来源:tracking_importer.php

示例4: LoadBackUp

function LoadBackUp()
{
    global $SAMSConf;
    global $USERConf;
    $DB = new SAMSDB();
    $lang = "./lang/lang.{$SAMSConf->LANG}";
    require $lang;
    if ($USERConf->ToWebInterfaceAccess("C") != 1) {
        exit;
    }
    PageTop("reark_48.jpg", "{$backupbuttom_2_loadbase_LoadBackUp_1}");
    if (($finp = gzopen($_FILES['userfile']['tmp_name'], "r")) != NULL) {
        while (gzeof($finp) == 0) {
            $string = gzgets($finp, 10000);
            $QUERY = strtok($string, ";");
            if (strstr($QUERY, "#") == FALSE) {
                echo "{$QUERY}<BR>";
                $num_rows = $DB->samsdb_query($QUERY . ";");
            }
            $count++;
        }
    }
    print "<SCRIPT>\n";
    print "  parent.lframe.location.href=\"lframe.php\"; \n";
    print "</SCRIPT> \n";
}
开发者ID:ruNovel,项目名称:sams2,代码行数:26,代码来源:configbuttom_5_restore.php

示例5: update_database

 public static function update_database()
 {
     set_time_limit(0);
     $outFile = self::get_upload_file_path();
     // for download_url()
     require_once ABSPATH . 'wp-admin/includes/file.php';
     $tmpFile = \download_url(self::SOURCE_URL);
     if (is_wp_error($tmpFile)) {
         die($tmpFile->get_error_message());
     }
     $zh = gzopen($tmpFile, 'rb');
     $h = fopen($outFile, 'wb');
     if (!$zh) {
         die('Downloaded file could not be opened for reading.');
     }
     if (!$h) {
         die(sprintf('Database could not be written (%s).', $outFile));
     }
     while (!gzeof($zh)) {
         fwrite($h, gzread($zh, 4096));
     }
     gzclose($zh);
     fclose($h);
     unlink($tmpFile);
     if (!self::is_db_valid()) {
         die(sprintf('Checksum does not match (%s).', $outFile));
     }
 }
开发者ID:johannes-mueller,项目名称:podlove-publisher,代码行数:28,代码来源:geo_ip.php

示例6: gzpassthru

 function gzpassthru($fp)
 {
     while (!gzeof($fp)) {
         print gzred($fp, 1 << 20);
     }
     gzclose($fp);
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:7,代码来源:fakezlib.php

示例7: feof

 function feof($fp)
 {
     if ($this->has_gzip()) {
         return gzeof($fp);
     }
     return feof($fp);
 }
开发者ID:bluedanbob,项目名称:wordpress,代码行数:7,代码来源:wordpress.php

示例8: wp_all_import_get_gz

 function wp_all_import_get_gz($filename, $use_include_path = 0, $targetDir = false)
 {
     $type = 'csv';
     $uploads = wp_upload_dir();
     $targetDir = !$targetDir ? wp_all_import_secure_file($uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::UPLOADS_DIRECTORY) : $targetDir;
     $tmpname = wp_unique_filename($targetDir, strlen(basename($filename)) < 30 ? basename($filename) : time());
     $localPath = $targetDir . '/' . urldecode(sanitize_file_name($tmpname));
     $fp = @fopen($localPath, 'w');
     $file = @gzopen($filename, 'rb', $use_include_path);
     if ($file) {
         $first_chunk = true;
         while (!gzeof($file)) {
             $chunk = gzread($file, 1024);
             if ($first_chunk and strpos($chunk, "<?") !== false and strpos($chunk, "</") !== false) {
                 $type = 'xml';
                 $first_chunk = false;
             }
             // if it's a 1st chunk, then chunk <? symbols to detect XML file
             @fwrite($fp, $chunk);
         }
         gzclose($file);
     } else {
         $tmpname = wp_unique_filename($targetDir, strlen(basename($filename)) < 30 ? basename($filename) : time());
         $localGZpath = $targetDir . '/' . urldecode(sanitize_file_name($tmpname));
         $request = get_file_curl($filename, $localGZpath, false, true);
         if (!is_wp_error($request)) {
             $file = @gzopen($localGZpath, 'rb', $use_include_path);
             if ($file) {
                 $first_chunk = true;
                 while (!gzeof($file)) {
                     $chunk = gzread($file, 1024);
                     if ($first_chunk and strpos($chunk, "<?") !== false and strpos($chunk, "</") !== false) {
                         $type = 'xml';
                         $first_chunk = false;
                     }
                     // if it's a 1st chunk, then chunk <? symbols to detect XML file
                     @fwrite($fp, $chunk);
                 }
                 gzclose($file);
             }
             @unlink($localGZpath);
         } else {
             return $request;
         }
     }
     @fclose($fp);
     if (preg_match('%\\W(gz)$%i', basename($localPath))) {
         if (@rename($localPath, str_replace('.gz', '.' . $type, $localPath))) {
             $localPath = str_replace('.gz', '.' . $type, $localPath);
         }
     } else {
         if (@rename($localPath, $localPath . '.' . $type)) {
             $localPath = $localPath . '.' . $type;
         }
     }
     return array('type' => $type, 'localPath' => $localPath);
 }
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:57,代码来源:wp_all_import_get_gz.php

示例9: decompress

 public function decompress()
 {
     $tgzFilePath = $this->getPath();
     if (!file_exists($tgzFilePath)) {
         throw new Exception(sprintf('File %s does not exist!', $tgzFilePath));
     }
     if (!is_readable($tgzFilePath)) {
         throw new Exception(sprintf('File %s is not readable!', $tgzFilePath));
     }
     // Open .tgz file for reading
     $gzHandle = @gzopen($tgzFilePath, 'rb');
     if (!$gzHandle) {
         throw new Exception(sprintf('Could not open %s for reading!', $tgzFilePath));
     }
     jimport('joomla.filesystem.file');
     while (!gzeof($gzHandle)) {
         if ($block = gzread($gzHandle, 512)) {
             $meta['filename'] = trim(substr($block, 0, 99));
             $meta['filesize'] = octdec(substr($block, 124, 12));
             if ($bytes = $meta['filesize'] % 512) {
                 $meta['nullbytes'] = 512 - $bytes;
             } else {
                 $meta['nullbytes'] = 0;
             }
             if ($meta['filesize']) {
                 // Make sure our extension is .xml
                 if (($ext = JFile::getExt($meta['filename'])) != 'xml') {
                     throw new Exception(sprintf('Attempted to extract a file with an invalid extension (%s) - archive might be damaged.', preg_replace('#[^a-z0-9]#is', '', $ext)));
                 }
                 // Make sure file does not contain invalid characters
                 if (preg_match('/[^a-z_\\-0-9]/i', JFile::stripExt($meta['filename']))) {
                     throw new Exception('Attempted to extract a file with invalid characters in its name.');
                 }
                 $chunk = 1024 * 1024;
                 $left = $meta['filesize'];
                 $fHandle = @fopen($this->path . '/' . $meta['filename'], 'wb');
                 if (!$fHandle) {
                     throw new Exception(sprintf('Could not write data to file %s!', htmlentities($meta['filename'], ENT_COMPAT, 'utf-8')));
                 }
                 do {
                     $left = $left - $chunk;
                     if ($left < 0) {
                         $chunk = $left + $chunk;
                     }
                     $data = gzread($gzHandle, $chunk);
                     fwrite($fHandle, $data);
                 } while ($left > 0);
                 fclose($fHandle);
             }
             if ($meta['nullbytes'] > 0) {
                 gzread($gzHandle, $meta['nullbytes']);
             }
         }
     }
     gzclose($gzHandle);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:56,代码来源:restore.php

示例10: _Open

 /**
 * Open the file containing the backup data
 * @return String a String containing the DB Dump 
 * @access private
 */
 function _Open()
 {
     $fp = gzopen($this->filename, "rb") or die("Error. No se pudo abrir el archivo {$this->filename}");
     while (!gzeof($fp)) {
         $line = gzgets($fp, 1024);
         $SQL .= "{$line}";
     }
     gzclose($fp);
     return $SQL;
 }
开发者ID:Fengtalk,项目名称:yiqicms,代码行数:15,代码来源:iam_restore.php

示例11: decompressFile

 /**
  * @param $fileName
  * @param $outputFilePath
  */
 private function decompressFile($fileName, $outputFilePath)
 {
     $gz = gzopen($fileName, 'rb');
     $outputFile = fopen($outputFilePath, 'wb');
     while (!gzeof($gz)) {
         fwrite($outputFile, gzread($gz, 4096));
     }
     fclose($outputFile);
     gzclose($gz);
 }
开发者ID:MaximeThoonsen,项目名称:CravlerMaxMindGeoIpBundle,代码行数:14,代码来源:UpdateDatabaseCommand.php

示例12: __endoffile

 function __endoffile()
 {
     switch ($this->type) {
         case 'gz':
             return gzeof($this->handle);
             break;
         case 'file':
             return feof($this->handle);
             break;
     }
 }
开发者ID:Sajaki,项目名称:wowroster_dev,代码行数:11,代码来源:luaparser.php

示例13: gzUncompressFile

function gzUncompressFile($srcName, $dstName)
{
    $sfp = gzopen($srcName, "rb");
    $fp = fopen($dstName, "w");
    while (!gzeof($sfp)) {
        $string = gzread($sfp, 4096);
        fwrite($fp, $string, strlen($string));
    }
    gzclose($sfp);
    fclose($fp);
}
开发者ID:scrow,项目名称:WX4AKQ_Offline_Tools,代码行数:11,代码来源:fo_download.inc.php

示例14: downloadRemoteDataStore

 /**
  * Download remote data store
  *
  * Used by the mautic:iplookup:update_data command and form fetch button (if applicable) to update local IP data stores
  *
  * @return bool
  */
 public function downloadRemoteDataStore()
 {
     $connector = HttpFactory::getHttp();
     $package = $this->getRemoteDateStoreDownloadUrl();
     try {
         $data = $connector->get($package);
     } catch (\Exception $exception) {
         $this->logger->error('Failed to fetch remote IP data: ' . $exception->getMessage());
     }
     $tempTarget = $this->cacheDir . '/' . basename($package);
     $tempExt = strtolower(pathinfo($package, PATHINFO_EXTENSION));
     $localTarget = $this->getLocalDataStoreFilepath();
     $localTargetExt = strtolower(pathinfo($localTarget, PATHINFO_EXTENSION));
     try {
         $success = false;
         switch (true) {
             case $localTargetExt === $tempExt:
                 $success = (bool) file_put_contents($localTarget, $data->body);
                 break;
             case 'gz' == $tempExt:
                 if (function_exists('gzdecode')) {
                     $success = (bool) file_put_contents($localTarget, gzdecode($data->body));
                 } elseif (function_exists('gzopen')) {
                     if (file_put_contents($tempTarget, $data->body)) {
                         $bufferSize = 4096;
                         // read 4kb at a time
                         $file = gzopen($tempTarget, 'rb');
                         $outFile = fopen($localTarget, 'wb');
                         while (!gzeof($file)) {
                             fwrite($outFile, gzread($file, $bufferSize));
                         }
                         fclose($outFile);
                         gzclose($file);
                         @unlink($tempTarget);
                         $success = true;
                     }
                 }
                 break;
             case 'zip' == $tempExt:
                 file_put_contents($tempTarget, $data->body);
                 $zipper = new \ZipArchive();
                 $zipper->open($tempTarget);
                 $success = $zipper->extractTo($localTarget);
                 $zipper->close();
                 @unlink($tempTarget);
                 break;
         }
     } catch (\Exception $exception) {
         error_log($exception);
         $success = false;
     }
     return $success;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:60,代码来源:AbstractLocalDataLookup.php

示例15: gunzip

function gunzip($file)
{
    $file = @gzopen($file, 'rb', 0);
    if ($file) {
        $data = '';
        while (!gzeof($file)) {
            $data .= gzread($file, 1024);
        }
        gzclose($file);
    }
    return $data;
}
开发者ID:h16o2u9u,项目名称:rtoss,代码行数:12,代码来源:lib_gzip.php


注:本文中的gzeof函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。