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


PHP gzfile函数代码示例

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


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

示例1: uncompress

function uncompress($srcName, $dstName)
{
    $string = implode("", gzfile($srcName));
    $fp = fopen($dstName, "w");
    fwrite($fp, $string, strlen($string));
    fclose($fp);
}
开发者ID:Braigns,项目名称:text-normalization,代码行数:7,代码来源:parse_subs.php

示例2: importSql

 /**
  * Read from SQL file and make sql query
  */
 function importSql($file)
 {
     // Reading SQL from file
     if ($this->compress) {
         $lines = gzfile($file);
     } else {
         $lines = file($file);
     }
     $x = 0;
     $importSql = "";
     $procent = 0;
     foreach ($lines as $line) {
         $x++;
         // Importing SQL
         $importSql .= $line;
         if (substr(trim($line), strlen(trim($line)) - 1) == ";") {
             $query = @mysql_query($importSql, $this->connection);
             if (!$query) {
                 return false;
             }
             $importSql = "";
         }
     }
     return true;
 }
开发者ID:googlesky,项目名称:snsp.vn,代码行数:28,代码来源:phpMyImporter.php

示例3: grab

 function grab()
 {
     set_time_limit(0);
     $str = implode("", gzfile($this->irs->cfg["grabber_libredb_audio1_url"]));
     preg_match_all("/<Track>(.*?)<\\/Track>/is", $str, $matches, PREG_SET_ORDER);
     for ($i = 0; $i < count($matches); $i++) {
         $arr = $this->makeXMLTree($matches[$i][0]);
         $id = $arr["Track"][0]["ldbid"][0] . "-0";
         $trackid = $this->irs->addTrack(array("artistname" => $arr["Track"][0]["artistname"][0], "id" => $id, "albumname" => $arr["Track"][0]["albumname"][0], "duration" => $arr["Track"][0]["duration"][0], "pubdate" => $arr["Track"][0]["pubdate"][0], "license" => $arr["Track"][0]["license"][0], "trackname" => $arr["Track"][0]["trackname"][0], "crediturl" => $arr["Track"][0]["crediturl"][0]));
         $dists =& $arr["Track"][0]["Distributions"][0]["Distribution"];
         for ($y = 0; $y < count($dists); $y++) {
             $sources =& $dists[$y]["Sources"][0]["Source"];
             $did = "";
             //check if the distribution already exists.
             for ($z = 0; $z < count($sources); $z++) {
                 $did = $this->irs->db->getOne("SELECT distribid FROM irate_sources WHERE protocol=? AND link=?", array($sources[$z]["protocol"][0], $sources[$z]["link"][0]));
                 if (!empty($did)) {
                     $z = 9999;
                 }
             }
             $did = $this->irs->addDistribution(array("id" => $did, "trackid" => $trackid, "crediturl" => $dists[$y]["crediturl"][0], "filesize" => $dists[$y]["filesize"][0], "hash_sha1" => $dists[$y]["hash_sha1"][0], "codec" => $dists[$y]["codec"][0]));
             $this->irs->resetSources($did);
             //delete all the sources, to add them again.
             for ($z = 0; $z < count($sources); $z++) {
                 $this->irs->addSource(array("distribid" => $did, "protocol" => $sources[$z]["protocol"][0], "crediturl" => $sources[$z]["crediturl"][0], "link" => $sources[$z]["link"][0], "media" => 1));
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:irate-svn,代码行数:29,代码来源:libredb_audio1.php

示例4: get_data

function get_data($filename)
{
    if (preg_match('/.*?\\.php/', $filename)) {
        return;
    }
    if (is_dir($filename)) {
        return;
    }
    echo "{$filename} size " . filesize($filename) . "\n";
    if (substr($filename, -3) == '.gz') {
        $inf_str = join('', gzfile($filename));
        //print_r(unserialize($inf_str));
        //return;
        $ar = unserialize($inf_str);
        //       print_r($ar);
        //       $inf = array_shift($ar);
        // print_r($inf);
        //  return;
        for ($i = 0; $i < count($ar); $i++) {
            echo "Name: " . $ar[$i]['name'] . "\n";
            echo "Title: " . $ar[$i]['title'] . "\n";
            //  echo "Item: " . $ar[$i]['item'] ."\n\n";
        }
        return;
    } else {
        $inf_str = file_get_contents($filename);
        $inf = unserialize($inf_str);
        //
        print_r($inf);
    }
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:get_inf.php

示例5: get

 /**
  * Get string value of $key from cache
  * @param string $key
  * @return string|boolean false on failure / cache miss
  */
 public function get($key)
 {
     $cleanKey = $this->sanitiseKey($key);
     $fname = $this->config->cachedir . '/' . $cleanKey;
     if (!file_exists($fname)) {
         $this->logger->debug("[Cache] Cache miss for [{$key}]");
         return false;
     }
     $this->logger->debug("[Cache] Cache hit for [{$key}]");
     if ($this->config->usezip) {
         if ($content = @join("", @gzfile($fname))) {
             if ($this->config->converttozip) {
                 @($fp = fopen($fname, "r"));
                 $zipchk = fread($fp, 2);
                 fclose($fp);
                 if (!($zipchk[0] == chr(31) && $zipchk[1] == chr(139))) {
                     //checking for zip header
                     /* converting on access */
                     $fp = @gzopen($fname, "w");
                     @gzputs($fp, $content);
                     @gzclose($fp);
                 }
             }
             return $content;
         }
     } else {
         // no zip
         return file_get_contents($fname);
     }
 }
开发者ID:snatcho,项目名称:laquinieladelososcars,代码行数:35,代码来源:imdb_cache.class.php

示例6: backwpup_read_logfile

function backwpup_read_logfile($logfile)
{
    if (is_file($logfile) and substr($logfile, -3) == '.gz') {
        $logfiledata = gzfile($logfile);
    } elseif (is_file($logfile . '.gz')) {
        $logfiledata = gzfile($logfile . '.gz');
    } elseif (is_file($logfile)) {
        $logfiledata = file($logfile);
    } else {
        return array();
    }
    $lines = array();
    $start = false;
    foreach ($logfiledata as $line) {
        $line = trim($line);
        if (strripos($line, '<body') !== false) {
            // jop over header
            $start = true;
            continue;
        }
        if ($line != '</body>' and $line != '</html>' and $start) {
            //no Footer
            $lines[] = $line;
        }
    }
    return $lines;
}
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:27,代码来源:show_working.php

示例7: gunzip2

 function gunzip2($infile, $outfile)
 {
     $string = implode("", gzfile($infile));
     $fp = fopen($outfile, "w");
     fwrite($fp, $string, strlen($string));
     fclose($fp);
 }
开发者ID:BackupTheBerlios,项目名称:idb,代码行数:7,代码来源:compression.php

示例8: preFillFromSourceLanguage

 public function preFillFromSourceLanguage($useGoogleTranslateData = true)
 {
     $path = APPPATH . "resources/languageforge/semdomtrans/GoogleTranslateHarvester/semdom-google-translate-{$this->languageIsoCode}.txt.gz";
     $googleTranslateData = [];
     if ($useGoogleTranslateData && file_exists($path)) {
         $lines = gzfile($path);
         foreach ($lines as $line) {
             $splitLine = explode("|", $line);
             if (count($splitLine) == 2) {
                 $googleTranslateData[$splitLine[0]] = $splitLine[1];
             }
         }
     }
     // cjh review: we may actually want to only prefill from English, if in the future we allow creating projects from incomplete source projects
     $sourceProject = new SemDomTransProjectModel($this->sourceLanguageProjectId->asString());
     $this->_copyXmlToAssets($sourceProject->xmlFilePath);
     $sourceItems = new SemDomTransItemListModel($sourceProject);
     $sourceItems->read();
     foreach ($sourceItems->entries as $item) {
         $newItem = new SemDomTransItemModel($this);
         // if Google translation exists for given name exists, use it
         if (array_key_exists($item['name']['translation'], $googleTranslateData)) {
             $newItem->name->translation = $googleTranslateData[$item['name']['translation']];
             $newItem->name->status = SemDomTransStatus::Suggested;
         }
         // if Google translation exists for given description exists, use it
         if (array_key_exists($item['description']['translation'], $googleTranslateData)) {
             $newItem->description->translation = $googleTranslateData[$item['description']['translation']];
             $newItem->description->status = SemDomTransStatus::Suggested;
         }
         $newItem->key = $item['key'];
         for ($x = 0; $x < count($item['questions']); $x++) {
             $q = new SemDomTransQuestion();
             // if Google translation exists for given question, use it
             if (array_key_exists($item['questions'][$x]['question']['translation'], $googleTranslateData)) {
                 $q->question->translation = $googleTranslateData[$item['questions'][$x]['question']['translation']];
                 $q->question->status = SemDomTransStatus::Suggested;
             }
             // if Google translation exists for given question term, use it
             if (array_key_exists($item['questions'][$x]['terms']['translation'], $googleTranslateData)) {
                 $q->terms->translation = $googleTranslateData[$item['questions'][$x]['terms']['translation']];
                 $q->terms->status = SemDomTransStatus::Suggested;
             }
             $newItem->questions[] = $q;
         }
         for ($x = 0; $x < count($item['searchKeys']); $x++) {
             $sk = new SemDomTransTranslatedForm();
             // if Google translation exists for given search key, use it
             if (array_key_exists($item['searchKeys'][$x]['translation'], $googleTranslateData)) {
                 $sk->translation = $googleTranslateData[$item['searchKeys'][$x]['translation']];
                 $sk->status = SemDomTransStatus::Suggested;
             }
             $newItem->searchKeys[] = $sk;
         }
         $newItem->xmlGuid = $item['xmlGuid'];
         $newItem->write();
     }
 }
开发者ID:bbriggs,项目名称:web-languageforge,代码行数:58,代码来源:SemDomTransProjectModel.php

示例9: fetchPageText

 function fetchPageText()
 {
     if ($this->useGzip()) {
         /* Why is there no gzfile_get_contents() or gzdecode()? */
         return implode('', gzfile($this->fileCacheName()));
     } else {
         return $this->fetchRawText();
     }
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:9,代码来源:CacheManager.php

示例10: gzReadFile

 public function gzReadFile($path)
 {
     if ($this->fileExists("{$path}.gz")) {
         return gzfile("{$path}.gz");
     } elseif ($this->fileExists($path)) {
         return file($path);
     }
     return null;
 }
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:9,代码来源:FileHandler.php

示例11: generateSnapshots

 /**
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots()
 {
     $uri = 'http://pokap.io/';
     $provider = new MementoProvider();
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/pokap.io-memento.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
开发者ID:pokap,项目名称:webarchive,代码行数:15,代码来源:MementoProviderTest.php

示例12: uncompress

 /**
  * TEST , try to uncompress a file and return the content or save on server
  * @param filename, path where uncompress
  * @return buffer uncompressed or boolean for save success if path given
  */
 public function uncompress($filename, $path = null)
 {
     if ($path) {
         if ($fp = fopen($path, 'w')) {
             fwrite($fp, implode('', gzfile($filename)), strlen(implode('', gzfile($filename))));
             fclose($fp);
             return true;
         }
         return false;
     }
     return implode('', gzfile($filename));
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:17,代码来源:copixgzipfile.class.php

示例13: wiki_download_icon

function wiki_download_icon($name) {
  global $icon_list;
  global $wiki_img;
  global $wiki_imgsrc;
  global $icon_dir;

  $icon=strtr($name, array(" "=>"_"));
  if(preg_match("/^(.*)\.[^\.]*$/", $name, $m))
    $icon_id=$m[1];
  else
    $icon_id=$name;

  if(preg_match("/^OSB (.*)$/i", $icon_id, $m))
    $icon_id=$m[1];

  $f=$icon_dir->get_obj($icon_id);
  if($f)
    return $icon_id;

  if(!isset($icon_list[$icon])) {
    $img_data=gzfile("$wiki_img$icon");

    if(!$img_data)
      print "Can't open $wiki_img$icon\n";

    unset($icon_path);
    foreach($img_data as $r) {
      if(eregi("<div class=\"fullImageLink\" .*<a href=\"([^\"]*)\">", $r, $m)) {
	print "DOWNLOADING $m[1]\n";
	$img=file_get_contents("$wiki_imgsrc$m[1]");
	if(!$img)
	  print "Can't download $wiki_imgsrc$m[1]\n";
      }
    }
  }

  $f=$icon_dir->create_obj($icon_id);
  $f->save("file.src", $img);

  $d=new DOMDocument();
  $tags=dom_create_append($d, "tags", $d);
  $tag=dom_create_append($tags, "tag", $d);
  $tag->setAttribute("k", "name");
  $tag->setAttribute("v", $icon_id);

  $tag=dom_create_append($tags, "tag", $d);
  $tag->setAttribute("k", "source");
  $tag->setAttribute("v", "$wiki_img$icon");

  $f->save("tags.xml", $d->saveXML());

  return $icon_id;
}
开发者ID:plepe,项目名称:OpenStreetBrowser,代码行数:53,代码来源:wiki_to_category_xml.php

示例14: generateSnapshots

 /**
  * @param int $year
  *
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots($year)
 {
     $uri = 'http://archive.org/';
     $provider = new WayBackProvider($year);
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/archive.org-' . $year . '.html.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
开发者ID:pokap,项目名称:webarchive,代码行数:17,代码来源:WayBackProviderTest.php

示例15: restore_file

function restore_file($datefile)
{
    //备用
    global $strDataRestoreNoFile, $DMC, $strDataRestoreBad, $strDataRestoreSuccess, $data_path, $_SESSION;
    $fname = $data_path . "/" . $datefile;
    if (strpos($fname, ".zip") > 0) {
        $sqls = gzfile($fname);
    } else {
        $sqls = file($fname);
    }
    //print_r($sqls);
    $query = "";
    $lastchar = false;
    foreach ($sqls as $sql) {
        $sql = trim($sql);
        $sql = str_replace("\r", "", $sql);
        $sql = str_replace("\n", "", $sql);
        if (substr($sql, 0, 2) != "--" && $sql != "") {
            if ($lastchar == true && preg_match("/^[DROP TABLE|CREATE TABLE|INSERT INTO]/", $sql)) {
                if (mysql_get_server_info() < 4.1) {
                    $query = str_replace("ENGINE=MyISAM DEFAULT CHARSET=utf8", "TYPE=MyISAM", $query);
                } else {
                    $query = str_replace("TYPE=MyISAM", "ENGINE=MyISAM DEFAULT CHARSET=utf8", $query);
                }
                $DMC->query($query, "T");
                if ($DMC->error()) {
                    $_SESSION['array_errorsql'][$DMC->error()] = $query;
                }
                $query = "";
                $lastchar = false;
            }
            $query .= $sql;
            if (substr($sql, strlen($sql) - 1) == ";") {
                $lastchar = true;
            }
        }
    }
    if ($query != "" && $lastchar == true) {
        //运行最后一个query;
        $DMC->query($query, "T");
        if ($DMC->error()) {
            $_SESSION['array_errorsql'][$DMC->error()] = $query;
        }
    }
    //返回结果
    if (is_array($_SESSION['array_errorsql'])) {
        $ActionMessage = "{$datefile} ==> " . $strDataRestoreBad;
    } else {
        $ActionMessage = "{$datefile} ==> " . $strDataRestoreSuccess;
    }
    return $ActionMessage;
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:52,代码来源:db_restore.php


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