本文整理汇总了PHP中gzinflate函数的典型用法代码示例。如果您正苦于以下问题:PHP gzinflate函数的具体用法?PHP gzinflate怎么用?PHP gzinflate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzinflate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEncode
public function testEncode()
{
$testString = 'a string to be compressed';
$result = $this->encoder->encode($testString);
$uncompressedResult = gzinflate($result);
$this->assertSame($testString, $uncompressedResult);
}
示例2: createAuthnRequestFromHttpRequest
/**
* @param Request $httpRequest
* @return SAML2_AuthnRequest
* @throws \Exception
*/
private static function createAuthnRequestFromHttpRequest(Request $httpRequest)
{
// the GET parameter is already urldecoded by Symfony, so we should not do it again.
$samlRequest = base64_decode($httpRequest->get(AuthnRequest::PARAMETER_REQUEST), true);
if ($samlRequest === false) {
throw new InvalidRequestException('Failed decoding the request, did not receive a valid base64 string');
}
// Catch any errors gzinflate triggers
$errorNo = $errorMessage = null;
set_error_handler(function ($number, $message) use(&$errorNo, &$errorMessage) {
$errorNo = $number;
$errorMessage = $message;
});
$samlRequest = gzinflate($samlRequest);
restore_error_handler();
if ($samlRequest === false) {
throw new InvalidRequestException(sprintf('Failed inflating the request; error "%d": "%s"', $errorNo, $errorMessage));
}
// additional security against XXE Processing vulnerability
$previous = libxml_disable_entity_loader(true);
$document = SAML2_DOMDocumentFactory::fromString($samlRequest);
libxml_disable_entity_loader($previous);
$request = SAML2_Message::fromXML($document->firstChild);
if (!$request instanceof SAML2_AuthnRequest) {
throw new RuntimeException(sprintf('The received request is not an AuthnRequest, "%s" received instead', substr(get_class($request), strrpos($request, '_') + 1)));
}
return $request;
}
示例3: 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));
}
示例4: init
/**
* Get request protocol based on Content-Type
*
* @return string default as xmlrpc
*/
protected function init()
{
$ver = phpversion();
if ($ver[0] >= 5) {
$data = file_get_contents('php://input');
} else {
$data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
}
if (count($_SERVER) == 0) {
self::alert('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
}
if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
$content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']);
} else {
$content_encoding = '';
}
if ($content_encoding != '' && strlen($data)) {
if ($content_encoding == 'deflate' || $content_encoding == 'gzip') {
// if decoding works, use it. else assume data wasn't gzencoded
if (function_exists('gzinflate')) {
if ($content_encoding == 'deflate' && ($degzdata = @gzuncompress($data))) {
$data = $degzdata;
} elseif ($degzdata = @gzinflate(substr($data, 10))) {
$data = $degzdata;
}
} else {
self::alert('XML-RPC: ' . __METHOD__ . ': Received from client compressed HTTP request and cannot decompress');
}
}
}
$parsers = php_xmlrpc_decode_xml($data);
$this->cmd = $parsers->methodname;
$this->input = php_xmlrpc_decode(new xmlrpcval($parsers->params, 'array'));
}
示例5: get
/**
* grabs data from the cache and returns it to the user.
* if data is expired or invalid, returns null.
*
* @param string $cacheKey the cache key to set.
* @return mixed|null
* @throws FileCacheException
*/
public function get($cacheKey)
{
//make sure key exists in the array.
$returnVal = null;
$isValid = $this->isValid($cacheKey);
if ($isValid === true) {
$file_contents = "";
$filename = $this->getFileName($cacheKey);
//if the cache dir doesn't exist for some reason...
if (!is_dir($this->cache_dir)) {
throw new FileCacheException("Could not read cache directory!");
}
if (is_file($filename)) {
$file_contents = file_get_contents($filename);
if ($this->use_compression) {
$file_contents = gzinflate($file_contents);
}
$returnVal = unserialize($file_contents);
}
} else {
if ($isValid == -1) {
$this->expire($cacheKey);
}
}
return $returnVal;
}
示例6: decode
/**
* (non-PHPdoc).
*
* @param string $data
*
* @see \Dms\Coding\CodingInterface::decode()
*/
public function decode($data = null)
{
if ($data != null) {
$this->setData($data);
}
return gzinflate($this->data);
}
示例7: decryptLink
public static function decryptLink($link, $ignore_exceptions = false)
{
if (preg_match('/^.*?!(?P<data>[0-9a-z_-]+)!(?P<hash>[0-9a-f]+)/i', trim(str_replace('/', '', $link)), $match)) {
if (hash_hmac(self::HMAC_ALGO, $match['data'], md5(MASTER_KEY)) != $match['hash']) {
throw new Exception_MegaCrypterLinkException(self::LINK_ERROR);
} else {
if (!$ignore_exceptions && BLACKLIST_LEVEL >= self::BLACKLIST_LEVEL_MC && self::isBlacklistedLink($match['data'])) {
throw new Exception_MegaCrypterLinkException(self::BLACKLISTED_LINK);
} else {
list($secret, $file_id, $file_key, $pass, $extra, $auth) = explode(self::SEPARATOR, gzinflate(Utils_CryptTools::aesCbcDecrypt(Utils_MiscTools::urlBase64Decode($match['data']), Utils_MiscTools::hex2bin(MASTER_KEY), md5(MASTER_KEY, true))));
if (!$ignore_exceptions && BLACKLIST_LEVEL == self::BLACKLIST_LEVEL_MEGA && self::isBlacklistedLink($file_id)) {
throw new Exception_MegaCrypterLinkException(self::BLACKLISTED_LINK);
} else {
if ($extra) {
list($extra_info, $hide_name, $expire, $referer, $email, $zombie, $no_expire_token) = explode(self::SEPARATOR_EXTRA, $extra);
if (!$ignore_exceptions && !empty($expire) && time() >= $expire) {
throw new Exception_MegaCrypterLinkException(self::EXPIRED_LINK);
}
if (!empty($zombie) && $zombie != $_SERVER['REMOTE_ADDR']) {
throw new Exception_MegaCrypterLinkException(self::LINK_ERROR);
}
}
return ['file_id' => $file_id, 'file_key' => $file_key, 'extra_info' => !empty($extra_info) ? base64_decode($extra_info) : false, 'pass' => !empty($pass) ? $pass : false, 'auth' => !empty($auth) ? base64_decode($auth) : false, 'hide_name' => !empty($hide_name), 'expire' => !empty($expire) ? $expire : false, 'no_expire_token' => !empty($no_expire_token), 'referer' => !empty($referer) ? base64_decode($referer) : false, 'email' => !empty($email) ? base64_decode($email) : false, 'zombie' => !empty($zombie) ? $zombie : false, 'secret' => $secret];
}
}
}
} else {
throw new Exception_MegaCrypterLinkException(self::LINK_ERROR);
}
}
示例8: act_detectSkuStoreInfo
function act_detectSkuStoreInfo()
{
$skuArr = isset($_POST['skuArr']) ? json_decode(gzinflate($_POST['skuArr'])) : '';
$storeId = isset($_POST['storeId']) ? $_POST['storeId'] : '';
if (!is_array($skuArr)) {
self::$errCode = 401;
self::$errMsg = "skuArr不是数组!";
return;
}
if (empty($storeId)) {
self::$errCode = 402;
self::$errMsg = "storeId不能为空";
return;
}
$sku_str = implode("','", $skuArr);
$sku_str = "('" . $sku_str . "')";
$sku_list = OmAvailableModel::getTNameList("wh_sku_location", "sku,actualStock", "where sku in {$sku_str} and actualStock>0 and storeId='{$storeId}'");
if ($sku_list) {
$return_info = array();
foreach ($sku_list as $list) {
$return_info[] = $list['sku'];
}
return json_encode($return_info);
} else {
return '';
}
}
示例9: logoutResponseUrl
/**
* Create a valid SAML logout response
* Based off of Sperantus_SAML2_SP_AuthRequest
*/
public function logoutResponseUrl($logoutRequest, $returnUrl)
{
$id = uniqid('', true);
$issueInstant = date('Y-m-d\\TH:i:s\\Z');
$issuer = $this->_token_key;
$response = @gzinflate(base64_decode($logoutRequest));
if (!strlen($response)) {
return FALSE;
}
$matches = array();
preg_match('/ID=\\"(.+?)\\"/', $response, $matches);
if (!isset($matches[1])) {
return FALSE;
}
$responseTo = $matches[1];
$request = '
<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="' . $id . '" Version="2.0" IssueInstant="' . $issueInstant . '"
InResponseTo="' . $responseTo . '">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">' . $issuer . '</saml:Issuer>
<samlp:Status xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<samlp:StatusCode
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
Value="urn:oasis:names:tc:SAML:2.0:status:Success">
</samlp:StatusCode>
</samlp:Status>
</samlp:LogoutResponse>';
return $returnUrl . '?entityid=' . urlencode($this->_consumer_key) . '&SAMLResponse=' . urlencode(base64_encode(gzdeflate($request)));
}
示例10: readChunk
function readChunk($posx, $posz)
{
global $REGION_DIR;
// calculate region file to read
$regionX = floor($posx / 32);
$regionZ = floor($posz / 32);
// open region file, seek to header info
$file = gzopen($REGION_DIR . "r.{$regionX}.{$regionZ}.mcr", 'r');
$chunkHeaderLoc = 4 * (floormod($posx, 32) + floormod($posz, 32) * 32);
gzseek($file, $chunkHeaderLoc);
$info = unpack('C*', gzread($file, 4));
$chunkDataLoc = $info[1] << 16 | $info[2] << 8 | $info[3];
// if chunk hasn't been generated, return empty
if ($chunkDataLoc == 0) {
return array();
}
// seek to data, write to gz and return
gzseek($file, $chunkDataLoc * 4096);
$info = unpack('C*', gzread($file, 4));
$chunkLength = $info[1] << 32 | $info[2] << 16 | $info[3] << 8 | $info[4];
// read to skip over compression byte
gzread($file, 1);
// skip first two bytes for deflate
gzread($file, 2);
// leave off last four bytes for deflate
$chunkLength -= 4;
$contents = gzread($file, $chunkLength - 1);
$contents = gzinflate($contents);
$data = array_merge(unpack("C*", $contents));
return $data;
}
示例11: decode_body
protected static function decode_body($headers, $str, $eol = "\r\n")
{
$tmp = $str;
$add = strlen($eol);
$str = '';
if (isset($headers['transfer-encoding']) && 'chunked' == $headers['transfer-encoding']) {
do {
$tmp = ltrim($tmp);
$pos = strpos($tmp, $eol);
$len = hexdec(substr($tmp, 0, $pos));
if (isset($headers['content-encoding'])) {
$str .= @gzinflate(substr($tmp, $pos + $add + 10, $len));
} else {
$str .= substr($tmp, $pos + $add, $len);
}
$tmp = substr($tmp, $len + $pos + $add);
$check = trim($tmp);
} while (!empty($check));
} else {
if (isset($headers['content-encoding'])) {
$str = @gzinflate(substr($tmp, 10));
} else {
$str = $tmp;
}
}
return $str;
}
示例12: __construct
public function __construct(ServerAPI $api, $server = false)
{
$this->api = $api;
if (substr(self::$chunkHeader, 0, 9) === "base64://") {
self::$chunkHeader = gzinflate(base64_decode(substr(self::$chunkHeader, 9)));
}
}
示例13: decode_gzip
function decode_gzip($data)
{
if (function_exists('gzdecode')) {
return gzdecode($data);
}
return gzinflate(substr($data, 10, -8));
}
示例14: genosage
static function genosage()
{
# CHECK THE INIT STATUS
if (is_dir('./App') and is_dir('./Config') and is_dir('./Cache')) {
return;
}
# > FOLDER
$sys_folders = array('App', 'App/M', 'App/V', 'App/C', 'Cache', 'Config', 'Public', 'Public/Js', 'Public/Css', 'Public/Img', 'Upload');
for ($i = 0; $i < count($sys_folders); $i++) {
if (!is_dir('./' . $sys_folders[$i])) {
mkdir('./' . $sys_folders[$i], 0777);
}
}
# > CONFIG FILE
$sys_config_files['core'] = gzinflate(base64_decode('4+VSSc4vSlWwVUgsKkqs1NC05uXihYhFq4cGuDiGuMaHePq6qscClagbGRgaGVgaGqpbw9U4+/t7e7rG+3i6ISm0MDMxMEBS4+js4RofHOmHUGGMkHVxdQp1j/cMgFhhaGSuZwCEQDsUlBVCg10VNHQ0FUL8FYJdAxyDgM5x4eUCAA=='));
$sys_config_files['auth'] = gzinflate(base64_decode('4+VSSSwtyVCwVUgsKkqs1NC05uXihYhFqzuGhnjE+/upxwKlDaxRhUP8vV394v0cfV3B0urpqXn5xYnpqfEl+dmpeeroqh2dfKAKQ4tTi9ClQ4NdgyCypUDZvMTcVHQVAY7BwRAVBYnFxeX5RSnoKtyD/EMDoG4pyi8tQJf38Xf3hHhFvTgzPS8T7Ea4Ei2wDCQMeLk4gXwFWzsFA14uUIAAAA=='));
$sys_config_files['database'] = gzinflate(base64_decode('4+VSSUksSUxKLE5VsFVILCpKrNTQtObl4kWIR6u7OMV7+AeHqMcClagbGpnrGQChoZWxsYGZujW6Sj9HX1eIyvTUvPzixPRUTDWhwa5BEDVF+fklmPIBjsHBEHksckGubp4RUBvyitPjQUoA'));
$sys_config_files['router'] = gzinflate(base64_decode('4+VSKcovLUktUrBVSCwqSqzU0LTm5eKFiUarZ+alpFaox8Klebk41bXUFWztFNQ9QVL6EAW8XCB9cF1axOoAAA=='));
file_put_contents('./Config/ConCore.php', '<?php' . $sys_config_files['core'] . '?>');
file_put_contents('./Config/ConRouter.php', '<?php' . $sys_config_files['router'] . '?>');
file_put_contents('./Config/ConAuth.php', '<?php' . $sys_config_files['auth'] . '?>');
file_put_contents('./Config/ConDatabase.php', '<?php' . $sys_config_files['database'] . '?>');
# > APP DEMO
$sys_app_demo = gzinflate(base64_decode('4+VS5uVSVnAMCPD0c3GN4AVxk3MSi4sVHAsKPPNSUisUUitKUvNSwAK8XNW8XJwFpUk5mckKaaV5ySWZ+XkKmSBlGppAGZAsZ0FRZl5JfJGGukdqTk6+Qnl+UU6KorqmNVCulpOXq5aXCwA='));
file_put_contents('./App/C/AppIndex.php', '<?php' . $sys_app_demo . '?>');
# > INIT CPMPLETE
}
示例15: parseResponse
function parseResponse(&$buff)
{
preg_match("/^(.*?)\r\n\r\n(.*?)\$/s", $buff, $match);
if (isset($match[2])) {
$this->header = $match[1];
$this->body = $match[2];
$headlines = explode("\n", $this->header);
// this->head
$status = false;
//$stop = false;
foreach ($headlines as $header) {
if (!$status) {
$status = $header;
// expecting HTTP/1.1 200 OK
if (!strpos($status, "200")) {
return false;
}
} else {
preg_match("/^([^:]*?):\\s*(.*?)[\r]\$/i", $header, $htmp);
if (isset($htmp[2])) {
$this->head[strtolower($htmp[1])] = $htmp[2];
}
}
}
// inflating gzip'ed pages
if (isset($this->head["content-encoding"]) && $this->head["content-encoding"] == "gzip" || isset($this->head["vary"]) && strtolower($this->head["vary"]) == "accept-encoding") {
// Read http://www.php.net/manual/en/function.gzinflate.php
$this->body = gzinflate(substr($this->body, 10));
}
}
}