{"id":297576,"date":"2020-01-23T15:00:57","date_gmt":"2020-01-23T15:00:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297576"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297576","title":{"rendered":"\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0430\u0441\u0442\u044c 3 \u2014 \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/484520\/\"><i>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/472966\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0430\u0441\u0442\u044c 2 \u2014 Data Descriptor \u0438 \u0441\u0436\u0430\u0442\u0438\u0435<\/a>.<\/i><\/p>\n<p>  \u0414\u043e\u0440\u043e\u0433\u0438\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438, \u044f \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0430\u0441 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u041d\u0435\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 PHP. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438 \u043e zip-\u0430\u0440\u0445\u0438\u0432\u0430\u0445: <a href=\"https:\/\/habr.com\/ru\/post\/471066\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/472966\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0430\u0441\u0442\u044c 2 \u2014 Data Descriptor \u0438 \u0441\u0436\u0430\u0442\u0438\u0435<\/a><\/p>\n<p>  \u0420\u0430\u043d\u0435\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u043a\u043e\u0434 \u043d\u0430 PHP \u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.zip.php\">zip<\/a>), \u0430 \u0442\u0430\u043a \u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0430 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043d\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u044f \u0438 \u043d\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0432, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043b\u0438\u0448\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0439, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432\u0437\u044f\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 (\u043d\u0443 \u043b\u0430\u0434\u043d\u043e, \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0435\u0449\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u043b, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435).<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043f\u0435\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0447\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0430\u0440\u0445\u0438\u0432. \u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0432 STDIN \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0432 json, \u0432 STDOUT \u043e\u0442\u0434\u0430\u0435\u0442 \u0441\u0430\u043c \u0430\u0440\u0445\u0438\u0432, \u0430 \u0432 STDERR json \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0432\u0435\u0440\u043a\u0438\u043b\u043b \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 native PHP, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u2014 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e).<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442, \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u043c\u0438, \u044f \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">zip.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php  $buffer = ''; while (!feof(STDIN)) {     $buffer .= fread(STDIN, 4096); }  $photos = json_decode($buffer, true, 512, JSON_THROW_ON_ERROR);  $skeleton = ['files' =&gt; []]; $written = 0;      [$written, $skeleton] = writeZip($written, $skeleton, $photos);  $CDFH_Offset = $written;  foreach ($skeleton['files'] as $index =&gt; $info) {     $written += fwrite(STDOUT, $info['CDFH']);     $skeleton['files'][$index]['CDFH'] = base64_encode($info['CDFH']); }  $skeleton['EOCD'] = pack('LSSSSLLS', 0x06054b50, 0, 0, $records = count($skeleton['files']), $records, $written - $CDFH_Offset, $CDFH_Offset, 0);  $written += fwrite(STDOUT, $skeleton['EOCD']); $skeleton['EOCD'] = base64_encode($skeleton['EOCD']);  fwrite(STDERR, json_encode($skeleton));  function writeZip($written, $skeleton, $files) {         $c = curl_init();          curl_setopt_array($c, [         CURLOPT_RETURNTRANSFER =&gt; 1,         CURLOPT_TIMEOUT        =&gt; 50,         CURLOPT_FOLLOWLOCATION =&gt; true,     ]);      foreach ($files as $index =&gt; $url) {         $fileName = $index . '.jpg';                  for ($i = 0; $i &lt; 1; $i++ ) {             try {                             curl_setopt($c, CURLOPT_URL, $url);                                  [$content, $code, $contentLength] = [                     curl_exec($c),                      (int) curl_getinfo($c, CURLINFO_HTTP_CODE),                      (int) curl_getinfo($c, CURLINFO_CONTENT_LENGTH_DOWNLOAD)                 ];                                  if ($code !== 200) {                     throw new \\Exception(&quot;[{$index}] &quot; . 'Photo download error (' . $code . '): ' . curl_error($c));                 }                                      if (strlen($content) !== $contentLength) {                     var_dump(strlen($content), $contentLength);                     throw new \\Exception(&quot;[{$index}] &quot; . 'Different content-length');                 }                                  if ((false === $imageSize = @getimagesizefromstring($content)) || $imageSize[0] &lt; 1 || $imageSize[1] &lt; 1) {                     throw new \\Exception(&quot;[{$index}] &quot; . 'Broken image');                 }                             [$width, $height] = $imageSize;                 $t = null;                 break;             } catch (\\Throwable $t) {}         }                  if ($t !== null) {             throw new \\Exception('Error: ' . $index . ' &gt; ' . $url, 0, $t);         }                  $fileInfo = [             'versionToExtract'      =&gt; 10,             'generalPurposeBitFlag' =&gt; 0,             'compressionMethod'     =&gt; 0,             'modificationTime'      =&gt; 28021,             'modificationDate'      =&gt; 20072,             'crc32'                 =&gt; hexdec(hash('crc32b', $content)),             'compressedSize'        =&gt; $size = strlen($content),             'uncompressedSize'      =&gt; $size,             'filenameLength'        =&gt; strlen($fileName),             'extraFieldLength'      =&gt; 0,         ];                  $LFH_Offset = $written;                  $skeleton['files'][$index] = [             'LFH'  =&gt; pack('LSSSSSLLLSSa*', 0x04034b50, ...array_values($fileInfo + ['filename' =&gt; $fileName])),             'CDFH' =&gt; pack('LSSSSSSLLLSSSSSLLa*', 0x02014b50, 798, ...array_values($fileInfo + [                 'fileCommentLength' =&gt; 0,                 'diskNumber' =&gt; 0,                 'internalFileAttributes' =&gt; 0,                 'externalFileAttributes' =&gt; 2176057344,                 'localFileHeaderOffset' =&gt; $LFH_Offset,                 'filename' =&gt; $fileName,             ])),             'width' =&gt; $width,             'height' =&gt; $height,         ];                  $written += fwrite(STDOUT, $skeleton['files'][$index]['LFH']);         $written += fwrite(STDOUT, $content);         $skeleton['files'][$index]['LFH'] = base64_encode($skeleton['files'][$index]['LFH']);     }          curl_close($c);          return [$written, $skeleton]; }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c, \u043d\u0430\u0437\u043e\u0432\u0435\u043c zip.php \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a, \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 ~18\u043c\u0431, \u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0440\u0445\u0438\u0432\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u043b 20\u043c\u0431 (\u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0437\u0430\u0447\u0435\u043c) \u2014 <a href=\"https:\/\/gist.githubusercontent.com\/userqq\/d0ca3aba6b6762c9ce5bc3ace92a9f9e\/raw\/70f446eb98f1ba6838ad3c19c3346cba371fd263\/photos.json\">https:\/\/gist.githubusercontent.com\/userqq\/d0ca3aba6b6762c9ce5bc3ace92a9f9e\/raw\/70f446eb98f1ba6838ad3c19c3346cba371fd263\/photos.json<\/a><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ curl -s \\     https:\/\/gist.githubusercontent.com\/userqq\/d0ca3aba6b6762c9ce5bc3ace92a9f9e\/raw\/70f446eb98f1ba6838ad3c19c3346cba371fd263\/photos.json \\     | php zip.php \\     2&gt; structure.json \\     1&gt; photos.zip<\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u2014 <i>photos.zip<\/i>, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ unzip -tq photos.zip<\/code><\/pre>\n<p>  \u0438 <i>structure.json<\/i>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c json c base64 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0430\u0440\u0445\u0438\u0432\u0435, \u043a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b LFH \u0438 CDFH, \u0430 \u0442\u0430\u043a \u0436\u0435 EOCD. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f EOCD \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0430\u0440\u0445\u0438\u0432\u0430 \u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443, \u0430 \u0432\u043e\u0442 \u0432 CDFH \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f LFH \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0434\u043b\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u0437\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0443 LFH \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u043d\u0430\u0442\u044c \u0441 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043d\u0430\u0447\u043d\u0443\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0433\u0434\u0435 \u043e\u043d\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043b\u0438\u0442\u044c \u043d\u0430\u0448 \u0444\u0430\u0439\u043b \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u043b\u0438\u043c\u0438\u0442 20\u043c\u0431.<\/p>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0431\u043e\u0442\u0430 \u0443 @BotFather, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u0442\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u043d\u0435\u0442, \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0435\u043c\u0443 \u0431\u043e\u0442\u0443 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0438\u0449\u0435\u043c \u0441\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 <a href=\"https:\/\/api.telegram.org\/bot%7B%7BTOKEN%7D%7D\/getUpdates\">https:\/\/api.telegram.org\/bot{{TOKEN}}\/getUpdates<\/a>, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u044b\u0447\u043b\u0435\u043d\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e message.from.id = \u044d\u0442\u043e id \u0432\u0430\u0448\u0435\u0433\u043e \u0441 \u0431\u043e\u0442\u043e\u043c \u0447\u0430\u0442\u0430.<\/p>\n<p>  \u0417\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u0441 \u0432\u0430\u043c\u0438 \u0430\u0440\u0445\u0438\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435:<\/p>\n<pre><code class=\"bash\">$ curl -F document=@&quot;photos.zip&quot; &quot;https:\/\/api.telegram.org\/bot{{TOKEN}}\/sendDocument?chat_id={{CHAT ID}}&quot; &gt; stored.json<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0430\u0436 \u0434\u0432\u0430 json \u0444\u0430\u0439\u043b\u0430 \u2014 <i>structure.json<\/i> \u0438 <i>stored.json<\/i>.<\/p>\n<p>  \u0418 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u043e \u0444\u0430\u0439\u043b stored.json \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c json \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 ok, \u0440\u0430\u0432\u043d\u044b\u043c true, \u0430 \u0435\u0449\u0435 result.document.file_id, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0442\u043e \u0438 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<h3>\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e, \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0434\u0435\u043b\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php  define('TOKEN', ''); \/\/ \u0442\u043e\u043a\u0435\u043d \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430  $structure = json_decode(file_get_contents('structure.json'), true, 512, JSON_THROW_ON_ERROR); $stored = json_decode(file_get_contents('stored.json'), true, 512, JSON_THROW_ON_ERROR);  $selectedFile = $structure['files'][array_rand($structure['files'])]; $LFH = base64_decode($selectedFile['LFH']); $CDFH = base64_decode($selectedFile['CDFH']);  $fileLength = unpack('Llen', substr($CDFH, 24, 4))['len']; $fileStart = unpack('Lpos', substr($CDFH, 42, 4))['pos'] + strlen($LFH); $fileEnd = $fileStart + $fileLength;  $response = json_decode(file_get_contents('https:\/\/api.telegram.org\/bot' . TOKEN  . '\/getFile?' . http_build_query([     'file_id' =&gt; $stored['result']['document']['file_id'] ])), true, 512, JSON_THROW_ON_ERROR);  header('Content-Type: image\/jpeg'); readfile('https:\/\/api.telegram.org\/file\/bot' . TOKEN . '\/' . $response['result']['file_path'], false, stream_context_create([     'http' =&gt; ['header'  =&gt; &quot;Range: bytes={$fileStart}-{$fileEnd}&quot;] ])); <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0443 \u043d\u0430\u0441 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043d\u0430\u0447\u0430\u043b\u0430 LFH, \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043d\u0435\u0439 \u0434\u043b\u0438\u043d\u0443 LFH \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u0431\u0430\u0432\u0438\u0432 \u043a \u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u043d\u0443 \u0444\u0430\u0439\u043b\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043a\u043e\u043d\u0446\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 (\u044d\u0442\u043e \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432\u0437\u044f\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043e\u043c) \u0438 \u0442\u043e\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c <code>Range: bytes=&lt;\u043d\u0430\u0447\u0430\u043b\u043e-\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430&gt;-&lt;\u043a\u043e\u043d\u0435\u0446-\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430&gt;<\/code><\/p>\n<p>  (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Range \u0437\u0430\u043f\u0440\u043e\u0441\u044b)<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<h3>\u041d\u0435, \u043d\u0443 \u044d\u0442\u043e \u043d\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e&#8230;<\/h3>\n<p>  \u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043a <i>getFile<\/i> \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u0435\u0434\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043f\u0440\u043e\u0436\u0438\u0432\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0447\u0430\u0441. \u0418 \u0432\u043e\u043e\u0431\u0449\u0435 \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0430 amphp. \u0412\u0435\u0434\u044c \u0440\u0430\u0437\u0434\u0430\u044e\u0442 \u0436\u0435 \u043b\u044e\u0434\u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0432 production \u043d\u0430 node.js, \u0430 \u0447\u0442\u043e \u043d\u0430\u043c \u043c\u0435\u0448\u0430\u0435\u0442 (\u043d\u0443 \u043a\u0440\u043e\u043c\u0435 \u0437\u0434\u0440\u0430\u0432\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430, \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439)? \u0423 \u043d\u0430\u0441 \u0442\u0443\u0442 \u0442\u043e\u0436\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0437\u043d\u0430\u0435\u0442\u0435 \u043b\u0438.<\/p>\n<p>  \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f 3 \u043f\u0430\u043a\u0435\u0442\u0430:<\/p>\n<ul>\n<li><b>amphp\/http-server<\/b> \u2014 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b<\/li>\n<li><b>amphp\/artax<\/b> \u2014 http-\u043a\u043b\u0438\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u044f\u043c\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0430\u0439\u043b \u0432 \u043a\u0435\u0448\u0435. <\/li>\n<li><b>amphp\/parallel<\/b> \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e. \u041d\u043e \u043d\u0435 \u0431\u043e\u0439\u0442\u0435\u0441\u044c, \u043d\u0430\u043c \u0438\u0437 \u043d\u0435\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e SharedMemoryParcel, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 im-memory \u043a\u0435\u0448\u0430.<\/li>\n<\/ul>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"bash\">$ composer require amphp\/http-server amphp\/artax amphp\/parallel<\/code><\/pre>\n<p>  \u0418 \u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043f\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\"> &lt;?php  define('TOKEN', ''); \/\/ \u0442\u043e\u043a\u0435\u043d \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430  use Amp\\Artax\\DefaultClient; use Amp\\Artax\\Request as ArtaxRequest; use Amp\\Http\\Server\\RequestHandler\\CallableRequestHandler; use Amp\\Http\\Server\\Server as HttpServer; use Amp\\Http\\Server\\Request; use Amp\\Http\\Server\\Response; use Amp\\Http\\Status; use Amp\\Parallel\\Sync\\SharedMemoryParcel; use Amp\\Socket; use Psr\\Log\\NullLogger;  require 'vendor\/autoload.php';  Amp\\Loop::run(function () {     $structure = json_decode(file_get_contents('structure.json'), true, 512, JSON_THROW_ON_ERROR);     $stored = json_decode(file_get_contents('stored.json'), true, 512, JSON_THROW_ON_ERROR);          $parcel = SharedMemoryParcel::create($id = bin2hex(random_bytes(10)), []);     $client = new DefaultClient();          $handler = function (Request $request) use ($parcel, $client, $structure, $stored) {         $cached = yield $parcel-&gt;synchronized(function (array $value) use ($client, $stored) {             if (!isset($value['file_path']) || $value['expires'] &lt;= time()) {                 $response = yield $client-&gt;request('https:\/\/api.telegram.org\/bot' . TOKEN  . '\/getFile?' . http_build_query([                     'file_id' =&gt; $stored['result']['document']['file_id']                 ]));                 $json = json_decode(yield $response-&gt;getBody(), true, 512, JSON_THROW_ON_ERROR);                                  $value = ['file_path' =&gt; $json['result']['file_path'], 'expires' =&gt; time() + 55 * 60];             }                          return $value;         });                  $selectedFile = $structure['files'][array_rand($structure['files'])];         $LFH = base64_decode($selectedFile['LFH']);         $CDFH = base64_decode($selectedFile['CDFH']);          $fileLength = unpack('Llen', substr($CDFH, 24, 4))['len'];         $fileStart = unpack('Lpos', substr($CDFH, 42, 4))['pos'] + strlen($LFH);         $fileEnd = $fileStart + $fileLength;                  $request = (new ArtaxRequest('https:\/\/api.telegram.org\/file\/bot' . TOKEN . '\/' . $cached['file_path']))             -&gt;withHeader('Range', &quot;bytes={$fileStart}-{$fileEnd}&quot;);         $response = yield $client-&gt;request($request);                  if (!in_array($response-&gt;getStatus(), [200, 206])) {             return new Response(Status::SERVICE_UNAVAILABLE, ['content-type' =&gt; 'text\/plain'], &quot;Service Unavailable.&quot;);         }                  return new Response(Status::OK, ['content-type' =&gt; 'image\/jpeg'], $response-&gt;getBody());     };          $server = new HttpServer([Socket\\listen(&quot;0.0.0.0:10051&quot;)], new CallableRequestHandler($handler), new NullLogger);     yield $server-&gt;start();      Amp\\Loop::onSignal(SIGINT, function (string $watcherId) use ($server) {         Amp\\Loop::cancel($watcherId);         yield $server-&gt;stop();     }); }); <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435: \u0443 \u043d\u0430\u0441 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u0442\u044c \u043a\u0435\u0448, \u0433\u0434\u0435 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043d\u0430 55 \u043c\u0438\u043d\u0443\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u0436\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043f\u043e\u0434\u0440\u044f\u0434, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0435\u0448\u0430. \u041d\u0443 \u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u044f\u0432\u043d\u043e \u043b\u0435\u0433\u0447\u0435 \u0447\u0435\u043c readfile \u0441 PHP-FPM (\u0438\u043b\u0438, \u043d\u0435 \u0434\u0430\u0439 \u0431\u043e\u0433, PHP-CGI).<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043f\u0443\u043b \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 amphp \u2014 SharedMemoryParcel \u0441\u0432\u043e\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448 \u043a\u0435\u0448 \u0431\u0443\u0434\u0435\u0442 \u0448\u0430\u0440\u0438\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438\/\u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u041d\u0443 \u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u0441\u0435 \u0436\u0435 \u0435\u0441\u0442\u044c \u0437\u0434\u043e\u0440\u043e\u0432\u044b\u0435 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0442\u043e <a href=\"https:\/\/habr.com\/ru\/post\/460685\/\">proxy_pass \u0438 nginx<\/a>.<\/p>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0438\u0434\u0435\u044f \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043d\u043e\u0432\u0430 \u0438 \u0435\u0449\u0435 \u0432 \u0431\u043e\u0440\u043e\u0434\u0430\u0442\u044b\u0435 \u0433\u043e\u0434\u044b DownloadMaster \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0437 Zip-\u0430\u0440\u0445\u0438\u0432\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043d\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u044f \u0432\u0435\u0441\u044c \u0430\u0440\u0445\u0438\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043f\u0430\u0440\u0443-\u0442\u0440\u043e\u0439\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0427\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u043b\u0435\u0442\u0443, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <\/p>\n<p>  \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f? \u0412 \u0446\u0435\u043b\u044f\u0445 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u0438\u043d\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u0411\u0414 \u2014 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0430\u0440\u0445\u0438\u0432\u0430\u0445, \u0437\u043d\u0430\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0437\u044f\u0442\u044b\u0439 \u0444\u0430\u0439\u043b. <\/p>\n<p>  \u0418\u043b\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e. \u0412 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0435, \u043f\u043e 20\u043c\u0431, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0440\u0430\u0437\u0433\u0443\u043b\u044f\u0435\u0448\u044c\u0441\u044f, \u043d\u043e \u043a\u0430\u043a \u0437\u043d\u0430\u0442\u044c, \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/484520\/\"> https:\/\/habr.com\/ru\/post\/484520\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/484520\/\"><i>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/472966\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0430\u0441\u0442\u044c 2 \u2014 Data Descriptor \u0438 \u0441\u0436\u0430\u0442\u0438\u0435<\/a>.<\/i><\/p>\n<p>  \u0414\u043e\u0440\u043e\u0433\u0438\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438, \u044f \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0430\u0441 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u041d\u0435\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 PHP. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438 \u043e zip-\u0430\u0440\u0445\u0438\u0432\u0430\u0445: <a href=\"https:\/\/habr.com\/ru\/post\/471066\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/472966\/\">\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 zip-\u0430\u0440\u0445\u0438\u0432 \u0438 \u0447\u0442\u043e \u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0427\u0430\u0441\u0442\u044c 2 \u2014 Data Descriptor \u0438 \u0441\u0436\u0430\u0442\u0438\u0435<\/a><\/p>\n<p>  \u0420\u0430\u043d\u0435\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u043a\u043e\u0434 \u043d\u0430 PHP \u0438 \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 <a href=\"https:\/\/www.php.net\/manual\/ru\/book.zip.php\">zip<\/a>), \u0430 \u0442\u0430\u043a \u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0430 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043d\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u044f \u0438 \u043d\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0432, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043b\u0438\u0448\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u0439, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432\u0437\u044f\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 (\u043d\u0443 \u043b\u0430\u0434\u043d\u043e, \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0435\u0449\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u043b, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297576","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297576"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297576\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}