• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP gzopen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: geoip_detect_update

function geoip_detect_update()
{
    // TODO: Currently cron is scheduled but not executed. Remove scheduling.
    if (get_option('geoip-detect-source') != 'auto') {
        return;
    }
    $download_url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz';
    $download_url = apply_filters('geoip_detect2_download_url', $download_url);
    $outFile = geoip_detect_get_database_upload_filename();
    // Download
    $tmpFile = download_url($download_url);
    if (is_wp_error($tmpFile)) {
        return $tmpFile->get_error_message();
    }
    // Ungzip File
    $zh = gzopen($tmpFile, 'r');
    $h = fopen($outFile, 'w');
    if (!$zh) {
        return __('Downloaded file could not be opened for reading.', 'geoip-detect');
    }
    if (!$h) {
        return sprintf(__('Database could not be written (%s).', 'geoip-detect'), $outFile);
    }
    while (($string = gzread($zh, 4096)) != false) {
        fwrite($h, $string, strlen($string));
    }
    gzclose($zh);
    fclose($h);
    unlink($tmpFile);
    return true;
}
开发者ID:ryan2407,项目名称:Vision,代码行数:31,代码来源:updater.php


示例2: openFile

 protected function openFile()
 {
     $this->handle = gzopen($this->filename, 'w9');
     if ($this->handle === false) {
         throw new \RuntimeException(sprintf('Impossible to open the file %s in write mode', $this->filename));
     }
 }
开发者ID:sagikazarmark,项目名称:SitemapGenerator,代码行数:7,代码来源:GzFileDumper.php


示例3: fopen

 function fopen($filename, $mode = 'r')
 {
     if ($this->has_gzip()) {
         return gzopen($filename, $mode);
     }
     return fopen($filename, $mode);
 }
开发者ID:nishant368,项目名称:newlifeoffice-new,代码行数:7,代码来源:class.wordpress_importer.php


示例4: animetitlesUpdate

 public function animetitlesUpdate()
 {
     $pdo = $this->pdo;
     $lastUpdate = $pdo->queryOneRow('SELECT max(unixtime) as utime FROM animetitles');
     if (isset($lastUpdate['utime']) && time() - $lastUpdate['utime'] < 604800) {
         if ($this->echooutput) {
             echo "\n";
             echo $this->c->info("Last update occurred less than 7 days ago, skipping full dat file update.\n\n");
         }
         return;
     }
     if ($this->echooutput) {
         echo $this->c->header("Updating animetitles by grabbing full dat AniDB dump.\n\n");
     }
     $zh = gzopen('http://anidb.net/api/anime-titles.dat.gz', 'r');
     preg_match_all('/(\\d+)\\|\\d\\|.+\\|(.+)/', gzread($zh, '10000000'), $animetitles);
     if (!$animetitles) {
         return false;
     }
     $pdo->queryExec('DELETE FROM animetitles WHERE anidbid IS NOT NULL');
     if ($this->echooutput) {
         echo $this->c->header("Total of " . count($animetitles[1]) . " titles to add\n\n");
     }
     for ($loop = 0; $loop < count($animetitles[1]); $loop++) {
         $pdo->queryInsert(sprintf('INSERT IGNORE INTO animetitles (anidbid, title, unixtime) VALUES (%d, %s, %d)', $animetitles[1][$loop], $pdo->escapeString(html_entity_decode($animetitles[2][$loop], ENT_QUOTES, 'UTF-8')), time()));
     }
     if ($loop % 2500 == 0 && $this->echooutput) {
         echo $this->c->header("Completed Processing " . $loop . " titles.\n\n");
     }
     gzclose($zh);
     if ($this->echooutput) {
         echo $this->c->header("Completed animetitles update.\n\n");
     }
 }
开发者ID:Jay204,项目名称:nZEDb,代码行数:34,代码来源:populate_anidb.php


示例5: gzcompressfile

/**
 * Compress file on disk
 *
 * @param	string	$source
 * @param	int		$level
 * @return	string|false
 */
function gzcompressfile($source, $level = false)
{
    if (file_exists($source)) {
        $dest = $source . '.gz';
        $mode = 'wb' . $level;
        $error = false;
        if ($fp_out = gzopen($dest, $mode)) {
            if ($fp_in = fopen($source, 'rb')) {
                while (!feof($fp_in)) {
                    gzwrite($fp_out, fread($fp_in, 4096));
                }
                fclose($fp_in);
            } else {
                $error = true;
            }
            gzclose($fp_out);
        } else {
            $error = true;
        }
        if ($error) {
            return false;
        }
        return $dest;
    }
    return false;
}
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:33,代码来源:db_maintence.php


示例6: zip

 /**
  * Gzip a file
  *
  * @param string $sSourceFile Path to the source file
  * @param string $sDestinationFile [optional] Path to save the zip contents.
  * <p>
  * If NULL, the default value is $this->getDefaultDestinationFilename($sSourceFile)
  * </p>
  *
  * @return string Path to the saved zip file
  *
  * @throws FileOpenException if there is any error opening the source or output files
  * @throws FileReadException if there is an error reading the source file
  * @throws FileWriteException if there is an error writing the output file
  */
 public function zip($sSourceFile, $sDestinationFile = null)
 {
     if ($sDestinationFile === null) {
         $sDestinationFile = $this->getDefaultDestinationFilename($sSourceFile);
     }
     if (!($fh = fopen($sSourceFile, 'rb'))) {
         throw new FileOpenException($sSourceFile);
     }
     if (!($zp = gzopen($sDestinationFile, 'wb9'))) {
         throw new FileOpenException($sDestinationFile);
     }
     while (!feof($fh)) {
         $data = fread($fh, static::READ_SIZE);
         if (false === $data) {
             throw new FileReadException($sSourceFile);
         }
         $sz = strlen($data);
         if ($sz !== gzwrite($zp, $data, $sz)) {
             throw new FileWriteException($sDestinationFile);
         }
     }
     gzclose($zp);
     fclose($fh);
     return $sDestinationFile;
 }
开发者ID:vube,项目名称:php-filesystem,代码行数:40,代码来源:Gzip.php


示例7: updateGeoIpFile

 /**
  * updates the GeoIP database file
  * works only if directory geoip has rights 777, set it in ftp client
  */
 function updateGeoIpFile()
 {
     global $cpd_path;
     // set directory mode
     @chmod($cpd_path . '/geoip', 0777);
     // function checks
     if (!ini_get('allow_url_fopen')) {
         return 'Sorry, <code>allow_url_fopen</code> is disabled!';
     }
     if (!function_exists('gzopen')) {
         return __('Sorry, necessary functions (zlib) not installed or enabled in php.ini.', 'cpd');
     }
     $gzfile = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz';
     $file = $cpd_path . '/geoip/GeoIP.dat';
     // get remote file
     $h = gzopen($gzfile, 'rb');
     $content = gzread($h, 1500000);
     fclose($h);
     // delete local file
     if (is_file($file)) {
         unlink($file);
     }
     // file deleted?
     $del = is_file($file) ? 0 : 1;
     // write new locale file
     $h = fopen($file, 'wb');
     fwrite($h, $content);
     fclose($h);
     @chmod($file, 0777);
     if (is_file($file) && $del) {
         return __('New GeoIP database installed.', 'cpd');
     } else {
         return __('Sorry, an error occurred. Try again or check the access rights of directory "geoip" is 777.', 'cpd');
     }
 }
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:39,代码来源:geoip.php


示例8: import_sql

 function import_sql($filename)
 {
     $handle = @gzopen($filename, "r");
     // can open normal files, too.
     $query = "";
     $queries = 0;
     while ($handle && !feof($handle)) {
         $line = gzgets($handle, 1024);
         // keep string manipulations sane
         if ($line != "" && substr($line, 0, 2) != "--") {
             // line doesnt start with comment
             $query .= $line;
             if (substr(trim($line), -1, 1) == ";") {
                 if (!mysql_query($query)) {
                     if (defined("DEBUG")) {
                         echo "MYSQL Error: " . mysql_error() . "<Br><br>in query: {$query}";
                     } else {
                         echo "MYSQL Error: " . mysql_error();
                     }
                 }
                 $query = "";
                 $queries++;
             }
         }
     }
     return true;
 }
开发者ID:Covert-Inferno,项目名称:eve-jackknife,代码行数:27,代码来源:update.php


示例9: openResource

 protected function openResource()
 {
     if ($this->gzip_file) {
         return gzopen($this->resource, 'a');
     }
     return fopen($this->resource, 'a');
 }
开发者ID:kidaa30,项目名称:climate,代码行数:7,代码来源:File.php


示例10: rotateLogs

 /**
  * Rotate all files in var/log which ends with .log
  */
 public function rotateLogs()
 {
     $var = Mage::getBaseDir('log');
     $logDir = new Varien_Io_File();
     $logDir->cd($var);
     $logFiles = $logDir->ls(Varien_Io_File::GREP_FILES);
     foreach ($logFiles as $logFile) {
         if ($logFile['filetype'] == 'log') {
             $filename = $logFile['text'];
             if (extension_loaded('zlib')) {
                 $zipname = $var . DS . $this->getArchiveName($filename);
                 $zip = gzopen($zipname, 'wb9');
                 gzwrite($zip, $logDir->read($filename));
                 gzclose($zip);
             } else {
                 $logDir->cp($filename, $this->getArchiveName($filename));
             }
             foreach ($this->getFilesOlderThan(self::MAX_FILE_DAYS, $var, $filename) as $oldFile) {
                 $logDir->rm($oldFile['text']);
             }
             $logDir->rm($filename);
         }
     }
     $logDir->close();
 }
开发者ID:kirchbergerknorr,项目名称:firegento-logger,代码行数:28,代码来源:Observer.php


示例11: WRITE

 function WRITE($hash, $overwrite = 0)
 {
     $id = $hash["id"];
     $version = $hash["version"];
     $dbfile = $this->FN("{$id}.{$version}");
     if (!$overwrite && file_exists($dbfile)) {
         return;
     }
     #-- read-lock
     if (file_exists($dbfile)) {
         $lock = fopen($dbfile, "rb");
         flock($lock, LOCK_EX);
     }
     #-- open file for writing, secondary lock
     if ($f = gzopen($dbfile, "wb" . $this->gz)) {
         if (!lock) {
             flock($f, LOCK_EX);
         }
         $r = gzwrite($f, serialize($hash));
         gzclose($f);
         $this->SETVER($id, $version);
         $this->CACHE_ADD($id, $version);
         return 1;
     }
     #-- dispose lock
     if ($lock) {
         flock($lock, LOCK_UN);
         fclose($lock);
     }
     return 0;
 }
开发者ID:gpuenteallott,项目名称:rox,代码行数:31,代码来源:dzf2.php


示例12: restoreAction

 function restoreAction()
 {
     $backupFile = new UploadedFile("backupFile");
     if (!$backupFile->wasUploaded()) {
         return;
     }
     $gzipMode = $this->request->fileType == "gzip";
     $fileName = $backupFile->getTempName();
     $fp = $gzipMode ? gzopen($fileName, "r") : fopen($fileName, "r");
     $inString = false;
     $query = "";
     while (!feof($fp)) {
         $line = $gzipMode ? gzgets($fp) : fgets($fp);
         if (!$inString) {
             $isCommentLine = false;
             foreach (array("#", "--") as $commentTag) {
                 if (strpos($line, $commentTag) === 0) {
                     $isCommentLine = true;
                 }
             }
             if ($isCommentLine || trim($line) == "") {
                 continue;
             }
         }
         $deslashedLine = str_replace('\\', '', $line);
         if ((substr_count($deslashedLine, "'") - substr_count($deslashedLine, "\\'")) % 2) {
             $inString = !$inString;
         }
         $query .= $line;
         if (substr_compare(rtrim($line), ";", -1) == 0 && !$inString) {
             $this->database->sqlQuery($query);
             $query = "";
         }
     }
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:35,代码来源:SystemController.php


示例13: Open

 /**
  * Open a descriptor for this archive
  *
  * @param GitPHP_Archive $archive archive
  * @return boolean true on success
  */
 public function Open($archive)
 {
     if (!$archive) {
         return false;
     }
     if ($this->handle) {
         return true;
     }
     $args = array();
     $args[] = '--format=tar';
     $args[] = "--prefix='" . $archive->GetPrefix() . "'";
     $args[] = $archive->GetObject()->GetHash();
     $this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args);
     // hack to get around the fact that gzip files
     // can't be compressed on the fly and the php zlib stream
     // doesn't seem to daisy chain with any non-file streams
     $this->tempfile = tempnam(sys_get_temp_dir(), "GitPHP");
     $mode = 'wb';
     if ($this->compressLevel) {
         $mode .= $this->compressLevel;
     }
     $temphandle = gzopen($this->tempfile, $mode);
     if ($temphandle) {
         while (!feof($this->handle)) {
             gzwrite($temphandle, fread($this->handle, 1048576));
         }
         gzclose($temphandle);
         $temphandle = fopen($this->tempfile, 'rb');
     }
     if ($this->handle) {
         pclose($this->handle);
     }
     $this->handle = $temphandle;
     return $this->handle !== false;
 }
开发者ID:fboender,项目名称:gitphp,代码行数:41,代码来源:Archive_Gzip.class.php


示例14: testCreate

 public function testCreate()
 {
     $sitemap = new Sitemap(['maxUrlsCountInFile' => 1]);
     $sitemapDirectory = $sitemap->sitemapDirectory = $this->path;
     $sitemap->addModel(Category::className());
     $sitemap->setDisallowUrls(['#category_2#']);
     $sitemap->create();
     $sitemapFileNames = array();
     foreach (glob("{$sitemapDirectory}/sitemap*") as $sitemapFilePath) {
         $sitemapFileNames[] = basename($sitemapFilePath);
     }
     $this->assertEquals($sitemapFileNames, array('sitemap.xml', 'sitemap.xml.gz', 'sitemap1.xml', 'sitemap1.xml.gz', 'sitemap2.xml', 'sitemap2.xml.gz'));
     $xmlData = file_get_contents("{$sitemapDirectory}/sitemap.xml");
     $this->assertNotFalse(strpos($xmlData, '<?xml version="1.0" encoding="UTF-8"?>'));
     $xmlData = file_get_contents("{$sitemapDirectory}/sitemap2.xml");
     $this->assertNotFalse(strpos($xmlData, '<loc>http://localhost/category_3</loc>'));
     $gzSitemap = gzopen("{$sitemapDirectory}/sitemap.xml.gz", "r");
     $sitemap = fopen("{$sitemapDirectory}/sitemap.xml", "r");
     $this->assertEquals(fread($gzSitemap, 2000), fread($sitemap, 2000));
     gzclose($gzSitemap);
     fclose($sitemap);
     $gzSitemap = gzopen("{$sitemapDirectory}/sitemap2.xml.gz", "r");
     $sitemap = fopen("{$sitemapDirectory}/sitemap2.xml", "r");
     $this->assertEquals(fread($gzSitemap, 2000), fread($sitemap, 2000));
     gzclose($gzSitemap);
     fclose($sitemap);
 }
开发者ID:zhelyabuzhsky,项目名称:yii2-sitemap,代码行数:27,代码来源:SitemapTest.php


示例15: gzcompressfile

/**
 * Pimcore
 *
 * This source file is available under two different licenses:
 * - GNU General Public License version 3 (GPLv3)
 * - Pimcore Enterprise License (PEL)
 * Full copyright and license information is available in
 * LICENSE.md which is distributed with this source code.
 *
 * @copyright  Copyright (c) 2009-2016 pimcore GmbH (http://www.pimcore.org)
 * @license    http://www.pimcore.org/license     GPLv3 and PEL
 */
function gzcompressfile($source, $level = null, $target = null)
{
    // this is a very memory efficient way of gzipping files
    if ($target) {
        $dest = $target;
    } else {
        $dest = $source . '.gz';
    }
    $mode = 'wb' . $level;
    $error = false;
    $fp_out = gzopen($dest, $mode);
    $fp_in = fopen($source, 'rb');
    if ($fp_out && $fp_in) {
        while (!feof($fp_in)) {
            gzwrite($fp_out, fread($fp_in, 1024 * 512));
        }
        fclose($fp_in);
        gzclose($fp_out);
    } else {
        $error = true;
    }
    if ($error) {
        return false;
    } else {
        return $dest;
    }
}
开发者ID:pimcore,项目名称:pimcore,代码行数:39,代码来源:helper.php


示例16: geoip_detect_update

function geoip_detect_update()
{
    $download_url = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz';
    $outFile = geoip_detect_get_database_upload_filename();
    // Download
    $tmpFile = download_url($download_url);
    if (is_wp_error($tmpFile)) {
        return $tmpFile->get_error_message();
    }
    // Ungzip File
    $zh = gzopen($tmpFile, 'r');
    $h = fopen($outFile, 'w');
    if (!$zh) {
        return __('Downloaded file could not be opened for reading.', 'geoip-detect');
    }
    if (!$h) {
        return sprintf(__('Database could not be written (%s).', 'geoip-detect'), $outFile);
    }
    while (($string = gzread($zh, 4096)) != false) {
        fwrite($h, $string, strlen($string));
    }
    gzclose($zh);
    fclose($h);
    //unlink($tmpFile);
    return true;
}
开发者ID:yavormilchev,项目名称:wp-geoip-detect,代码行数:26,代码来源:updater.php


示例17: 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


示例18: setFile

 private function setFile()
 {
     $recognize = '';
     $recognize = implode('_', $this->dbName);
     $fileName = $this->trimPath($this->config['path'] . self::DIR_SEP . time() . '.sql');
     $path = $this->setPath($fileName);
     if ($path !== true) {
         $this->error("无法创建备份目录目录 '{$path}'");
     }
     if ($this->config['isCompress'] == 0) {
         if (!file_put_contents($fileName, $this->content, LOCK_EX)) {
             $this->error('写入文件失败,请检查磁盘空间或者权限!');
         }
     } else {
         if (function_exists('gzwrite')) {
             $fileName .= '.gz';
             if ($gz = gzopen($fileName, 'wb')) {
                 gzwrite($gz, $this->content);
                 gzclose($gz);
             } else {
                 $this->error('写入文件失败,请检查磁盘空间或者权限!');
             }
         } else {
             $this->error('没有开启gzip扩展!');
         }
     }
     if ($this->config['isDownload']) {
         $this->downloadFile($fileName);
     }
 }
开发者ID:liuguogen,项目名称:weixin,代码行数:30,代码来源:MySQLReback.class.php


示例19: 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


示例20: __construct

	/**
	 * Opens a gzip file.
	 * 
	 * @param	string		$filename
	 * @param	string		$mode
	 */
	public function __construct($filename, $mode = 'wb') {
		$this->filename = $filename;
		$this->resource = gzopen($filename, $mode);
		if ($this->resource === false) {
			throw new SystemException('Can not open file ' . $filename);
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:13,代码来源:GZipFile.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP gzopen64函数代码示例发布时间:2022-05-15
下一篇:
PHP gzip_page函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap