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"');
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ export function editFile(fileName, folder) {
|
|||||||
? "uploads/"
|
? "uploads/"
|
||||||
: "uploads/" + folderUsed.split("/").map(encodeURIComponent).join("/") + "/";
|
: "uploads/" + folderUsed.split("/").map(encodeURIComponent).join("/") + "/";
|
||||||
const fileUrl = folderPath + encodeURIComponent(fileName) + "?t=" + new Date().getTime();
|
const fileUrl = folderPath + encodeURIComponent(fileName) + "?t=" + new Date().getTime();
|
||||||
|
|
||||||
fetch(fileUrl, { method: "HEAD" })
|
fetch(fileUrl, { method: "HEAD" })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const contentLength = response.headers.get("Content-Length");
|
const contentLength = response.headers.get("Content-Length");
|
||||||
@@ -625,7 +625,7 @@ export function editFile(fileName, folder) {
|
|||||||
`;
|
`;
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
|
|
||||||
// Initialize CodeMirror on the textarea.
|
// Initialize CodeMirror on the textarea.
|
||||||
const editor = CodeMirror.fromTextArea(document.getElementById("fileEditor"), {
|
const editor = CodeMirror.fromTextArea(document.getElementById("fileEditor"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
@@ -635,33 +635,33 @@ export function editFile(fileName, folder) {
|
|||||||
});
|
});
|
||||||
// Set editor size to use most of the modal height.
|
// Set editor size to use most of the modal height.
|
||||||
editor.setSize("100%", "60vh");
|
editor.setSize("100%", "60vh");
|
||||||
|
|
||||||
// Store the CodeMirror instance globally for saving.
|
// Store the CodeMirror instance globally for saving.
|
||||||
window.currentEditor = editor;
|
window.currentEditor = editor;
|
||||||
|
|
||||||
// Set a starting font size and apply it.
|
// Set a starting font size and apply it.
|
||||||
let currentFontSize = 14; // default font size in px
|
let currentFontSize = 14; // default font size in px
|
||||||
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
editor.getWrapperElement().style.fontSize = currentFontSize + "px";
|
||||||
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