本文整理汇总了PHP中gzdecode函数的典型用法代码示例。如果您正苦于以下问题:PHP gzdecode函数的具体用法?PHP gzdecode怎么用?PHP gzdecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzdecode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decodeGz64
function decodeGz64()
{
$contentNodes = $this->xpath->query("//content");
foreach ($contentNodes as $contentNode) {
if ($contentNode->getAttribute("contentType") == "application/x-gzip" && $contentNode->getAttribute('contentTransferEncoding') == "base64") {
$contentDOM = new \DOMDocument();
$contentDOM->loadXML(gzdecode(base64_decode($contentNode->nodeValue)));
$xmlns = "http://schemas.ogf.org/nml/2013/05/base#";
$tagName = "Topology";
foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $netNode) {
$node = $this->xml->importNode($netNode, true);
$contentNode->nodeValue = "";
$contentNode->removeAttribute("contentType");
$contentNode->removeAttribute('contentTransferEncoding');
$contentNode->appendChild($node);
}
$xmlns = "http://schemas.ogf.org/nsi/2014/02/discovery/nsa";
$tagName = "nsa";
foreach ($contentDOM->getElementsByTagNameNS($xmlns, $tagName) as $nsaNode) {
$node = $this->xml->importNode($nsaNode, true);
$contentNode->nodeValue = "";
$contentNode->removeAttribute("contentType");
$contentNode->removeAttribute('contentTransferEncoding');
$contentNode->appendChild($node);
}
}
}
}
示例2: process
public static function process()
{
$security = new Security();
$security->verifyPre();
$data = stream_get_contents(fopen('php://input', 'r'));
$compressedSize = strlen($data);
$security->verifyCompressedData($data, $compressedSize);
$data = @gzdecode($data);
$uncompressedSize = strlen($data);
$security->validateData($data, $uncompressedSize);
$json = json_decode($data, true);
$security->validateJson($json);
if (isset($json['icon'])) {
$img = self::getServerIcon($json['icon']);
$json['icon'] = $img;
$data = json_encode($json);
$uncompressedSize = strlen($data);
}
$key = Util::uuid(false);
$cacheFile = Cache::getFile($key);
Log::info("Uploaded {$uncompressedSize} bytes as {$key} to {$cacheFile}");
Cache::put($key, $data);
header("Location: " . BASE_URL_VIEW . "/?id={$key}");
self::error("Compressed Size: {$compressedSize}\nUncompressed Size: {$uncompressedSize}\nRaw Upload: " . BASE_URL_VIEW . "/?id={$key}&raw=1");
}
示例3: load
public function load()
{
$file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->name;
if (is_file($file)) {
$this->data = array_merge($this->data, unserialize(gzdecode(file_get_contents($file))));
}
}
示例4: setContentAndInfo
/**
* Adds the content to the response, which will get JSON decoded and the curl info array.
*
* @param string $content JSON encoded response content
* @param array $info the curl info array
*
* @return void
*/
public function setContentAndInfo($content, array $info)
{
$this->content = json_decode($content);
$this->info = $info;
//for some reason curl sometimes fails to decompress gzipped responses, so we must do it manually
if (empty($this->content) and isset($this->header['Content-Encoding']) and $this->header['Content-Encoding'] == 'gzip') {
$this->content = json_decode(gzdecode($content));
}
//add the response timestamp to the content
if (isset($this->header['Date'])) {
$this->content->dateTs = strtotime($this->header['Date']);
}
if (isset($this->content->access_token)) {
//we need to expire (and refresh) the access token before it expires on CCPs side, which appears to happen
//earlier than it should
$this->expiry = time() + (int) $this->content->expires_in - 20;
} elseif (isset($this->content->expires_in)) {
$this->expiry = time() + (int) $this->content->expires_in;
} elseif (isset($this->header['Cache-Control'])) {
foreach (explode(',', $this->header['Cache-Control']) as $frag) {
if (substr(trim($frag), 0, 8) == 'max-age=') {
$this->expiry = time() + (int) substr(trim($frag), 8);
}
}
}
}
示例5: output
public function output($files, $cache_key)
{
header('Content-Type: ' . $this->contentType);
OC_Response::enableCaching();
$etag = $this->generateETag($files);
$cache_key .= '-' . $etag;
$gzout = false;
$cache = OC_Cache::getGlobalCache();
if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)) {
OC_Response::setETagHeader($etag);
$gzout = $cache->get($cache_key . '.gz');
}
if (!$gzout) {
$out = $this->minimizeFiles($files);
$gzout = gzencode($out);
$cache->set($cache_key . '.gz', $gzout);
OC_Response::setETagHeader($etag);
}
if ($encoding = OC_Request::acceptGZip()) {
header('Content-Encoding: ' . $encoding);
$out = $gzout;
} else {
$out = gzdecode($gzout);
}
header('Content-Length: ' . strlen($out));
echo $out;
}
示例6: decompress
/**
* Decompress the given value with the specific compression
*
* @param String $sValue
*
* @return String
*
* @throws Exception
*/
public function decompress($sValue)
{
if (!is_string($sValue)) {
throw new Exception('Invalid first argument, must be a string');
}
return gzdecode($sValue);
}
示例7: packDecode
public static function packDecode($str)
{
$header = substr($str, 0, 4);
$len = unpack("Nlen", $header);
$len = $len["len"];
if (DoraConst::SW_DATASIGEN_FLAG == true) {
$signedcode = substr($str, 4, 4);
$result = substr($str, 8);
//check signed
if (pack("N", crc32($result . DoraConst::SW_DATASIGEN_SALT)) != $signedcode) {
return self::packFormat("Signed check error!", 100005);
}
$len = $len - 4;
} else {
$result = substr($str, 4);
}
if ($len != strlen($result)) {
//结果长度不对
echo "error length...\n";
return self::packFormat("packet length invalid 包长度非法", 100007);
}
//if compress the packet
if (DoraConst::SW_DATACOMPRESS_FLAG == true) {
$result = gzdecode($result);
}
$result = unserialize($result);
return self::packFormat("OK", 0, $result);
}
示例8: decompress
protected function decompress($content)
{
if ($this->gzipEnabled && \substr($content, 0, 2) === "‹") {
return \gzdecode($content);
}
return $content;
}
示例9: send
/**
* @param array $params
*
* @return mixed
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
private function send($params)
{
$url = $this->build_url();
if (!$url) {
throw new InvalidArgumentException('Empty target URL given!');
}
$response = null;
if ($params) {
$url = $this->add_parameters_to_url($url, $params);
if ($this->method === 'GET') {
$url = $this->add_params_to_query_string($url, $params);
}
}
$context = $this->filter_request_params($params, $this->method);
$api_response = $this->http_transport->request(esc_url_raw($url), $context);
$this->handle_request_exceptions($api_response);
if ($this->must_respond) {
$api_response = $this->validate_response_content_type($api_response);
$content_type = $api_response['headers']['content-type'];
$response = $api_response['body'];
if (false !== strpos($content_type, 'zip')) {
$response = gzdecode($api_response['body']);
}
if ('json' === $this->response_format) {
$response = json_decode($response);
}
}
return $response;
}
示例10: put
public static function put($killID, $raw)
{
$file = static::getFile($killID, true);
$sem = sem_get(5632);
// kmdb is 5632 on a phone
if (!sem_acquire($sem)) {
throw new Exception('Unable to obtain kmdb semaphore');
}
// Thread safe from here until sem_release
if (!file_exists($file)) {
$kills = array();
} else {
$contents = file_get_contents($file);
$deflated = gzdecode($contents);
$kills = unserialize($deflated);
$contents = null;
}
if (!isset($kills["{$killID}"])) {
$kills["{$killID}"] = $raw;
$contents = serialize($kills);
$compressed = gzencode($contents);
file_put_contents($file, $compressed, LOCK_EX);
}
sem_release($sem);
}
示例11: decode_gzip
function decode_gzip($data)
{
if (function_exists('gzdecode')) {
return gzdecode($data);
}
return gzinflate(substr($data, 10, -8));
}
示例12: PerformDownload
public function PerformDownload()
{
print 'Qcodo Package Manager (QPM) Downloader Tool v' . QCODO_VERSION . "\r\n\r\n";
$strEndPoint = sprintf('%s/DownloadPackage?name=%s&u=%s&gz=', QPackageManager::QpmServiceEndpoint, $this->strPackageName, $this->strUsername);
if (function_exists('gzdecode')) {
$strQpmXmlCompressed = QFileInManifest::DownloadFileFromWebWithStatusOutput($strEndPoint . '1');
$this->strQpmXml = gzdecode($strQpmXmlCompressed);
} else {
$this->strQpmXml = trim(QFileInManifest::DownloadFileFromWebWithStatusOutput($strEndPoint . '0'));
}
if (!$this->strQpmXml) {
throw new Exception(sprintf('package not found: %s/%s', $this->strUsername, $this->strPackageName));
}
$this->objQpmXml = new SimpleXMLElement($this->strQpmXml);
$this->CheckVersion();
if (!$this->blnVersionMatch && !$this->blnForce) {
print $this->GetVersionMismatchWarningText();
}
$strErrorArray = $this->AnalyzePackage();
if (count($strErrorArray)) {
print $this->GetErrorText($strErrorArray);
}
if (!$this->blnLive) {
print $this->GetNonLiveText();
} else {
if (($this->blnVersionMatch || $this->blnForce) && !count($strErrorArray)) {
$this->ExecuteDownload();
}
}
}
示例13: transformResponse
/**
* @param string $rawResponse
*
* @return Torrent[]
*/
protected function transformResponse($rawResponse)
{
$crawler = new Crawler(gzdecode($rawResponse));
return $crawler->filter('tr[id^="torrent_"]')->each(function ($node) {
$magnet = $node->filter('.ka-magnet')->parents()->attr('href');
preg_match('/btih:([0-9A-Za-z]+)&/', $magnet, $matches);
$hash = $matches[1];
$size = $node->filter('td.nobr')->text();
preg_match('/([0-9\\.]+) ([A-Za-z]+)/', $size, $matches);
$size = $matches[1];
$unit = $matches[2];
$converter = new Nomnom($size);
$torrent = new Torrent();
$torrent->setName($node->filter('a.cellMainLink')->text());
$torrent->setHash($hash);
$torrent->setMagnet($magnet);
if ($unit == 'KB') {
$unit = 'kB';
}
$torrent->setSize($converter->from($unit)->to('B'));
$torrent->setSeeds($node->filter('td.green')->text());
$torrent->setPeers($node->filter('td.red')->text());
return $torrent;
});
}
示例14: testEncode
public function testEncode()
{
$testString = 'a string to be compressed';
$result = $this->encoder->encode($testString);
$uncompressedResult = gzdecode($result);
$this->assertSame($testString, $uncompressedResult);
}
示例15: legitimateRequest
/**
* Simulate a user visiting the URL from a browser as closely as we can
*
* @param string $url
* @param array|null $cookies
* @param string|null $referrer
* @param bool $skipBody
*
* @return array
*/
static function legitimateRequest($url, $cookies = null, $referrer = null, bool $skipBody = false)
{
$r = curl_init();
$curl_opt = array(CURLOPT_HTTPHEADER => array("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Encoding: gzip, deflate, sdch", "Accept-Language: hu,en-GB;q=0.8,en;q=0.6", "Connection: keep-alive"), CURLOPT_HEADER => true, CURLOPT_URL => $url, CURLOPT_BINARYTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.5678.91 Safari/537.36");
if (isset($referrer)) {
$curl_opt[CURLOPT_REFERER] = $referrer;
}
if (is_array($cookies)) {
$curl_opt[CURLOPT_COOKIE] = implode('; ', $cookies);
}
if ($skipBody === true) {
$curl_opt[CURLOPT_NOBODY] = $skipBody;
}
curl_setopt_array($r, $curl_opt);
$response = curl_exec($r);
$responseCode = curl_getinfo($r, CURLINFO_HTTP_CODE);
$headerSize = curl_getinfo($r, CURLINFO_HEADER_SIZE);
$responseHeaders = rtrim(CoreUtils::substring($response, 0, $headerSize));
$response = CoreUtils::substring($response, $headerSize);
$curlError = curl_error($r);
curl_close($r);
if ($responseCode < 200 || $responseCode >= 300) {
throw new CURLRequestException(rtrim("cURL fail for URL \"{$url}\" (HTTP {$responseCode}); {$curlError}", ' ;'), $responseCode);
}
global $http_response_header;
$http_response_header = array_map("rtrim", explode("\n", $responseHeaders));
if (preg_match(new RegExp('Content-Encoding:\\s?gzip'), $responseHeaders)) {
$response = gzdecode($response);
}
return array('responseHeaders' => $responseHeaders, 'response' => $response);
}