Fixed file creation, changed server messaging setup, applied styling to msgview.
This commit is contained in:
parent
a7f27dd487
commit
8c8e4ae53d
|
@ -100,6 +100,14 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#serverMsgView {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0em;
|
||||||
|
height: 5em;
|
||||||
|
overflow-y: scroll;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* Classes */
|
/* Classes */
|
||||||
.imgViewImg {
|
.imgViewImg {
|
||||||
width: inherit;
|
width: inherit;
|
||||||
|
|
|
@ -72,9 +72,8 @@ async function uploadFiles() {
|
||||||
for (var i = 0; i < size; i++) {
|
for (var i = 0; i < size; i++) {
|
||||||
data.append("filesToUpload[]", toUpload.files[i]);
|
data.append("filesToUpload[]", toUpload.files[i]);
|
||||||
}
|
}
|
||||||
|
fileUploader(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUploader(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createItem(type) {
|
function createItem(type) {
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
function createPassField(data) {
|
function createPassField(data) {
|
||||||
var msg = data.getElementsByTagName('SERV_MSG')[0].innerHTML;
|
|
||||||
console.log("No PATH_HEAD tag in XML. Checking for error MESSAGE tag.");
|
|
||||||
console.log("Message: " + msg);
|
|
||||||
|
|
||||||
insertArea.innerHTML = "";
|
insertArea.innerHTML = "";
|
||||||
var passField = document.createElement("INPUT");
|
var passField = document.createElement("INPUT");
|
||||||
var submitBttn = document.createElement("BUTTON");
|
var submitBttn = document.createElement("BUTTON");
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
include 'serverMessanger.php';
|
||||||
|
|
||||||
// Create file or folder
|
// Create file or folder
|
||||||
function createItem($FILE, $TYPE) {
|
function createItem($FILE, $TYPE) {
|
||||||
$FILE = preg_replace('/[^.[:alnum:]_-]/','_',trim($FILE)); // converting all on alphanumeric chars to _
|
$FILE = trim($FILE);
|
||||||
$FILE = preg_replace('/\.*$/','',$FILE); // removing dot . after file extension
|
$FILE = preg_replace('/\.*$/','',$FILE); // removing dot . after file extension
|
||||||
|
|
||||||
if ($TYPE == "dir"){
|
if ($TYPE == "dir"){
|
||||||
mkdir($FILE, 0755);
|
mkdir($FILE, 0755);
|
||||||
|
@ -12,6 +13,9 @@ function createItem($FILE, $TYPE) {
|
||||||
$myfile = fopen($FILE, "w");
|
$myfile = fopen($FILE, "w");
|
||||||
fclose($myfile);
|
fclose($myfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$message = "Server: [Success] --> The file " . $FILE . " has been created.";
|
||||||
|
serverMessage("success", $message);
|
||||||
$_SESSION["refreshState"] = "updateListing";
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,19 +31,25 @@ function deleteItem($FILE) {
|
||||||
} else if (is_file($FILE)) {
|
} else if (is_file($FILE)) {
|
||||||
unlink($FILE);
|
unlink($FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$message = "Server: [Success] --> The file(s) has/have been deleted.";
|
||||||
|
serverMessage("success", $message);
|
||||||
$_SESSION["refreshState"] = "updateListing";
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename file or folder
|
// Rename file or folder
|
||||||
function renameItem($OLDFILE, $NEWNAME, $PATH) {
|
function renameItem($OLDFILE, $NEWNAME, $PATH) {
|
||||||
rename($PATH . $OLDFILE, $PATH . $NEWNAME);
|
rename($PATH . $OLDFILE, $PATH . $NEWNAME);
|
||||||
|
$message = "Server: [Success] --> The file " . $OLDFILE . " has been renamed to " . $NEWNAME . " side.";
|
||||||
|
serverMessage("success", $message);
|
||||||
$_SESSION["refreshState"] = "updateListing";
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uploader
|
// Uploader
|
||||||
function uploadFiles($targetDir) {
|
function uploadFiles($targetDir) {
|
||||||
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
|
||||||
$numberOfFiles = count($_FILES['filesToUpload']['name']);
|
$numberOfFiles = count($_FILES['filesToUpload']['name']);
|
||||||
|
$type = "";
|
||||||
|
$message = "";
|
||||||
|
|
||||||
for ($i=0; $i < $numberOfFiles; $i++) {
|
for ($i=0; $i < $numberOfFiles; $i++) {
|
||||||
$uploadOk = 1;
|
$uploadOk = 1;
|
||||||
|
@ -51,11 +61,9 @@ function uploadFiles($targetDir) {
|
||||||
if (file_exists($targetFile)) {
|
if (file_exists($targetFile)) {
|
||||||
if (is_file($targetFile)) {
|
if (is_file($targetFile)) {
|
||||||
unlink($targetFile);
|
unlink($targetFile);
|
||||||
$GeneratedXML .= "<SERV_MSG class='warnning'>" .
|
$message = "Server: [Warnning] --> This file already exists. Overwriting it.";
|
||||||
"Server: [Warnning] --> This file already exists. Overwriting it.</SERV_MSG>";
|
|
||||||
} else {
|
} else {
|
||||||
$GeneratedXML .= "<SERV_MSG class='warnning'>" .
|
$message = "Server: [Warnning] --> This file might be a directory. Or, no files were submitted for uploading.";
|
||||||
"Server: [Warnning] --> This file might be a directory. Or, no files were submitted for uploading.</SERV_MSG>";
|
|
||||||
$uploadOk = 0;
|
$uploadOk = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,31 +71,31 @@ function uploadFiles($targetDir) {
|
||||||
// Check file size
|
// Check file size
|
||||||
$fileSize = $_FILES['filesToUpload']['size'][$i];
|
$fileSize = $_FILES['filesToUpload']['size'][$i];
|
||||||
if ($fileSize > 500000000000) {
|
if ($fileSize > 500000000000) {
|
||||||
$GeneratedXML .= "<SERV_MSG class='warnning'>" .
|
$message = "Server: [Warnning] --> This file is too large.";
|
||||||
"Server: [Warnning] --> This file is too large.</SERV_MSG>";
|
|
||||||
$uploadOk = 0;
|
$uploadOk = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow certain file formats
|
// Allow certain file formats
|
||||||
// $ext = pathinfo($targetFile,PATHINFO_EXTENSION);
|
// $ext = pathinfo($targetFile,PATHINFO_EXTENSION);
|
||||||
// if(!preg_match('/^.*\.(rar|iso|img|tar|zip|7z|7zip|jpg|jpeg|png|gif|mpeg|mov|flv|avi|mp4|webm|mpg|mkv|m4a|mp3|ogg|docx|doc|odt|txt|pdf|)$/i', strtolower($ext))) {
|
// if(!preg_match('/^.*\.(rar|iso|img|tar|zip|7z|7zip|jpg|jpeg|png|gif|mpeg|mov|flv|avi|mp4|webm|mpg|mkv|m4a|mp3|ogg|docx|doc|odt|txt|pdf|)$/i', strtolower($ext))) {
|
||||||
// $GeneratedXML .= "<SERV_MSG class='warnning'>This file type is not allowed. File Not uploade.</SERV_MSG>";
|
// $message = "Server: [Warnning] --> This file type is not allowed.";
|
||||||
// $uploadOk = 0;
|
// $uploadOk = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if everything is ok, try to upload file
|
// if everything is ok, try to upload file
|
||||||
if ($uploadOk !== 0) {
|
if ($uploadOk !== 0) {
|
||||||
if (move_uploaded_file($fileTmpName, $targetFile)) {
|
if (move_uploaded_file($fileTmpName, $targetFile)) {
|
||||||
$GeneratedXML .= "<SERV_MSG class='success'>" .
|
$type = "success";
|
||||||
"Server: [Success] --> The file " . $fileName . " has been uploaded.</SERV_MSG>";
|
$message = "Server: [Success] --> The file " . $fileName . " has been uploaded.";
|
||||||
$_SESSION["refreshState"] = "updateListing";
|
$_SESSION["refreshState"] = "updateListing";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$GeneratedXML .= "<SERV_MSG class='error'>" .
|
$type = "error";
|
||||||
"Server: [Error] --> Your file " . $fileName . " was not uploaded.</SERV_MSG>";
|
$message .= "\nServer: [Error] --> Your file " . $fileName . " was not uploaded.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo $GeneratedXML;
|
|
||||||
|
serverMessage($type, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local program file access
|
// Local program file access
|
||||||
|
@ -108,6 +116,9 @@ function openFile($FILE) {
|
||||||
} else if (preg_match('(pdf)', $EXTNSN) === 1) {
|
} else if (preg_match('(pdf)', $EXTNSN) === 1) {
|
||||||
shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &');
|
shell_exec($PDFVIEWER . ' "' . $FILE . '" > /dev/null &');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$message = "Server: [Success] --> The file " . $FILE . " has been opened server side.";
|
||||||
|
serverMessage("success", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,8 +139,8 @@ if (isset($_POST["createItem"],
|
||||||
} else if (isset($_POST["media"])) {
|
} else if (isset($_POST["media"])) {
|
||||||
openFile($_POST["media"]);
|
openFile($_POST["media"]);
|
||||||
} else {
|
} else {
|
||||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><SERV_MSG class='error'>" .
|
$message = "Server: [Error] --> Incorrect access attempt!";
|
||||||
"Server: [Error] --> Incorrect access attempt!</SERV_MSG>";
|
serverMessage("error", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
function serverMessage($TYPE, $MESSAGE) {
|
||||||
|
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
|
$GeneratedXML .= "<SERV_MSG class='" . $TYPE . "'>" . $MESSAGE ."</SERV_MSG>";
|
||||||
|
echo $GeneratedXML;
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue