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


PHP gzdeflate函数代码示例

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


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

示例1: writeFile

 private function writeFile($filename, $contents, $gzip = true)
 {
     if ($gzip && self::$enable_gzip) {
         $contents = gzdeflate($contents);
     }
     file_put_contents($filename, $contents);
 }
开发者ID:thezawad,项目名称:vakuum,代码行数:7,代码来源:File.php

示例2: samlEncodeMessage

/**
 * Generates an encoded and compressed string from the specified 
 * string. The string is encoded in the following order:
 *
 * 1. Deflate
 * 2. Base64 encode
 * 3. URL encode
 * @param string $msg
 * @return string
 */
function samlEncodeMessage($msg)
{
    $encmsg = gzdeflate($msg);
    $encmsg = base64_encode($encmsg);
    $encmsg = urlencode($encmsg);
    return $encmsg;
}
开发者ID:aruneapachenmec,项目名称:google-apps-sso-sample,代码行数:17,代码来源:saml_util.php

示例3: __out

function __out($data, $type = '', $callback = '')
{
    if (empty($type)) {
        if (isset($_REQUEST['gz'])) {
            $type = 'gz';
        } else {
            if (isset($_REQUEST['gz2'])) {
                $type = 'gz2';
            } elseif (isset($_REQUEST['json'])) {
                $type = 'json';
            } elseif (isset($_REQUEST['jsonp'])) {
                $type = 'jsonp';
            }
        }
    }
    if ($type === 'gz') {
        $s = serialize($data);
        print gzdeflate($s, 9);
    } elseif ($type === 'gz2') {
        $s = serialize($data);
        print gzencode($s, 9);
    } elseif ($type === 'json') {
        print json_encode($data);
    } elseif ($type === 'jsonp') {
        if (empty($callback) && isset($_GET['callback'])) {
            $callback = $_GET['callback'];
        }
        print $callback . '(' . json_encode($data) . ');';
    } else {
        $s = serialize($data);
        print $s;
    }
}
开发者ID:openthink-laurent,项目名称:dolibarr_module_abricot,代码行数:33,代码来源:abricot.lib.php

示例4: siteExport

 /**
  * 导出
  */
 public function siteExport($filename = '')
 {
     if (IS_POST) {
         $setting_db = M('setting');
         $data = array('type' => 'setting');
         $data['data'] = $setting_db->select();
         $data['verify'] = md5(var_export($data['data'], true) . $data['type']);
         //数据进行多次加密,防止数据泄露
         $data = base64_encode(gzdeflate(json_encode($data)));
         $uniqid = uniqid();
         $filename = UPLOAD_PATH . 'export/' . $uniqid . '.data';
         if (file_write($filename, $data)) {
             $this->success('导出成功', U('Setting/siteExport', array('filename' => $uniqid)));
         }
         $this->error('导出失败,请重试!');
     } else {
         //过滤特殊字符,防止非法下载文件
         $filename = str_replace(array('.', '/', '\\'), '', $filename);
         $filename = UPLOAD_PATH . 'export/' . $filename . '.data';
         if (!file_exist($filename)) {
             $this->error('非法访问');
         }
         header('Content-type: application/octet-stream');
         header('Content-Disposition: attachment; filename="站点设置.data"');
         echo file_read($filename);
         file_delete($filename);
     }
 }
开发者ID:huangxulei,项目名称:app,代码行数:31,代码来源:SettingController.class.php

示例5: saveAction

 public function saveAction($data)
 {
     if ($data === false) {
         return false;
     }
     return gzdeflate($data);
 }
开发者ID:puwenhan,项目名称:TCrypto,代码行数:7,代码来源:CompressPlugin.php

示例6: push

 /**
  * Saves a cached object in the file system.
  *
  * @param mixed  $content The object to be stored. Stores all types, except the resource-type.
  */
 public function push($content)
 {
     if (!file_exists($this->path)) {
         mkdir($this->path, 0755);
     }
     file_put_contents($this->cacheFile, gzdeflate(serialize($content)));
 }
开发者ID:calebeoliveira,项目名称:Spock,代码行数:12,代码来源:Spock.php

示例7: demoapp

 public function demoapp()
 {
     $sharedKey = 'abracadabra';
     $self = 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
     if ($_POST['doit']) {
         $idp = $_POST['idp'];
         if (!$idp) {
             $idp = "sp";
         }
         $request = array('_ID' => sha1(uniqid(mt_rand(), true)), '_Version' => '2.0', '_IssueInstant' => gmdate('Y-m-d\\TH:i:s\\Z', time()), '_Destination' => $self . "/{$idp}/singleSignOnService", '_ForceAuthn' => $_REQUEST['ForceAuthn'] ? 'true' : 'false', '_IsPassive' => $_REQUEST['IsPassive'] ? 'true' : 'false', '_AssertionConsumerServiceURL' => $self . "/main/" . __FUNCTION__, '_AttributeConsumingServiceIndex' => 5, '_ProtocolBinding' => 'JSON-Redirect', 'saml:Issuer' => array('__v' => $self . "/main"));
         foreach ((array) $_REQUEST['IDPList'] as $idp) {
             $idpList[] = array('_ProviderID' => $idp);
         }
         $relayState = 'Dummy RelayState ...';
         if ($idpList) {
             $request['samlp:Scoping']['samlp:IDPList']['samlp:IDPEntry'] = $idpList;
         }
         #$request['samlp:Scoping']['_ProxyCount'] = 2;
         $location = $request['_Destination'];
         $request = "SAMLRequest=" . urlencode(base64_encode(gzdeflate(json_encode($request)))) . ($relayState ? '&RelayState=' . urlencode($relayState) : '');
         $signature = urlencode(base64_encode(sha1($sharedKey . sha1($request))));
         header('Location: ' . $location . "?" . $request . "&Signature=" . $signature);
         print "<a href=\"{$location}?{$request}&Signature={$signature}\">{$location}</a>";
         exit;
     }
     $response = base64_decode($_REQUEST['SAMLResponse']);
     $hSAMLResponse = json_decode(gzinflate($response), 1);
     if ($rs = $_POST['RelayState']) {
         $rs = '&RelayState=' . $rs;
     }
     if ($response && base64_encode(sha1($sharedKey . sha1("jSAMLResponse={$response}{$rs}"))) != $_POST['Signature']) {
         $message = 'Integrity check failed (Sharedkey) ' . $_POST['Signature'] . ' != ' . base64_encode(sha1($sharedKey . sha1("jSAMLResponse={$response}{$rs}")));
     }
     print $this->_server->renderTemplate('demo', array('action' => $self . "/main/demoapp", 'hSAMLResponse' => $hSAMLResponse, 'message' => $message . " RelayState: " . $_GET['RelayState'], 'self' => $self));
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:35,代码来源:DemoServices.php

示例8: encode

 /**
  * (non-PHPdoc).
  *
  * @param string $data
  *
  * @see \Dms\Coding\CodingInterface::encode()
  */
 public function encode($data = null)
 {
     if ($data != null) {
         $this->setData($data);
     }
     return gzdeflate($this->data);
 }
开发者ID:buse974,项目名称:dms,代码行数:14,代码来源:Deflate.php

示例9: testDecodeThrowsErrorOnEmptyResult

 /**
  * @expectedException \Brainbits\Transcoder\Exception\DecodeFailedException
  */
 public function testDecodeThrowsErrorOnEmptyResult()
 {
     $testString = '';
     $encodedString = gzdeflate($testString);
     $result = $this->decoder->decode($encodedString);
     $this->assertSame($testString, $result);
 }
开发者ID:brainbits,项目名称:transcoder,代码行数:10,代码来源:DeflateDecoderTest.php

示例10: streamData

 function streamData($data, $name, $time = 0, $level = -1)
 {
     $time = $this->dosTime($time);
     $crc = crc32($data);
     $dlen = strlen($data);
     $level < 0 && ($level = (int) $this->level);
     $level < 0 && ($level = self::LEVEL);
     $data = gzdeflate($data, $level);
     $zlen = strlen($data);
     $name = strtr($name, '\\', '/');
     $n = @iconv('UTF-8', 'CP850', $name);
     // If CP850 can not represent the filename, use unicode
     if ($name !== @iconv('CP850', 'UTF-8', $n)) {
         $n = $name;
         $h = "";
     } else {
         $h = "";
     }
     $nlen = strlen($n);
     $h = "" . $h . "" . pack('V', $time) . pack('V', $crc) . pack('V', $zlen) . pack('V', $dlen) . pack('v', $nlen) . pack('v', 0);
     // extra field length
     echo "PK", $h, $n, $data;
     $dlen = $this->dataLen;
     $this->dataLen += 4 + strlen($h) + $nlen + $zlen;
     $this->cdr[] = "PK" . "" . $h . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('V', 32) . pack('V', $dlen) . $n;
 }
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:26,代码来源:zipStream.php

示例11: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->name]['file'])) {
         $this->data[$this->name]['file'] = gzdeflate($this->data[$this->name]['file'], 9);
     }
     return true;
 }
开发者ID:sing-group,项目名称:Markyt,代码行数:7,代码来源:ProjectResource.php

示例12: encrypt

 /**
  * Performs text encryption with openssl_encrypt and returns it as a string.<br />
  * If openssl_encrypt is not available encrypts with mcrypt, if mcrypt is not available encrypts with xor
  * 
  * @param string $text      The text to encode
  * @param string $key       [optionnal] The key to use. Default is the application key
  * @return string           The encrypted string
  */
 public static function encrypt($text, $key = null)
 {
     // Get the application key if no key is given
     if ($key === null) {
         $key = self::_getKey();
     }
     // To avoid same encoded string for the same string
     $text = self::hash($text) . '~~~' . $text;
     // If zlib is active we compress the value to crypt
     if (function_exists('gzdeflate')) {
         $text = gzdeflate($text, 9);
     }
     // Use openssl_encrypt with PHP >= 5.3.0
     if (Config::get('general.crypt_method', 'openssl') === 'openssl' && function_exists('openssl_encrypt') && in_array('BF-ECB', openssl_get_cipher_methods())) {
         $method = 'BF-ECB';
         $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
         return strtr(openssl_encrypt($text, $method, $key), '+/', '-_');
     } else {
         if (function_exists('mcrypt_encrypt')) {
             $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
             $iv = mcrypt_create_iv($size, MCRYPT_RAND);
             $crypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
             return rtrim(strtr(base64_encode($crypt), '+/', '-_'), '=');
         }
     }
     // ... else encrypt with xor technique
     $n = mb_strlen($text, '8bit');
     $m = mb_strlen($key, '8bit');
     if ($n !== $m) {
         $key = mb_substr(str_repeat($key, ceil($n / $m)), 0, $n, '8bit');
     }
     return base64_encode($text ^ $key);
 }
开发者ID:salomalo,项目名称:php-oxygen,代码行数:41,代码来源:security.class.php

示例13: compress

 public static function compress(string $output)
 {
     $request = Request::createFromGlobals();
     // Check to see if we have data, if not, then return empty string
     if ($output === null) {
         return (string) '';
     }
     // Handle the supported compressions.
     $supported_enc = array();
     if ($request->headers->get('HTTP_ACCEPT_ENCODING')) {
         $supported_enc = explode(',', $request->headers->get('HTTP_ACCEPT_ENCODING'));
     }
     if (in_array('gzip', $supported_enc) === true) {
         header('Vary: Accept-Encoding');
         header('Content-Encoding: gzip');
         $encoded_output = gzencode($output, 9);
         return (string) $encoded_output;
     } elseif (in_array('deflate', $supported_enc) === true) {
         header('Vary: Accept-Encoding');
         header('Content-Encoding: deflate');
         $deflated_output = gzdeflate($output, 9);
         return (string) $deflated_output;
     } else {
         return (string) $output;
     }
 }
开发者ID:thekabal,项目名称:tki,代码行数:26,代码来源:Compress.php

示例14: save

 /**
  * Serialize and add data to cache
  *
  * @param  array   $data  Data to be cached
  * @param  string  $filename  Name of cache file
  * @return bool    Status
  */
 public function save($data, $filename)
 {
     clearstatcache();
     $path = $this->_gen_path($filename);
     $file = $this->_full_file_path($filename);
     if ($this->_options['num_directory_levels'] > 0) {
         if (!is_writable($path)) {
             // Cache directory structure may need to be created
             $this->_create_sub_dir_structure($filename);
         }
         if (!is_writable($path)) {
             // A second check to make sure dir was created successfully
             return false;
         }
     }
     if ($this->_options['gzip_level'] > 0) {
         $res = @file_put_contents($file, gzdeflate($this->_serialize($data), $this->_options['gzip_level']));
     } else {
         $res = @file_put_contents($file, $this->_serialize($data));
     }
     // Serialize Only
     if ($res) {
         @chmod($file, $this->_options['umask_file']);
     }
     return $res;
 }
开发者ID:kmoughan,项目名称:Simple-PHP-Cache,代码行数:33,代码来源:simple_php_cache.php

示例15: save

 public function save($data, $id, $tags = array(), $specificLifetime = false)
 {
     if ($this->_options['compression']) {
         $data = gzdeflate($data);
     }
     return parent::save($data, $id, $tags, $specificLifetime);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:7,代码来源:File.php


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