From 8c55fc44a64f46d64ced2f053d8b441247cc1f36 Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Mon, 15 Feb 2021 09:58:55 +0200 Subject: configuration --- php/.gitignore | 1 + php/configuration.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 php/.gitignore diff --git a/php/.gitignore b/php/.gitignore new file mode 100644 index 0000000..f980a0f --- /dev/null +++ b/php/.gitignore @@ -0,0 +1 @@ +custom_configuration.php diff --git a/php/configuration.php b/php/configuration.php index 1f2f423..6cfef48 100644 --- a/php/configuration.php +++ b/php/configuration.php @@ -23,6 +23,6 @@ $password_hash_algo=PASSWORD_BCRYPT; $has_email_verification=false; -@include_once("$_SERVER[HOME]/.fileup.config.php"); +@include_once("custom_configuration.php"); -?> \ No newline at end of file +?> -- cgit v1.2.3 From b6930703bb100ff3dc3637c5150b6ab993c1275a Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Mon, 15 Feb 2021 10:22:26 +0200 Subject: Front end for password protected files --- css/sharefile_style.css | 25 +++++++++++++++++++++++++ php/share.php | 14 +++++++++++++- share_frontend.php | 27 +++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 css/sharefile_style.css create mode 100644 share_frontend.php diff --git a/css/sharefile_style.css b/css/sharefile_style.css new file mode 100644 index 0000000..f7118fc --- /dev/null +++ b/css/sharefile_style.css @@ -0,0 +1,25 @@ +body { + display: flex; + align-items: center; + justify-content: center; +} + +.content { + flex: 0 0 0; + display: flex; + flex-direction: column; + gap: 1rem; + align-items: center; + justify-content: center; +} + +.h { + display: flex; + gap: 0.8rem; + align-items: center; + justify-content: center; +} + +input[type=submit] { + margin-top: 0.5rem; +} diff --git a/php/share.php b/php/share.php index 8cc150a..c549c8a 100644 --- a/php/share.php +++ b/php/share.php @@ -69,11 +69,23 @@ if($_SERVER["REQUEST_METHOD"] == "POST") } $shared_node=$database->get_shared_node($code); - if($shared_node==NULL || $shared_node->password!=$password) + if($shared_node==NULL) { http_response_code(409); exit(0); } + if ($shared_node->password!=$password) { + if ($password == "") + { + require_once("../share_frontend.php"); + exit(0); + }else + { + echo "Invalid password"; + http_response_code(409); + exit(0); + } + } if(isset($_SESSION["user_object"])) { $user=$_SESSION["user_object"]; diff --git a/share_frontend.php b/share_frontend.php new file mode 100644 index 0000000..0a13cd7 --- /dev/null +++ b/share_frontend.php @@ -0,0 +1,27 @@ + + + + + + + + + shady file upload + shady file upload + + + +
"> +

Fileup

+
+ This file is password protected. + ">
+
+ Password + +
+ +
+
+ + -- cgit v1.2.3 From 31533d6c9c94e23148c5d39ebcac3a59dc5acf62 Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Mon, 15 Feb 2021 10:53:06 +0200 Subject: Image viewer now sucke less --- css/style.css | 13 +++++++++++++ loggedin.js | 23 ++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/css/style.css b/css/style.css index 619c4d8..bc625a6 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,4 @@ + html, body { margin: 0; height: 100%; @@ -306,6 +307,17 @@ input[type=submit]:hover { background: white; } +.filecontents.imgview { + background-color: black; + background-repeat: no-repeat; + background-position: center; +} + +.filecontentsroot, .foldercontents { + display: flex; + flex-direction: column; +} + .filecontents { padding: 0.8rem; font-size: 1.1rem; @@ -465,3 +477,4 @@ input[type=submit]:hover { .close_button:hover { background: white; } + diff --git a/loggedin.js b/loggedin.js index da894dd..33721e7 100644 --- a/loggedin.js +++ b/loggedin.js @@ -311,23 +311,24 @@ function openfile_nondir() { xhr.open('POST', '/php/readfile.php', true); focus.filecontents.innerText = ""; - focus.filecontentsroot.style.display = 'block'; + focus.filecontentsroot.style.display = 'flex'; focus.foldercontents.style.display = 'none'; if (mimetype.split("/")[0] == "image") { xhr.responseType = 'arraybuffer'; xhr.onload = function () { - var b = base64ArrayBuffer(xhr.response); - var image = new Image(); - image.src = `data:image/png;base64,${b}`; - image.style.minWidth = "0px"; - image.style.minHeight = "0px"; - - focus.filecontents.appendChild(image); - focus.filecontents.display = "flex"; + let b = `data:image/png;base64,${base64ArrayBuffer(xhr.response)}`; + + + focus.filecontents.style.backgroundImage = `url('${b}')`; + focus.filecontents.classList.add('imgview'); + focus.filecontents.innerText = "asdf"; } } else { + focus.filecontents.classList.remove('imgview'); + focus.filecontents.style.backgroundImage = "unset"; + xhr.onload = function () { focus.filecontents.innerText = xhr.responseText; }; @@ -402,7 +403,7 @@ function opendir() { xhr.send(data); focus.filecontentsroot.style.display = 'none'; - focus.foldercontents.style.display = 'block'; + focus.foldercontents.style.display = 'flex'; } @@ -1020,4 +1021,4 @@ document.body.oncontextmenu = (e) => { the_file.onchange = on_file_added; -main(); \ No newline at end of file +main(); -- cgit v1.2.3 From e2ab5591cc6d30b1fa26e094b2c50aa7879cdd88 Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Mon, 15 Feb 2021 11:06:52 +0200 Subject: Editable text 0.1 --- css/style.css | 17 +++++++++++++++-- loggedin.js | 7 ++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/css/style.css b/css/style.css index bc625a6..09456a3 100644 --- a/css/style.css +++ b/css/style.css @@ -307,6 +307,10 @@ input[type=submit]:hover { background: white; } +.filecontents { + font-family: monospace; +} + .filecontents.imgview { background-color: black; background-repeat: no-repeat; @@ -319,8 +323,17 @@ input[type=submit]:hover { } .filecontents { - padding: 0.8rem; - font-size: 1.1rem; + overflow-y: scroll; +} +[contenteditable] { + outline: 0px solid transparent; +} + +pre { + font-size: 1.3rem; + min-height: 100%; + margin: 0.3rem; + box-sizing: border-box; } .window h3, diff --git a/loggedin.js b/loggedin.js index 33721e7..9efbb75 100644 --- a/loggedin.js +++ b/loggedin.js @@ -318,8 +318,6 @@ function openfile_nondir() { xhr.responseType = 'arraybuffer'; xhr.onload = function () { let b = `data:image/png;base64,${base64ArrayBuffer(xhr.response)}`; - - focus.filecontents.style.backgroundImage = `url('${b}')`; focus.filecontents.classList.add('imgview'); focus.filecontents.innerText = "asdf"; @@ -329,8 +327,11 @@ function openfile_nondir() { focus.filecontents.classList.remove('imgview'); focus.filecontents.style.backgroundImage = "unset"; + var pre = mk(focus.filecontents, 'pre'); + xhr.onload = function () { - focus.filecontents.innerText = xhr.responseText; + pre.innerText = xhr.responseText; + pre.contentEditable = "true"; }; } -- cgit v1.2.3