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


PHP gzputs函数代码示例

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


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

示例1: gzipContent

 /**
  * Gzip content
  *
  * @param string $filePath
  * @param string $content
  * @return void
  */
 protected function gzipContent($filePath, $content)
 {
     $functionName = function_exists('gzopen') ? 'gzopen' : 'gzopen64';
     $gzip = $functionName($filePath . $this->gzFileExtension, $this->gzCompressionLevel);
     gzputs($gzip, $content);
     gzclose($gzip);
 }
开发者ID:esase,项目名称:dream-cms,代码行数:14,代码来源:LayoutHeadResource.php

示例2: setInternal

 /**
  * @inheritdoc
  */
 public function setInternal($key, $cleanKey, $value)
 {
     $fname = $this->config->cachedir . '/' . $cleanKey;
     $this->logger->debug("[Cache] Writing key [{$key}] to [{$fname}]");
     if ($this->config->usezip) {
         $fp = gzopen($fname, "w");
         gzputs($fp, $value);
         gzclose($fp);
     } else {
         // no zip
         $this->logger->debug("[Cache] Writing {$fname}");
         file_put_contents($fname, $value);
     }
 }
开发者ID:tboothman,项目名称:imdbphp,代码行数:17,代码来源:Cache.php

示例3: fputcsvex

function fputcsvex($f, $listi, $d = ",", $q = '"')
{
    $line = "";
    foreach ($listi as $field) {
        $field = iconv("utf-8", "windows-1251", $field);
        # remove any windows new lines,
        # as they interfere with the parsing at the other end
        $field = str_replace("\r\n", " ", $field);
        # if a deliminator char, a double quote char or a newline
        # are in the field, add quotes
        if (ereg("[{$d}{$q}\n\r]", $field)) {
            $field = $q . str_replace($q, $q . $q, $field) . $q;
        }
        $line .= $field . $d;
    }
    # strip the last deliminator
    $line = substr($line, 0, -1);
    # add the newline
    $line .= "\n";
    # we don't care if the file pointer is invalid,
    # let fputs take care of it
    return gzputs($f, $line);
}
开发者ID:gblok,项目名称:rsc,代码行数:23,代码来源:catalog_excel_export.php

示例4: set

 /**
  * Store $value to the disk cache
  * @param string $key
  * @param string $value
  * @return bool successful?
  */
 public function set($key, $value)
 {
     $cleanKey = $this->sanitiseKey($key);
     if (!is_dir($this->config->cachedir)) {
         $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] does not exist!");
         return false;
     }
     if (!is_writable($this->config->cachedir)) {
         $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] lacks write permission!");
         return false;
     }
     $fname = $this->config->cachedir . '/' . $cleanKey;
     $this->logger->debug("[Cache] Writing key [{$key}] to [{$fname}]");
     if ($this->config->usezip) {
         $fp = gzopen($fname, "w");
         gzputs($fp, $value);
         gzclose($fp);
     } else {
         // no zip
         $this->logger->debug("[Cache] Writing {$fname}");
         file_put_contents($fname, $value);
     }
     return true;
 }
开发者ID:snatcho,项目名称:laquinieladelososcars,代码行数:30,代码来源:imdb_cache.class.php

示例5: cache_write

 /** Writing content to cache
  * @method cache_write
  * @param string filename file name relative to cache dir to store the content into
  * @param ref string content content to store
  */
 public function cache_write($file, &$content)
 {
     if (!is_dir($this->cachedir)) {
         $this->debug_scalar("<BR>***ERROR*** Configured cache directory does not exist!<BR>");
     } elseif (!is_writable($this->cachedir)) {
         $this->debug_scalar("<BR>***ERROR*** Configured cache directory lacks write permission!<BR>");
     } else {
         $fname = $this->cachedir . '/' . $file;
         if ($this->usezip) {
             $fp = gzopen($fname, "w");
             gzputs($fp, $content);
             gzclose($fp);
         } else {
             // no zip
             $fp = fopen($fname, "w");
             fputs($fp, $content);
             fclose($fp);
         }
     }
 }
开发者ID:UniversalAdministrator,项目名称:U-232-V4,代码行数:25,代码来源:mdb_base.class.php

示例6: privAddFileUsingTempFile

 function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
 {
     $startTime = microtime(true);
     $v_result = IWP_PCLZIP_ERR_NO_ERROR;
     // ----- Working variable
     $p_filename = $p_filedescr['filename'];
     // ----- Open the source file
     if (($v_file = @fopen($p_filename, "rb")) == 0) {
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '{$p_filename}' in binary read mode. Please try changing the file permission to 644 or exclude this file from your backup.");
         //return array( 'error' => "Unable to open file '$p_filename' in binary read mode. Please try changing the file permission to 644 or exclude this file from your backup.");
         return IWPPclZip::errorCode();
     }
     // ----- Creates a compressed temporary file
     $v_gzip_temp_name = IWP_PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz';
     if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
         fclose($v_file);
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode');
         //return array( 'error' => 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
         return IWPPclZip::errorCode();
     }
     $tempLoopStart = microtime(true);
     // ----- Read the file by IWP_PCLZIP_READ_BLOCK_SIZE octets blocks
     //$v_size = iwp_mmb_get_file_size($p_filename);
     $v_size = $p_filedescr['size'];
     //darkPrince setting fileSize from Array
     if ($p_filedescr['splitFilename'] != '') {
         @fseek($v_file, $p_filedescr['splitOffset']);
     }
     while ($v_size != 0) {
         $v_read_size = $v_size < IWP_PCLZIP_READ_BLOCK_SIZE ? $v_size : IWP_PCLZIP_READ_BLOCK_SIZE;
         $v_buffer = @fread($v_file, $v_read_size);
         //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
         @gzputs($v_file_compressed, $v_buffer, $v_read_size);
         $v_size -= $v_read_size;
     }
     // ----- Close the file
     @fclose($v_file);
     @gzclose($v_file_compressed);
     //$timeTak = microtime(true) - $tempLoopStart;
     // ----- Check the minimum file size
     if (iwp_mmb_get_file_size($v_gzip_temp_name) < 18) {
         echo "Check the minimum file size error";
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \'' . $v_gzip_temp_name . '\' has invalid filesize - should be minimum 18 bytes');
         //return array( 'error' => 'Zip-error: Error compressing the file "'.$p_filedescr['filename'].'".Try excluding this file and try again.');
         return IWPPclZip::errorCode();
     }
     // ----- Extract the compressed attributes
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
         return IWPPclZip::errorCode();
     }
     // ----- Read the gzip file header
     $v_binary_data = @fread($v_file_compressed, 10);
     $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
     // ----- Check some parameters
     $v_data_header['os'] = bin2hex($v_data_header['os']);
     // ----- Read the gzip file footer
     @fseek($v_file_compressed, iwp_mmb_get_file_size($v_gzip_temp_name) - 8);
     $v_binary_data = @fread($v_file_compressed, 8);
     $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
     // ----- Set the attributes
     $p_header['compression'] = ord($v_data_header['cm']);
     //$p_header['mtime'] = $v_data_header['mtime'];
     $p_header['crc'] = $v_data_footer['crc'];
     $p_header['compressed_size'] = iwp_mmb_get_file_size($v_gzip_temp_name) - 18;
     if ($p_filedescr['splitFilename'] != '') {
         $p_header['filename'] = $p_filedescr['stored_filename'] . $p_filedescr['splitFilename'];
     }
     // ----- Close the file
     @fclose($v_file_compressed);
     // ----- Call the header generation
     if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
         return $v_result;
     }
     // ----- Add the compressed data
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
         return IWPPclZip::errorCode();
     }
     // ----- Read the file by IWP_PCLZIP_READ_BLOCK_SIZE octets blocks
     @fseek($v_file_compressed, 10);
     $v_size = $p_header['compressed_size'];
     while ($v_size != 0) {
         $v_read_size = $v_size < IWP_PCLZIP_READ_BLOCK_SIZE ? $v_size : IWP_PCLZIP_READ_BLOCK_SIZE;
         $v_buffer = @fread($v_file_compressed, $v_read_size);
         if ($v_buffer === false) {
             return -1;
         }
         //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
         $wr_result = @fwrite($this->zip_fd, $v_buffer, $v_read_size);
         if ($wr_result === false) {
             return -1;
         }
         $v_size -= $v_read_size;
     }
     // ----- Close the file
     @fclose($v_file_compressed);
     // ----- Unlink the temporary file
     @unlink($v_gzip_temp_name);
     $timeTakenFOrTempAdd = microtime(true) - $startTime;
//.........这里部分代码省略.........
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:101,代码来源:pclzip.class.php

示例7: _writeBlock

 private function _writeBlock($v_binary_data, $iLen = false)
 {
     if (is_resource($this->_dFile)) {
         if ($iLen === false) {
             if ($this->_bCompress) {
                 @gzputs($this->_dFile, $v_binary_data);
             } else {
                 @fputs($this->_dFile, $v_binary_data);
             }
         } else {
             if ($this->_bCompress) {
                 @gzputs($this->_dFile, $v_binary_data, $iLen);
             } else {
                 @fputs($this->_dFile, $v_binary_data, $iLen);
             }
         }
     }
     return true;
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:19,代码来源:tar_gz.php

示例8: PclTarHandleUpdate


//.........这里部分代码省略.........
         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 {
开发者ID:chegestar,项目名称:catroxs,代码行数:67,代码来源:pcltar.lib.php

示例9: serProductAndCategoriesSerialization

function serProductAndCategoriesSerialization($fileName)
{
    $f = gzopen($fileName, "w");
    $xmlTables = new XmlNode();
    $xmlTables->LoadInnerXmlFromFile(DATABASE_STRUCTURE_XML_PATH);
    $array = $xmlTables->SelectNodes("DataBaseStructure/tables/table");
    foreach ($array as $xmlTable) {
        $attrubtes = $xmlTable->GetXmlNodeAttributes();
        if (isset($attrubtes["PRODUCTANDCATEGORYSYNC"])) {
            if (strtoupper($attrubtes["PRODUCTANDCATEGORYSYNC"]) == "TRUE") {
                $res = _tableSerialization($xmlTable);
                gzputs($f, $res . "\n");
            }
        }
    }
    gzclose($f);
}
开发者ID:gblok,项目名称:rsc,代码行数:17,代码来源:serialization_functions.php

示例10: dirname

<?php

$filename = dirname(__FILE__) . "/gzputs_basic.txt.gz";
$h = gzopen($filename, 'w');
$str = "Here is the string to be written. ";
$length = 10;
var_dump(gzputs($h, $str));
var_dump(gzputs($h, $str, $length));
gzclose($h);
$h = gzopen($filename, 'r');
gzpassthru($h);
gzclose($h);
echo "\n";
unlink($filename);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:16,代码来源:gzputs_basic.php

示例11: privAddFile


//.........这里部分代码省略.........
     // ----- Check the path length
     if (strlen($p_header['stored_filename']) > 0xff) {
         $p_header['status'] = 'filename_too_long';
     }
     // ----- Look if no error, or file not skipped
     if ($p_header['status'] == 'ok') {
         // ----- Look for a file
         if (is_file($p_filename)) {
             // ----- Open the source file
             if (($v_file = @fopen($p_filename, "rb")) == 0) {
                 // ----- Error log
                 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '{$p_filename}' in binary read mode");
                 // ----- Return
                 PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
                 return PclZip::errorCode();
             }
             // ----- Creates a compressed temporary file
             if (($v_file_compressed = @gzopen($p_filename . '.gz', "wb")) == 0) {
                 // ----- Close the file
                 fclose($v_file);
                 // ----- Error log
                 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Unable to open file '{$p_filename}.gz' in gz binary write mode");
                 // ----- Return
                 PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
                 return PclZip::errorCode();
             }
             // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
             $v_size = filesize($p_filename);
             while ($v_size != 0) {
                 $v_read_size = $v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE;
                 PclTraceFctMessage(__FILE__, __LINE__, 2, "Read {$v_read_size} bytes");
                 $v_buffer = fread($v_file, $v_read_size);
                 $v_binary_data = pack('a' . $v_read_size, $v_buffer);
                 @gzputs($v_file_compressed, $v_binary_data, $v_read_size);
                 $v_size -= $v_read_size;
             }
             // ----- Close the file
             @fclose($v_file);
             @gzclose($v_file_compressed);
             // ----- Check the minimum file size
             PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size " . filesize($p_filename . '.gz'));
             if (filesize($p_filename . '.gz') < 18) {
                 // ----- Error log
                 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Invalid file "' . $p_filename . '.gz' . '" size (less than header size)');
                 // ----- Return
                 PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
                 return PclZip::errorCode();
             }
             // ----- Extract the compressed attributes
             if (($v_file_compressed = @fopen($p_filename . '.gz', "rb")) == 0) {
                 // ----- Error log
                 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '{$p_filename}.gz' in gz binary read mode");
                 // ----- Return
                 PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
                 return PclZip::errorCode();
             }
             // ----- Read the gzip file header
             $v_binary_data = @fread($v_file_compressed, 10);
             $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
             // ----- Check some parameters
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]=' . bin2hex($v_data_header['id1']));
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]=' . bin2hex($v_data_header['id2']));
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]=' . bin2hex($v_data_header['cm']));
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]=' . bin2hex($v_data_header['flag']));
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]=' . $v_data_header['mtime']);
             PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]=' . bin2hex($v_data_header['xfl']));
开发者ID:BackupTheBerlios,项目名称:phreakpic,代码行数:67,代码来源:pclzip-trace.lib.php

示例12: openpage

 /** Load an IMDB page into the corresponding property (variable)
  * @method private openpage
  * @param string wt internal name of the page
  * @param optional string type whether its a "movie" (default) or a "person"
  */
 function openpage($wt, $type = "movie")
 {
     if (strlen($this->imdbID) != 7) {
         $this->debug_scalar("not valid imdbID: " . $this->imdbID . "<BR>" . strlen($this->imdbID));
         $this->page[$wt] = "cannot open page";
         return;
     }
     $urlname = $this->set_pagename($wt);
     if ($urlname === false) {
         return;
     }
     if ($this->usecache) {
         $fname = "{$this->cachedir}/{$this->imdbID}.{$wt}";
         if ($this->usezip) {
             if ($this->page[$wt] = @join("", @gzfile($fname))) {
                 if ($this->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, $this->page[$wt]);
                         @gzclose($fp);
                     }
                 }
                 return;
             }
         } else {
             // no zip
             @($fp = fopen($fname, "r"));
             if ($fp) {
                 $temp = "";
                 while (!feof($fp)) {
                     $temp .= fread($fp, 1024);
                     $this->page[$wt] = $temp;
                 }
                 return;
             }
         }
     }
     // end cache
     $req = new IMDB_Request("");
     switch ($type) {
         case "person":
             $url = "http://" . $this->imdbsite . "/name/nm" . $this->imdbID . $urlname;
             break;
         default:
             $url = "http://" . $this->imdbsite . "/title/tt" . $this->imdbID . $urlname;
     }
     $req->setURL($url);
     $req->sendRequest();
     $this->page[$wt] = $req->getResponseBody();
     if ($this->page[$wt]) {
         //storecache
         if ($this->storecache) {
             if (!is_dir($this->cachedir)) {
                 $this->debug_scalar("<BR>***ERROR*** Configured cache directory does not exist!<BR>");
                 return;
             }
             if (!is_writable($this->cachedir)) {
                 $this->debug_scalar("<BR>***ERROR*** Configured cache directory lacks write permission!<BR>");
                 return;
             }
             $fname = "{$this->cachedir}/{$this->imdbID}.{$wt}";
             if ($this->usezip) {
                 $fp = gzopen($fname, "w");
                 gzputs($fp, $this->page[$wt]);
                 gzclose($fp);
             } else {
                 // no zip
                 $fp = fopen($fname, "w");
                 fputs($fp, $this->page[$wt]);
                 fclose($fp);
             }
         }
         return;
     }
     $this->page[$wt] = "cannot open page";
     $this->debug_scalar("cannot open page: {$url}");
 }
开发者ID:squiddz,项目名称:moviesquiddz,代码行数:87,代码来源:imdb_base.class.php

示例13: Ajouter_visite

 public static function Ajouter_visite($nom_page, $langue, $anonymisation_ip, $respect_dnt)
 {
     // Récupération des infos
     if (strlen($nom_page) == 0) {
         return;
     }
     $dnt = isset($_SERVER["HTTP_DNT"]) ? !strcmp($_SERVER["HTTP_DNT"], "1") : false;
     if ($respect_dnt && $dnt) {
         $ip = _DB_VISITES_IP_DNT;
         $pays = _DB_VISITES_LABEL_GEOLOC_INCONNUE;
         $ville = _DB_VISITES_LABEL_GEOLOC_INCONNUE;
         $long = (double) _DB_VISITES_LABEL_COORD_INCONNUE;
         $lat = (double) _DB_VISITES_LABEL_COORD_INCONNUE;
         $referer = "";
     } else {
         $ip_stricte = self::Get_adresse_ip();
         if (strlen($ip_stricte) == 0) {
             return;
         }
         if (in_array($ip_stricte, self::$IP_a_bloquer)) {
             return;
         }
         $agent = self::Get_user_agent();
         if (strlen($agent) == 0) {
             return;
         }
         if (self::Is_bot($agent)) {
             return;
         }
         $referer = self::Get_referer();
         if (self::Is_spam($referer)) {
             return;
         }
         if (in_array($referer, self::$Ref_a_bloquer)) {
             return;
         }
         list($pays, $ville, $long, $lat) = self::Get_IP_geolocalisation($ip_stricte);
         if (in_array($pays, self::$Pays_a_bloquer)) {
             return;
         }
         if ($anonymisation_ip) {
             $ip_stricte = md5($ip_stricte);
         }
         $ip = (self::Is_mobile($agent) ? _DB_VISITES_INDICATEUR_MOBILE : "") . $ip_stricte;
     }
     $ip = strtoupper($langue) . $ip;
     $ip .= _DB_VISITES_SEPARATEUR_IP . $pays . _DB_VISITES_SEPARATEUR_IP . $ville;
     $ip .= _DB_VISITES_SEPARATEUR_IP . (double) $long . _DB_VISITES_SEPARATEUR_IP . (double) $lat;
     $ip .= _DB_VISITES_INDICATEUR_REFERER . self::Beautify_referer($referer);
     $date_courante = date("ymd");
     $date_peremtion = date("ymd", strtotime("-" . _DB_VISITES_DUREE_ARCHIVAGE . " days"));
     // Stockage dans le fichier db de la page
     $nom_db = _DB_PATH_ROOT . $nom_page . _DB_EXT;
     $nom_tmp = _DB_VISITES_TEMPORAIRE . uniqid() . ".db";
     $tmp = @gzopen($nom_tmp, "w");
     if (!$tmp) {
         return;
     }
     // if (!(@flock($tmp, LOCK_EX))) {@fclose($tmp);return;}
     $db_a_jour = false;
     $fichier = @gzopen($nom_db, "r");
     if ($fichier) {
         while (!@gzeof($fichier)) {
             $ligne = @gzgets($fichier);
             $champs = explode("|", $ligne);
             if (count($champs) != 3) {
                 continue;
             }
             list($date_db, $ip_db, $nb_db) = $champs;
             if (!preg_match("/^[0-9]{6}\$/", $date_db)) {
                 continue;
             }
             if ($date_db < $date_peremtion) {
                 continue;
             }
             $nb_visites = (int) $nb_db;
             if ($nb_visites < 1 || $nb_visites > 98) {
                 continue;
             }
             if (!strcmp($date_db, $date_courante) && !strcmp($ip_db, $ip)) {
                 $nb_visites += 1;
                 $db_a_jour = true;
             }
             @gzputs($tmp, $date_db . "|" . $ip_db . "|" . $nb_visites . "\n");
         }
         @gzclose($fichier);
     }
     if (!$db_a_jour) {
         @gzputs($tmp, $date_courante . "|" . $ip . "|1\n");
     }
     // @flock($tmp, LOCK_UN);
     @gzclose($tmp);
     @rename($nom_tmp, $nom_db);
     @chmod($nom_db, 0700);
 }
开发者ID:PetiLabo,项目名称:PetiLabo,代码行数:95,代码来源:visites.php

示例14: dump

 public function dump($params)
 {
     $dump_path = fx::config('dev.mysqldump_path');
     if (!$dump_path) {
         return;
     }
     if (is_string($params)) {
         $params = array('file' => $params);
     }
     if (!$params['file']) {
         return;
     }
     $target_file = fx::path($params['file']);
     $params = array_merge(array('data' => true, 'schema' => true, 'add' => false, 'where' => false, 'tables' => array()), $params);
     $command = $dump_path . ' -u' . fx::config('db.user') . ' -p' . fx::config('db.password') . ' --host=' . fx::config('db.host');
     $command .= ' ' . fx::config('db.name');
     if (!$params['schema']) {
         $command .= ' --no-create-info';
     }
     if (!$params['data']) {
         $command .= ' --no-data';
     }
     $command .= ' --skip-comments';
     if ($params['where']) {
         $command .= ' --where="' . $params['where'] . '"';
     }
     foreach ($params['tables'] as $t) {
         $command .= ' ' . $this->replacePrefix('{{' . $t . '}}');
     }
     $do_gzip = isset($params['gzip']) && $params['gzip'] || preg_match("~\\.gz\$~", $target_file);
     if ($do_gzip) {
         $target_file = preg_replace("~\\.gz\$~", '', $target_file);
     }
     $command .= ($params['add'] ? ' >> ' : ' > ') . $target_file;
     exec($command);
     if ($do_gzip && file_exists($target_file)) {
         $gzipped_file = $target_file . '.gz';
         $gzipped = gzopen($gzipped_file, 'w');
         $raw = fopen($target_file, 'r');
         while (!feof($raw)) {
             $s = fgets($raw, 4096);
             gzputs($gzipped, $s, 4096);
         }
         fclose($raw);
         gzclose($gzipped);
         unlink($target_file);
         return $gzipped_file;
     }
 }
开发者ID:floxim,项目名称:floxim,代码行数:49,代码来源:Db.php

示例15: var_dump

//////////////////////////////////////////////////////////////////////
var_dump(readgzfile(__DIR__ . "/test_ext_zlib.gz"));
VS(gzfile(__DIR__ . "/test_ext_zlib.gz"), array("Testing Ext Zlib\n"));
VS(gzuncompress(gzcompress("testing gzcompress")), "testing gzcompress");
VS(gzinflate(gzdeflate("testing gzdeflate")), "testing gzdeflate");
$zipped = gzencode("testing gzencode");
$tmpfile = tempnam('/tmp', 'vmzlibtest');
$f = fopen($tmpfile, "w");
fwrite($f, $zipped);
fclose($f);
var_dump(readgzfile($tmpfile));
$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);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ext_zlib.php


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