本文整理汇总了PHP中gzdeflate函数的典型用法代码示例。如果您正苦于以下问题:PHP gzdeflate函数的具体用法?PHP gzdeflate怎么用?PHP gzdeflate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzdeflate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: xthreads_attach_hash
function xthreads_attach_hash(&$odd = false)
{
static $secret = null;
if (!isset($secret)) {
if (isset($GLOBALS['mybb']->config['database']['password'])) {
$config =& $GLOBALS['mybb']->config;
} else {
@(include MYBB_ROOT . 'inc/config.php');
}
$secret = md5(substr(md5($config['database']['database'] . ',' . $config['database']['password']), 0, 12) . __FILE__);
unset($config);
}
$key = $secret;
if (defined('XTHREADS_EXPIRE_ATTACH_LINK') && XTHREADS_EXPIRE_ATTACH_LINK) {
$time = floor(time() / XTHREADS_EXPIRE_ATTACH_LINK);
if ($odd !== false) {
if ($time % 2 != $odd) {
--$time;
}
} else {
$odd = $time % 2;
}
$key .= '|' . $time;
}
if (defined('XTHREADS_ATTACH_LINK_IPMASK') && XTHREADS_ATTACH_LINK_IPMASK) {
$key .= '|' . (xthreads_get_ip() & 0xffffffff << 32 - XTHREADS_ATTACH_LINK_IPMASK);
}
// because PHP doesn't like ~(0xffffffff >> x)
return crc32(md5(gzdeflate($key)));
}
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:30,代码来源:xt_attachfuncs.php
示例17: getRedirectUrl
/**
* Generate the request.
*
* @return string A fully qualified URL that can be redirected to in order to process the authorization request.
*/
public function getRedirectUrl()
{
$id = $this->_generateUniqueID();
$issueInstant = $this->_getTimestamp();
$request = <<<AUTHNREQUEST
<samlp:AuthnRequest
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="{$id}"
Version="2.0"
IssueInstant="{$issueInstant}"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
AssertionConsumerServiceURL="{$this->_settings->spReturnUrl}">
<saml:Issuer>{$this->_settings->spIssuer}</saml:Issuer>
<samlp:NameIDPolicy
Format="{$this->_settings->requestedNameIdFormat}"
AllowCreate="true"></samlp:NameIDPolicy>
<samlp:RequestedAuthnContext Comparison="exact">
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
AUTHNREQUEST;
$deflatedRequest = gzdeflate($request);
$base64Request = base64_encode($deflatedRequest);
$encodedRequest = urlencode($base64Request);
if (strpos($this->_settings->idpSingleSignOnUrl, '?') === FALSE) {
return $this->_settings->idpSingleSignOnUrl . "?SAMLRequest=" . $encodedRequest;
}
return $this->_settings->idpSingleSignOnUrl . "&SAMLRequest=" . $encodedRequest;
}
开发者ID:ravi-sharma,项目名称:saml-sso-integration,代码行数:35,代码来源:AuthRequest.php
示例18: getRedirectUrl
/**
* Generate the request.
*
* @return string A fully qualified URL that can be redirected to in order to process the authorization request.
*/
public function getRedirectUrl()
{
// Build the request
$id = $this->_generateUniqueID();
$issueInstant = $this->_getTimestamp();
$request = <<<AUTHNREQUEST
<samlp:AuthnRequest
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="{$id}"
Version="2.0"
IssueInstant="{$issueInstant}"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
AssertionConsumerServiceURL="{$this->_settings->spReturnUrl}">
<saml:Issuer>{$this->_settings->spIssuer}</saml:Issuer>
<samlp:NameIDPolicy
Format="{$this->_settings->requestedNameIdFormat}"
AllowCreate="true"></samlp:NameIDPolicy>
<samlp:RequestedAuthnContext Comparison="exact">
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
AUTHNREQUEST;
// Encode the request
$deflatedRequest = gzdeflate($request);
$base64Request = base64_encode($deflatedRequest);
$encodedRequest = urlencode($base64Request);
// Build redirect URL
$url = $this->_settings->idpSingleSignOnUrl . "?SAMLRequest=" . $encodedRequest;
// Keep the original GET parameters
foreach ($this->_get_params as $param => $value) {
$url .= "&" . $param . "=" . urlencode($value);
}
return $url;
}
开发者ID:BrunoChauvet,项目名称:Filemanager,代码行数:40,代码来源:Request.php
示例19: encode
/**
* Encode data.
*
* @param $data
* @param bool $compress
*
* @return array|null|string
* @throws HttpDataEncodeException
*/
protected function encode($data, $compress = true)
{
if (!is_null($data)) {
if ($compress) {
// First serialize the data.
$data = serialize($data);
// Now compress it.
if (!($data = gzdeflate($data, 9))) {
throw new HttpDataEncodeException();
}
// Create an array containing the compressed data and the
// 'compressed' item.
$data = [static::DATA_INDEX => $data];
$data['compressed'] = true;
// Serialize it again.
if (!($data = serialize($data))) {
throw new HttpDataEncodeException();
}
} else {
// Add the 'compressed' item and serialize.
$data = [static::DATA_INDEX => $data];
$data['compressed'] = false;
$data = serialize($data);
}
}
return $data;
}
开发者ID:datrim,项目名称:http-data,代码行数:36,代码来源:HttpData.php
示例20: save
/**
* Saves and unlocks a session
* @param array $data to store (an empty array is equivalent to destruction of the session)
* @param int $ttl time until session expiration (always > 0)
* @return \Amp\Promise resolving after success
*/
public function save(string $id, array $data, int $ttl) : Promise
{
$promisor = new Deferred();
if (empty($data)) {
$this->client->del("sess:" . $id)->when(function ($error) use($id, $promisor) {
if ($error) {
$promisor->fail(new Exception("couldn't delete session", 0, $error));
} else {
$promisor->succeed($this->unlock($id));
}
});
} else {
$data = json_encode([$ttl, $data]);
$flags = 0;
if (strlen($data) > self::COMPRESSION_THRESHOLD) {
$data = gzdeflate($data, 1);
$flags |= 0x1;
}
$data = $flags % 256 . $data;
$this->client->set("sess:" . $id, $data, $ttl)->when(function ($error) use($id, $promisor) {
if ($error) {
$promisor->fail(new Exception("couldn't persist session data", 0, $error));
} else {
$promisor->succeed($this->unlock($id));
}
});
}
return $promisor->promise();
}
开发者ID:amphp,项目名称:aerys-session,代码行数:35,代码来源:Redis.php
注:本文中的gzdeflate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论