From 6c745ea0f54e660577d070b2ddaf4977039a094a Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Thu, 3 Dec 2020 21:10:17 +0200 Subject: initial --- .gitignore | 1 + arrow.svg | 62 ++++++++++++++++ arrows.js | 37 ++++++++++ bottom.svg | 62 ++++++++++++++++ file_type_recogniser.php | 84 ++++++++++++++++++++++ index.html | 55 ++++++++++++++ sql/fileshare.sql | 49 +++++++++++++ style.css | 181 +++++++++++++++++++++++++++++++++++++++++++++++ svg/icons/.dat.svg | 67 ++++++++++++++++++ svg/icons/.txt.svg | 65 +++++++++++++++++ upload.php | 23 ++++++ 11 files changed, 686 insertions(+) create mode 100644 .gitignore create mode 100644 arrow.svg create mode 100644 arrows.js create mode 100644 bottom.svg create mode 100644 file_type_recogniser.php create mode 100644 index.html create mode 100644 sql/fileshare.sql create mode 100644 style.css create mode 100644 svg/icons/.dat.svg create mode 100644 svg/icons/.txt.svg create mode 100644 upload.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..533e888 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +screen diff --git a/arrow.svg b/arrow.svg new file mode 100644 index 0000000..1f65efe --- /dev/null +++ b/arrow.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/arrows.js b/arrows.js new file mode 100644 index 0000000..4584aea --- /dev/null +++ b/arrows.js @@ -0,0 +1,37 @@ + +arrows = []; + +const minSpeed = 3; +const maxSpeed = 8; +const delay = 3000; +const lifetime = 20000; + +function make_arrow() { + const svg = document.getElementById("protoarrow").cloneNode(); + svg.style.left = Math.random() * 100 + '%'; + svg.style.display = 'block'; + document.getElementById('arrows').append(svg); + const ob = { + y: -800, + svg: svg, + speed: Math.random() * (maxSpeed - minSpeed) + minSpeed + }; + arrows.push(ob); + setTimeout(make_arrow, delay); + setTimeout(() => { + svg.remove(); + arrows.remove(ob); + }, lifetime); +} + +function update() { + for (const arrow of arrows) { + arrow.y += arrow.speed; + arrow.svg.style.bottom = arrow.y + 'px'; + } + + window.requestAnimationFrame(update); +} + +make_arrow(); +update(); diff --git a/bottom.svg b/bottom.svg new file mode 100644 index 0000000..772081e --- /dev/null +++ b/bottom.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/file_type_recogniser.php b/file_type_recogniser.php new file mode 100644 index 0000000..f160fb7 --- /dev/null +++ b/file_type_recogniser.php @@ -0,0 +1,84 @@ +file($path_to_file); +} + + +function file_extension($path_to_file) { + #FILEINFO_EXTENSION introduced in php7.2.0 https://www.php.net/manual/en/fileinfo.constants.php + if(defined("FILEINFO_EXTENSION")) + { + $file_type_database = new finfo(FILEINFO_EXTENSION); + return "." . $file_type_database->file($path_to_file); + }else + { + $result=file_type($path_to_file); + + $optimus_prime = array( + 'text/plain'=>'.txt', + 'text/html'=>'.html', + 'text/php'=>'.php', + 'text/css'=>'.css', + 'application/javascript'=>'.js', + 'application/json'=>'.json', + 'application/xml'=>'.xml', + 'application/x-shockwave-flash'=>'.swf', + 'video/x-flv'=>'.flv', + 'image/png'=>'.png', + 'image/jpeg'=>'.jpe', + 'image/jpeg'=>'.jpeg', + 'image/jpeg'=>'.jpg', + 'image/gif'=>'.gif', + 'image/bmp'=>'.bmp', + 'image/vnd.microsoft.icon'=>'.ico', + 'image/tiff'=>'.tiff', + 'image/tiff'=>'.tif', + 'image/svg+xml'=>'.svg', + 'image/svg+xml'=>'.svgz', + 'application/zip'=>'.zip', + 'application/x-rar-compressed'=>'.rar', + 'application/x-msdownload'=>'.exe', + 'application/x-msdownload'=>'.msi', + 'application/vnd.ms-cab-compressed'=>'.cab', + 'audio/mpeg'=>'.mp3', + 'video/quicktime'=>'.qt', + 'video/quicktime'=>'.mov', + 'application/pdf'=>'.pdf', + 'image/vnd.adobe.photoshop'=>'.psd', + 'application/postscript'=>'.ai', + 'application/postscript'=>'.eps', + 'application/postscript'=>'.ps', + 'application/msword'=>'.doc', + 'application/rtf'=>'.rtf', + 'application/vnd.ms-excel'=>'.xls', + 'application/vnd.ms-powerpoint'=>'.ppt', + 'application/vnd.oasis.opendocument.text'=>'.odt', + 'application/vnd.oasis.opendocument.spreadsheet'=>'.ods' + ); + + if(!array_key_exists($result,$optimus_prime)) + { + return ".dat"; + }else + { + return $optimus_prime[$result]; + } + + } +} + +function get_icon($path_to_file) +{ + $file_ext="svg/icons/".file_extension($path_to_file).".svg"; + if(!file_exists($file_ext)) + { + return "svg/icons/.dat.svg"; + }else + { + return $file_ext; + } +} + +?> diff --git a/index.html b/index.html new file mode 100644 index 0000000..5a60526 --- /dev/null +++ b/index.html @@ -0,0 +1,55 @@ + + + + + shady file upload + + + + +
+
+ + +
+
+
+ +
+ +
+

file upload service

+

that just about works

+

most of the time

+
+
+ +
+
+

Get started

+
+

Username

+ +

Password

+ +

Repeat Password

+ + +

Already have an account? Sign in +

+
+
+ + +
+
+ + +
+ + + + + diff --git a/sql/fileshare.sql b/sql/fileshare.sql new file mode 100644 index 0000000..f927ffc --- /dev/null +++ b/sql/fileshare.sql @@ -0,0 +1,49 @@ +drop database fileshare; + + + + + +create database fileshare; +use fileshare; + +/*base user information*/ +create table users ( + id int not null auto_increment, + username varchar(50) not null unique, + password varchar(100) not null unique, + primary key (id) +); + +/*table has only one owner and is identifyed by a number*/ +create table files ( + id int not null auto_increment, + owner int default null, + absolutepath varchar(500) not null, + type varchar(20) not null default 'data', + primary key (id), + foreign key (owner) references users(id) +); + +/*the user with userid is given some kind of access to the file with fileid*/ +/*there is no edit bit because it will be too dificult to implement prehaps a change bit is in order (but not an edit bit)*/ +/*might be beneficial to even go full minimalist and remove the remove bit and only have the view bit*/ +create table access ( + fileid int not null, + userid int not null, + canview boolean not null default true, + canremove boolean not null default false, + check (canview=true or canremove=true) , + foreign key (fileid) references files(id), + foreign key (userid) references users(id) +); + + + +/*basic info for testing purposes*/ +insert into users(username,password) values ("root","asdf"); +insert into users(username,password) values ("tester","tester"); +insert into files(owner,absolutepath,type) values (1,"/root/jiberish.sh","shell script"); +insert into access(fileid,userid,canview,canremove) values(1,2,true,false); +/*I am not sure why this passes ....*/ +insert into access(fileid,userid,canview,canremove) values(1,2,false,false); diff --git a/style.css b/style.css new file mode 100644 index 0000000..89442f4 --- /dev/null +++ b/style.css @@ -0,0 +1,181 @@ +html, body { + margin: 0; + height: 100%; +} + +body { + background: #f0f0f0; + color: black; + font-family: sans-serif; + overflow: hidden; +} + +#page { + display: flex; + flex: 1 0 0; + align-items: stretch; +} + +#page > * { + flex: 1 0 0; +} + +#header { + background: white; + margin: 0; + padding: 1rem; + font-size: 2em; +} + +.logo { + font-family: monospace; + margin: 0; +} + +#hero { + flex: 1.5 0 0; + position: relative; + font-size: 3.5rem; +} + +.vcenter { + display: flex; + flex-direction: column; + justify-content: center; +} + +#hero .bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: -5; +} + +#hero > * > p { + color: #676d75; + margin: 0rem; + padding: 0.5rem; + white-space: nowrap; + text-align: center; +} + +#hero .big { + font-size: 1.2em; +} + +.blue { + color: #231179; + font-weight: bold; +} + + +form { + background: white; + margin: 4.5rem; + padding-top: 0; + box-shadow: 0 0.8rem 1.3rem rgba(0,0,0,0.2); + border-radius: 0.5rem; + border-radius: 0.5rem; + border: 1px solid #b9b9b9; +} + +.vert { + justify-content: center; + display: flex; + flex-direction: column; +} + +.vert2 { + display: flex; + flex-direction: column; +} + +.overlay { + display: grid; +} + +.overlay > * { + grid-row: 1; + grid-column: 1; +} + +form > .content { + margin: 2rem; + margin-top: 1rem; + margin-bottom: 1.7rem; + padding: 0; + display: flex; + flex-direction: column; + justify-content: center; +} + +form > h2 { + color: #4d4d4d; + margin: 0; + text-align: center; + padding: 1rem; + background: #f0f0f0; + border-top-left-radius: 0.5rem; + border-top-right-radius: 0.5rem; +} + +form p { + margin: 1rem 0px 0.3rem 0px; +} + +input { + min-width: 300px; + border: 1px solid #bbb; + padding: 0.5rem; + font-size: inherit; + font-family: inherit; + border-radius: 0.3rem; + background: #fdfdfd; + transition: background 0.15s, border-color 0.35s; +} + +input[type=submit] { + cursor: pointer; + margin-top: 2rem; + width: 100%; + display: block; + padding: 0.7rem; + font-size: 1.1em; + box-shadow: 0 0.2rem 0.6rem #eee; + background: #231179; + color: white; +} + +input:focus, +input:hover { + background: white; +} + +input:focus { + border-color: black; +} + +input[type=submit]:hover { + background: #5b4d9d; +} + +.bgbottom { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + z-index: -100; +} + + +#arrows { + position: relative; +} + +#arrows > img { + position: absolute; + bottom: 0; + z-index: 200; +} diff --git a/svg/icons/.dat.svg b/svg/icons/.dat.svg new file mode 100644 index 0000000..69a4c60 --- /dev/null +++ b/svg/icons/.dat.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + Data + + diff --git a/svg/icons/.txt.svg b/svg/icons/.txt.svg new file mode 100644 index 0000000..db35ac4 --- /dev/null +++ b/svg/icons/.txt.svg @@ -0,0 +1,65 @@ + + + + + + + + image/svg+xml + + + + + + + txt + + diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..93fa778 --- /dev/null +++ b/upload.php @@ -0,0 +1,23 @@ + -- cgit v1.2.3