本文整理汇总了PHP中gzuncompress函数的典型用法代码示例。如果您正苦于以下问题:PHP gzuncompress函数的具体用法?PHP gzuncompress怎么用?PHP gzuncompress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzuncompress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cookie_to_object
/**
* Decoding with object_to_coockie ecoded sting into php-object
*
* @param string $cookie
* @return mixed
*/
function cookie_to_object($cookie){
$z = urldecode($cookie);
$z = base64_decode($z);
$z = gzuncompress($z);
$z = unserialize($z);
return $z;
}
示例2: get
/**
* 读取缓存
*
* @access public
* @param string $name
* 缓存变量名
* @return mixed
*/
public function get($name = false)
{
N('cache_read', 1);
$id = shmop_open($this->handler, 'c', 0600, 0);
if ($id !== false) {
$ret = unserialize(shmop_read($id, 0, shmop_size($id)));
shmop_close($id);
if ($name === false) {
return $ret;
}
$name = $this->options['prefix'] . $name;
if (isset($ret[$name])) {
$content = $ret[$name];
if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
// 启用数据压缩
$content = gzuncompress($content);
}
return $content;
} else {
return null;
}
} else {
return false;
}
}
示例3: convert
function convert()
{
$searchstart = 'stream';
$searchend = 'endstream';
$pdfText = '';
$pos = 0;
$pos2 = 0;
$startpos = 0;
while ($pos !== false && $pos2 !== false) {
$pos = strpos($this->source, $searchstart, $startpos);
$pos2 = strpos($this->source, $searchend, $startpos + 1);
if ($pos !== false && $pos2 !== false) {
if ($this->source[$pos] == 0xd && $this->source[$pos + 1] == 0xa) {
$pos += 2;
} else {
if ($this->source[$pos] == 0xa) {
$pos++;
}
}
if ($this->source[$pos2 - 2] == 0xd && $this->source[$pos2 - 1] == 0xa) {
$pos2 -= 2;
} else {
if ($this->source[$pos2 - 1] == 0xa) {
$pos2--;
}
}
$textsection = substr($this->source, $pos + strlen($searchstart) + 2, $pos2 - $pos - strlen($searchstart) - 1);
$data = @gzuncompress($textsection);
$pdfText .= $this->extractTextFromPdf($data);
$startpos = $pos2 + strlen($searchend) - 1;
}
}
return preg_replace('/(\\s)+/', ' ', $pdfText);
}
示例4: unserialize
/**
* Re-inflates and unserializes a blob of compressed data
* @param string $data
* @return mixed false if an error occurred
*/
public static function unserialize($data)
{
if (Auditing::current()->compressData) {
$data = gzuncompress($data);
}
return unserialize($data);
}
示例5: deal_file
function deal_file($params)
{
global $log;
if (isset($params['fileContent'])) {
$log->LogInfo("---------处理后台报文返回的文件---------");
$fileContent = $params['fileContent'];
if (empty($fileContent)) {
$log->LogInfo('文件内容为空');
} else {
$content = gzuncompress(base64_decode($fileContent));
$root = SDK_FILE_DOWN_PATH;
$filePath = null;
if (empty($params['fileName'])) {
$log->LogInfo("文件名为空");
$filePath = $root . $params['merId'] . '_' . $params['batchNo'] . '_' . $params['txnTime'] . 'txt';
} else {
$filePath = $root . $params['fileName'];
}
$handle = fopen($filePath, "w+");
if (!is_writable($filePath)) {
$log->LogInfo("文件:" . $filePath . "不可写,请检查!");
} else {
file_put_contents($filePath, $content);
$log->LogInfo("文件位置 >:" . $filePath);
}
fclose($handle);
}
}
}
示例6: end
public static function end()
{
$content = gzuncompress(gzcompress(ob_get_contents()));
ob_end_clean();
$r = RenderingStack::peek();
if (self::$store_mode == self::STORE_MODE_OVERWRITE || self::$store_mode == self::STORE_MODE_ERROR_ON_OVERWRITE) {
$r->set(self::$sector_path, $content);
}
if (self::$store_mode == self::STORE_MODE_APPEND) {
if ($r->is_set(self::$sector_path)) {
$old_content = $r->get(self::$sector_path);
$r->set(self::$sector_path, $old_content . $content);
} else {
$r->set(self::$sector_path, $content);
}
}
if (self::$store_mode == self::STORE_MODE_PREPEND) {
if ($r->is_set(self::$sector_path)) {
$old_content = $r->get(self::$sector_path);
$r->set(self::$sector_path, $content . $old_content);
} else {
$r->set(self::$sector_path, $content);
}
}
self::$sector_opened = false;
self::$store_mode = null;
self::$sector_path = null;
}
示例7: read
public function read($id)
{
// Check for the existance of a cookie with the name of the session id
// Make sure that the cookie is atleast the size of our hash, otherwise it's invalid
// Return an empty string if it's invalid.
if (!isset($_COOKIE[$id])) {
return '';
}
// We expect the cookie to be base64 encoded, so let's decode it and make sure
// that the cookie, at a minimum, is longer than our expact hash length.
$raw = gzuncompress(base64_decode($_COOKIE[$id]));
if ($raw === false || strlen($raw) < $this->HASH_LEN) {
return '';
}
// The cookie data contains the actual data w/ the hash concatonated to the end,
// since the hash is a fixed length, we can extract the last HMAC_LENGTH chars
// to get the hash.
$hash = substr($raw, strlen($raw) - $this->HASH_LEN, $this->HASH_LEN);
$data = substr($raw, 0, -$this->HASH_LEN);
// Calculate what the hash should be, based on the data. If the data has not been
// tampered with, $hash and $hash_calculated will be the same
$hash_calculated = hash_hmac($this->HASH_ALGO, $data, $this->HASH_SECRET);
// If we calculate a different hash, we can't trust the data. Return an empty string.
if ($hash_calculated !== $hash) {
return '';
}
// Return the data, now that it's been verified.
return (string) $data;
}
示例8: decodeMessages
/**
* 解密网络消息
* @param $message_str
* @param bool|true $alloc
* @param bool $encrypt
* true 返回 RPCMessage 实例数组 ,
* false 返回数组
* @return mixed|null
*/
static function decodeMessages($message_str, $alloc = true, $encrypt = false)
{
try {
// 解压缩数据
$unBase64 = base64_decode($message_str);
if ($unBase64 === FALSE) {
return null;
}
if ($encrypt) {
// 解密
for ($i = strlen($unBase64) - 1; $i >= self::NOT_OR_KEY_LEN; $i--) {
$unBase64[$i] = $unBase64[$i - self::NOT_OR_KEY_LEN] ^ $unBase64[$i];
}
$unBase64 = substr($unBase64, self::NOT_OR_KEY_LEN);
}
$messagesData = gzuncompress($unBase64);
if ($messagesData === FALSE) {
return null;
}
$jsonDecodeMessages = json_decode($messagesData, true);
$messages = [];
if ($alloc) {
foreach ($jsonDecodeMessages as $key => $jsonDecodeMessage) {
$messages[$key] = RPCMessage::createWithArray($jsonDecodeMessage);
}
} else {
$messages = $jsonDecodeMessages;
}
} catch (\Exception $e) {
return null;
}
return $messages;
}
示例9: Load
public static function Load($strPostDataState)
{
// Pull Out intStateIndex
if (!is_null(QForm::$EncryptionKey)) {
// Use QCryptography to Decrypt
$objCrypto = new QCryptography(QForm::$EncryptionKey, true);
$intStateIndex = $objCrypto->Decrypt($strPostDataState);
} else {
$intStateIndex = $strPostDataState;
}
// Pull FormState from Session
// NOTE: if gzcompress is used, we are restoring 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_decode before restoring from session (see note above).
if (array_key_exists('qform_' . $intStateIndex, $_SESSION)) {
$strSerializedForm = $_SESSION['qform_' . $intStateIndex];
// Uncompress (if available)
if (function_exists('gzcompress')) {
$strSerializedForm = gzuncompress($strSerializedForm);
}
return $strSerializedForm;
} else {
return null;
}
}
示例10: unpack
function unpack($packed)
{
if (!$packed) {
return false;
}
// ZLIB format has a five bit checksum in it's header.
// Lets check for sanity.
if ((ord($packed[0]) * 256 + ord($packed[1])) % 31 == 0 and substr($packed, 0, 2) == "‹" or substr($packed, 0, 2) == "xÚ") {
if (function_exists('gzuncompress')) {
// Looks like ZLIB.
$data = gzuncompress($packed);
return unserialize($data);
} else {
// user our php lib. TESTME
include_once "ziplib.php";
$zip = new ZipReader($packed);
list(, $data, $attrib) = $zip->readFile();
return unserialize($data);
}
}
if (substr($packed, 0, 2) == "O:") {
// Looks like a serialized object
return unserialize($packed);
}
if (preg_match("/^\\w+\$/", $packed)) {
return $packed;
}
// happened with _BackendInfo problem also.
trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.", E_USER_WARNING);
return false;
}
示例11: __construct
public function __construct()
{
session_start();
if (!$_SESSION['user'] || !$_SESSION['id']) {
if ($_COOKIE['codekb_user'] && $_COOKIE['codekb_id']) {
$succ = true;
if (!session_name('codeKB')) {
$succ = false;
}
if (!($_SESSION['user'] = gzuncompress(urldecode($_COOKIE['codekb_user'])))) {
$succ = false;
}
if (!($_SESSION['id'] = gzuncompress(urldecode($_COOKIE['codekb_id'])))) {
$succ = false;
}
if (!$succ) {
throw new CodeKBException(__METHOD__, "admin", "sessionfailed");
}
}
}
$user = $_SESSION['user'];
$pass = $_SESSION['id'];
$db = new CodeKBDatabase();
$db->dosql("SELECT id " . "FROM users " . "WHERE name = '{$db->string($user)}' AND " . "pass = '{$db->string($pass)}'");
if ($db->countrows() != 1) {
return false;
}
$this->_name = $user;
$this->_id = $db->column("id");
$this->_valid = true;
return true;
}
示例12: render
/**
* Render avatar
*/
private function render($data)
{
// Load Class and set parameters
$chargen = new CharacterRender();
$chargen->action = CharacterRender::ACTION_IDLE;
$chargen->direction = CharacterRender::DIRECTION_SOUTH;
$chargen->body_animation = 0;
$chargen->doridori = 0;
$chargen->loadFromSqlData($data);
// Load images
$player = $chargen->render();
$border = imagecreatefrompng(Cache::$path . "avatar/data/border.png");
$background = imagecreatefromjpeg(Cache::$path . "avatar/data/background01.jpg");
$output = imagecreatetruecolor(128, 128);
// Build image
imagecopy($output, $background, 7, 7, 0, 0, 114, 114);
imagecopy($output, $player, 7, 7, 35 + 7, 65 + 7, imagesx($player) - 14, imagesx($player) - 14);
imagecopy($output, $border, 0, 0, 0, 0, 128, 128);
// Add emblem
if (!empty($data['emblem_data'])) {
$binary = @gzuncompress(pack('H*', $data['emblem_data']));
if ($binary && ($emblem = imagecreatefrombmpstring($binary))) {
imagecopy($output, $emblem, 128 - 10 - 24, 128 - 10 - 24, 0, 0, 24, 24);
}
}
// Set color for text
$name_color = imagecolorallocate($output, 122, 122, 122);
$lvl_color = imagecolorallocate($output, 185, 109, 179);
$status_color = $data['online'] ? imagecolorallocate($output, 59, 129, 44) : imagecolorallocate($output, 188, 98, 98);
// Draw text
imagestring($output, 1, 12, 12, strtoupper($data['name']), $name_color);
imagestring($output, 1, 12, 25, $data['base_level'] . "/" . $data['job_level'], $lvl_color);
imagestring($output, 1, 81, 12, $data['online'] ? "ONLINE" : "OFFLINE", $status_color);
imagepng($output);
}
示例13: __wakeup
public function __wakeup()
{
if (is_array($this->pages)) {
return;
}
$this->pages = unserialize(gzuncompress($this->pages));
}
示例14: get
/**
* 得到ID数组
*
* @access public
* @param obj $obj
* @param array $ids id集合
* @return array
* @author 刘建辉
* @修改日期 2015-08-03 15:56:28
*/
public function get($getName, $id)
{
$diObj = \Phalcon\DI::getDefault()->get($getName);
$data = $diObj->get($id);
$newdataArr = array($id => gzuncompress($data));
return $newdataArr;
}
示例15: get
public function get($key)
{
$hash = md5($key);
if (self::$_data[$hash]) {
return unserialize(self::$_data[$hash]);
}
$fileName = $this->genFileName($key);
if (file_exists($fileName) && is_readable($fileName)) {
$content = file_get_contents($fileName);
$expireTime = substr($content, 0, 9);
$lastUpdate = filemtime($fileName);
if ($expireTime != -1 && TIME - $lastUpdate > $expireTime) {
if (is_writeable($fileName)) {
@unlink($fileName);
return false;
}
}
$content = substr($content, 9);
if (IS_SHM && function_exists('gzuncompress')) {
$content = gzuncompress($content);
}
return unserialize($content);
}
return false;
}