diff options
author | adam <adam@> | 2021-02-15 11:09:03 +0200 |
---|---|---|
committer | adam <adam@> | 2021-02-15 11:09:03 +0200 |
commit | ceb1706e1caf92054bbc6291a70824f16e30eff0 (patch) | |
tree | f61414f03c85753790b39603c5906fe1209be328 | |
parent | f4e5ef20b3d0dd21867f24db5bea2b2137abe1e1 (diff) | |
parent | e2ab5591cc6d30b1fa26e094b2c50aa7879cdd88 (diff) | |
download | fileup-ceb1706e1caf92054bbc6291a70824f16e30eff0.tar.gz |
Merge https://github.com/alexvitkov/india
-rw-r--r-- | css/sharefile_style.css | 25 | ||||
-rw-r--r-- | css/style.css | 30 | ||||
-rw-r--r-- | loggedin.js | 26 | ||||
-rw-r--r-- | php/.gitignore | 1 | ||||
-rw-r--r-- | php/configuration.php | 2 | ||||
-rw-r--r-- | php/share.php | 14 | ||||
-rw-r--r-- | share_frontend.php | 27 |
7 files changed, 109 insertions, 16 deletions
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/css/style.css b/css/style.css index 619c4d8..09456a3 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,4 @@ + html, body { margin: 0; height: 100%; @@ -307,8 +308,32 @@ input[type=submit]:hover { } .filecontents { - padding: 0.8rem; - font-size: 1.1rem; + font-family: monospace; +} + +.filecontents.imgview { + background-color: black; + background-repeat: no-repeat; + background-position: center; +} + +.filecontentsroot, .foldercontents { + display: flex; + flex-direction: column; +} + +.filecontents { + 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, @@ -465,3 +490,4 @@ input[type=submit]:hover { .close_button:hover { background: white; } + diff --git a/loggedin.js b/loggedin.js index da894dd..9efbb75 100644 --- a/loggedin.js +++ b/loggedin.js @@ -311,25 +311,27 @@ 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"; + + var pre = mk(focus.filecontents, 'pre'); + xhr.onload = function () { - focus.filecontents.innerText = xhr.responseText; + pre.innerText = xhr.responseText; + pre.contentEditable = "true"; }; } @@ -402,7 +404,7 @@ function opendir() { xhr.send(data); focus.filecontentsroot.style.display = 'none'; - focus.foldercontents.style.display = 'block'; + focus.foldercontents.style.display = 'flex'; } @@ -1020,4 +1022,4 @@ document.body.oncontextmenu = (e) => { the_file.onchange = on_file_added; -main();
\ No newline at end of file +main(); 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 4a516f4..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"); ?> 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 @@ +<!DOCTYPE html> +<html> + <head> + <head> + <meta charset="utf-8"> + <link rel="preconnect" href="https://fonts.gstatic.com"> + <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet"> + <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> + <title>shady file upload</title> <link rel="stylesheet" type="text/css" href="../css/style.css"> + <title>shady file upload</title> <link rel="stylesheet" type="text/css" href="../css/sharefile_style.css"> + </head> + </head> + <body> + <form method="GET" action="<?php echo "/php/share.php"; ?>"> + <h2>Fileup</h2> + <div class="content"> + This file is password protected. + <input type="hidden" name="file" value="<?php echo $_GET["file"];?>"><br> + <div class="h"> + <span>Password</span> + <input type="password" name="password"> + </div> + <input type="submit" value="Download"> + </div> + </form> + </body> +</html> |