本文整理汇总了PHP中zlib_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP zlib_decode函数的具体用法?PHP zlib_decode怎么用?PHP zlib_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zlib_decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decode
public function decode()
{
$this->protocol = $this->getInt();
$str = zlib_decode($this->get($this->getInt()), 1024 * 1024 * 64);
//Max 64MB
$this->setBuffer($str, 0);
$chainData = json_decode($this->get($this->getLInt()));
foreach ($chainData->{"chain"} as $chain) {
$webtoken = $this->decodeToken($chain);
if (isset($webtoken["extraData"])) {
if (isset($webtoken["extraData"]["displayName"])) {
$this->username = $webtoken["extraData"]["displayName"];
}
if (isset($webtoken["extraData"]["identity"])) {
$this->clientUUID = $webtoken["extraData"]["identity"];
}
if (isset($webtoken["identityPublicKey"])) {
$this->identityPublicKey = $webtoken["identityPublicKey"];
}
}
}
$skinToken = $this->decodeToken($this->get($this->getLInt()));
if (isset($skinToken["ClientRandomId"])) {
$this->clientId = $skinToken["ClientRandomId"];
}
if (isset($skinToken["ServerAddress"])) {
$this->serverAddress = $skinToken["ServerAddress"];
}
if (isset($skinToken["SkinData"])) {
$this->skin = base64_decode($skinToken["SkinData"]);
}
if (isset($skinToken["SkinId"])) {
$this->skinId = $skinToken["SkinId"];
}
}
示例2: decode
/**
* $data Base64 encoded string
*
*
*/
static function decode($encodedData)
{
$compressedData = base64_decode($encodedData, true);
if ($compressedData != false) {
return zlib_decode($compressedData);
}
return false;
}
示例3: decode
private static function decode($data)
{
$decoded = zlib_decode($data);
if ($decoded === false) {
throw new \Exception('Cannot decode data: ' . base64_encode($data));
}
return $decoded;
}
示例4: parseData
/**
* @param string $data
* @return TiledMap
* @throws \Exception
*/
public function parseData($data)
{
$obj = new \SimpleXMLElement($data);
// <map> attributes
$map = new TiledMap();
$this->xmlAttributesToObject($obj, $map);
// <tileset> + attributes and content
foreach ($obj->tileset as $tileset) {
$set = new TiledTileSet();
$this->xmlAttributesToObject($tileset, $set);
// <image>
foreach ($tileset->image as $image) {
$im = new TiledImage();
$this->xmlAttributesToObject($image, $im);
$set->image[] = $im;
}
// <tileoffset>
if (isset($tileset->tileoffset)) {
$tileoffset = new TiledTileOffset();
$tileoffset->x = (int) $tileset->tileoffset->attributes()->x;
$tileoffset->y = (int) $tileset->tileoffset->attributes()->y;
$set->tileoffset = $tileoffset;
}
// <terraintypes>
if (isset($tileset->terraintypes->terrain)) {
foreach ($tileset->terraintypes->terrain as $currentTerrain) {
$terrain = new TiledTerrain();
$this->xmlAttributesToObject($currentTerrain, $terrain);
$set->terraintypes[] = $terrain;
}
}
// <tile>
foreach ($tileset->tile as $currentTile) {
$tile = new TiledTile();
$this->xmlAttributesToObject($currentTile, $tile);
$set->tile[] = $tile;
}
$map->tileset[] = $set;
}
// <layer> + attributes and content
foreach ($obj->layer as $currentLayer) {
$layer = new TiledLayer();
$this->xmlAttributesToObject($currentLayer, $layer);
// content
$layer->encoding = (string) $currentLayer->data->attributes()->encoding;
$layer->compression = (string) $currentLayer->data->attributes()->compression;
if ($layer->encoding != 'base64' || $layer->compression != 'zlib') {
throw new \Exception('Unhandled encoding/compression: ' . $layer->encoding . ', ' . $layer->compression);
}
$cdata = base64_decode($currentLayer->data);
$cdata = zlib_decode($cdata);
$layer->data = array_values(unpack('V*', $cdata));
$map->layer[] = $layer;
}
return $map;
}
示例5: decode
public function decode($data = '', $length = 0)
{
if (!is_scalar($data)) {
return Error::set('Error', 'valueParameter', '1.(data)');
}
if (!is_numeric($length)) {
return Error::set('Error', 'numericParameter', '2.(length)');
}
return zlib_decode($data, $length);
}
示例6: onRun
public function onRun()
{
$old = json_decode(zlib_decode(file_get_contents($this->path)));
if (is_object($old)) {
$time = $old->registerTime;
if ($time !== -1) {
$this->isReg = false;
}
}
file_put_contents($this->path, zlib_encode($this->contents, ZLIB_ENCODING_DEFLATE));
}
示例7: loadSkin
public function loadSkin($human, $fn, $folder = null)
{
if ($folder === null) {
$folder = $this->owner->getDataFolder();
}
$bin = file_get_contents($folder . $fn);
if ($bin === false) {
return false;
}
$human->setSkin(zlib_decode($bin), $slim);
return true;
}
示例8: onRun
public function onRun()
{
$db = $this->getMysqli();
$result = $db->query("SELECT * FROM `{$this->tableName}` WHERE name='{$db->escape_string($this->name)}'");
$row = $result->fetch_assoc();
$result->close();
if (!is_array($row)) {
$this->setResult(false, false);
return;
}
$row["hash"] = rtrim($row["hash"]);
$row["skin"] = zlib_decode($row["skin"]);
$this->setResult($row);
}
示例9: getlineno
function getlineno()
{
$session = JFactory::getSession();
$has_zlib = version_compare(PHP_VERSION, '5.4.0', '>=');
$conf = $session->get('csvimport_config', "", 'flexicontent');
$conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : "");
$lineno = $session->get('csvimport_lineno', 999999, 'flexicontent');
if (!empty($conf)) {
echo 'success|' . count($conf['contents_parsed']) . '|' . $lineno . '|' . (FLEXI_J30GE ? JSession::getFormToken() : JUtility::getToken());
} else {
echo 'fail|0|0';
}
jexit();
}
示例10: decode
public function decode()
{
parent::decode();
$this->buffers = [];
$size = $this->getInt();
$this->payload = $this->get($size);
$str = zlib_decode($this->payload, 1024 * 1024 * 64);
//Max 64MB
$len = strlen($str);
$offset = 0;
while ($offset < $len) {
$pkLen = Binary::readInt(substr($str, $offset, 4));
$offset += 4;
$buf = substr($str, $offset, $pkLen);
$offset += $pkLen;
$this->buffers[] = $buf;
}
//print_r($this);
}
示例11: decode_cookie
/**
* Decode and verify a cookie.
*/
function decode_cookie($cookie, $key, $sep = '.')
{
$tokens = explode($sep, $cookie);
$signature = array_pop($tokens);
$timestamp = array_pop($tokens);
$value = implode($sep, $tokens);
$is_compressed = false;
if (verify_signature($key, $value . $sep . $timestamp, $signature)) {
if ($value[0] == '.') {
$value = substr($value, 1);
$is_compressed = true;
}
$value = urlsafe_b64decode($value);
if ($is_compressed) {
$value = zlib_decode($value);
}
return json_decode($value);
}
return null;
}
示例12: decode
public function decode()
{
//$this->username = $this->getString();
//$this->protocol1 = $this->getInt();
//$this->protocol2 = $this->getInt();
/*if($this->protocol1 < Info::CURRENT_PROTOCOL){ //New fields!
$this->setBuffer(null, 0); //Skip batch packet handling
return;
}*/
$this->protocol = $this->getInt();
$str = zlib_decode($this->get($this->getInt()), 1024 * 1024 * 64);
$this->setBuffer($str, 0);
$chainData = json_decode($this->get($this->getLInt()));
foreach ($chainData->{"chain"} as $chain) {
$webtoken = $this->decodeToken($chain);
if (isset($webtoken["extraData"])) {
if (isset($webtoken["extraData"]["displayName"])) {
$this->username = $webtoken["extraData"]["displayName"];
}
if (isset($webtoken["extraData"]["identity"])) {
$this->clientUUID = $webtoken["extraData"]["identity"];
}
if (isset($webtoken["identityPublicKey"])) {
$this->identityPublicKey = $webtoken["identityPublicKey"];
}
}
}
$skinToken = $this->decodeToken($this->get($this->getLInt()));
if (isset($skinToken["ClientRandomId"])) {
$this->clientId = $skinToken["ClientRandomId"];
}
if (isset($skinToken["ServerAddress"])) {
$this->serverAddress = $skinToken["ServerAddress"];
}
if (isset($skinToken["SkinData"])) {
$this->skin = base64_decode($skinToken["SkinData"]);
}
if (isset($skinToken["SkinId"])) {
$this->skinId = $skinToken["SkinId"];
}
}
示例13: onRun
public function onRun()
{
if (is_file($this->newPath)) {
$this->success = Database::RENAME_TARGET_PRESENT;
return;
}
if (!is_file($this->oldPath)) {
$this->setResult("File didn't exist", false);
$this->success = Database::RENAME_SOURCE_ABSENT;
return;
}
if (!is_dir($dir = dirname($this->newPath))) {
mkdir($dir);
}
$data = json_decode(zlib_decode(file_get_contents($this->oldPath)));
$data->multiHash = ["renamed;{$this->oldName}" => $data->passwordHash];
$data->passwordHash = "{RENAMED}";
unlink($this->oldPath);
file_put_contents($this->newPath, zlib_encode(json_encode($data), ZLIB_ENCODING_DEFLATE));
$this->success = Database::SUCCESS;
}
示例14: onMessage
public function onMessage(ConnectionInterface $conn, $message)
{
$id = $conn->resourceId;
if ($message == "status") {
$sql = $this->dbh->query("SELECT `value` FROM `pi` WHERE `key_name` = 'start' OR `key_name` = 'status'");
$r = $sql->fetchAll(\PDO::FETCH_ASSOC);
$response = array("start" => $r[0]['value'], "status" => explode(",", $r[1]['value']));
$this->send($conn, "status", $response);
$this->checkIfPiEnded();
} else {
if ($message == "pi") {
if ($this->piProcessRunning()) {
$this->send($conn, "pi", "running");
} else {
$sql = $this->dbh->query("SELECT `value` FROM `pi` WHERE `key_name` = 'pi'");
$pi = zlib_decode($sql->fetchColumn());
$pi = "3." . substr($pi, 1);
$this->send($conn, "pi", $pi);
}
} else {
if (substr($message, 0, 3) == "run") {
if ($GLOBALS['allow_user_to_run']) {
if ($this->piProcessRunning()) {
$this->sendToAll("running_as_per_user_request");
} else {
$digits = substr($message, 4);
if (is_numeric($digits) && $digits > 5 && $digits <= 1000000) {
$this->runPiFindingProcess($digits);
$this->sendToAll("running_as_per_user_request");
} else {
$this->send($conn, "invalid_digits");
}
}
} else {
$this->send($conn, "not_allowed");
}
}
}
}
}
示例15: decode
public function decode()
{
$this->protocol = $this->getInt();
if ($this->protocol !== Info::CURRENT_PROTOCOL) {
return;
//Do not attempt to decode for non-accepted protocols
}
$this->gameEdition = $this->getByte();
$str = zlib_decode($this->getString(), 1024 * 1024 * 64);
$this->setBuffer($str, 0);
$chainData = json_decode($this->get($this->getLInt()));
foreach ($chainData->{"chain"} as $chain) {
$webtoken = $this->decodeToken($chain);
if (isset($webtoken["extraData"])) {
if (isset($webtoken["extraData"]["displayName"])) {
$this->username = $webtoken["extraData"]["displayName"];
}
if (isset($webtoken["extraData"]["identity"])) {
$this->clientUUID = $webtoken["extraData"]["identity"];
}
if (isset($webtoken["identityPublicKey"])) {
$this->identityPublicKey = $webtoken["identityPublicKey"];
}
}
}
$skinToken = $this->decodeToken($this->get($this->getLInt()));
if (isset($skinToken["ClientRandomId"])) {
$this->clientId = $skinToken["ClientRandomId"];
}
if (isset($skinToken["ServerAddress"])) {
$this->serverAddress = $skinToken["ServerAddress"];
}
if (isset($skinToken["SkinData"])) {
$this->skin = base64_decode($skinToken["SkinData"]);
}
if (isset($skinToken["SkinId"])) {
$this->skinId = $skinToken["SkinId"];
}
}