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

PHP gzcompress函数代码示例

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

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



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

示例1: Save

 public static function Save($strFormState, $blnBackButtonFlag)
 {
     // Compress (if available)
     if (function_exists('gzcompress')) {
         $strFormState = gzcompress($strFormState, 9);
     }
     // Setup CurrentStateIndex (if none yet exists)
     if (!array_key_exists('qform_current_state_index', $_SESSION)) {
         $_SESSION['qform_current_state_index'] = 0;
     }
     // Increment CurrentStateIndex if BackButtonFlag is true
     // Otherwise, we're in an ajax-to-ajax call, and the back button is invalid anyway
     // No need to increment session state index -- let's not to save space
     //			if ($blnBackButtonFlag)
     $_SESSION['qform_current_state_index'] = $_SESSION['qform_current_state_index'] + 1;
     $intStateIndex = $_SESSION['qform_current_state_index'];
     // Save THIS formstate
     // NOTE: if gzcompress is used, we are saving the *BINARY* data stream of the compressed formstate
     // In theory, this SHOULD work.  But if there is a webserver/os/php version that doesn't like
     // binary session streams, you can first base64_encode before saving to session (see note below).
     $_SESSION['qform_' . $intStateIndex] = $strFormState;
     // Return StateIndex
     if (!is_null(QForm::$EncryptionKey)) {
         // Use QCryptography to Encrypt
         $objCrypto = new QCryptography(QForm::$EncryptionKey, true);
         return $objCrypto->Encrypt($intStateIndex);
     } else {
         return $intStateIndex;
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:30,代码来源:QSessionFormStateHandler.class.php


示例2: compress

function compress($data, $compressed)
{
    if ($compressed == 1) {
        return gzcompress($data);
    }
    return $data;
}
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:7,代码来源:common.functions.php


示例3: wirte

 /**
  * 写入缓存
  * @param string $name 缓存文件名字
  * @param function $callback 回调函数,必须要有返回值
  * @param Array or string or Object $params 要传进去的参数
  * @param int $time 写入的缓存时间
  * @return array
  * @author wave
  */
 public static function wirte($name, $callback, $params = null, $time = TIME)
 {
     self::init();
     $file = ROOT . DS . APP_PATH . DS . self::$cache_dir;
     $content = '';
     if (!file_exists($file . self::CACHE_PREFIX . $name)) {
         $content = $callback($params);
         if (!empty($content)) {
             file_put_contents($file . self::CACHE_PREFIX . $name, gzcompress(serialize($content)));
             return;
         }
     }
     if (empty($time)) {
         return;
     }
     if (file_exists($file . self::CACHE_PREFIX . $name)) {
         $cache_time = strtotime(date('Y-m-d H:i:s')) - strtotime(date('Y-m-d H:i:s', filemtime($file . self::CACHE_PREFIX . $name)));
         if ($cache_time / 1000 >= $time || $time == 1) {
             $content = $callback($params);
             if (!empty($content)) {
                 file_put_contents($file . self::CACHE_PREFIX . $name, gzcompress(serialize($content)));
                 return;
             }
         }
     }
 }
开发者ID:DenonHuang,项目名称:xbphp,代码行数:35,代码来源:Cache.php


示例4: set

 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param int $expire  有效时间 0为永久
  * @return boolean
  */
 public function set($name, $value, $expire = null)
 {
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $filename = $this->getFileName($name);
     $data = serialize($value);
     //是否数据压缩
     if ($this->options['compress'] && function_exists('gzcompress')) {
         //数据压缩
         $data = gzcompress($data, 3);
     }
     //是否数据校验
     if ($this->options['check']) {
         $check = md5($data);
     } else {
         $check = '';
     }
     $data = "<?php\n//" . sprintf('%012d', $expire) . $check . $data . "\n?>";
     $result = file_put_contents($filename, $data);
     if ($result) {
         //            if($this->options['length']>0) {
         //                // 记录缓存队列
         //                $this->queue($name);
         //            }
         clearstatcache();
         return true;
     } else {
         return false;
     }
 }
开发者ID:huangbinzd,项目名称:yaf_private_test,代码行数:39,代码来源:File.php


示例5: save_array_dump

function save_array_dump($filename, $array)
{
    $dump = addslashes(gzcompress(var_export($array, true), 9));
    $fp = fopen($filename, "wb+");
    fwrite($fp, $dump);
    fclose($fp);
}
开发者ID:ItsLines,项目名称:ThePreviouslyDesigned,代码行数:7,代码来源:helper_lib.php


示例6: secure_serialize

 function secure_serialize($data)
 {
     $mainframe =& JFactory::getApplication();
     $secret = $mainframe->getCfg('secret');
     $sData = strtr(base64_encode(addslashes(gzcompress(serialize($data), 9))), '+/=', '-_,');
     return sha1($sData . $secret) . $sData;
 }
开发者ID:acculitx,项目名称:fleetmatrixsite,代码行数:7,代码来源:cfaction_load_js.php


示例7: print_gzipped_page

 function print_gzipped_page()
 {
     $HTTP_ACCEPT_ENCODING = getenv("HTTP_ACCEPT_ENCODING");
     if (headers_sent()) {
         $encoding = false;
     } elseif (strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) {
         $encoding = 'x-gzip';
     } elseif (strpos($HTTP_ACCEPT_ENCODING, 'gzip') !== false) {
         $encoding = 'gzip';
     } else {
         $encoding = false;
     }
     if ($encoding) {
         $contents = ob_get_contents();
         ob_end_clean();
         header('Content-Encoding: ' . $encoding);
         header("ETag: " . md5($contents));
         // ETag im Header senden
         header("Expires: " . date("r", mktime(0, 0, 0, date("n"), date("j") + 365)));
         print "�";
         $size = strlen($contents);
         $contents = gzcompress($contents, 9);
         $contents = substr($contents, 0, $size);
         print $contents;
         //             exit();
     } else {
         ob_end_flush();
         //             exit();
     }
 }
开发者ID:BackupTheBerlios,项目名称:ewebuki-bvv-svn,代码行数:30,代码来源:gzip_files.php


示例8: exec

 /**
  * Sends a command to the server and returns an object with the result 
  * 
  * @param string $cmd               Protocol command to be executed
  * @param string $message           Full email message
  * @param array  $additionalHeaders Associative array with additional headers
  */
 protected function exec($cmd, $message, array $additionalHeaders = array())
 {
     $socket = $this->getSocket();
     $message .= "\r\n";
     $contentLength = strlen($message);
     if (!empty($this->maxSize)) {
         if ($contentLength > $this->maxSize) {
             throw new Exception("Message exceeds the maximum allowed size of {$this->maxSize} kbytes");
         }
     }
     $cmd = $cmd . ' SPAMC/' . $this->protocolVersion . "\r\n";
     $cmd .= "Content-length: {$contentLength}\r\n";
     if ($this->enableZlib && function_exists('gzcompress')) {
         $cmd .= "Compress: zlib\r\n";
         $message = gzcompress($message);
     }
     if (!empty($this->user)) {
         $cmd .= 'User: ' . $this->user . "\r\n";
     }
     if (!empty($additionalHeaders)) {
         foreach ($additionalHeaders as $headerName => $val) {
             $cmd .= $headerName . ': ' . $val . "\r\n";
         }
     }
     $cmd .= "\r\n";
     $cmd .= $message;
     $cmd .= "\r\n";
     $this->write($socket, $cmd);
     list($headers, $message) = $this->read($socket);
     return $this->parseOutput($headers, $message);
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:38,代码来源:Local.php


示例9: compile

 function compile($compressionLevel = 0)
 {
     $this->header->setCompressed($compressionLevel > 0);
     $data = '';
     foreach ($this->tags as $tag) {
         $data .= $tag->getTagContent();
     }
     $header = $this->header->getPacked();
     $len = strlen($header) + strlen($data);
     $this->header->filelength->set($len);
     $data = $this->header->getPacked() . $data;
     if ($compressionLevel > 0) {
         $compressionStartTime = $this->microtime_float();
         // The first eight bytes are uncompressed
         $uncompressedBytes = substr($data, 0, 8);
         // Remove first eight bytes
         $data = substr_replace($data, '', 0, 8);
         // Compress the rest of the SWF
         $data = gzcompress($data, $compressionLevel);
         // Add the uncompressed header
         $data = $uncompressedBytes . $data;
         $compressionDuration = $this->microtime_float() - $compressionStartTime;
         if (LOG_ALL) {
             error_log('[SWX] PROFILING: SWF compression took ' . $compressionDuration . ' seconds.');
         }
         // Stats
         $compressedSize = strlen($data);
         if (LOG_ALL) {
             error_log('[SWX] INFO Compressed size of SWF: ' . $compressedSize . ' bytes.');
         }
     }
     $this->data = $data;
 }
开发者ID:hafizubikm,项目名称:bakeme,代码行数:33,代码来源:SwxAssembler3.php


示例10: append

 /**
  * Forwards the logging event to the Graylog2 server.
  * @param LoggerLoggingEvent $event
  */
 protected function append(LoggerLoggingEvent $event)
 {
     $message = gzcompress($this->layout->format($event));
     $socket = $this->getSocketConnection();
     if (strlen($message) > $this->getChunkSize()) {
         // A unique id which consists of the microtime and a random value
         $messageId = uniqid();
         // Split the message into chunks
         $messageChunks = str_split($message, $this->getChunkSize());
         $messageChunksCount = count($messageChunks);
         // Send chunks to graylog server
         foreach ($messageChunks as $messageChunkIndex => $messageChunk) {
             $bytesWritten = $this->writeMessageChunkToSocket($socket, $messageId, $messageChunk, $messageChunkIndex, $messageChunksCount);
             if (false === $bytesWritten) {
                 // Abort due to write error
                 return false;
             }
         }
     } else {
         // A single write is enough to get the message published
         if (false === $this->writeMessageToSocket($socket, $message)) {
             // Abort due to write error
             return false;
         }
     }
 }
开发者ID:rurri,项目名称:log4php-graylog2,代码行数:30,代码来源:LoggerAppenderGraylog2.php


示例11: set

 public function set($key, $value, $expire = '')
 {
     $freeSpace = disk_free_space($this->config['path']);
     $freeSpaceMB = $freeSpace ? floor($freeSpace / 1024 / 1024) : 0;
     if ($freeSpaceMB < 10) {
         Axion_log::getinstance()->newMessage('磁盘容量过小,无法存储数据缓存文件', AXION_LOG::WARNING);
         return false;
     }
     $hash = md5($key);
     $expire = $expire ? $expire : $this->config['expire'];
     $expire = sprintf('%09d', $expire);
     $data = serialize($value);
     self::$_data[$hash] = $data;
     if (!is_dir($this->config['path'])) {
         if (!AXION_UTIL_FILE::mkdir($this->config['path'])) {
             throw new AXION_EXCEPTION('无法创建Cache文件目录:' . $this->config['path']);
         }
     }
     $fileName = $this->genFileName($key);
     if (IS_SHM && function_exists('gzcompress')) {
         $data = gzcompress($data, 4);
     }
     $data = $expire . $data;
     $result = file_put_contents($fileName, $data);
     if ($result) {
         clearstatcache();
         return true;
     } else {
         return false;
     }
 }
开发者ID:kellenqian,项目名称:axion,代码行数:31,代码来源:file.class.php


示例12: save

 public static function save($label, $data, $expires = null, $compress = true)
 {
     $label = urlencode($label);
     $dir = rtrim(self::$dir, "/");
     if (is_object($data) || is_array($data)) {
         if (method_exists($data, "__toString")) {
             $data = call_user_func(array($data, '__toString'));
         } else {
             $data = serialize($data);
         }
     }
     $str = (string) gzcompress($data);
     if (strlen($str) > $data) {
         $str = $data;
     }
     if ((bool) file_put_contents("{$dir}/{$label}", $str)) {
         if ($expires) {
             $expires = time() + (int) $expires;
         } else {
             $expires = time() + 60 * 60 * 24 * 365 * 10;
         }
         touch("{$dir}/{$label}", time(), $expires);
         return $data;
     } else {
         throw new Exception("Could not cache file.", 0);
     }
 }
开发者ID:alexbrombal,项目名称:saffyre-junk,代码行数:27,代码来源:Cache.php


示例13: encode

 protected function encode($value = null)
 {
     if (!$value) {
         return '';
     }
     return base64_encode(gzcompress(serialize($value)));
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:7,代码来源:Cookie.php


示例14: ncd_new

function ncd_new($sx, $sy, $prec = 0, $MAXLEN = 9000)
{
    # NCD with gzip artifact correctoin and percentual return.
    # sx,sy = strings to compare.
    # Use $prec=-1 for result range [0-1], $pres=0 for percentual,
    # For NCD definition see http://arxiv.org/abs/0809.2553
    $x = $min = strlen(gzcompress($sx));
    $y = $max = strlen(gzcompress($sy));
    $xy = strlen(gzcompress($sx . $sy));
    $a = $sx;
    if ($x > $y) {
        # swap min/max
        $min = $y;
        $max = $x;
        $a = $sy;
    }
    $res = ($xy - $min) / $max;
    # NCD definition.
    #Little strings):
    if ($MAXLEN < 0 || $xy < $MAXLEN) {
        $aa = strlen(gzcompress($a . $a));
        $ref = ($aa - $min) / $min;
        $res = $res - $ref;
        # correction
    }
    return $prec < 0 ? $res : 100 * round($res, 2 + $prec);
}
开发者ID:zahidhameed,项目名称:Plagiarism-Detection-Tool,代码行数:27,代码来源:pattern.php


示例15: serialize

 public static function serialize($data, $type)
 {
     $types = explode('|', $type, 2);
     switch ($types[0]) {
         case self::SERIALIZE_TYPE_BASE64:
             if (!empty($types[1])) {
                 $data = self::serialize($data, $types[1]);
             }
             return self::SERIALIZE_TYPE_BASE64 . ' ' . base64_encode($data);
         case self::SERIALIZE_TYPE_GZIP:
             if (!empty($types[1])) {
                 $data = self::serialize($data, $types[1]);
             }
             if (strlen($data) < self::GZIP_MIN_LENGTH) {
                 return $data;
             }
             return self::SERIALIZE_TYPE_GZIP . ' ' . gzcompress($data);
         case self::SERIALIZE_TYPE_PHP_SERIALIZE:
             return self::SERIALIZE_TYPE_PHP_SERIALIZE . ' ' . serialize($data);
         case self::SERIALIZE_TYPE_JSON:
             return self::SERIALIZE_TYPE_JSON . ' ' . json_encode($data);
         default:
             throw new InvalidArgumentException();
     }
 }
开发者ID:mailru,项目名称:queue-processor,代码行数:25,代码来源:MapperUtils.php


示例16: vdk_pack

function vdk_pack($vdk, $dirname, &$table = [], &$folders = 0, $parent = null)
{
    if (!($folder = scandir($dirname))) {
        return;
    }
    usort($folder, 'strcasecmp');
    if (is_null($parent)) {
        array_splice($folder, 1, 1);
    }
    $current = ftell($vdk);
    $last = count($folder) - 1;
    foreach ($folder as $i => $filename) {
        echo $pathname = "{$dirname}/{$filename}", "\n";
        if (is_dir($pathname)) {
            $start = ftell($vdk);
            fseek($vdk, 145, SEEK_CUR);
            if (!in_array($filename, ['.', '..'])) {
                vdk_pack($vdk, $pathname, $table, $folders, $current);
                $folders++;
            }
            $end = ftell($vdk);
            fseek($vdk, $start);
            fwrite($vdk, pack('Ca128V4', 1, $filename, 0, 0, $filename == '..' ? $parent : $start + ($filename == '.' ? 0 : 145), $i == $last ? 0 : $end));
            fseek($vdk, $end);
        } else {
            $table[$pathname] = ftell($vdk);
            $data = gzcompress(file_get_contents($pathname), $GLOBALS['level']);
            fwrite($vdk, pack('Ca128V4', 0, $filename, filesize($pathname), $size = strlen($data), 0, $i == $last ? 0 : $table[$pathname] + 145 + $size) . $data);
        }
    }
}
开发者ID:abouvier,项目名称:vdk,代码行数:31,代码来源:vdk.php


示例17: save

 /**
  * Save data
  *
  * @param string $data
  * @param string $id
  * @param array $tags
  * @param int $lifeTime
  * @return bool
  */
 public function save($data, $id, $tags = array(), $lifeTime = null)
 {
     if (!in_array(self::CACHE_TAG, $tags)) {
         $tags[] = self::CACHE_TAG;
     }
     if (is_null($lifeTime)) {
         $lifeTime = (int) $this->getFrontend()->getOption('lifetime');
     }
     // edit cached object
     $cacheData = new Varien_Object();
     $cacheData->setCachedata($data);
     $cacheData->setCacheId($id);
     $cacheData->setTags($tags);
     $cacheData->setLifeTime($lifeTime);
     Mage::dispatchEvent('fpc_save_data_before', array('cache_data' => $cacheData));
     $data = $cacheData->getCachedata();
     $id = $cacheData->getCacheId();
     $tags = $cacheData->getTags();
     $lifeTime = $cacheData->getLifeTime();
     $compressLevel = Mage::getStoreConfig(self::GZCOMPRESS_LEVEL_XML_PATH);
     if ($compressLevel != -2) {
         $data = gzcompress($data, $compressLevel);
     }
     return $this->_frontend->save($data, $this->_id($id), $this->_tags($tags), $lifeTime);
 }
开发者ID:AndreKlang,项目名称:Lesti_Fpc,代码行数:34,代码来源:Fpc.php


示例18: _gzipOutput

function _gzipOutput(& $output)
{
  global $HTTP_SERVER_VARS;

  if(defined('OUTPUT_GZIP_ENABLED') &&  constant('OUTPUT_GZIP_ENABLED') == false)
    return;

  if(isset($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING']) &&  strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip'))
  {
    $size = strlen($output);
    if(extension_loaded('zlib') &&   $size >= 20000)
    {
      $crc = crc32($output);

      $output = gzcompress($output, 9);

      // We can't just output it here, since the CRC is messed up. Strip off the old CRC
      $output = substr($output, 0, strlen($output) - 4);

      _gzipAppend4_chars($output, $crc);
      _gzipAppend4_chars($output, $size);

      $output = "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $output;

      header('Content-Encoding: gzip');
    }
  }
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:28,代码来源:process_output.php


示例19: set

 public function set($name, $value, $expireTime = 0)
 {
     $data = serialize($value);
     $name = addslashes($name);
     $this->W(1);
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         $data = gzcompress($data, 3);
     }
     if (C('DATA_CACHE_CHECK')) {
         $crc = md5($data);
     } else {
         $crc = '';
     }
     $expire = !empty($expireTime) ? $expireTime : $this->options['expire'];
     $map = array();
     $map['cachekey'] = $name;
     $map['data'] = $data;
     $map['datacrc'] = $crc;
     $map['expire'] = $expire == -1 ? -1 : time() + $expire;
     $map['datasize'] = strlen($data);
     $result = $this->db->getRow('select `id` from `' . $this->options['table'] . '` where `cachekey`=\'' . $name . '\' limit 0,1');
     if (false !== $result) {
         $result = $this->db->save($map, $this->options['table'], '`cachekey`=\'' . $name . '\'');
     } else {
         $result = $this->db->add($map, $this->options['table']);
     }
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:BGCX067,项目名称:fakebook-svn-to-git,代码行数:32,代码来源:CacheDb.class.php


示例20: compress

 /**
  * Compress
  * @param mixed $data
  * @return string binary blob of data
  */
 public static function compress($data)
 {
     if (Audit::getInstance()->compressData) {
         $data = gzcompress($data);
     }
     return $data;
 }
开发者ID:brucealdridge,项目名称:yii2-audit,代码行数:12,代码来源:Helper.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP gzdecode函数代码示例发布时间:2022-05-15
下一篇:
PHP gzclose函数代码示例发布时间: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