{"id":135470,"date":"2026-07-31T08:24:07","date_gmt":"2026-07-31T02:24:07","guid":{"rendered":"https:\/\/rcl-radio.ru\/?p=135470"},"modified":"2026-07-31T08:31:55","modified_gmt":"2026-07-31T02:31:55","slug":"%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%b0-%d1%81-zip-%d0%b0%d1%80%d1%85%d0%b8%d0%b2%d0%b0%d0%bc%d0%b8-%d0%b2-php-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d0%bd%d0%b8%d0%b5-%d0%b8-%d1%80%d0%b0%d1%81%d0%bf","status":"publish","type":"post","link":"https:\/\/rcl-radio.ru\/?p=135470","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u0430\u043c\u0438 \u0432 PHP: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432"},"content":{"rendered":"<p>\u0412 \u0432\u0435\u0431\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 ZIP\u2011\u0430\u0440\u0445\u0438\u0432 \u0438\u043b\u0438, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0412 PHP \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code class=\"CodeInlined\">ZipArchive<\/code>\u00a0\u2014\u00a0\u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u044b \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0444\u0430\u0439\u043b\u044b, \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<hr \/>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041a\u043b\u0430\u0441\u0441 <code class=\"CodeInlined\">ZipArchive<\/code> \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <code class=\"CodeInlined\">zip<\/code>. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043e\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0432 \u0432\u0430\u0448\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 PHP. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437:<\/p>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\nvar_dump<span style=\"color: #66cc66;\">(<\/span>class_exists<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'ZipArchive'<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span>;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f <code class=\"CodeInlined\">bool(true)<\/code>\u00a0\u2014\u00a0\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 <code class=\"CodeInlined\">false<\/code>, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 <code class=\"CodeInlined\">php.ini<\/code>: \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e <code class=\"CodeInlined\">extension=zip<\/code> (\u0438\u043b\u0438 <code class=\"CodeInlined\">php_zip.dll<\/code> \u043d\u0430 Windows).<\/p>\n<hr \/>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u0430<\/h2>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b <code class=\"CodeInlined\">readme.txt<\/code> \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0430\u0440\u0445\u0438\u0432 <code class=\"CodeInlined\">archive.zip<\/code>.<\/p>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n$filename = <span style=\"color: #ff0000;\">'archive.zip'<\/span>;\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">\/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0430\u0440\u0445\u0438\u0432; \u0444\u043b\u0430\u0433 ZipArchive::CREATE \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u0440\u0445\u0438\u0432, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442<\/span>\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span>$filename, ZipArchive::CREATE<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0430\u0440\u0445\u0438\u0432<\/span>\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span>addFile<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'readme.txt'<\/span>, <span style=\"color: #ff0000;\">'readme.txt'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\necho <span style=\"color: #ff0000;\">'\u0410\u0440\u0445\u0438\u0432 \u0441\u043e\u0437\u0434\u0430\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e'<\/span>;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code class=\"CodeInlined\">addFile<\/code>\u00a0\u2014\u00a0\u044d\u0442\u043e \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0440\u0445\u0438\u0432\u0430. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, PHP \u0432\u043e\u0437\u044c\u043c\u0451\u0442 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u043a\u0430\u043a \u0438\u043c\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a<\/h3>\n<p>\u0427\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u043f\u0430\u043f\u043a\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b:<\/p>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n<span style=\"color: #000000; font-weight: bold;\">function<\/span> addFilesFromDir<span style=\"color: #66cc66;\">(<\/span>$zip, $sourceDir, $baseDir = <span style=\"color: #ff0000;\">''<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    $files = <span style=\"color: #000000; font-weight: bold;\">new<\/span> RecursiveIteratorIterator<span style=\"color: #66cc66;\">(<\/span>\r\n        <span style=\"color: #000000; font-weight: bold;\">new<\/span> RecursiveDirectoryIterator<span style=\"color: #66cc66;\">(<\/span>$sourceDir<span style=\"color: #66cc66;\">)<\/span>,\r\n        RecursiveIteratorIterator::SELF_FIRST\r\n    <span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n    <span style=\"color: #b1b100;\">foreach<\/span> <span style=\"color: #66cc66;\">(<\/span>$files as $file<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n        <span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">!<\/span>$file-<span style=\"color: #66cc66;\">&gt;<\/span>isFile<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n            <span style=\"color: #b1b100;\">continue<\/span>;\r\n        <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n        $filePath = $file-<span style=\"color: #66cc66;\">&gt;<\/span>getRealPath<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n        $relativePath = preg_replace<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'#^'<\/span> . <span style=\"color: #006600;\">preg_quote<\/span><span style=\"color: #66cc66;\">(<\/span>$sourceDir, <span style=\"color: #ff0000;\">'#'<\/span><span style=\"color: #66cc66;\">)<\/span> . <span style=\"color: #ff0000;\">'#'<\/span>, <span style=\"color: #ff0000;\">''<\/span>, $filePath<span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n        <span style=\"color: #808080; font-style: italic;\">\/\/ \u0423\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u0441\u043b\u044d\u0448, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u044b\u043b\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439<\/span>\r\n        $relativePath = ltrim<span style=\"color: #66cc66;\">(<\/span>$relativePath, DIRECTORY_SEPARATOR<span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n        <span style=\"color: #808080; font-style: italic;\">\/\/ \u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043f\u0430\u043f\u043a\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0451 \u043a \u043f\u0443\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0440\u0445\u0438\u0432\u0430<\/span>\r\n        $archivePath = $baseDir ? $baseDir . <span style=\"color: #006600;\">DIRECTORY_SEPARATOR<\/span> . $relativePath : $relativePath;\r\n\u00a0\r\n        $zip-<span style=\"color: #66cc66;\">&gt;<\/span>addFile<span style=\"color: #66cc66;\">(<\/span>$filePath, $archivePath<span style=\"color: #66cc66;\">)<\/span>;\r\n    <span style=\"color: #66cc66;\">}<\/span>\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'site-backup.zip'<\/span>, ZipArchive::CREATE<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\naddFilesFromDir<span style=\"color: #66cc66;\">(<\/span>$zip, __DIR__ . <span style=\"color: #ff0000;\">'\/public'<\/span>, <span style=\"color: #ff0000;\">'public'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\necho <span style=\"color: #ff0000;\">'\u0410\u0440\u0445\u0438\u0432 site-backup.zip \u0441\u043e\u0437\u0434\u0430\u043d'<\/span>;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043f\u043a\u0438 <code class=\"CodeInlined\">public<\/code> \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0430\u0440\u0445\u0438\u0432 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u043f\u043a\u0430 <code class=\"CodeInlined\">public\/<\/code>.<\/p>\n<h3>\u0412\u0430\u0436\u043d\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0440\u0445\u0438\u0432\u0430<\/h3>\n<ul>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/strong>: \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0443 PHP \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0433\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0430\u0440\u0445\u0438\u0432.<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong>: <code class=\"CodeInlined\">addFile()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code class=\"CodeInlined\">false<\/code> \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">!<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>addFile<span style=\"color: #66cc66;\">(<\/span>$filePath, $archivePath<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    echo <span style=\"color: #ff0000;\">'\u041e\u0448\u0438\u0431\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430: '<\/span> . $filePath . <span style=\"color: #006600;\">PHP_EOL<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u043c\u0451\u043d \u0444\u0430\u0439\u043b\u043e\u0432<\/strong>: \u0432 ZIP \u0438\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430\u0445. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 UTF\u20118 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043d\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u0435\u0439. \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u0441 \u0438\u0441\u043a\u0430\u0436\u0451\u043d\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 <code class=\"CodeInlined\">zip<\/code> \u0447\u0435\u0440\u0435\u0437 <code class=\"CodeInlined\">exec<\/code>).<\/li>\n<\/ul>\n<hr \/>\n<h2>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code class=\"CodeInlined\">extractTo<\/code>.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0451 \u0432 \u043f\u0430\u043f\u043a\u0443<\/h3>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n$filename = <span style=\"color: #ff0000;\">'archive.zip'<\/span>;\r\n$destination = __DIR__ . <span style=\"color: #ff0000;\">'\/extracted'<\/span>;\r\n\u00a0\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">!<\/span>is_dir<span style=\"color: #66cc66;\">(<\/span>$destination<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    mkdir<span style=\"color: #66cc66;\">(<\/span>$destination, 0755, <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span>$filename<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0430\u0440\u0445\u0438\u0432'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>extractTo<span style=\"color: #66cc66;\">(<\/span>$destination<span style=\"color: #66cc66;\">)<\/span> === <span style=\"color: #000000; font-weight: bold;\">false<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0435'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\necho <span style=\"color: #ff0000;\">'\u0424\u0430\u0439\u043b\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u044b \u0432 '<\/span> . $destination;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h3>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/h3>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043d\u0443\u0436\u043d\u044b\u0435:<\/p>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'archive.zip'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0430\u0440\u0445\u0438\u0432'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n$destination = __DIR__ . <span style=\"color: #ff0000;\">'\/partial-extract'<\/span>;\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">!<\/span>is_dir<span style=\"color: #66cc66;\">(<\/span>$destination<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    mkdir<span style=\"color: #66cc66;\">(<\/span>$destination, 0755, <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #66cc66;\">(<\/span>$i = <span style=\"color: #cc66cc;\">0<\/span>; $i <span style=\"color: #66cc66;\">&lt;<\/span> $zip-<span style=\"color: #66cc66;\">&gt;<\/span>numFiles; $i++<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    $name = $zip-<span style=\"color: #66cc66;\">&gt;<\/span>getNameIndex<span style=\"color: #66cc66;\">(<\/span>$i<span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n    <span style=\"color: #808080; font-style: italic;\">\/\/ \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c .txt<\/span>\r\n    <span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>pathinfo<span style=\"color: #66cc66;\">(<\/span>$name, PATHINFO_EXTENSION<span style=\"color: #66cc66;\">)<\/span> === <span style=\"color: #ff0000;\">'txt'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n        $zip-<span style=\"color: #66cc66;\">&gt;<\/span>extractTo<span style=\"color: #66cc66;\">(<\/span>$destination, $name<span style=\"color: #66cc66;\">)<\/span>;\r\n    <span style=\"color: #66cc66;\">}<\/span>\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p><code class=\"CodeInlined\">numFiles<\/code>\u00a0\u2014\u00a0\u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435, <code class=\"CodeInlined\">getNameIndex<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443.<\/p>\n<hr \/>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 \u0431\u0435\u0437 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438<\/h2>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0430\u0440\u0445\u0438\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'archive.zip'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0430\u0440\u0445\u0438\u0432'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\necho <span style=\"color: #ff0000;\">'&lt;ul&gt;'<\/span>;\r\n<span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #66cc66;\">(<\/span>$i = <span style=\"color: #cc66cc;\">0<\/span>; $i <span style=\"color: #66cc66;\">&lt;<\/span> $zip-<span style=\"color: #66cc66;\">&gt;<\/span>numFiles; $i++<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    $stats = $zip-<span style=\"color: #66cc66;\">&gt;<\/span>statIndex<span style=\"color: #66cc66;\">(<\/span>$i<span style=\"color: #66cc66;\">)<\/span>;\r\n    echo <span style=\"color: #ff0000;\">'&lt;li&gt;'<\/span> . <span style=\"color: #006600;\">htmlspecialchars<\/span><span style=\"color: #66cc66;\">(<\/span>$stats<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'name'<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span> . <span style=\"color: #ff0000;\">' ('<\/span> . $stats<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'size'<\/span><span style=\"color: #66cc66;\">]<\/span> . <span style=\"color: #ff0000;\">' \u0431\u0430\u0439\u0442)&lt;\/li&gt;'<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\necho <span style=\"color: #ff0000;\">'&lt;\/ul&gt;'<\/span>;\r\n\u00a0\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0422\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043d\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0430 \u0434\u0438\u0441\u043a.<\/p>\n<hr \/>\n<h2>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/h2>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u0440\u0445\u0438\u0432\u0430\u043c\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0432\u0430\u0436\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043c\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041d\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u043e\u0432\u0435\u0440\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/strong>. \u041b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443.<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0443\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u0440\u0445\u0438\u0432\u0430<\/strong>. \u0412 ZIP \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u0432\u0440\u043e\u0434\u0435 <code class=\"CodeInlined\">..\/..\/etc\/passwd<\/code>. \u041f\u0440\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u043e\u0439:\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>strpos<span style=\"color: #66cc66;\">(<\/span>$name, <span style=\"color: #ff0000;\">'..'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">false<\/span> <span style=\"color: #66cc66;\">||<\/span> strpos<span style=\"color: #66cc66;\">(<\/span>$name, <span style=\"color: #ff0000;\">':'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">false<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    <span style=\"color: #808080; font-style: italic;\">\/\/ \u041f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043f\u0443\u0442\u0438<\/span>\r\n    <span style=\"color: #b1b100;\">continue<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432<\/strong>. \u0415\u0441\u043b\u0438 \u0430\u0440\u0445\u0438\u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043b\u0438\u043c\u0438\u0442\u044b \u043d\u0430 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u0430<\/strong>. <code class=\"CodeInlined\">ZipArchive::checkZipConsistency<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0430\u0440\u0445\u0438\u0432 \u043d\u0430 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f (\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0431\u043e\u0440\u043a\u0430\u0445 PHP).<\/li>\n<\/ul>\n<hr \/>\n<h2>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b<\/h2>\n<ul>\n<li data-value=\"\" data-shift=\"0\"><strong>\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/strong>: \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d <code class=\"CodeInlined\">zip<\/code> \u0438 <code class=\"CodeInlined\">unzip<\/code>. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <code class=\"CodeInlined\">exec()<\/code> \u0438\u043b\u0438 <code class=\"CodeInlined\">shell_exec()<\/code>. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0430\u0440\u0445\u0438\u0432\u043e\u0432 \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e.<\/li>\n<li data-value=\"\" data-shift=\"0\"><strong>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432<\/strong>: \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 ZIP (\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b), \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0437\u0430\u0434\u0430\u0447 <code class=\"CodeInlined\">ZipArchive<\/code> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/li>\n<\/ul>\n<hr \/>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440: \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u0430\u0440\u0445\u0438\u0432\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 ZIP \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u0435\u0439. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li data-value=\"1.\" data-shift=\"1\">\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e ZIP.<\/li>\n<li data-value=\"2.\" data-shift=\"1\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435.<\/li>\n<li data-value=\"3.\" data-shift=\"1\">\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443.<\/li>\n<\/ol>\n<div class=\"CodeBlock CodeBlock_overflow_visible CodeBlock_highlight\">\n<div class=\"CodeBlock-StickyWrapper\">\n<div class=\"CodeBlock-Header\">\n<div class=\"CodeBlock-HeaderTitle\">php<\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 14px;\"><span style=\"color: #66cc66;\">&lt;<\/span>?php\r\n$uploadFile = $_FILES<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'archive'<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'tmp_name'<\/span><span style=\"color: #66cc66;\">]<\/span>;\r\n$destination = __DIR__ . <span style=\"color: #ff0000;\">'\/user-uploads\/'<\/span> . <span style=\"color: #006600;\">uniqid<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'upload_'<\/span>, <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\nmkdir<span style=\"color: #66cc66;\">(<\/span>$destination, 0755, <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n$zip = <span style=\"color: #000000; font-weight: bold;\">new<\/span> ZipArchive<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>$zip-<span style=\"color: #66cc66;\">&gt;<\/span>open<span style=\"color: #66cc66;\">(<\/span>$uploadFile<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">true<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    die<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">'\u0424\u0430\u0439\u043b \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u043e\u043c'<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #66cc66;\">(<\/span>$i = <span style=\"color: #cc66cc;\">0<\/span>; $i <span style=\"color: #66cc66;\">&lt;<\/span> $zip-<span style=\"color: #66cc66;\">&gt;<\/span>numFiles; $i++<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n    $stats = $zip-<span style=\"color: #66cc66;\">&gt;<\/span>statIndex<span style=\"color: #66cc66;\">(<\/span>$i<span style=\"color: #66cc66;\">)<\/span>;\r\n    $name = $stats<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'name'<\/span><span style=\"color: #66cc66;\">]<\/span>;\r\n\u00a0\r\n    <span style=\"color: #808080; font-style: italic;\">\/\/ \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u0443\u0442\u0435\u0439 \u0441 \"..\"<\/span>\r\n    <span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span>strpos<span style=\"color: #66cc66;\">(<\/span>$name, <span style=\"color: #ff0000;\">'..'<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">!<\/span>== <span style=\"color: #000000; font-weight: bold;\">false<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n        <span style=\"color: #b1b100;\">continue<\/span>;\r\n    <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n    $ext = strtolower<span style=\"color: #66cc66;\">(<\/span>pathinfo<span style=\"color: #66cc66;\">(<\/span>$name, PATHINFO_EXTENSION<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n    <span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">!<\/span>in_array<span style=\"color: #66cc66;\">(<\/span>$ext, <span style=\"color: #66cc66;\">[<\/span><span style=\"color: #ff0000;\">'txt'<\/span>, <span style=\"color: #ff0000;\">'md'<\/span>, <span style=\"color: #ff0000;\">'html'<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n        <span style=\"color: #808080; font-style: italic;\">\/\/ \u041f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b<\/span>\r\n        <span style=\"color: #b1b100;\">continue<\/span>;\r\n    <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n    $zip-<span style=\"color: #66cc66;\">&gt;<\/span>extractTo<span style=\"color: #66cc66;\">(<\/span>$destination, $name<span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n$zip-<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #0066cc;\">close<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\necho <span style=\"color: #ff0000;\">'\u0424\u0430\u0439\u043b\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 '<\/span> . $destination;\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0432\u0435\u0431\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 ZIP\u2011\u0430\u0440\u0445\u0438\u0432 \u0438\u043b\u0438, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0412 PHP \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 ZipArchive\u00a0\u2014\u00a0\u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432. \u041d\u0438\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c ZIP\u2011\u0430\u0440\u0445\u0438\u0432\u044b \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0444\u0430\u0439\u043b\u044b, \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u041a\u043b\u0430\u0441\u0441 ZipArchive \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 zip. [&hellip;]<\/p>\n","protected":false},"author":9194254,"featured_media":135473,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[],"class_list":["post-135470","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"views":9,"_links":{"self":[{"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/135470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/users\/9194254"}],"replies":[{"embeddable":true,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=135470"}],"version-history":[{"count":1,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/135470\/revisions"}],"predecessor-version":[{"id":135472,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/135470\/revisions\/135472"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/media\/135473"}],"wp:attachment":[{"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}