removed pclzip
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
// downloadZip.php
|
||||
|
||||
session_start();
|
||||
require_once 'config.php';
|
||||
require_once 'lib/pclzip.lib.php';
|
||||
|
||||
// Check if the user is authenticated.
|
||||
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
|
||||
@@ -54,7 +52,6 @@ if ($baseDir === false) {
|
||||
|
||||
$folderPath = $baseDir . DIRECTORY_SEPARATOR . $relativePath;
|
||||
$folderPathReal = realpath($folderPath);
|
||||
|
||||
if ($folderPathReal === false || strpos($folderPathReal, $baseDir) !== 0) {
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
@@ -95,19 +92,24 @@ if (empty($filesToZip)) {
|
||||
}
|
||||
|
||||
// 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.
|
||||
$archive = new PclZip($tempZip);
|
||||
$v_list = $archive->create($filesToZip, PCLZIP_OPT_REMOVE_PATH, $folderPathReal);
|
||||
|
||||
if ($v_list === 0) {
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($tempZip, ZipArchive::CREATE) !== TRUE) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(["error" => "Failed to create zip archive."]);
|
||||
echo json_encode(["error" => "Could not create zip archive."]);
|
||||
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.
|
||||
header('Content-Type: application/zip');
|
||||
header('Content-Disposition: attachment; filename="files.zip"');
|
||||
|
||||
@@ -590,7 +590,7 @@ export function editFile(fileName, folder) {
|
||||
? "uploads/"
|
||||
: "uploads/" + folderUsed.split("/").map(encodeURIComponent).join("/") + "/";
|
||||
const fileUrl = folderPath + encodeURIComponent(fileName) + "?t=" + new Date().getTime();
|
||||
|
||||
|
||||
fetch(fileUrl, { method: "HEAD" })
|
||||
.then(response => {
|
||||
const contentLength = response.headers.get("Content-Length");
|
||||
@@ -625,7 +625,7 @@ export function editFile(fileName, folder) {
|
||||
`;
|
||||
document.body.appendChild(modal);
|
||||
modal.style.display = "block";
|
||||
|
||||
|
||||
// Initialize CodeMirror on the textarea.
|
||||
const editor = CodeMirror.fromTextArea(document.getElementById("fileEditor"), {
|
||||
lineNumbers: true,
|
||||
@@ -635,33 +635,33 @@ export function editFile(fileName, folder) {
|
||||
});
|
||||
// Set editor size to use most of the modal height.
|
||||
editor.setSize("100%", "60vh");
|
||||
|
||||
|
||||
// Store the CodeMirror instance globally for saving.
|
||||
window.currentEditor = editor;
|
||||
|
||||
|
||||
// Set a starting font size and apply it.
|
||||
let currentFontSize = 14; // default font size in px
|
||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||
editor.refresh();
|
||||
|
||||
|
||||
// Zoom out button: Decrease font size.
|
||||
document.getElementById("decreaseFont").addEventListener("click", function () {
|
||||
document.getElementById("decreaseFont").addEventListener("click", function() {
|
||||
currentFontSize = Math.max(8, currentFontSize - 2);
|
||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||
editor.refresh();
|
||||
});
|
||||
|
||||
|
||||
// Zoom in button: Increase font size.
|
||||
document.getElementById("increaseFont").addEventListener("click", function () {
|
||||
document.getElementById("increaseFont").addEventListener("click", function() {
|
||||
currentFontSize = Math.min(32, currentFontSize + 2);
|
||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||
editor.refresh();
|
||||
});
|
||||
|
||||
document.getElementById("saveBtn").addEventListener("click", function () {
|
||||
|
||||
document.getElementById("saveBtn").addEventListener("click", function() {
|
||||
saveFile(fileName, folderUsed);
|
||||
});
|
||||
document.getElementById("closeBtn").addEventListener("click", function () {
|
||||
document.getElementById("closeBtn").addEventListener("click", function() {
|
||||
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