removed pclzip
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
// downloadZip.php
|
session_start();
|
||||||
|
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
require_once 'lib/pclzip.lib.php';
|
|
||||||
|
|
||||||
// Check if the user is authenticated.
|
// Check if the user is authenticated.
|
||||||
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
|
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
|
||||||
@@ -54,7 +52,6 @@ if ($baseDir === false) {
|
|||||||
|
|
||||||
$folderPath = $baseDir . DIRECTORY_SEPARATOR . $relativePath;
|
$folderPath = $baseDir . DIRECTORY_SEPARATOR . $relativePath;
|
||||||
$folderPathReal = realpath($folderPath);
|
$folderPathReal = realpath($folderPath);
|
||||||
|
|
||||||
if ($folderPathReal === false || strpos($folderPathReal, $baseDir) !== 0) {
|
if ($folderPathReal === false || strpos($folderPathReal, $baseDir) !== 0) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
@@ -95,19 +92,24 @@ if (empty($filesToZip)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a temporary file for the ZIP archive.
|
// Create a temporary file for the ZIP archive.
|
||||||
$tempZip = tempnam(sys_get_temp_dir(), 'zip') . '.zip';
|
$tempZip = tempnam(sys_get_temp_dir(), 'zip');
|
||||||
|
unlink($tempZip); // Remove the temporary file so ZipArchive can create a new one.
|
||||||
|
$tempZip .= '.zip';
|
||||||
|
|
||||||
// Create the archive using PclZip.
|
$zip = new ZipArchive();
|
||||||
$archive = new PclZip($tempZip);
|
if ($zip->open($tempZip, ZipArchive::CREATE) !== TRUE) {
|
||||||
$v_list = $archive->create($filesToZip, PCLZIP_OPT_REMOVE_PATH, $folderPathReal);
|
|
||||||
|
|
||||||
if ($v_list === 0) {
|
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(["error" => "Failed to create zip archive."]);
|
echo json_encode(["error" => "Could not create zip archive."]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add each file to the archive using its base name.
|
||||||
|
foreach ($filesToZip as $filePath) {
|
||||||
|
$zip->addFile($filePath, basename($filePath));
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
// Serve the ZIP file.
|
// Serve the ZIP file.
|
||||||
header('Content-Type: application/zip');
|
header('Content-Type: application/zip');
|
||||||
header('Content-Disposition: attachment; filename="files.zip"');
|
header('Content-Disposition: attachment; filename="files.zip"');
|
||||||
|
|||||||
@@ -645,23 +645,23 @@ export function editFile(fileName, folder) {
|
|||||||
editor.refresh();
|
editor.refresh();
|
||||||
|
|
||||||
// Zoom out button: Decrease font size.
|
// Zoom out button: Decrease font size.
|
||||||
document.getElementById("decreaseFont").addEventListener("click", function () {
|
document.getElementById("decreaseFont").addEventListener("click", function() {
|
||||||
currentFontSize = Math.max(8, currentFontSize - 2);
|
currentFontSize = Math.max(8, currentFontSize - 2);
|
||||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||||
editor.refresh();
|
editor.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Zoom in button: Increase font size.
|
// Zoom in button: Increase font size.
|
||||||
document.getElementById("increaseFont").addEventListener("click", function () {
|
document.getElementById("increaseFont").addEventListener("click", function() {
|
||||||
currentFontSize = Math.min(32, currentFontSize + 2);
|
currentFontSize = Math.min(32, currentFontSize + 2);
|
||||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||||
editor.refresh();
|
editor.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("saveBtn").addEventListener("click", function () {
|
document.getElementById("saveBtn").addEventListener("click", function() {
|
||||||
saveFile(fileName, folderUsed);
|
saveFile(fileName, folderUsed);
|
||||||
});
|
});
|
||||||
document.getElementById("closeBtn").addEventListener("click", function () {
|
document.getElementById("closeBtn").addEventListener("click", function() {
|
||||||
modal.remove();
|
modal.remove();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
5421
lib/pclzip.lib.php
5421
lib/pclzip.lib.php
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user