diff options
author | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-15 10:22:26 +0200 |
---|---|---|
committer | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-15 10:22:26 +0200 |
commit | b6930703bb100ff3dc3637c5150b6ab993c1275a (patch) | |
tree | 34310454da27d01ad73068464a463a548fbea0c9 | |
parent | 8c55fc44a64f46d64ced2f053d8b441247cc1f36 (diff) | |
download | fileup-b6930703bb100ff3dc3637c5150b6ab993c1275a.tar.gz |
Front end for password protected files
-rw-r--r-- | css/sharefile_style.css | 25 | ||||
-rw-r--r-- | php/share.php | 14 | ||||
-rw-r--r-- | share_frontend.php | 27 |
3 files changed, 65 insertions, 1 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/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> |