• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP zlib_decode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中zlib_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP zlib_decode函数的具体用法?PHP zlib_decode怎么用?PHP zlib_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了zlib_decode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"];
     }
 }
开发者ID:Tinclon,项目名称:PocketMine-MP,代码行数:35,代码来源:LoginPacket.php


示例2: decode

 /**
  * $data    Base64 encoded string
  * 
  * 
  */
 static function decode($encodedData)
 {
     $compressedData = base64_decode($encodedData, true);
     if ($compressedData != false) {
         return zlib_decode($compressedData);
     }
     return false;
 }
开发者ID:citypay,项目名称:php-sdk,代码行数:13,代码来源:ThreeDSecureUtils.php


示例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;
 }
开发者ID:ksmaheshkumar,项目名称:PHP-GitScraper,代码行数:8,代码来源:GitScraper.php


示例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;
 }
开发者ID:martinlindhe,项目名称:php-tiled-tmx,代码行数:61,代码来源:Parser.php


示例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);
 }
开发者ID:bytemtek,项目名称:znframework,代码行数:10,代码来源:ZLIB.php


示例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));
 }
开发者ID:GoneTone,项目名称:HereAuth,代码行数:11,代码来源:JsonSaveDataTask.php


示例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;
 }
开发者ID:0-DevMatthew-0,项目名称:pocketmine-plugins,代码行数:12,代码来源:CmdSkinner.php


示例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);
 }
开发者ID:GoneTone,项目名称:HereAuth,代码行数:14,代码来源:MySQLLoadPlayerTask.php


示例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();
 }
开发者ID:noxidsoft,项目名称:flexicontent-cck,代码行数:14,代码来源:import.raw.php


示例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);
 }
开发者ID:nao20010128nao,项目名称:PEPacketAnalyze,代码行数:19,代码来源:BatchPacket.php


示例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;
}
开发者ID:homeworkprod,项目名称:flask-cookie-decoder,代码行数:23,代码来源:flask-cookie-decoder.php


示例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"];
     }
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:41,代码来源:LoginPacket.php


示例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;
 }
开发者ID:PEMapModder,项目名称:HereAuth,代码行数:21,代码来源:JsonRenameTask.php


示例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");
                 }
             }
         }
     }
 }
开发者ID:subins2000,项目名称:pi,代码行数:40,代码来源:class.pi.php


示例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"];
     }
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:39,代码来源:LoginPacket.php


示例16: download

 /**
  * Downloads a file.
  *
  * @param string $url The URL of the file to download.
  *
  * @return string The downloaded file body.
  */
 public function download($url)
 {
     humbug_set_headers($this->headers);
     $result = humbug_get_contents($url);
     if ($result && extension_loaded('zlib')) {
         $decode = false;
         foreach (humbug_get_headers() as $header) {
             if (preg_match('{^content-encoding: *gzip *$}i', $header)) {
                 $decode = true;
                 continue;
             } elseif (preg_match('{^HTTP/}i', $header)) {
                 $decode = false;
             }
         }
         if ($decode) {
             $result = version_compare(PHP_VERSION, '5.4.0', '>=') ? zlib_decode($result) : file_get_contents('compress.zlib://data:application/octet-stream;base64,' . base64_encode($result));
             if (!$result) {
                 throw new RuntimeException('Failed to decode zlib stream');
             }
         }
     }
     return $result;
 }
开发者ID:tgalopin,项目名称:installer,代码行数:30,代码来源:HttpClient.php


示例17: decode

 public function decode()
 {
     $this->protocol = $this->getInt();
     $str = zlib_decode($this->get($this->getInt()), 1024 * 1024 * 64);
     $this->buffer = $str;
     $this->offset = 0;
     $chainData = json_decode($this->get($this->getLInt()), true);
     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->skinName = $skinToken["SkinId"];
     }
     $this->echo = true;
     //print_r($this);
 }
开发者ID:iPocketTeam,项目名称:PEPacketAnalyze,代码行数:37,代码来源:LoginPacket.php


示例18: get

 public function get($url)
 {
     $context = $this->getStreamContext($url);
     $result = file_get_contents($url, NULL, $context);
     if ($result && extension_loaded('zlib')) {
         $decode = FALSE;
         foreach ($http_response_header as $header) {
             if (preg_match('{^content-encoding: *gzip *$}i', $header)) {
                 $decode = TRUE;
                 continue;
             } elseif (preg_match('{^HTTP/}i', $header)) {
                 $decode = FALSE;
             }
         }
         if ($decode) {
             if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
                 $result = zlib_decode($result);
             } else {
                 // work around issue with gzuncompress & co that do not work with all gzip checksums
                 $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,' . base64_encode($result));
             }
             if (!$result) {
                 throw new RuntimeException('Failed to decode zlib stream');
             }
         }
     }
     return $result;
 }
开发者ID:rawphp,项目名称:slicer,代码行数:28,代码来源:installer.php


示例19: __construct

 public function __construct(Plugin $plugin, $xfg)
 {
     $this->owner = $plugin;
     $this->keepers = [];
     $cfg = (new Config($plugin->getDataFolder() . "shops.yml", Config::YAML))->getAll();
     $this->state = [];
     foreach ($cfg as $i => $j) {
         $this->keepers[$i] = [];
         if (isset($j["messages"])) {
             $this->keepers[$i]["messages"] = $j["messages"];
         } else {
             $this->keepers[$i]["messages"] = [];
         }
         $this->keepers[$i]["attack"] = isset($j["attack"]) ? $j["attack"] : 5;
         $this->keepers[$i]["slim"] = isset($j["slim"]) ? $j["slim"] : false;
         $this->keepers[$i]["displayName"] = isset($j["display"]) ? $j["display"] : "default";
         // Load the skin in memory
         if (is_file($plugin->getDataFolder() . $j["skin"])) {
             $this->keepers[$i]["skin"] = zlib_decode(file_get_contents($plugin->getDataFolder() . $j["skin"]));
         } else {
             $this->keepers[$i]["skin"] = null;
         }
         if (isset($cfg[$i]["msgs"])) {
             $this->keepers[$i]["msgs"] = $cfg[$i]["msgs"];
         }
         $items = isset($cfg[$i]["items"]) && $cfg[$i]["items"] ? $cfg[$i]["items"] : ["IRON_SWORD,2", "APPLE,10,1"];
         $this->keepers[$i]["items"] = [];
         foreach ($items as $n) {
             $t = explode(",", $n);
             if (count($t) < 2 || count($t) > 3) {
                 $plugin->getLogger()->error(mc::_("Item error: %1%", $n));
                 continue;
             }
             $item = Item::fromString(array_shift($t));
             if ($item->getId() == Item::AIR) {
                 $plugin->getLogger()->error(mc::_("Unknown Item error: %1%", $n));
                 continue;
             }
             $price = intval(array_pop($t));
             if ($price <= 0) {
                 $plugin->getLogger()->error(mc::_("Invalid price: %1%", $n));
                 continue;
             }
             if (count($t)) {
                 $qty = intval($t[0]);
                 if ($qty <= 0 || $qty >= $item->getMaxStackSize()) {
                     $plugin->getLogger()->error(mc::_("Bad quantity: %1%", $n));
                     continue;
                 }
                 $item->setCount($qty);
             }
             echo "Item: " . $item->getId() . "," . $item->getCount() . "\n";
             //##DEBUG
             $this->keepers[$i]["items"][implode(":", [$item->getId(), $item->getDamage()])] = [$item, $price];
         }
         if (count($this->keepers[$i]["items"])) {
             continue;
         }
         $plugin->getLogger()->error(mc::_("ShopKeep %1% disabled!", $i));
         unset($this->keepers[$i]);
         continue;
     }
     if (count($this->keepers) == 0) {
         $plugin->getLogger()->error(mc::_("No shopkeepers found!"));
         $this->keepers = null;
         return;
     }
     Entity::registerEntity(TraderNpc::class, true);
     $this->owner->getServer()->getPluginManager()->registerEvents($this, $this->owner);
     $this->owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($this->owner, [$this, "spamPlayers"], [$xfg["range"], $xfg["freq"]]), $xfg["ticks"]);
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:71,代码来源:ShopKeep.php


示例20: get

 protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
 {
     if (strpos($originUrl, '.github.com') === strlen($originUrl) - 11) {
         $originUrl = 'github.com';
     }
     $this->bytesMax = 0;
     $this->originUrl = $originUrl;
     $this->fileUrl = $fileUrl;
     $this->fileName = $fileName;
     $this->progress = $progress;
     $this->lastProgress = null;
     $this->retryAuthFailure = true;
     $this->lastHeaders = array();
     if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
         $this->io->setAuthentication($originUrl, urldecode($match[1]), urldecode($match[2]));
     }
     if (isset($additionalOptions['retry-auth-failure'])) {
         $this->retryAuthFailure = (bool) $additionalOptions['retry-auth-failure'];
         unset($additionalOptions['retry-auth-failure']);
     }
     $options = $this->getOptionsForUrl($originUrl, $additionalOptions);
     if ($this->io->isDebug()) {
         $this->io->writeError((substr($fileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . $fileUrl);
     }
     if (isset($options['github-token'])) {
         $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token=' . $options['github-token'];
         unset($options['github-token']);
     }
     if (isset($options['http'])) {
         $options['http']['ignore_errors'] = true;
     }
     $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
     if ($this->progress) {
         $this->io->writeError("    Downloading: <comment>Connecting...</comment>", false);
     }
     $errorMessage = '';
     $errorCode = 0;
     $result = false;
     set_error_handler(function ($code, $msg) use(&$errorMessage) {
         if ($errorMessage) {
             $errorMessage .= "\n";
         }
         $errorMessage .= preg_replace('{^file_get_contents\\(.*?\\): }', '', $msg);
     });
     try {
         $result = file_get_contents($fileUrl, false, $ctx);
     } catch (\Exception $e) {
         if ($e instanceof TransportException && !empty($http_response_header[0])) {
             $e->setHeaders($http_response_header);
         }
         if ($e instanceof TransportException && $result !== false) {
             $e->setResponse($result);
         }
         $result = false;
     }
     if ($errorMessage && !ini_get('allow_url_fopen')) {
         $errorMessage = 'allow_url_fopen must be enabled in php.ini (' . $errorMessage . ')';
     }
     restore_error_handler();
     if (isset($e) && !$this->retry) {
         throw $e;
     }
     if (!empty($http_response_header[0]) && preg_match('{^HTTP/\\S+ ([45]\\d\\d)}i', $http_response_header[0], $match)) {
         $errorCode = $match[1];
         if (!$this->retry) {
             $e = new TransportException('The "' . $this->fileUrl . '" file could not be downloaded (' . $http_response_header[0] . ')', $errorCode);
             $e->setHeaders($http_response_header);
             $e->setResponse($result);
             throw $e;
         }
         $result = false;
     }
     if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http') {
         $decode = false;
         foreach ($http_response_header as $header) {
             if (preg_match('{^content-encoding: *gzip *$}i', $header)) {
                 $decode = true;
                 continue;
             } elseif (preg_match('{^HTTP/}i', $header)) {
                 $decode = false;
             }
         }
         if ($decode) {
             if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
                 $result = zlib_decode($result);
             } else {
                 $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,' . base64_encode($result));
             }
             if (!$result) {
                 throw new TransportException('Failed to decode zlib stream');
             }
         }
     }
     if ($this->progress && !$this->retry) {
         $this->io->overwriteError("    Downloading: <comment>100%</comment>");
     }
     if (false !== $result && null !== $fileName) {
         if ('' === $result) {
             throw new TransportException('"' . $this->fileUrl . '" appears broken, and returned an empty 200 response');
         }
//.........这里部分代码省略.........
开发者ID:VicDeo,项目名称:poc,代码行数:101,代码来源:RemoteFilesystem.php



注:本文中的zlib_decode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP zlib_encode函数代码示例发布时间:2022-05-23
下一篇:
PHP zl_option函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap