Added whitelist for uploadable files.

Added greyscale mdlogo to git and set it as the default logo.
This commit is contained in:
2018-06-18 21:42:14 +02:00
committed by Stefan Rohde-Enslin
parent 0eab8391dd
commit 768c0998aa
6 changed files with 103 additions and 24 deletions

View File

@ -209,6 +209,11 @@ document.addEventListener("DOMContentLoaded", function() {
uploadSize.name = "MAX_FILE_SIZE";
uploadSize.value = "300000";
let uploadBackTo = document.createElement("input");
uploadBackTo.type = "hidden";
uploadBackTo.name = "backTo";
uploadBackTo.value = location.href;
let uploadTask = document.createElement("input");
uploadTask.type = "hidden";
uploadTask.name = "task";
@ -226,10 +231,57 @@ document.addEventListener("DOMContentLoaded", function() {
uploadForm.appendChild(uploadLabel);
uploadForm.appendChild(uploadSize);
uploadForm.appendChild(uploadTask);
uploadForm.appendChild(uploadBackTo);
uploadForm.appendChild(uploadInput);
uploadForm.appendChild(uploadButton);
overlay.appendChild(uploadForm);
/**
* Function for generating file list.
*
* @param {function} callback Function to call on clicking on a file name.
*
* @return {DOMElement}
*/
function generateFileList(callback) {
let fileList = document.createElement("table");
fileList.classList.add("fileList");
queryPage(
encodeURI('./files.php'),
function (request) {
let allFiles = JSON.parse(request.response);
for (let i = 0, max = allFiles.length; i < max; i++) {
let fileLine = document.createElement("tr");
let fileLineName = document.createElement("td"); // Add TD for displaying file name and main action
fileLineName.textContent = allFiles[i]; // Display file name
fileLineName.addEventListener('click', function(e) {
callback("../files/" + allFiles[i]);
});
fileLine.appendChild(fileLineName);
let fileLineDelete = document.createElement("td"); // Add TD for deleting file
let fileLineDeleteLink = document.createElement("a"); // Add a.
fileLineDeleteLink.textContent = "\u2326"; // Delete Symbole
fileLineDeleteLink.href = "files.php?task=delete&subject=" + encodeURI(allFiles[i]) + "&backTo=" + encodeURI(location.href);
fileLineDelete.appendChild(fileLineDeleteLink);
fileLine.appendChild(fileLineDelete);
fileList.appendChild(fileLine);
}
});
return fileList;
}
overlay.appendChild(generateFileList(function(value) { location.href = value; }));
document.getElementsByTagName("body")[0].appendChild(overlay);
document.getElementsByTagName("body")[0].addEventListener('keydown', async function(e) {
@ -237,17 +289,6 @@ document.addEventListener("DOMContentLoaded", function() {
removeElement(overlay);
});
queryPage(
encodeURI('./files.php'),
function (request) {
let allFiles = JSON.parse(request.response);
for (let i = 0, max = allFiles.length; i < max; i++) {
console.log(allFiles[i]);
}
});
});
})();